生产计划-自动排位功能优化 5.12

master
zhc077 2 years ago
parent ef6fb5c1c6
commit 132f31c519
  1. 20
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java
  2. 42
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/ZyPlanProcessServiceImpl.java

@ -6,6 +6,8 @@ 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.device.entity.ZyDevice;
import org.jeecg.modules.device.service.IZyDeviceService;
import org.jeecg.modules.operationtool.entity.ZyOperationtool;
import org.jeecg.modules.operationtool.service.IZyOperationtoolService;
import org.jeecg.modules.productplan.entity.ZyPlanProcess;
@ -380,9 +382,10 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
List<ZyProcessMachine> machineList = iZyProcessMachineService.list(new LambdaQueryWrapper<ZyProcessMachine>().eq(ZyProcessMachine::getProcessId, obj.getProcessId()));
List<ZyOperationtool> toolList = iZyOperationtoolService.list(new LambdaQueryWrapper<ZyOperationtool>().eq(ZyOperationtool::getOperationid, obj.getProcessId()));
List<String> zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList());
List<String> zyProcessCodes = machineList.stream().map(ZyProcessMachine::getCode).collect(Collectors.toList());
List<String> zyProcessToolIds = toolList.stream().map(ZyOperationtool::getOperationid).collect(Collectors.toList());
ZyPlanProcess diffMachine = this.diffMachine(obj, zyProcessMachineIds, stationList);
ZyPlanProcess diffMachine = this.diffMachine(obj, zyProcessMachineIds, zyProcessCodes, stationList);
//设备匹配失败,直接结束
if (ObjectUtils.isEmpty(diffMachine)) {
b.set(false);
@ -447,14 +450,19 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp
zyPlanProcessService.saveOrUpdateBatch(zyPlanProcessList);
}
ZyPlanProcess diffMachine(ZyPlanProcess zyPlanProcess, List<String> zyProcessMachineIds, List<Station> stationList) {
@Autowired
private IZyDeviceService iZyDeviceService;
ZyPlanProcess diffMachine(ZyPlanProcess zyPlanProcess, List<String> zyProcessMachineIds, List<String> zyProcessCodes, List<Station> stationList) {
for (int j = 0; j < stationList.size(); j++) {
Station station = stationList.get(j);
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, station.getId()));
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream()
.map(StationMachine::getMachineId).collect(Collectors.toList());
// 设备匹配成功
if (stationMachineIds.containsAll(zyProcessMachineIds)) {
//工位设备ids
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream().map(StationMachine::getMachineId).collect(Collectors.toList());
List<ZyDevice> zyDeviceList = iZyDeviceService.list(new LambdaQueryWrapper<ZyDevice>().in(ZyDevice::getId, stationMachineIds));
List<String> zyDevice_typeCodes = Optional.ofNullable(zyDeviceList).orElse(new ArrayList<>()).stream().map(ZyDevice::getTypeCode).collect(Collectors.toList());
// 工位设备包含工序设备即匹配成功
if (zyDevice_typeCodes.containsAll(zyProcessCodes)) {
String machineIds = zyProcessMachineIds.stream().collect(Collectors.joining(","));
zyPlanProcess.setMachineIds(machineIds);
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(zyProcessMachineIds));

@ -25,6 +25,8 @@ import org.jeecg.modules.demo.pro.service.IZyProcessFabricService;
import org.jeecg.modules.demo.pro.service.IZyProcessMachineService;
import org.jeecg.modules.demo.zyorders.entity.ZyOrders;
import org.jeecg.modules.demo.zyorders.service.IZyOrdersService;
import org.jeecg.modules.device.entity.ZyDevice;
import org.jeecg.modules.device.service.IZyDeviceService;
import org.jeecg.modules.product.zyproductprocess.entity.ZyProductProcess;
import org.jeecg.modules.product.zyproductprocess.service.IZyProductProcessService;
import org.jeecg.modules.productplan.entity.*;
@ -128,7 +130,7 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
private IZyPlanProcessAccessoriesService iZyPlanProcessAccessoriesService;
@Autowired
private IZyProcessFabricService iZyProcessFabricService;
private IZyDeviceService iZyDeviceService;
@Autowired
private IZyProcessAccessoriesService iZyProcessAccessoriesService;
@ -248,8 +250,9 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
* 根据工序查询工序设备表zy_process_machine
*/
Optional.ofNullable(planProcessList).orElse(new ArrayList<>()).forEach(e -> {
List<ZyProcessMachine> machineList = iZyProcessMachineService.list(new LambdaQueryWrapper<ZyProcessMachine>().eq(ZyProcessMachine::getProcessId, e.getProcessId()));
this.diffMachine(e, stationList, machineList);
//工序设备列表
List<ZyProcessMachine> zyProcessMachineList = iZyProcessMachineService.list(new LambdaQueryWrapper<ZyProcessMachine>().eq(ZyProcessMachine::getProcessId, e.getProcessId()));
this.diffMachine(e, stationList, zyProcessMachineList);
});
}
@ -298,16 +301,29 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
}
void diffMachine(ZyPlanProcess zyPlanProcess, List<Station> stationList, List<ZyProcessMachine> machineList) {
if (!ObjectUtils.isEmpty(machineList)) {
List<String> machineList1 = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList());
/**
* @param zyPlanProcess 生产计划工序
* @param stationList 车间工位
* @param zyProcessMachineList 工序设备列表
*/
void diffMachine(ZyPlanProcess zyPlanProcess, List<Station> stationList, List<ZyProcessMachine> zyProcessMachineList) {
if (!ObjectUtils.isEmpty(zyProcessMachineList)) {
//工序设备类型列表
List<String> zyDevicetype_codes = zyProcessMachineList.stream().map(ZyProcessMachine::getCode).collect(Collectors.toList());
Optional.ofNullable(stationList).orElse(new ArrayList<>()).forEach(e -> {
List<StationMachine> stationMachineList = iStationMachineService.list(new LambdaQueryWrapper<StationMachine>().eq(StationMachine::getStationId, e.getId()));
List<String> machineList2 = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream().map(StationMachine::getMachineId).collect(Collectors.toList());
if (machineList2.containsAll(machineList1)) {
String collect = machineList1.stream().collect(Collectors.joining(","));
//工位设备ids
List<String> stationMachineIds = Optional.ofNullable(stationMachineList).orElse(new ArrayList<>()).stream().map(StationMachine::getMachineId).collect(Collectors.toList());
List<ZyDevice> zyDeviceList = iZyDeviceService.list(new LambdaQueryWrapper<ZyDevice>().in(ZyDevice::getId, stationMachineIds));
List<String> zyDevice_typeCodes = Optional.ofNullable(zyDeviceList).orElse(new ArrayList<>()).stream().map(ZyDevice::getTypeCode).collect(Collectors.toList());
/**
* 工位设备包含工序设备即匹配成功
*/
if (zyDevice_typeCodes.containsAll(zyDevicetype_codes)) {
String collect = zyProcessMachineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.joining(","));
zyPlanProcess.setMachineIds(collect);
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(machineList1));
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(stationMachineIds));
zyPlanProcess.setStationId(e.getId());
zyPlanProcess.setStationName(e.getStationName());
zyPlanProcess.setStationNum(e.getStationNum());
@ -373,15 +389,13 @@ public class ZyPlanProcessServiceImpl extends ServiceImpl<ZyPlanProcessMapper, Z
//第一个没有前导工序
if (i == 0) {
//判断是否有下到工序
if(planProcessList.size()>1)
{
if (planProcessList.size() > 1) {
ZyPlanProcess process1 = planProcessList.get(i);
ZyPlanProcess process2 = planProcessList.get(i + 1);
process1.setPostProcess(process2.getProcessId());
process1.setPostProcessName(process2.getProcessName());
updateList.add(process1);
}else
{
} else {
ZyPlanProcess process1 = planProcessList.get(i);
updateList.add(process1);
}

Loading…
Cancel
Save