|
@@ -3,6 +3,8 @@ package com.fjhx.mes.service.production.impl;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
+import com.fjhx.item.service.product.ProductBomDetailService;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.production.dto.ProduceOrderDetailSelectDto;
|
|
|
import com.fjhx.mes.entity.production.po.ProductionOrder;
|
|
@@ -18,10 +20,8 @@ import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -40,6 +40,8 @@ public class ProduceOrderDetailServiceImpl extends ServiceImpl<ProduceOrderDetai
|
|
|
private ProductInfoService productInfoService;
|
|
|
@Autowired
|
|
|
private ProductionProcessesMapper productionProcessesMapper;
|
|
|
+ @Autowired
|
|
|
+ private ProductBomDetailService productBomDetailService;
|
|
|
|
|
|
@Override
|
|
|
public Page<ProductionOrderDetailVo> getPage(ProduceOrderDetailSelectDto dto) {
|
|
@@ -73,19 +75,46 @@ public class ProduceOrderDetailServiceImpl extends ServiceImpl<ProduceOrderDetai
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
- //赋值产品信息
|
|
|
- productInfoService.attributeAssign(records, ProductionOrderDetail::getProductId, (item, product) -> {
|
|
|
- item.setProductCode(product.getCustomCode());
|
|
|
- item.setProductName(product.getName());
|
|
|
- item.setProductUnit(product.getUnit());
|
|
|
- item.setProductSpec(product.getSpec());
|
|
|
- item.setProductLength(product.getLength());
|
|
|
- item.setProductWidth(product.getWidth());
|
|
|
- item.setProductHeight(product.getHeight());
|
|
|
- });
|
|
|
-
|
|
|
- //赋值生产用时
|
|
|
+ //获取产品信息
|
|
|
+ List<Long> pIds = records.stream().map(ProductionOrderDetail::getProductId).collect(Collectors.toList());
|
|
|
+ List<ProductInfo> productInfoList = productInfoService.list(q -> q.in(ProductInfo::getId, pIds));
|
|
|
+ Map<Long, ProductInfo> productMap = productInfoList.stream().collect(Collectors.toMap(ProductInfo::getId, Function.identity()));
|
|
|
+ //获取原材料信息
|
|
|
+ Map<Long, ProductInfo> rawMaterialMap = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(productInfoList)) {
|
|
|
+ List<Long> rmIds = productInfoList.stream().map(ProductInfo::getRawMaterialId).collect(Collectors.toList());
|
|
|
+ rawMaterialMap = productInfoService.mapKEntity(ProductInfo::getId, q -> q.in(ProductInfo::getId, rmIds));
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值工序列表
|
|
|
+ Map<Long, List<ProductionProcessesVo>> processesMap = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(pIds)) {
|
|
|
+ List<ProductionProcessesVo> processes = productionProcessesMapper.getProcessesByProductId(IWrapper.getWrapper().in("pi.id", pIds));
|
|
|
+ processesMap = processes.stream().collect(Collectors.groupingBy(ProductionProcessesVo::getProductId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
for (ProductionOrderDetailVo record : records) {
|
|
|
+ //赋值产品信息
|
|
|
+ ProductInfo product = productMap.get(record.getProductId());
|
|
|
+ if (ObjectUtil.isNotEmpty(product)) {
|
|
|
+ record.setProductCode(product.getCustomCode());
|
|
|
+ record.setProductName(product.getName());
|
|
|
+ record.setProductUnit(product.getUnit());
|
|
|
+ record.setProductSpec(product.getSpec());
|
|
|
+ record.setProductLength(product.getLength());
|
|
|
+ record.setProductWidth(product.getWidth());
|
|
|
+ record.setProductHeight(product.getHeight());
|
|
|
+
|
|
|
+ //赋值原材料信息
|
|
|
+ ProductInfo rawMaterial = rawMaterialMap.get(product.getRawMaterialId());
|
|
|
+ if (ObjectUtil.isNotEmpty(rawMaterial)) {
|
|
|
+ record.setRawMaterialCode(rawMaterial.getCustomCode());
|
|
|
+ record.setRawMaterialName(rawMaterial.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值生产用时
|
|
|
record.setUsageTime(0L);
|
|
|
Date produceTime = record.getProduceTime();
|
|
|
Date finishTime = record.getFinishTime();
|
|
@@ -93,17 +122,10 @@ public class ProduceOrderDetailServiceImpl extends ServiceImpl<ProduceOrderDetai
|
|
|
long usageTime = finishTime.getTime() - produceTime.getTime();
|
|
|
record.setUsageTime(usageTime / 1000 / 60 / 60);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //赋值工序列表
|
|
|
- List<Long> pIds = records.stream().map(ProductionOrderDetail::getProductId).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(pIds)) {
|
|
|
- List<ProductionProcessesVo> processes = productionProcessesMapper.getProcessesByProductId(IWrapper.getWrapper().in("pi.id", pIds));
|
|
|
- Map<Long, List<ProductionProcessesVo>> processesMap = processes.stream().collect(Collectors.groupingBy(ProductionProcessesVo::getProductId));
|
|
|
- for (ProductionOrderDetailVo record : records) {
|
|
|
- List<ProductionProcessesVo> productionProcessesVo = processesMap.get(record.getProductId());
|
|
|
- record.setProductionProcessesList(productionProcessesVo);
|
|
|
- }
|
|
|
+ //赋值工序列表
|
|
|
+ List<ProductionProcessesVo> productionProcessesVo = processesMap.get(record.getProductId());
|
|
|
+ record.setProductionProcessesList(productionProcessesVo);
|
|
|
}
|
|
|
|
|
|
return page;
|