|
@@ -69,6 +69,8 @@ public class BizReturnTurnoverController extends BaseController
|
|
|
@Resource
|
|
|
private IBizProductionResourceGroupService bizProductionResourceGroupService;
|
|
|
@Resource
|
|
|
+ private IBizCarrierCategoryService carrierCategoryService;
|
|
|
+ @Resource
|
|
|
private SysDeptMapper sysDeptMapper;
|
|
|
@Resource
|
|
|
private RedisCache redisCache;
|
|
@@ -95,6 +97,7 @@ public class BizReturnTurnoverController extends BaseController
|
|
|
//查询周转到外协的工序
|
|
|
List<Long> outsourceDetailIds = list.stream().map(BizOutsourcedOrderDetail::getId).collect(Collectors.toList());
|
|
|
List<Long> dayworkIds = list.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList());
|
|
|
+ List<BizDaywork> dayworks = bizDayworkService.query().in("id", dayworkIds.isEmpty()? Collections.singletonList(0L): dayworkIds).list();
|
|
|
if(!dayworkIds.isEmpty()) {
|
|
|
List<BizOutsourcedOrderDetailProcess> outsourceDetailProcess = bizOutsourcedOrderDetailProcessService.query().in("detail_id", outsourceDetailIds).list();
|
|
|
//如果下道序扫码开始新批次了,则不能编辑载具和周转信息
|
|
@@ -108,6 +111,13 @@ public class BizReturnTurnoverController extends BaseController
|
|
|
if(!Objects.equals(lastProcess.getProcessStepNumber(), lastItem.getProcessStepNumber())) {
|
|
|
detail.setFlag(false);
|
|
|
}
|
|
|
+ BizDaywork daywork = dayworks.stream().filter(l -> l.getId().equals(detail.getDayworkId())).findFirst().orElse(null);
|
|
|
+ if (daywork != null) {
|
|
|
+ detail.setIsAmend(daywork.getIsAmend());
|
|
|
+ detail.setIsWaste(daywork.getIsWaste());
|
|
|
+ detail.setIsWasteRecycling(Integer.parseInt(daywork.getIsWasteRecycling().toString()));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
// List<BizDayworkCarrier> dayworkCarrierList = bizDayworkCarrierService.query().in("daywork_id", dayworkIds).eq("is_changed",0).list();
|
|
|
// for (BizOutsourcedOrderDetail detail : list) {
|
|
@@ -327,6 +337,126 @@ public class BizReturnTurnoverController extends BaseController
|
|
|
return success();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:returnTurnover:edit')")
|
|
|
+ @Log(title = "外协批量周转", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional
|
|
|
+ @PostMapping("/batchTurnover")
|
|
|
+ public AjaxResult batchTurnover(@RequestBody BizOutsourcedOrderDetail outsourcedOrderDetail) throws NoSuchFieldException, IllegalAccessException {
|
|
|
+ // 批量周转不换箱 则不需要判断是否箱被占用
|
|
|
+ //修改收回单明细的箱号和周转工段
|
|
|
+ List<BizOutsourcedOrderDetail> batches = outsourcedOrderDetail.getBatches();
|
|
|
+ List<BizDayworkItem> addItems = new ArrayList<>();
|
|
|
+ List<BizDayworkItem> removeItems = new ArrayList<>();
|
|
|
+ List<BizDaywork> updateDaywork = new ArrayList<>();
|
|
|
+ List<BizProductionResourceGroupSubPlan> subPlanList = new ArrayList<>();
|
|
|
+ //操作dayworkCarrier表,如果该批次已经绑箱,把对应箱解绑,并重新绑定新箱子
|
|
|
+ List<BizDayworkCarrier> newDayworkCarrierList = new ArrayList<>();
|
|
|
+ List<BizDayworkItem> bizDayworkItems = bizDayworkItemService.getListByDayworkIds(batches.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList()));
|
|
|
+ List<BizDayworkCarrier> returnDayworkCarrierList = bizDayworkCarrierService.query().in("daywork_id", batches.isEmpty() ? Collections.singletonList(0L) : batches.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList())).eq("is_changed",0).list();
|
|
|
+ List<BizDaywork> bizDayworks = bizDayworkService.query().in("id", batches.isEmpty() ? Collections.singletonList(0L) : batches.stream().map(BizOutsourcedOrderDetail::getDayworkId).collect(Collectors.toList())).list();
|
|
|
+
|
|
|
+ if (returnDayworkCarrierList.size() > 0){
|
|
|
+ returnDayworkCarrierList.stream().forEach(bizDayworkCarrier -> bizDayworkCarrier.setIsChanged(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自动派活
|
|
|
+ SysDept sysDept = sysDeptMapper.selectDeptById(outsourcedOrderDetail.getProductionDeptId());
|
|
|
+
|
|
|
+ List<BizProductionResourceGroup> productionResourceGroupList = bizProductionResourceGroupService.list(new QueryWrapper<BizProductionResourceGroup>().eq("dept_id", outsourcedOrderDetail.getProductionDeptId()).eq("is_deactivate", 0));
|
|
|
+
|
|
|
+ batches.forEach(l -> {
|
|
|
+ l.setProductionCarrier(l.getNewCarrierName());
|
|
|
+ l.setProductionDeptId(outsourcedOrderDetail.getProductionDeptId());
|
|
|
+ l.setProductionDeptName(outsourcedOrderDetail.getProductionDeptName());
|
|
|
+ l.getCarriers().forEach(v -> {
|
|
|
+ BizDayworkCarrier carrier = new BizDayworkCarrier();
|
|
|
+ carrier.setCarrierId(v.getId());
|
|
|
+ carrier.setCarrierCode(v.getCode());
|
|
|
+ carrier.setDayworkId(l.getDayworkId());
|
|
|
+ carrier.setLotId(l.getLotId());
|
|
|
+ newDayworkCarrierList.add(carrier);
|
|
|
+ });
|
|
|
+ BizDaywork daywork = bizDayworks.stream().filter(v -> v.getId().equals(l.getDayworkId())).findFirst().orElse(null);
|
|
|
+ BizDayworkItem lastDayworkItem = bizDayworkItems.stream().filter(v -> v.getDayworkId().equals(l.getDayworkId())).sorted(Comparator.comparing(BizDayworkItem::getProcessStepNumber).reversed()).collect(Collectors.toList()).get(0);
|
|
|
+ if("4".equals(lastDayworkItem.getStatus())){
|
|
|
+ removeItems.add(lastDayworkItem);
|
|
|
+ }
|
|
|
+ BizDayworkItem item = new BizDayworkItem();
|
|
|
+ item.setDayworkId(l.getDayworkId());
|
|
|
+ item.setProductionPlanDetailId(lastDayworkItem.getProductionPlanDetailId());
|
|
|
+ item.setLotId(l.getLotId());
|
|
|
+ item.setProdNum(lastDayworkItem.getProdNum());
|
|
|
+ item.setQualifiedNum(lastDayworkItem.getQualifiedNum());
|
|
|
+ item.setTechnologicalProcessId(lastDayworkItem.getTechnologicalProcessId());
|
|
|
+ item.setTechnologicalProcessDetailId(lastDayworkItem.getTechnologicalProcessDetailId());
|
|
|
+ item.setProcessStepNumber(lastDayworkItem.getProcessStepNumber());
|
|
|
+ item.setProcessId(lastDayworkItem.getProcessId());
|
|
|
+ item.setDeptId(l.getProductionDeptId());
|
|
|
+ item.setDeptName(l.getProductionDeptName());
|
|
|
+ item.setStatus("4");
|
|
|
+ item.setNickName("外协");
|
|
|
+ item.setStartTime(new Date());
|
|
|
+ item.setTurnoverType("2");
|
|
|
+ item.setTurnoverArea("外协周转区");
|
|
|
+ addItems.add(item);
|
|
|
+
|
|
|
+ //修改daywork主表数据
|
|
|
+ daywork.setProcessQualifiedNum(outsourcedOrderDetail.getAuditNum());
|
|
|
+ daywork.setTemporaryProcessQualifiedNum(outsourcedOrderDetail.getAuditNum());
|
|
|
+ daywork.setDeptId(outsourcedOrderDetail.getProductionDeptId());
|
|
|
+ updateDaywork.add(daywork);
|
|
|
+
|
|
|
+ if (sysDept.getAutoAllocation() == 1) {
|
|
|
+ // 查资源组
|
|
|
+
|
|
|
+ //查询是否已经分配资源组
|
|
|
+ BizProductionResourceGroupSubPlan groupSubPlan=new BizProductionResourceGroupSubPlan();
|
|
|
+ groupSubPlan.setDeptId(outsourcedOrderDetail.getProductionDeptId());
|
|
|
+ groupSubPlan.setProductionPlanDetailId(daywork.getProductionPlanDetailId());
|
|
|
+
|
|
|
+ List<BizProductionResourceGroupSubPlan> groupSubPlanList = bizProductionResourceGroupSubPlanService.getAotList(groupSubPlan);
|
|
|
+ //如果没分配
|
|
|
+ if(groupSubPlanList.size()==0){
|
|
|
+ //查产品id
|
|
|
+ BizProductionPlanDetail productionPlanDetail = bizProductionPlanDetailService.getOne(new QueryWrapper<BizProductionPlanDetail>().eq("id", item.getProductionPlanDetailId()));
|
|
|
+ for (BizProductionResourceGroup info : productionResourceGroupList) {
|
|
|
+ BizProductionResourceGroupSubPlan subPlan = new BizProductionResourceGroupSubPlan();
|
|
|
+ subPlan.setProductId(productionPlanDetail.getProductId());
|
|
|
+ subPlan.setProductionPlanDetailId(lastDayworkItem.getProductionPlanDetailId());
|
|
|
+ subPlan.setTechnologicalProcessId(outsourcedOrderDetail.getTechnologicalProcessId());
|
|
|
+ subPlan.setResourceGroupId(info.getId());
|
|
|
+ subPlan.setDeptId(outsourcedOrderDetail.getProductionDeptId());
|
|
|
+ subPlan.setResourceGroupCode(info.getCode());
|
|
|
+ subPlanList.add(subPlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ bizOutsourcedOrderDetailService.updateBatchById(batches);
|
|
|
+ bizDayworkCarrierService.updateBatchById(returnDayworkCarrierList);
|
|
|
+ bizDayworkCarrierService.saveBatch(newDayworkCarrierList);
|
|
|
+ bizDayworkItemService.removeBatchByIds(removeItems);
|
|
|
+ bizDayworkItemService.saveBatch(addItems);
|
|
|
+ bizDayworkService.updateBatchById(updateDaywork);
|
|
|
+ bizProductionResourceGroupSubPlanService.saveBatch(subPlanList);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "判断携带箱类型", businessType = BusinessType.SELECT)
|
|
|
+ @GetMapping("/checkCarriers")
|
|
|
+ public AjaxResult checkCarriers(@RequestParam String carriers) {
|
|
|
+ List<String> carrierCodes = Arrays.stream(carriers.split(",")).collect(Collectors.toList());
|
|
|
+ List<BizCarrier> carrierList = carrierService.query().in("code", carrierCodes).list();
|
|
|
+ List<BizCarrierCategory> categories = carrierCategoryService.query().eq("name", "外协箱").list();
|
|
|
+ if (carrierList.stream().anyMatch(t -> categories.stream().anyMatch(e -> t.getCategoryId().equals(e.getId())))) {
|
|
|
+ return success(false);
|
|
|
+ } else {
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
/**
|
|
|
* 删除外协单主
|
|
|
带箱方式,是整单的。如果换新箱子,明细中,都需要更换箱子
|