|
@@ -1,9 +1,15 @@
|
|
|
package com.fjhx.mes.service.production.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
+import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.production.po.ProductionPlan;
|
|
|
+import com.fjhx.mes.entity.work.po.WorkOrder;
|
|
|
import com.fjhx.mes.mapper.production.ProductionPlanMapper;
|
|
|
import com.fjhx.mes.service.production.ProductionPlanService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.mes.service.work.WorkOrderService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fjhx.mes.entity.production.vo.ProductionPlanVo;
|
|
@@ -12,6 +18,10 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.fjhx.mes.entity.production.dto.ProductionPlanDto;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -24,11 +34,35 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
@Service
|
|
|
public class ProductionPlanServiceImpl extends ServiceImpl<ProductionPlanMapper, ProductionPlan> implements ProductionPlanService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ WorkOrderService workOrderService;
|
|
|
+ @Autowired
|
|
|
+ ProductInfoService productInfoService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<ProductionPlanVo> getPage(ProductionPlanSelectDto dto) {
|
|
|
IWrapper<ProductionPlan> wrapper = getWrapper();
|
|
|
wrapper.orderByDesc("pp", ProductionPlan::getId);
|
|
|
Page<ProductionPlanVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<ProductionPlanVo> records = page.getRecords();
|
|
|
+
|
|
|
+ //获取工单信息
|
|
|
+ List<Long> workOrderIds = records.stream().map(ProductionPlanVo::getWorkOrderId).collect(Collectors.toList());
|
|
|
+ List<WorkOrder> workOrderList = workOrderService.list(q -> q.in(WorkOrder::getId, workOrderIds));
|
|
|
+ Map<Long, WorkOrder> workOrderMap = workOrderList.stream().collect(Collectors.groupingBy(WorkOrder::getId,
|
|
|
+ Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
|
|
|
+ //获取产品信息
|
|
|
+ List<Long> productIds = workOrderList.stream().map(WorkOrder::getProductId).collect(Collectors.toList());
|
|
|
+ List<ProductInfo> productInfos = productInfoService.listByIds(productIds);
|
|
|
+ Map<Long, ProductInfo> productInfoMap = productInfos.stream().collect(Collectors.groupingBy(ProductInfo::getId,
|
|
|
+ Collectors.collectingAndThen(Collectors.toList(), value -> value.get(0))));
|
|
|
+ for (ProductionPlanVo productionPlanVo : records){
|
|
|
+ WorkOrder workOrder = workOrderMap.get(productionPlanVo.getWorkOrderId());
|
|
|
+ ProductInfo productInfo = productInfoMap.get(workOrder.getProductId());
|
|
|
+ if(ObjectUtil.isNotEmpty(productInfo)){
|
|
|
+ productionPlanVo.setProductName(productInfo.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -41,6 +75,7 @@ public class ProductionPlanServiceImpl extends ServiceImpl<ProductionPlanMapper,
|
|
|
|
|
|
@Override
|
|
|
public void add(ProductionPlanDto productionPlanDto) {
|
|
|
+ productionPlanDto.setStatus(0);
|
|
|
this.save(productionPlanDto);
|
|
|
}
|
|
|
|