|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.production.bo.WorkshopReportBo;
|
|
|
+import com.fjhx.mes.entity.production.bo.WorkshopReportMaterialsUsedBo;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionTaskProgressSelectDto;
|
|
|
import com.fjhx.mes.entity.production.po.ProductionTaskProgress;
|
|
|
import com.fjhx.mes.entity.production.vo.ProductionTaskProgressVo;
|
|
@@ -12,10 +13,13 @@ import com.fjhx.mes.mapper.production.ProductionTaskProgressMapper;
|
|
|
import com.fjhx.mes.service.production.ProductionTaskProgressService;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
@@ -23,16 +27,19 @@ import java.util.List;
|
|
|
* 生产任务进度 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
- * @author
|
|
|
+ * @author _
|
|
|
* @since 2024-01-15
|
|
|
*/
|
|
|
@Service
|
|
|
public class ProductionTaskProgressServiceImpl extends ServiceImpl<ProductionTaskProgressMapper, ProductionTaskProgress> implements ProductionTaskProgressService {
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProductInfoService productInfoService;
|
|
|
+ private final ProductInfoService productInfoService;
|
|
|
|
|
|
- private IWrapper<ProductionTaskProgress> getWorkshopReportWrapper(ProductionTaskProgressSelectDto dto) {
|
|
|
+ public ProductionTaskProgressServiceImpl(ProductInfoService productInfoService) {
|
|
|
+ this.productInfoService = productInfoService;
|
|
|
+ }
|
|
|
+
|
|
|
+ private IWrapper<ProductionTaskProgress> getWorkshopReportWrapper() {
|
|
|
IWrapper<ProductionTaskProgress> wrapper = getWrapper();
|
|
|
wrapper.in("pod.company_id", SecurityUtils.getCompanyIds());
|
|
|
return wrapper;
|
|
@@ -40,16 +47,15 @@ public class ProductionTaskProgressServiceImpl extends ServiceImpl<ProductionTas
|
|
|
|
|
|
@Override
|
|
|
public List<ProductionTaskProgressVo> workshopReportStatistics(ProductionTaskProgressSelectDto dto) {
|
|
|
- IWrapper<ProductionTaskProgress> wrapper = getWorkshopReportWrapper(dto);
|
|
|
+ IWrapper<ProductionTaskProgress> wrapper = getWorkshopReportWrapper();
|
|
|
wrapper.eq("DATEDIFF( ps.scheduling_date,now() )", 0);
|
|
|
wrapper.groupBy("ptp.processes_id");
|
|
|
- List<ProductionTaskProgressVo> workshopReportStatistics = baseMapper.workshopReportStatistics(wrapper);
|
|
|
- return workshopReportStatistics;
|
|
|
+ return baseMapper.workshopReportStatistics(wrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Page<WorkshopReportBo> workshopReport(ProductionTaskProgressSelectDto dto) {
|
|
|
- IWrapper<ProductionTaskProgress> wrapper = getWorkshopReportWrapper(dto);
|
|
|
+ IWrapper<ProductionTaskProgress> wrapper = getWorkshopReportWrapper();
|
|
|
|
|
|
|
|
|
wrapper.in("DATEDIFF(ps.scheduling_date, now())", -1, 0, 1);
|
|
@@ -69,6 +75,42 @@ public class ProductionTaskProgressServiceImpl extends ServiceImpl<ProductionTas
|
|
|
item.setProductHeight(productInfo.getHeight());
|
|
|
item.setProductColor(productInfo.getColor());
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+ List<Long> taskIds = records.stream().map(WorkshopReportBo::getTaskId).collect(Collectors.toList());
|
|
|
+ List<WorkshopReportMaterialsUsedBo> materialsUsedBos = baseMapper.workshopReportMaterialsUsed(IWrapper.getWrapper()
|
|
|
+ .in("pod.id", taskIds)
|
|
|
+ .ne("cpb.type", 3)
|
|
|
+ );
|
|
|
+ for (WorkshopReportMaterialsUsedBo materialsUsedBo : materialsUsedBos) {
|
|
|
+ BigDecimal quantity = materialsUsedBo.getQuantity().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal usedQuantity = materialsUsedBo.getUsedQuantity().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal lossQuantity = materialsUsedBo.getLossQuantity().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ BigDecimal surplusQuantity = materialsUsedBo.getSurplusQuantity().setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+
|
|
|
+ materialsUsedBo.setQuantity(quantity);
|
|
|
+ materialsUsedBo.setUsedQuantity(usedQuantity);
|
|
|
+ materialsUsedBo.setLossQuantity(lossQuantity);
|
|
|
+ materialsUsedBo.setSurplusQuantity(surplusQuantity);
|
|
|
+ }
|
|
|
+ productInfoService.attributeAssign(materialsUsedBos, WorkshopReportMaterialsUsedBo::getMaterialId, (item, productInfo) -> {
|
|
|
+ item.setMaterialName(productInfo.getName());
|
|
|
+ item.setMaterialCode(productInfo.getCustomCode());
|
|
|
+
|
|
|
+ item.setMaterialLength(productInfo.getLength());
|
|
|
+ item.setMaterialWidth(productInfo.getWidth());
|
|
|
+ item.setMaterialHeight(productInfo.getHeight());
|
|
|
+ item.setMaterialNetWeight(productInfo.getNetWeight());
|
|
|
+ item.setMaterialUnit(productInfo.getUnit());
|
|
|
+ item.setMaterialColor(productInfo.getColor());
|
|
|
+
|
|
|
+ });
|
|
|
+ Map<Long, List<WorkshopReportMaterialsUsedBo>> materialsUsedMap = materialsUsedBos
|
|
|
+ .stream().collect(Collectors.groupingBy(WorkshopReportMaterialsUsedBo::getProductionOrderDetailId));
|
|
|
+ for (WorkshopReportBo record : records) {
|
|
|
+ record.setMaterialsUsedList(materialsUsedMap.getOrDefault(record.getTaskId(), new ArrayList<>()));
|
|
|
+ }
|
|
|
+
|
|
|
return workshopReportBoPage;
|
|
|
}
|
|
|
}
|