|
@@ -93,6 +93,8 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
private ISysDeptService deptService;
|
|
|
@Resource
|
|
|
private IBizLotService bizLotService;
|
|
|
+ @Resource
|
|
|
+ private IBizFurnaceNoInfoService furnaceNoInfoService;
|
|
|
|
|
|
/**
|
|
|
* 查询外协单主
|
|
@@ -618,6 +620,40 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
+ @Log(title = "首序外协保存方法", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("/submitDetailsOnFirst")
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult submitDetailsOnFirst(@RequestBody BizOutsourcedOrder bizOutsourcedOrder) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ setTenantId(bizOutsourcedOrder);
|
|
|
+ //若有id,则说将之前的明细删除不生成新的单号
|
|
|
+ List<BizOutsourcedOrderDetail> insertDetail = new ArrayList<>();
|
|
|
+ List<BizOutsourcedOrderDetail> updateDetail = new ArrayList<>();
|
|
|
+ List<Long> removeIds = new ArrayList<>();
|
|
|
+ List<BizDaywork> insertDaywork = new ArrayList<>();
|
|
|
+ List<BizDaywork> updateDaywork = new ArrayList<>();
|
|
|
+ List<Long> removeDayworkIds = new ArrayList<>();
|
|
|
+ List<BizDayworkItem> insertDayworkItem = new ArrayList<>();
|
|
|
+ List<BizDayworkItem> updateDayworkItem = new ArrayList<>();
|
|
|
+ List<Long> removeDayworkItem = new ArrayList<>();
|
|
|
+ List<Long> removeDayworkCarrier = new ArrayList<>();
|
|
|
+ List<BizFurnaceNoInfo> insertFurnaceNoInfo = new ArrayList<>();
|
|
|
+ List<Long> removeFurnaceIds = new ArrayList<>();
|
|
|
+ List<BizOutsourcedRecords> insertRecord = new ArrayList<>();
|
|
|
+ List<BizOutsourcedOrderDetailProcess> insertProcess = new ArrayList<>();
|
|
|
+ List<BizOutsourcedOrderDetailProcess> updateProcess = new ArrayList<>();
|
|
|
+ List<Long> removeProcessIds = new ArrayList<>();
|
|
|
+ if (bizOutsourcedOrder.getId() != null && !bizOutsourcedOrder.getId().equals(0L)) {
|
|
|
+ List<BizOutsourcedOrderDetail> oldDetails = bizOutsourcedOrderDetailService.query().eq("master_id", bizOutsourcedOrder.getId()).list();
|
|
|
+ List<BizOutsourcedOrderDetail> removeDetails = oldDetails.stream().filter(v -> bizOutsourcedOrder.getDetails().stream().noneMatch(e -> e.getId().equals(v.getId()))).collect(Collectors.toList());
|
|
|
+ removeIds = removeDetails.stream().map(BizOutsourcedOrderDetail::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ bizOutsourcedOrderDetailService.removeByIds(removeIds);
|
|
|
+ } else {
|
|
|
+ saveAllForFirst(bizOutsourcedOrder);
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
/**
|
|
|
* 修改外协单主
|
|
|
* 带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|
|
@@ -875,4 +911,83 @@ public class BizOutsourcedOrderController extends BaseController {
|
|
|
return success(result);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void saveAllForFirst(BizOutsourcedOrder bizOutsourcedOrder) {
|
|
|
+ bizOutsourcedOrderService.save(bizOutsourcedOrder);
|
|
|
+ List<BizOutsourcedOrderDetail> details = bizOutsourcedOrder.getDetails();
|
|
|
+ SysDept condition = new SysDept();
|
|
|
+ condition.setDeptCode("170000");
|
|
|
+ SysDept dept = deptService.getDeptList(condition).stream().findFirst().orElse(null);
|
|
|
+ List<BizDaywork> dayworks = new ArrayList<>();
|
|
|
+ List<BizFurnaceNoInfo> furnaceNoInfos = new ArrayList<>();
|
|
|
+ List<BizOutsourcedOrderDetailProcess> detailProcesses = new ArrayList<>();
|
|
|
+ List<BizLot> lots = bizLotService.query().in("id", details.isEmpty() ?Collections.singletonList(0L) : details.stream().map(BizOutsourcedOrderDetail::getLotId).collect(Collectors.toList())).list();
|
|
|
+ List<BizDayworkItem> items = new ArrayList<>();
|
|
|
+ details.forEach(l -> {
|
|
|
+ l.setMasterId(bizOutsourcedOrder.getId());
|
|
|
+ BizDaywork daywork = new BizDaywork();
|
|
|
+ BizLot lot = lots.stream().filter(e -> e.getId().equals(l.getLotId())).findFirst().orElse(null);
|
|
|
+ daywork.setProductionPlanDetailId(l.getProductionPlanDetailId());
|
|
|
+ daywork.setProductId(l.getProductId());
|
|
|
+ daywork.setLotId(l.getLotId());
|
|
|
+ daywork.setLotCode(l.getLotCode());
|
|
|
+ daywork.setDeptId(dept != null ? dept.getDeptId() : 0L);
|
|
|
+ daywork.setProductId(l.getProductId());
|
|
|
+ daywork.setTechnologicalProcessId(l.getTechnologicalProcessId());
|
|
|
+ daywork.setProcessQualifiedNum(l.getProductNum());
|
|
|
+ daywork.setIsLast(lot != null ? lot.getIsLast() : null);
|
|
|
+ daywork.setIsWaste(lot != null ? lot.getIsWaste() : null);
|
|
|
+ daywork.setIsAmend(lot != null ? lot.getIsAmend() : null);
|
|
|
+ daywork.setIsWasteRecycling(lot != null ? lot.getIsWasteRecycling() :null);
|
|
|
+ dayworks.add(daywork);
|
|
|
+ l.setDayworkId(daywork.getId());
|
|
|
+ BizFurnaceNoInfo furnaceNoInfo = l.getFurnaceNoInfo();
|
|
|
+ furnaceNoInfo.setDayworkId(daywork.getId());
|
|
|
+ furnaceNoInfos.add(furnaceNoInfo);
|
|
|
+ l.getProcesses().forEach(v -> {
|
|
|
+ v.setMasterId(l.getMasterId());
|
|
|
+ v.setDetailId(l.getId());
|
|
|
+ v.setLotId(l.getLotId());
|
|
|
+ v.setLotCode(l.getLotCode());
|
|
|
+ v.setFormDate(l.getFormDate());
|
|
|
+ v.setDayworkId(l.getDayworkId());
|
|
|
+ v.setFormCode(l.getFormCode());
|
|
|
+ v.setProductDescription(l.getProductDescription());
|
|
|
+ v.setTechnologicalProcessId(l.getTechnologicalProcessId());
|
|
|
+ v.setSupplierId(l.getSupplierId());
|
|
|
+ v.setSupplierName(l.getSupplierName());
|
|
|
+ v.setDeliveryMethod(l.getDeliveryMethod());
|
|
|
+ v.setProductId(l.getProductId());
|
|
|
+ v.setTechnologyVersion(l.getTechnologyVersion());
|
|
|
+ v.setPackagingMethod(l.getPackagingMethod());
|
|
|
+ v.setProductNum(l.getProductNum());
|
|
|
+ v.setTenantId(l.getTenantId());
|
|
|
+ detailProcesses.add(v);
|
|
|
+ BizDayworkItem item = new BizDayworkItem();
|
|
|
+ item.setDayworkId(l.getDayworkId());
|
|
|
+ item.setOutsourceDetailId(l.getId());
|
|
|
+ item.setLotId(l.getLotId());
|
|
|
+ item.setProcessId(v.getProcessId());
|
|
|
+ item.setProcessStepNumber(v.getProcessStepNumber());
|
|
|
+ item.setStatus("1");
|
|
|
+ item.setProdNum(l.getProductNum());
|
|
|
+ item.setDeptId(dept != null ? dept.getDeptId() : null);
|
|
|
+ item.setDeptName(dept != null ? dept.getDeptName() : null);
|
|
|
+ item.setStartTime(new Date());
|
|
|
+ item.setDeptCode(dept != null ? dept.getDeptCode() : null);
|
|
|
+ item.setProductionPlanDetailId(l.getProductionPlanDetailId());
|
|
|
+ item.setTechnologicalProcessId(l.getTechnologicalProcessId());
|
|
|
+ item.setTechnologicalProcessDetailId(v.getTechnologicalProcessDetailId());
|
|
|
+ item.setIsWx(1);
|
|
|
+ items.add(item);
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ bizDayworkService.saveBatch(dayworks);
|
|
|
+ furnaceNoInfoService.saveBatch(furnaceNoInfos);
|
|
|
+ bizOutsourcedOrderDetailService.saveBatch(details);
|
|
|
+ bizOutsourcedOrderDetailProcessService.saveBatch(detailProcesses);
|
|
|
+ bizDayworkItemService.saveBatch(items);
|
|
|
+ }
|
|
|
+
|
|
|
}
|