From ad8a9bf67cb176e39ee53cd048aa89bbba274a56 Mon Sep 17 00:00:00 2001 From: zhc077 <565291854> Date: Fri, 24 Feb 2023 17:56:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E8=AE=A1=E5=88=92=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=96=202.24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/productplan/ProductplanManage.vue | 4 +- .../service/IZyProductPlanAutoService.java | 2 +- .../impl/IZyProductPlanAutoServiceImpl.java | 217 ++++++++++++++---- .../impl/ZyPlanProcessServiceImpl.java | 41 +++- 4 files changed, 199 insertions(+), 65 deletions(-) diff --git a/ant-design-vue-jeecg/src/views/productplan/ProductplanManage.vue b/ant-design-vue-jeecg/src/views/productplan/ProductplanManage.vue index 77870d39..f16ae16a 100644 --- a/ant-design-vue-jeecg/src/views/productplan/ProductplanManage.vue +++ b/ant-design-vue-jeecg/src/views/productplan/ProductplanManage.vue @@ -240,7 +240,7 @@ export default { path: '/productplan/ZyPlanProcessFabricDataList', query: { // 路由携带参数 'planId': props.row.planId, - 'planProcessId': props.row.processId, + 'planProcessId': props.row.id, }, }); }, @@ -251,7 +251,7 @@ export default { path: '/productplan/ZyPlanProcessAccessoriesDataList', query: { // 路由携带参数 'planId': props.row.planId, - 'planProcessId': props.row.processId, + 'planProcessId': props.row.id, }, }); }, diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanAutoService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanAutoService.java index 0d8110cb..d68eb088 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanAutoService.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/IZyProductPlanAutoService.java @@ -16,5 +16,5 @@ public interface IZyProductPlanAutoService extends IService { void doAuto(HttpServletRequest req); - void filling4Auto(String planId); + boolean filling4Auto(String planId); } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java index da1ed032..56cf578c 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java @@ -2,26 +2,30 @@ package org.jeecg.modules.productplan.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.apache.commons.lang3.StringUtils; import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.demo.pro.entity.ZyProcessMachine; import org.jeecg.modules.demo.pro.service.IZyProcessMachineService; +import org.jeecg.modules.operationtool.entity.ZyOperationtool; +import org.jeecg.modules.operationtool.service.IZyOperationtoolService; import org.jeecg.modules.productplan.entity.ZyPlanProcess; +import org.jeecg.modules.productplan.entity.ZyPlanProcessAccessories; +import org.jeecg.modules.productplan.entity.ZyPlanProcessFabric; import org.jeecg.modules.productplan.entity.ZyProductPlan; import org.jeecg.modules.productplan.enums.ProductPlanStatusEnum; +import org.jeecg.modules.productplan.mapper.ZyPlanProcessAccessoriesMapper; +import org.jeecg.modules.productplan.mapper.ZyPlanProcessFabricMapper; import org.jeecg.modules.productplan.mapper.ZyProductPlanMapper; -import org.jeecg.modules.productplan.service.IZyPlanProcessService; -import org.jeecg.modules.productplan.service.IZyProductPlanAutoService; -import org.jeecg.modules.productplan.service.IZyProductPlanService; +import org.jeecg.modules.productplan.service.*; +import org.jeecg.modules.productprocessaccessories.service.IProductProcessAccessoriesService; +import org.jeecg.modules.productprocessfabric.entity.ProductProcessFabric; +import org.jeecg.modules.productprocessfabric.service.IProductProcessFabricService; import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.service.ISysDepartService; import org.jeecg.modules.system.service.ISysUserService; -import org.jeecg.modules.team.entity.Groupx; -import org.jeecg.modules.team.entity.Station; -import org.jeecg.modules.team.entity.StationMachine; -import org.jeecg.modules.team.service.IGroupxService; -import org.jeecg.modules.team.service.IStationMachineService; -import org.jeecg.modules.team.service.IStationService; +import org.jeecg.modules.team.entity.*; +import org.jeecg.modules.team.service.*; import org.jeecg.modules.workorder.entity.WorkOrder; import org.jeecg.modules.workorder.enums.WorkOrderStatusEnum; import org.jeecg.modules.workorder.service.IWorkOrderService; @@ -63,15 +67,30 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl saveProductPlan(List workOrderList) { if (ObjectUtils.isEmpty(workOrderList)) return Collections.EMPTY_LIST; @@ -90,6 +109,8 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl groupxList = iGroupxService.list(new LambdaQueryWrapper().eq(Groupx::getDepartId, sysDepart)); + List groupxList = iGroupxService.list(new LambdaQueryWrapper().eq(Groupx::getDepartId, sysDepart.getId())); if (!ObjectUtils.isEmpty(groupxList)) { Groupx groupx = groupxList.get(0); //班组 @@ -112,8 +133,13 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl productPlanList = this.saveProductPlan(workOrderList); if (ObjectUtils.isEmpty(productPlanList)) return; - //3,保存计划生产工序 + //3,同步计划生产工序、同步生产计划工序面料、同步生产计划辅料 productPlanList.stream().forEach(f -> { ZyPlanProcess zyPlanProcess = new ZyPlanProcess(); zyPlanProcess.setPlanId(f.getId()); zyPlanProcessService.syncProductBaseProcess(zyPlanProcess); }); - //4,自动排位 + //4,自动排位(匹配工序设备、工序工具、工人) + // 匹配工序设备、工序工具有一个工序失败,则工单作为异常处理,删除生产计划及相关子表 + //只有一个生产计划的设备、工具都匹配成功才进行一下操作(生成物料单、发送到仓库) productPlanList.stream().forEach(k -> { - this.filling4Auto(k.getId()); +// boolean b = this.filling4Auto(k.getId()); +// if (b) { + List planProcessList = zyPlanProcessService.list(new LambdaQueryWrapper().eq(ZyPlanProcess::getPlanId, k.getId())); + Optional.ofNullable(planProcessList).orElse(new LinkedList<>()).forEach(e -> { + // 5,生成物料单 + zyPlanProcessService.createMaterialBill(e); + // 5,发送到仓库 + zyPlanProcessService.sendToRepository(e); + }); + +// } }); } @@ -202,7 +240,7 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl planProcessList = zyPlanProcessService.list(new LambdaQueryWrapper().eq(ZyPlanProcess::getPlanId, planId)); //是否有计划工序 - if (ObjectUtils.isEmpty(planProcessList)) return; + if (ObjectUtils.isEmpty(planProcessList)) return false; //生产计划车间工位列表 List stationList = iStationService.list(new LambdaQueryWrapper().eq(Station::getDepartId, zyProductPlan.getWorkshopId())); @@ -221,9 +259,15 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl planProcessList, List stationList, final String planId) { - if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false; + public boolean diff(List planProcessList, List stationList, final String planId) { - AtomicBoolean b = new AtomicBoolean(true); List updateList = new LinkedList<>(); - k: if (b.get()) { - f: for (int i = 0; i < planProcessList.size(); i++) { + if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false; + AtomicBoolean b = new AtomicBoolean(true); + flag: + if (b.get()) { + planProcessList: + for (int i = 0; i < planProcessList.size(); i++) { ZyPlanProcess obj = planProcessList.get(i); List machineList = iZyProcessMachineService.list(new LambdaQueryWrapper().eq(ZyProcessMachine::getProcessId, obj.getProcessId())); + List toolList = iZyOperationtoolService.list(new LambdaQueryWrapper().eq(ZyOperationtool::getOperationid, obj.getProcessId())); List zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList()); - for (int j = 0; j < stationList.size(); j++) { - Station station = stationList.get(j); - List stationMachineList = iStationMachineService.list(new LambdaQueryWrapper().eq(StationMachine::getStationId, station.getId())); - List stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream() - .map(StationMachine::getMachineId).collect(Collectors.toList()); -// 设备匹配成功 - if (stationMachineIds.containsAll(zyProcessMachineIds)) { - String collect = zyProcessMachineIds.stream().collect(Collectors.joining(",")); - obj.setMachineIds(collect); - obj.setMachineNames(iStationMachineService.convertByMachineIds(zyProcessMachineIds)); - obj.setStationId(station.getId()); - obj.setStationName(station.getStationName()); - obj.setStationNum(station.getStationNum()); - updateList.add(obj); - break f; - } else { -// 作工单异常处理,删除该工单的生产计划,删除生产计划工序 - ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId); - iWorkOrderService.lambdaUpdate() - .set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.EXCEPTION.getCode()) - .eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()).update(); - zyPlanProcessService.remove(new LambdaQueryWrapper().in(ZyPlanProcess::getPlanId, planId)); - iZyProductPlanService.remove(new LambdaQueryWrapper().in(ZyProductPlan::getId, planId)); + List zyProcessToolIds = toolList.stream().map(ZyOperationtool::getOperationid).collect(Collectors.toList()); + + ZyPlanProcess diffMachine = this.diffMachine(obj, zyProcessMachineIds, stationList); + //设备匹配失败,直接结束 + if (ObjectUtils.isEmpty(diffMachine)) { + b.set(false); + break flag; + } else { // 设备匹配,则匹配工具 + ZyPlanProcess diffTool = this.diffTool(diffMachine, zyProcessToolIds, stationList); + if (ObjectUtils.isEmpty(diffTool)) { b.set(false); - break k; + break flag; + } else { // 匹配工人 + updateList.add(diffTool); + //匹配下一个工序的设备和工具 + continue planProcessList; } } } - } - if (b.get()) { zyPlanProcessService.saveOrUpdateBatch(updateList); + return true; + } else { + ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId); + // 1,作工单异常处理, + iWorkOrderService.lambdaUpdate() + .set(WorkOrder::getWorkOrderStatus, WorkOrderStatusEnum.EXCEPTION.getCode()) + .eq(WorkOrder::getProductCode, zyProductPlan.getProductCode()).update(); + // 2,删除生产计划工序面料 + iZyPlanProcessFabricService.remove(new LambdaQueryWrapper().in(ZyPlanProcessFabric::getPlanId, planId)); + // 3,删除生产计划工序辅料 + iZyPlanProcessAccessoriesService.remove(new LambdaQueryWrapper().in(ZyPlanProcessAccessories::getPlanId, planId)); + // 4,删除生产计划工序 + zyPlanProcessService.remove(new LambdaQueryWrapper().in(ZyPlanProcess::getPlanId, planId)); + // 5,删除生产计划 + iZyProductPlanService.remove(new LambdaQueryWrapper().in(ZyProductPlan::getId, planId)); + return false; + } + return false; + } + + @Transactional(rollbackFor = Exception.class, readOnly = false) + public void diffWorker(List zyPlanProcessList, final String planId) { + ZyProductPlan zyProductPlan = iZyProductPlanService.getById(planId); + Groupx groupx = iGroupxService.getOne(new LambdaQueryWrapper().eq(Groupx::getDepartId, zyProductPlan.getWorkshopId())); + List memberList = iGroupxMemberService.list(new LambdaQueryWrapper() + .eq(GroupxMember::getGroupxId, groupx.getId())); + if (ObjectUtils.isEmpty(memberList)) return; + + int size = zyPlanProcessList.size(); + List groupxMember2 = new LinkedList<>(); + groupxMember2.addAll(memberList); + int size2 = groupxMember2.size(); + while (size2 < size) { + groupxMember2.addAll(memberList); + size2 = groupxMember2.size(); + } + AtomicInteger i = new AtomicInteger(0); + Optional.ofNullable(zyPlanProcessList).orElse(new LinkedList<>()).forEach(e -> { + GroupxMember groupxMember = groupxMember2.get(i.get()); + e.setUserIds(groupxMember.getUserId()); + SysUser sysUser = iSysUserService.getById(groupxMember.getUserId()); + e.setUserNames(sysUser.getRealname()); + i.set(i.get() + 1); + }); + zyPlanProcessService.saveOrUpdateBatch(zyPlanProcessList); + } + + ZyPlanProcess diffMachine(ZyPlanProcess zyPlanProcess, List zyProcessMachineIds, List stationList) { + for (int j = 0; j < stationList.size(); j++) { + Station station = stationList.get(j); + List stationMachineList = iStationMachineService.list(new LambdaQueryWrapper().eq(StationMachine::getStationId, station.getId())); + List stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream() + .map(StationMachine::getMachineId).collect(Collectors.toList()); +// 设备匹配成功 + if (stationMachineIds.containsAll(zyProcessMachineIds)) { + String machineIds = zyProcessMachineIds.stream().collect(Collectors.joining(",")); + zyPlanProcess.setMachineIds(machineIds); + zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(zyProcessMachineIds)); + zyPlanProcess.setStationId(station.getId()); + zyPlanProcess.setStationName(station.getStationName()); + zyPlanProcess.setStationNum(station.getStationNum()); + return zyPlanProcess; + } + } + return null; + } + + ZyPlanProcess diffTool(ZyPlanProcess zyPlanProcess, List zyProcessToolIds, List stationList) { + for (int j = 0; j < stationList.size(); j++) { + Station station = stationList.get(j); + List stationToolList = iStationToolService.list(new LambdaQueryWrapper().eq(StationTool::getToolsId, station.getId())); + List stationToolIds = Optional.ofNullable(stationToolList).orElse(new ArrayList<>()).stream() + .map(StationTool::getToolsId).collect(Collectors.toList()); +// 工具匹配成功 + if (stationToolIds.containsAll(zyProcessToolIds)) { + String toolIds = zyProcessToolIds.stream().collect(Collectors.joining(",")); + zyPlanProcess.setToolsIds(toolIds); + return zyPlanProcess; + } } - return b.get(); + return null; } } diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java index cff2de67..7591baab 100644 --- a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java @@ -34,6 +34,10 @@ import org.jeecg.modules.productplan.mapper.ZyPlanProcessAccessoriesMapper; import org.jeecg.modules.productplan.mapper.ZyPlanProcessFabricMapper; import org.jeecg.modules.productplan.mapper.ZyPlanProcessMapper; import org.jeecg.modules.productplan.service.*; +import org.jeecg.modules.productprocessaccessories.entity.ProductProcessAccessories; +import org.jeecg.modules.productprocessaccessories.service.IProductProcessAccessoriesService; +import org.jeecg.modules.productprocessfabric.entity.ProductProcessFabric; +import org.jeecg.modules.productprocessfabric.service.IProductProcessFabricService; import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.entity.SysUser; import org.jeecg.modules.system.service.ISysDepartService; @@ -111,7 +115,6 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl planProcessList = this.list(new LambdaQueryWrapper().eq(ZyPlanProcess::getPlanId, zyPlanProcess.getPlanId())); //工序面料同步到计划工序面料表 + //产品工序面料同步到计划工序面料表 this.saveBatchFabricByProcessIdList(planProcessList); - //工序辅料同步到计划工序辅料表 + //产品工序辅料同步到计划工序辅料表 this.saveBatchAccessoriesByProcessIdList(planProcessList); //填充前导工序、和后导工序 @@ -413,13 +424,17 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl planProcessList) { Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).forEach(e -> { - List accessoriesList = this.iZyProcessAccessoriesService.list(new LambdaQueryWrapper() - .eq(ZyProcessAccessories::getProcessId, e.getProcessId())); +// List accessoriesList = this.iZyProcessAccessoriesService.list(new LambdaQueryWrapper() +// .eq(ZyProcessAccessories::getProcessId, e.getProcessId())); + + List accessoriesList = iProductProcessAccessoriesService.list(new LambdaQueryWrapper() + .eq(ProductProcessAccessories::getProductProcessId, e.getProcessId())); List list = new LinkedList<>(); Optional.ofNullable(accessoriesList).orElse(new ArrayList<>()).forEach(obj -> { ZyPlanProcessAccessories en = new ZyPlanProcessAccessories(); en.setPlanProcessId(e.getId()); en.setPlanId(e.getPlanId()); + en.setAmount(new BigDecimal(obj.getAmount())); en.setAccessoriesId(obj.getAccessoriesId()); ZyAccessories zyAccessories = iZyAccessoriesService.getById(obj.getAccessoriesId()); en.setAccessoriesName(StringUtils.isNotBlank(zyAccessories.getContents()) ? zyAccessories.getContents() : ""); @@ -430,17 +445,21 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl planProcessList) { - if (!org.springframework.util.StringUtils.isEmpty(planProcessList)) { + if (!ObjectUtils.isEmpty(planProcessList)) { planProcessList.forEach(e -> { - List fabricList = this.iZyProcessFabricService.list(new LambdaQueryWrapper() - .eq(ZyProcessFabric::getProcessId, e.getProcessId())); +// List fabricList = this.iZyProcessFabricService.list(new LambdaQueryWrapper() +// .eq(ZyProcessFabric::getProcessId, e.getProcessId())); + + List fabricList = iProductProcessFabricService.list(new LambdaQueryWrapper() + .eq(ProductProcessFabric::getProductProcessId, e.getProcessId())); List list = new LinkedList<>(); - if (!org.springframework.util.StringUtils.isEmpty(fabricList)) { + if (!ObjectUtils.isEmpty(fabricList)) { fabricList.forEach(obj -> { ZyPlanProcessFabric en = new ZyPlanProcessFabric(); en.setPlanProcessId(e.getId()); en.setPlanId(e.getPlanId()); en.setFabricId(obj.getFabricId()); + en.setAmount(new BigDecimal(obj.getAmount())); ZyFabric zyFabric = iZyFabricService.getById(obj.getFabricId()); en.setFabricName(StringUtils.isNotBlank(zyFabric.getName()) ? zyFabric.getName() : ""); list.add(en);