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