|
|
@ -81,62 +81,62 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
@Override |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
protected void create() throws BadRequestException { |
|
|
|
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion("GHS","2"); |
|
|
|
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion("GHS", "2"); |
|
|
|
for (SchBasePoint schBasePoint : schBasePointList) { |
|
|
|
if (!schBasePoint.getPoint_code().endsWith("01") && |
|
|
|
!schBasePoint.getPoint_code().endsWith("06")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
if (schBasePoint.getVehicle_qty()==3&&ObjectUtil.isEmpty(schBasePoint.getIng_task_code())) { |
|
|
|
log.info("固化室对接位{}已经放满,开始进行后续判断",schBasePoint.getPoint_code()); |
|
|
|
String first=schBasePoint.getPoint_code().substring(0,schBasePoint.getPoint_code().length()-2); |
|
|
|
String last=schBasePoint.getPoint_code().substring(schBasePoint.getPoint_code().length()-1); |
|
|
|
String middle=schBasePoint.getPoint_code().substring(schBasePoint.getPoint_code().length()-4,schBasePoint.getPoint_code().length()-2); |
|
|
|
boolean flag=false; |
|
|
|
String pointCode=null; |
|
|
|
if (schBasePoint.getVehicle_qty() == 3 && ObjectUtil.isEmpty(schBasePoint.getIng_task_code())) { |
|
|
|
log.info("固化室对接位{}已经放满,开始进行后续判断", schBasePoint.getPoint_code()); |
|
|
|
String first = schBasePoint.getPoint_code().substring(0, schBasePoint.getPoint_code().length() - 2); |
|
|
|
String last = schBasePoint.getPoint_code().substring(schBasePoint.getPoint_code().length() - 1); |
|
|
|
String middle = schBasePoint.getPoint_code().substring(schBasePoint.getPoint_code().length() - 4, schBasePoint.getPoint_code().length() - 2); |
|
|
|
boolean flag = false; |
|
|
|
String pointCode = null; |
|
|
|
//倒叙检查是否有符合要求的终点
|
|
|
|
for(int i=4;i>0;i--){ |
|
|
|
pointCode=first+ String.format("%02d",Integer.valueOf(last)+i); |
|
|
|
for(SchBasePoint schBasePoint1 : schBasePointList){ |
|
|
|
for (int i = 4; i > 0; i--) { |
|
|
|
pointCode = first + String.format("%02d", Integer.valueOf(last) + i); |
|
|
|
for (SchBasePoint schBasePoint1 : schBasePointList) { |
|
|
|
if (schBasePoint1.getPoint_code().equals(pointCode) |
|
|
|
&&schBasePoint1.getVehicle_qty()==0&&ObjectUtil.isEmpty(schBasePoint1.getIng_task_code())){ |
|
|
|
log.info("找到当前列内部存在空位{}",pointCode); |
|
|
|
flag=true; |
|
|
|
&& schBasePoint1.getVehicle_qty() == 0 && ObjectUtil.isEmpty(schBasePoint1.getIng_task_code())) { |
|
|
|
log.info("找到当前列内部存在空位{}", pointCode); |
|
|
|
flag = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if(flag){ |
|
|
|
if (flag) { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if (flag){ |
|
|
|
if (flag) { |
|
|
|
//生成任务并下发
|
|
|
|
this.createTask(schBasePoint,pointCode); |
|
|
|
}else{ |
|
|
|
this.createTask(schBasePoint, pointCode); |
|
|
|
} else { |
|
|
|
//如果当列均已放满,检查隔壁列是否已全部放满
|
|
|
|
if("1".equals(last)){ |
|
|
|
last="6"; |
|
|
|
if ("1".equals(last)) { |
|
|
|
last = "6"; |
|
|
|
} |
|
|
|
for(int i=0;i<=4;i++){ |
|
|
|
pointCode=first+ String.format("%02d",Integer.valueOf(last)+i); |
|
|
|
for(SchBasePoint schBasePoint1 : schBasePointList){ |
|
|
|
for (int i = 0; i <= 4; i++) { |
|
|
|
pointCode = first + String.format("%02d", Integer.valueOf(last) + i); |
|
|
|
for (SchBasePoint schBasePoint1 : schBasePointList) { |
|
|
|
if (schBasePoint1.getPoint_code().equals(pointCode) |
|
|
|
&&(schBasePoint1.getVehicle_qty()!=3||ObjectUtil.isNotEmpty(schBasePoint1.getIng_task_code()))){ |
|
|
|
log.info("检查当前固化室{}隔壁列,找到当前列内部存在空位{},不发送固化请求",schBasePoint.getPoint_code(),pointCode); |
|
|
|
flag=true; |
|
|
|
&& (schBasePoint1.getVehicle_qty() != 3 || ObjectUtil.isNotEmpty(schBasePoint1.getIng_task_code()))) { |
|
|
|
log.info("检查当前固化室{}隔壁列,找到当前列内部存在空位{},不发送固化请求", schBasePoint.getPoint_code(), pointCode); |
|
|
|
flag = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if(!flag){ |
|
|
|
if (!flag) { |
|
|
|
//通知acs已经放满,固化室可以进行固化
|
|
|
|
String device_code="ZDM"+middle; |
|
|
|
log.info("当前固化室已经全部放满,通知固化室的自动门{}开始固化",device_code); |
|
|
|
String device_code = "ZDM" + middle; |
|
|
|
log.info("当前固化室已经全部放满,通知固化室的自动门{}开始固化", device_code); |
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
map.put("device_code",device_code); |
|
|
|
map.put("type","1"); |
|
|
|
map.put("device_code", device_code); |
|
|
|
map.put("type", "1"); |
|
|
|
wmsToAcsService.notifyAcs(map); |
|
|
|
} |
|
|
|
} |
|
|
@ -150,10 +150,10 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
* @param endPoint |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private void createTask(SchBasePoint schBasePoint,String endPoint) { |
|
|
|
private void createTask(SchBasePoint schBasePoint, String endPoint) { |
|
|
|
// 申请任务
|
|
|
|
SchBaseTask task = new SchBaseTask(); // 任务实体
|
|
|
|
String apply_point_code =schBasePoint.getPoint_code(); // 请求点
|
|
|
|
String apply_point_code = schBasePoint.getPoint_code(); // 请求点
|
|
|
|
String config_code = "GHSFMTask"; |
|
|
|
// 1、校验数据
|
|
|
|
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|
|
@ -163,7 +163,7 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
Integer tcmn = taskConfig.getTask_create_max_num(); |
|
|
|
// 获取执行中的任务
|
|
|
|
List<SchBaseTask> unFinishTasksByTaskConfig = taskService.findUnFinishTasksByTaskConfig( |
|
|
|
taskConfig.getConfig_code(), apply_point_code+"01", taskConfig.getTask_direction()); |
|
|
|
taskConfig.getConfig_code(), apply_point_code + "01", taskConfig.getTask_direction()); |
|
|
|
|
|
|
|
Assert.isFalse(unFinishTasksByTaskConfig.size() >= tcmn, |
|
|
|
"该点位申请的任务未完成数已超过上限,无法申请任务"); |
|
|
@ -183,7 +183,7 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
task.setTask_status(TaskStatus.APPLY.getCode()); |
|
|
|
task.setWorkshop_code(taskConfig.getWorkshop_code()); // 车间编码
|
|
|
|
//acs固化室首位不存在01和06整体概念,需要补充01生成第一个点位的任务
|
|
|
|
task.setPoint_code1(apply_point_code+"01"); |
|
|
|
task.setPoint_code1(apply_point_code + "01"); |
|
|
|
task.setPoint_code2(endPoint); |
|
|
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
|
|
|
task.setRemark(""); |
|
|
@ -216,7 +216,7 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { |
|
|
|
throw new BadRequestException("该任务已取消!"); |
|
|
|
} |
|
|
|
String startPoint = taskObj.getPoint_code1().substring(0,taskObj.getPoint_code1().length()-2); // 获取起点
|
|
|
|
String startPoint = taskObj.getPoint_code1().substring(0, taskObj.getPoint_code1().length() - 2); // 获取起点
|
|
|
|
String endPoint = taskObj.getPoint_code2(); // 获取终点
|
|
|
|
SchBasePoint startPointObj = pointService.getById(startPoint); |
|
|
|
SchBasePoint endPointObj = pointService.getById(endPoint); |
|
|
@ -226,7 +226,7 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
taskObj.setRemark("执行中"); |
|
|
|
} |
|
|
|
if (status.equals(TaskStatus.FINISHED)) { // 完成
|
|
|
|
StringBuilder group_id= new StringBuilder(); |
|
|
|
StringBuilder group_id = new StringBuilder(); |
|
|
|
// 终点解锁
|
|
|
|
endPointObj.setIng_task_code(""); |
|
|
|
endPointObj.setVehicle_type(startPointObj.getVehicle_type()); |
|
|
@ -235,23 +235,24 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
endPointObj.setUpdate_time(DateUtil.now()); |
|
|
|
pointService.update(endPointObj); |
|
|
|
List<String> vehicleCodeList = Arrays.stream(startPointObj.getVehicle_code().split(",")).collect(Collectors.toList()); |
|
|
|
for(String vehicleCode:vehicleCodeList) { |
|
|
|
for (String vehicleCode : vehicleCodeList) { |
|
|
|
SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>() |
|
|
|
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, |
|
|
|
GroupBindMaterialStatusEnum.BOUND.getValue())); |
|
|
|
if (ObjectUtil.isEmpty(one)) { |
|
|
|
throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到"); |
|
|
|
if (ObjectUtil.isNotEmpty(one)) { |
|
|
|
// throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到");
|
|
|
|
// }
|
|
|
|
one.setTask_code(taskObj.getTask_code()); |
|
|
|
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
|
|
|
|
one.setPoint_name(endPointObj.getPoint_name()); |
|
|
|
one.setMove_way(one.getMove_way() == null ? "" : (one.getMove_way() + " -> ") + endPointObj.getPoint_code()); |
|
|
|
one.setUpdate_id(GeneralDefinition.ACS_ID); |
|
|
|
one.setUpdate_name(GeneralDefinition.ACS_NAME); |
|
|
|
one.setUpdate_time(DateUtil.now()); |
|
|
|
vehiclematerialgroupService.updateById(one); |
|
|
|
group_id.append(one.getGroup_id()).append(','); |
|
|
|
} |
|
|
|
one.setTask_code(taskObj.getTask_code()); |
|
|
|
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
|
|
|
|
one.setPoint_name(endPointObj.getPoint_name()); |
|
|
|
one.setMove_way(one.getMove_way()==null?"":(one.getMove_way() + " -> ") + endPointObj.getPoint_code()); |
|
|
|
one.setUpdate_id(GeneralDefinition.ACS_ID); |
|
|
|
one.setUpdate_name(GeneralDefinition.ACS_NAME); |
|
|
|
one.setUpdate_time(DateUtil.now()); |
|
|
|
vehiclematerialgroupService.updateById(one); |
|
|
|
group_id.append(one.getGroup_id()).append(','); |
|
|
|
} |
|
|
|
// 起点清空
|
|
|
|
if (ObjectUtil.isNotEmpty(startPointObj)) { |
|
|
@ -286,7 +287,7 @@ public class GHSFMTask extends AbstractTask { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) { |
|
|
|
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { |
|
|
|
//todo 重算最优点
|
|
|
|
} |
|
|
|
} |
|
|
|