|
@@ -10,9 +10,6 @@ import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.mes.entity.bom.po.BomDetail;
|
|
|
import com.fjhx.mes.entity.bom.po.BomInfo;
|
|
|
-import com.fjhx.mes.entity.production.po.ProductionPlan;
|
|
|
-import com.fjhx.mes.entity.production.po.ProductionTask;
|
|
|
-import com.fjhx.mes.entity.production.po.ProductionTaskDetail;
|
|
|
import com.fjhx.mes.entity.work.dto.WorkOrderDto;
|
|
|
import com.fjhx.mes.entity.work.dto.WorkOrderSelectDto;
|
|
|
import com.fjhx.mes.entity.work.po.WorkOrder;
|
|
@@ -20,9 +17,6 @@ import com.fjhx.mes.entity.work.vo.WorkOrderVo;
|
|
|
import com.fjhx.mes.mapper.work.WorkOrderMapper;
|
|
|
import com.fjhx.mes.service.bom.BomDetailService;
|
|
|
import com.fjhx.mes.service.bom.BomInfoService;
|
|
|
-import com.fjhx.mes.service.production.ProductionPlanService;
|
|
|
-import com.fjhx.mes.service.production.ProductionTaskDetailService;
|
|
|
-import com.fjhx.mes.service.production.ProductionTaskService;
|
|
|
import com.fjhx.mes.service.work.WorkOrderService;
|
|
|
import com.fjhx.mes.utils.code.CodeEnum;
|
|
|
import com.fjhx.sale.entity.contract.po.ContractProduct;
|
|
@@ -38,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.math.RoundingMode;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -58,8 +51,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
|
|
|
@Autowired
|
|
|
private ProductInfoService productInfoService;
|
|
|
- @Autowired
|
|
|
- private ProductionPlanService productionPlanService;
|
|
|
|
|
|
@Autowired
|
|
|
private ContractProductService contractProductService;
|
|
@@ -71,10 +62,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
private StockService stockService;
|
|
|
@Autowired
|
|
|
private StockFrozenService stockFrozenService;
|
|
|
- @Autowired
|
|
|
- private ProductionTaskService productionTaskService;
|
|
|
- @Autowired
|
|
|
- private ProductionTaskDetailService productionTaskDetailService;
|
|
|
|
|
|
@Override
|
|
|
public Page<WorkOrderVo> getPage(WorkOrderSelectDto dto) {
|
|
@@ -106,23 +93,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
for (WorkOrderVo workOrder : records) {
|
|
|
workOrder.setRemainingQuantity(workOrder.getQuantity());
|
|
|
}
|
|
|
- List<Long> workOrderIds = records.stream().map(WorkOrder::getId).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(workOrderIds)) {
|
|
|
- List<ProductionPlan> productionPlanList = productionPlanService.list(q -> q.in(ProductionPlan::getWorkOrderId, workOrderIds));
|
|
|
- if (ObjectUtil.isNotEmpty(productionPlanList)) {
|
|
|
- //根据工单id分组
|
|
|
- Map<Long, List<ProductionPlan>> productionPlanMap = productionPlanList.stream().collect(Collectors.groupingBy(ProductionPlan::getWorkOrderId));
|
|
|
- for (WorkOrderVo workOrder : records) {
|
|
|
- List<ProductionPlan> productionPlanList1 = productionPlanMap.get(workOrder.getId());
|
|
|
- BigDecimal count = BigDecimal.ZERO;
|
|
|
- if (ObjectUtil.isNotEmpty(productionPlanList1)) {
|
|
|
- count = productionPlanList1.stream().map(ProductionPlan::getQuantity)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- }
|
|
|
- workOrder.setRemainingQuantity(workOrder.getQuantity().subtract(count));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
return page;
|
|
|
}
|
|
|
|
|
@@ -130,8 +100,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
public WorkOrderVo detail(Long id) {
|
|
|
WorkOrder WorkOrder = this.getById(id);
|
|
|
WorkOrderVo result = BeanUtil.toBean(WorkOrder, WorkOrderVo.class);
|
|
|
- List<ProductionPlan> list = productionPlanService.list(q -> q.eq(ProductionPlan::getWorkOrderId, id));
|
|
|
- result.setProductionPlans(list);
|
|
|
ProductInfo productInfo = productInfoService.getById(result.getProductId());
|
|
|
if (ObjectUtil.isNotEmpty(productInfo)) {
|
|
|
result.setProductName(productInfo.getName());
|
|
@@ -152,7 +120,7 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
throw new ServiceException("查询不到产品信息 产品id->" + workOrderDto.getProductId());
|
|
|
}
|
|
|
//搜索BOM明细并到冻结库存
|
|
|
- BomInfo bomInfo = bomInfoService.getOne(q -> q.eq(BomInfo::getProductId, workOrderDto.getProductId()).eq(BomInfo::getCurrentVersion,1));
|
|
|
+ BomInfo bomInfo = bomInfoService.getOne(q -> q.eq(BomInfo::getProductId, workOrderDto.getProductId()).eq(BomInfo::getCurrentVersion, 1));
|
|
|
if (ObjectUtil.isEmpty(bomInfo)) {
|
|
|
throw new ServiceException("查询不到产品的BOM信息 产品名称->" + productInfo.getName());
|
|
|
}
|
|
@@ -247,23 +215,6 @@ public class WorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, WorkOrder
|
|
|
for (WorkOrderVo workOrderVo : records) {
|
|
|
//赋值已计划数量
|
|
|
workOrderVo.setArrangedQuantity(workOrderVo.getQuantity().subtract(workOrderVo.getRemainingQuantity()));
|
|
|
- //赋值完成率
|
|
|
- long count =0;
|
|
|
- //获取工单下的所有计划
|
|
|
- List<Long> productionPlanIds = productionPlanService.listObject(ProductionPlan::getId,
|
|
|
- q -> q.eq(ProductionPlan::getWorkOrderId, workOrderVo.getId()));
|
|
|
- if (ObjectUtil.isNotEmpty(productionPlanIds)) {
|
|
|
- //获取计划下的所有任务
|
|
|
- List<Long> productionTaskIds = productionTaskService.listObject(ProductionTask::getId,
|
|
|
- q -> q.in(ProductionTask::getId, productionPlanIds));
|
|
|
- if (ObjectUtil.isNotEmpty(productionTaskIds)) {
|
|
|
- count = productionTaskDetailService.count(q ->
|
|
|
- q.in(ProductionTaskDetail::getProductionTaskId, productionTaskIds)
|
|
|
- .eq(ProductionTaskDetail::getFinishStatus, 1));
|
|
|
- }
|
|
|
- }
|
|
|
- BigDecimal divide = BigDecimal.valueOf(count).divide(workOrderVo.getQuantity(), 2, RoundingMode.HALF_UP);
|
|
|
- workOrderVo.setCompletionRate(divide);
|
|
|
}
|
|
|
return page;
|
|
|
}
|