|
@@ -17,10 +17,12 @@ import com.fjhx.mes.entity.technology.po.TechnologyProcessLine;
|
|
|
import com.fjhx.mes.mapper.production.ProductionReportingMapper;
|
|
|
import com.fjhx.mes.service.production.*;
|
|
|
import com.fjhx.mes.service.technology.TechnologyProcessLineService;
|
|
|
+import com.fjhx.tenant.utils.DeptUstil;
|
|
|
import com.ruoyi.common.core.domain.BasePo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import com.ruoyi.system.utils.UserUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -62,11 +64,56 @@ public class ProductionReportingServiceImpl extends ServiceImpl<ProductionReport
|
|
|
@Override
|
|
|
public Page<ProductionReportingVo> getPage(ProductionReportingSelectDto dto) {
|
|
|
IWrapper<ProductionReporting> wrapper = getWrapper();
|
|
|
+
|
|
|
+ //权限过滤:生产报工
|
|
|
+ wrapper.in("pr", ProductionReporting::getCompanyId, SecurityUtils.getCompanyIds());
|
|
|
+ wrapper.eq("pr", ProductionReporting::getCompanyId, dto.getCompanyId());
|
|
|
+
|
|
|
+ //工序过滤
|
|
|
+ wrapper.eq("pr", ProductionReporting::getProductionProcessesId, dto.getProductionProcessesId());
|
|
|
+
|
|
|
+ //用户过滤
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getUserId())) {
|
|
|
+ wrapper.apply("FIND_IN_SET( {0}, pr.user_set )", dto.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //日期过滤
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getDataDate())) {
|
|
|
+ wrapper.apply("DATE_FORMAT(pr.create_time, '%Y-%m') = DATE_FORMAT({0}, '%Y-%m')", dto.getDataDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ //关键字检索
|
|
|
+ wrapper.keyword(dto.getKeyword(),
|
|
|
+ new SqlField("pr.user_name"),
|
|
|
+ new SqlField("po.code")
|
|
|
+ );
|
|
|
+
|
|
|
wrapper.orderByDesc("pr", ProductionReporting::getId);
|
|
|
- wrapper.like("pt.code", dto.getKeyword());
|
|
|
Page<ProductionReportingVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<ProductionReportingVo> records = page.getRecords();
|
|
|
- UserUtil.assignmentNickName(records, ProductionReporting::getCreateUser, ProductionReportingVo::setOperatorName);
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取生产公司信息
|
|
|
+ List<Long> companyIds = records.stream().map(ProductionReporting::getCompanyId).collect(Collectors.toList());
|
|
|
+ Map<Long, String> companyNameMap = DeptUstil.getDeptNameMap(companyIds);
|
|
|
+
|
|
|
+ for (ProductionReportingVo record : records) {
|
|
|
+ //赋值生产公司名称
|
|
|
+ record.setCompanyName(companyNameMap.get(record.getCompanyId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值产品信息
|
|
|
+ productInfoService.attributeAssign(records, ProductionReportingVo::getProductId, (item, productInfo) -> {
|
|
|
+ item.setProductName(productInfo.getName());
|
|
|
+ item.setProductCode(productInfo.getCustomCode());
|
|
|
+ item.setProductLength(productInfo.getLength());
|
|
|
+ item.setProductWidth(productInfo.getWidth());
|
|
|
+ item.setProductHeight(productInfo.getHeight());
|
|
|
+ item.setProductColor(productInfo.getColor());
|
|
|
+ });
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -266,10 +313,66 @@ public class ProductionReportingServiceImpl extends ServiceImpl<ProductionReport
|
|
|
// productionReportingDetailService.updateBatchById(productionReportingDetailList);
|
|
|
}
|
|
|
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
public void delete(Long id) {
|
|
|
+ ProductionReporting dataById = this.getById(id);
|
|
|
+ Assert.notEmpty(dataById, "查询不到报工信息!");
|
|
|
+ Long taskId = dataById.getProductionTaskId();
|
|
|
+ Long processesId = dataById.getProductionProcessesId();
|
|
|
+ BigDecimal quantity = dataById.getQuantity();
|
|
|
+
|
|
|
this.removeById(id);
|
|
|
productionReportingDetailService.remove(q -> q.eq(ProductionReportingDetail::getProductionReportingId, id));
|
|
|
+
|
|
|
+ //获取工艺信息
|
|
|
+ ProductionOrderDetail pod = produceOrderDetailService.getById(taskId);
|
|
|
+ Assert.notEmpty(pod, "查询不到生产任务信息!");
|
|
|
+ ProductInfo productInfo = productInfoService.getById(pod.getProductId());
|
|
|
+ Assert.notEmpty(productInfo, "查询不到生产产品信息!");
|
|
|
+ Long technologyId = productInfo.getTechnologyId();
|
|
|
+
|
|
|
+ //回滚当前工序生产进度
|
|
|
+ productionTaskProgressService.update(q -> q
|
|
|
+ .eq(ProductionTaskProgress::getTaskId, taskId)
|
|
|
+ .eq(ProductionTaskProgress::getProcessesId, processesId)
|
|
|
+ .setSql("finish_quantity = finish_quantity - " + quantity)
|
|
|
+ .setSql("balance_quantity = balance_quantity + " + quantity)
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+
|
|
|
+ //回滚下一工序结存数量
|
|
|
+ List<Long> nextProcessIds = technologyProcessLineService.listObject(TechnologyProcessLine::getTargetProcessesId, q -> q
|
|
|
+ .eq(TechnologyProcessLine::getTechnologyId, technologyId)
|
|
|
+ .eq(TechnologyProcessLine::getSourceProcessesId, processesId)
|
|
|
+ .ne(TechnologyProcessLine::getTargetProcessesId, 99)
|
|
|
+ );
|
|
|
+ if (ObjectUtil.isNotEmpty(nextProcessIds)) {
|
|
|
+ productionTaskProgressService.update(q -> q
|
|
|
+ .eq(ProductionTaskProgress::getTaskId, taskId)
|
|
|
+ .in(ProductionTaskProgress::getProcessesId, nextProcessIds)
|
|
|
+ .setSql("balance_quantity = balance_quantity - " + quantity)
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ //回滚生产任务完成数量以及状态
|
|
|
+ produceOrderDetailService.update(q -> q
|
|
|
+ .eq(ProductionOrderDetail::getId, taskId)
|
|
|
+ .setSql("produce_status = IF(produce_status=2,1,produce_status)")
|
|
|
+ .setSql("finish_quantity = finish_quantity - " + quantity)
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
+ //回滚生产订单状态
|
|
|
+ produceOrderService.update(q -> q
|
|
|
+ .eq(ProductionOrder::getId, pod.getProduceOrderId())
|
|
|
+ .setSql("produce_status = IF(produce_status=2,1,produce_status)")
|
|
|
+ .set(BasePo::getUpdateTime, new Date())
|
|
|
+ .set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
}
|