生产计划自动化-工序设备匹配规则 优化 5.15

master
zhc077 2 years ago
parent af4f8fa357
commit c62e4e7c16
  1. 16
      ant-design-vue-jeecg/src/views/message/ZySpeechMessageList.vue
  2. 43
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/productplan/service/impl/IZyProductPlanAutoServiceImpl.java
  3. 4
      jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/team/entity/Station.java

@ -84,24 +84,12 @@
class="j-table-force-nowrap" class="j-table-force-nowrap"
@change="handleTableChange"> @change="handleTableChange">
<span slot="action" slot-scope="text, record"> <span slot="action" slot-scope="text, record">
<!-- <a @click="handleEdit(record)">编辑</a>--> <a @click="MySpeak(record)">播放</a>
<a-divider type="vertical"/>
<!-- <a-divider type="vertical" />-->
<!-- <a-dropdown>-->
<!-- <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!-- <a-menu slot="overlay">-->
<!-- <a-menu-item>-->
<!-- <a @click="handleDetail(record)">详情</a>-->
<!-- </a-menu-item>-->
<!-- <a-menu-item>-->
<a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)"> <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
<a>删除</a> <a>删除</a>
</a-popconfirm> </a-popconfirm>
<!-- </a-menu-item>-->
<!-- </a-menu>-->
<!-- </a-dropdown>-->
</span> </span>
</a-table> </a-table>
</div> </div>

@ -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;
} }

@ -78,6 +78,10 @@ public class Station {
@Excel(name = "工位序号", width = 15) @Excel(name = "工位序号", width = 15)
@ApiModelProperty(value = "工位序号") @ApiModelProperty(value = "工位序号")
private Integer stationNum; private Integer stationNum;
@Excel(name = "已分配任务量", width = 15)
@ApiModelProperty(value = "已分配任务量")
private Integer tasksCount;
/** /**
* 备注 * 备注
*/ */

Loading…
Cancel
Save