opt:任务数优化
This commit is contained in:
@@ -169,7 +169,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
String to_taskNum = null;
|
||||
String last_to_taskNum = null;
|
||||
|
||||
|
||||
Integer outbound_task_num = null;
|
||||
|
||||
//子卷条码
|
||||
String material_barcode = null;
|
||||
@@ -329,12 +329,14 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
// 1. 查询设备
|
||||
Device device = deviceAppService.findDeviceByCode(device_code);
|
||||
|
||||
Integer result = updateOutboundTaskNum(-1,true);
|
||||
|
||||
// 2. 更新任务数
|
||||
device.setOutbound_task_num(device.getOutbound_task_num() - 1);
|
||||
device.setOutbound_task_num(result);
|
||||
|
||||
// 3. 保存更新(假设需要显式保存)
|
||||
deviceservice.update(new UpdateWrapper<Device>()
|
||||
.set("outbound_task_num",device.getOutbound_task_num())
|
||||
.set("outbound_task_num",result)
|
||||
.eq("device_code",device.getDevice_code()));
|
||||
|
||||
// 更新task的出库完成数
|
||||
@@ -350,7 +352,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
list1.add(map);
|
||||
Map map2 = new HashMap();
|
||||
map2.put("code", "to_taskNum");//下发出库数
|
||||
map2.put("value", device.getOutbound_task_num());
|
||||
map2.put("value", result);
|
||||
this.writing(list1);
|
||||
|
||||
// 5. 只有成功后才设置标记
|
||||
@@ -431,7 +433,6 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
// luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 申请任务
|
||||
*/
|
||||
@@ -549,6 +550,15 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized Integer updateOutboundTaskNum(Integer num,Boolean addFlag) throws Exception {
|
||||
if(addFlag) {
|
||||
this.outbound_task_num = this.outbound_task_num + num;
|
||||
} else{
|
||||
this.outbound_task_num = num;
|
||||
}
|
||||
return this.outbound_task_num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
|
||||
@@ -1929,8 +1929,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
public int queryInstructionCount(String deviceCode) {
|
||||
List<Instruction> instructionsList = instructions.stream()
|
||||
.filter(item -> StrUtil.equals(item.getNext_device_code(), deviceCode)
|
||||
&& StrUtil.equals(item.getInstruction_status(), TaskStatusEnum.READY.getIndex())
|
||||
&& StrUtil.equals(item.getInstruction_status(), TaskStatusEnum.BUSY.getIndex())).collect(Collectors.toList());
|
||||
&& (StrUtil.equals(item.getInstruction_status(), TaskStatusEnum.READY.getIndex())
|
||||
|| StrUtil.equals(item.getInstruction_status(), TaskStatusEnum.BUSY.getIndex()))).collect(Collectors.toList());
|
||||
return instructionsList.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -198,6 +198,7 @@ public class AutoCreateInst {
|
||||
if (beltConveyorDeviceDriver.getType() == 2) {
|
||||
//因为已经创建成功,因此这个时候可以+1了
|
||||
int count = instructionService.queryInstructionCount(next_device_code);
|
||||
beltConveyorDeviceDriver.updateOutboundTaskNum(count,false);
|
||||
beltConveyorDeviceDriver.writing("to_taskNum", count + "");
|
||||
nextdevice.setOutbound_task_num(count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user