|
|
@ -11,6 +11,7 @@ import org.jeecg.modules.device.entity.ZyDevice; |
|
|
|
import org.jeecg.modules.device.service.IZyDeviceService; |
|
|
|
import org.jeecg.modules.device.service.IZyDeviceService; |
|
|
|
import org.jeecg.modules.operationtool.entity.ZyOperationtool; |
|
|
|
import org.jeecg.modules.operationtool.entity.ZyOperationtool; |
|
|
|
import org.jeecg.modules.operationtool.service.IZyOperationtoolService; |
|
|
|
import org.jeecg.modules.operationtool.service.IZyOperationtoolService; |
|
|
|
|
|
|
|
import org.jeecg.modules.person.vo.station; |
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcess; |
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcess; |
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcessAccessories; |
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcessAccessories; |
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcessFabric; |
|
|
|
import org.jeecg.modules.productplan.entity.ZyPlanProcessFabric; |
|
|
@ -351,7 +352,7 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
* 依次用该生产计划的车间工位设备循环与工序设备比对【(工位设备包含工序设备即是匹配成功,则自动填充工位、设备字段数据,匹配不上则不自动填充,由用户自己录入)】 |
|
|
|
* 依次用该生产计划的车间工位设备循环与工序设备比对【(工位设备包含工序设备即是匹配成功,则自动填充工位、设备字段数据,匹配不上则不自动填充,由用户自己录入)】 |
|
|
|
* 根据工序,查询工序设备表zy_process_machine, |
|
|
|
* 根据工序,查询工序设备表zy_process_machine, |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
boolean b = this.diff(planProcessList, stationList, planId); |
|
|
|
boolean b = this.diff(planProcessList, stationList, zyProductPlan); |
|
|
|
//工序匹配失败,已删除生产计划、生产计划工序
|
|
|
|
//工序匹配失败,已删除生产计划、生产计划工序
|
|
|
|
if (!b) { |
|
|
|
if (!b) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -371,7 +372,7 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
* @param stationList |
|
|
|
* @param stationList |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class, readOnly = false) |
|
|
|
@Transactional(rollbackFor = Exception.class, readOnly = false) |
|
|
|
public boolean diff(List<ZyPlanProcess> planProcessList, List<Station> stationList, final String planId) { |
|
|
|
public boolean diff(List<ZyPlanProcess> planProcessList, List<Station> stationList, final ZyProductPlan zyProductPlan) { |
|
|
|
|
|
|
|
|
|
|
|
List<ZyPlanProcess> updateList = new LinkedList<>(); |
|
|
|
List<ZyPlanProcess> updateList = new LinkedList<>(); |
|
|
|
if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false; |
|
|
|
if (ObjectUtils.isEmpty(stationList) || ObjectUtils.isEmpty(planProcessList)) return false; |
|
|
@ -382,17 +383,19 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
List<String> zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList()); |
|
|
|
List<String> zyProcessMachineIds = machineList.stream().map(ZyProcessMachine::getMachineId).collect(Collectors.toList()); |
|
|
|
List<String> zyProcessCodes = machineList.stream().map(ZyProcessMachine::getCode).collect(Collectors.toList()); |
|
|
|
List<String> zyProcessCodes = machineList.stream().map(ZyProcessMachine::getCode).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
ZyPlanProcess diffMachine = this.diffMachine(obj, zyProcessMachineIds, zyProcessCodes, stationList); |
|
|
|
//匹配设备时,已更新station.tasksCount值,在这时查询最新的数据
|
|
|
|
|
|
|
|
List<Station> stationListNew = iStationService.list(new LambdaQueryWrapper<Station>().eq(Station::getDepartId, zyProductPlan.getWorkshopId())); |
|
|
|
|
|
|
|
ZyPlanProcess diffMachine = this.diffMachine(obj, zyProcessMachineIds, zyProcessCodes, stationListNew); |
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(diffMachine)) { |
|
|
|
if (ObjectUtils.isEmpty(diffMachine)) { |
|
|
|
//设备匹配失败,删除该生产计划相半数据,直接结束
|
|
|
|
//设备匹配失败,删除该生产计划相半数据,直接结束
|
|
|
|
this.doException(planId, obj, "工序设备匹配"); |
|
|
|
this.doException(zyProductPlan.getId(), obj, "工序设备匹配"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} /*else { // 设备匹配成功,则匹配工具 //TODO 暂时注释掉 工序工具匹配
|
|
|
|
} /*else { // 设备匹配成功,则匹配工具 //TODO 暂时注释掉 工序工具匹配
|
|
|
|
ZyPlanProcess diffTool = this.diffTool(diffMachine, toolList, stationList); |
|
|
|
ZyPlanProcess diffTool = this.diffTool(diffMachine, toolList, stationList); |
|
|
|
if (ObjectUtils.isEmpty(diffTool)) { |
|
|
|
if (ObjectUtils.isEmpty(diffTool)) { |
|
|
|
//设备匹配失败,删除该生产计划相半数据,直接结束
|
|
|
|
//设备匹配失败,删除该生产计划相半数据,直接结束
|
|
|
|
this.doException(planId, obj, "工序工具匹配"); |
|
|
|
this.doException(zyProductPlan.getId(), obj, "工序工具匹配"); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} else { // 匹配工人
|
|
|
|
} else { // 匹配工人
|
|
|
|
updateList.add(diffTool); |
|
|
|
updateList.add(diffTool); |
|
|
@ -477,7 +480,10 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
private IZyDeviceService iZyDeviceService; |
|
|
|
private IZyDeviceService iZyDeviceService; |
|
|
|
|
|
|
|
|
|
|
|
ZyPlanProcess diffMachine(ZyPlanProcess zyPlanProcess, List<String> zyProcessMachineIds, List<String> zyProcessCodes, List<Station> stationList) { |
|
|
|
ZyPlanProcess diffMachine(ZyPlanProcess zyPlanProcess, List<String> zyProcessMachineIds, List<String> zyProcessCodes, List<Station> stationList) { |
|
|
|
|
|
|
|
|
|
|
|
if (!ObjectUtils.isEmpty(zyProcessCodes) && !ObjectUtils.isEmpty(zyProcessMachineIds)) { |
|
|
|
if (!ObjectUtils.isEmpty(zyProcessCodes) && !ObjectUtils.isEmpty(zyProcessMachineIds)) { |
|
|
|
|
|
|
|
// Set<Station> matchStationList = new LinkedHashSet<>(stationList.size());
|
|
|
|
|
|
|
|
Map<String, List<ZyDevice>> matchObj = new LinkedHashMap<>(); |
|
|
|
for (int j = 0; j < stationList.size(); j++) { |
|
|
|
for (int j = 0; j < stationList.size(); j++) { |
|
|
|
Station station = stationList.get(j); |
|
|
|
Station station = stationList.get(j); |
|
|
|
//工位设备ids
|
|
|
|
//工位设备ids
|
|
|
@ -493,18 +499,29 @@ public class IZyProductPlanAutoServiceImpl extends ServiceImpl<ZyProductPlanMapp |
|
|
|
.in(ZyDevice::getTypeCode, zyProcessCodes) |
|
|
|
.in(ZyDevice::getTypeCode, zyProcessCodes) |
|
|
|
); |
|
|
|
); |
|
|
|
if (!ObjectUtils.isEmpty(machineList)) { |
|
|
|
if (!ObjectUtils.isEmpty(machineList)) { |
|
|
|
String ids = machineList.stream().map(ZyDevice::getId).collect(Collectors.joining(",")); |
|
|
|
matchObj.put(station.getId(), machineList); |
|
|
|
List<String> collect = machineList.stream().map(ZyDevice::getId).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
zyPlanProcess.setMachineIds(ids); |
|
|
|
|
|
|
|
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(collect)); |
|
|
|
|
|
|
|
zyPlanProcess.setStationId(station.getId()); |
|
|
|
|
|
|
|
zyPlanProcess.setStationName(station.getStationName()); |
|
|
|
|
|
|
|
zyPlanProcess.setStationNum(station.getStationNum()); |
|
|
|
|
|
|
|
return zyPlanProcess; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ObjectUtils.isEmpty(matchObj)) { |
|
|
|
|
|
|
|
Set<String> keySet = matchObj.keySet(); |
|
|
|
|
|
|
|
List<Station> stationList2 = iStationService.list(new LambdaQueryWrapper<Station>().in(Station::getId, keySet)); |
|
|
|
|
|
|
|
Station minTaskCountStation = stationList2.stream().min(Comparator.comparing(Station::getTasksCount)).get(); |
|
|
|
|
|
|
|
List<ZyDevice> machineList2 = matchObj.get(minTaskCountStation.getId()); |
|
|
|
|
|
|
|
String ids = machineList2.stream().map(ZyDevice::getId).collect(Collectors.joining(",")); |
|
|
|
|
|
|
|
List<String> collect = machineList2.stream().map(ZyDevice::getId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
zyPlanProcess.setMachineIds(ids); |
|
|
|
|
|
|
|
zyPlanProcess.setMachineNames(iStationMachineService.convertByMachineIds(collect)); |
|
|
|
|
|
|
|
zyPlanProcess.setStationId(minTaskCountStation.getId()); |
|
|
|
|
|
|
|
zyPlanProcess.setStationName(minTaskCountStation.getStationName()); |
|
|
|
|
|
|
|
zyPlanProcess.setStationNum(minTaskCountStation.getStationNum()); |
|
|
|
|
|
|
|
minTaskCountStation.setTasksCount(minTaskCountStation.getTasksCount() + 1); |
|
|
|
|
|
|
|
iStationService.updateById(minTaskCountStation); |
|
|
|
|
|
|
|
return zyPlanProcess; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|