|
|
@ -2,6 +2,7 @@ package org.nl.wms.sch.tasks; |
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
@ -43,13 +44,14 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
/** |
|
|
|
*改变任务状态 |
|
|
|
**/ |
|
|
|
String task_id = taskObj.getString("task_id"); |
|
|
|
String task_code = taskObj.getString("task_code"); |
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task"); |
|
|
|
JSONObject jsonTask = taskTab.query("task_id='" + task_id + "'").uniqueResult(0); |
|
|
|
JSONObject jsonTask = taskTab.query("task_code='" + task_code + "'").uniqueResult(0); |
|
|
|
String task_id = jsonTask.getString("task_id"); |
|
|
|
|
|
|
|
if (StrUtil.equals(status,"0")) { |
|
|
|
if (StrUtil.equals(status, "0")) { |
|
|
|
// 取消删除任务
|
|
|
|
taskTab.delete("task_id = '"+task_id+"'"); |
|
|
|
taskTab.delete("task_id = '" + task_id + "'"); |
|
|
|
} |
|
|
|
|
|
|
|
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) { |
|
|
@ -76,32 +78,32 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_regionIO"); |
|
|
|
JSONObject mstObj = mstTab.query("task_id='" + task_id + "' and is_delete='0'").uniqueResult(0); |
|
|
|
//审核 加库存可和用数量
|
|
|
|
StoreIvtServiceImpl ivtService = new StoreIvtServiceImpl(); |
|
|
|
// StoreIvtServiceImpl ivtService = new StoreIvtServiceImpl();
|
|
|
|
mstObj.put("bill_status", "50"); |
|
|
|
mstObj.put("confirm_optid", SecurityUtils.getCurrentUserId()); |
|
|
|
mstObj.put("confirm_optname", SecurityUtils.getNickName()); |
|
|
|
mstObj.put("confirm_time", DateUtil.now()); |
|
|
|
mstTab.update(mstObj); |
|
|
|
|
|
|
|
String iostorinv_id = mstObj.getString("iostorinv_id"); |
|
|
|
String bill_code = mstObj.getString("bill_code"); |
|
|
|
String bill_type_scode =mstObj.getString("bill_type"); |
|
|
|
String next_point_code = mstObj.getString("end_point_code"); |
|
|
|
String start_point_code = mstObj.getString("start_point_code"); |
|
|
|
JSONObject param = new JSONObject(); |
|
|
|
param.put("material_id", mstObj.getString("material_id")); |
|
|
|
param.put("bill_code", bill_code); |
|
|
|
param.put("bill_type_scode", bill_type_scode); |
|
|
|
param.put("bill_id", iostorinv_id); |
|
|
|
param.put("qty_unit_id", mstObj.getString("qty_unit_id")); |
|
|
|
param.put("pcsn", mstObj.getString("pcsn")); |
|
|
|
param.put("change_qty", mstObj.getString("qty")); |
|
|
|
param.put("vehicle_code", mstObj.getString("vehicle_code")); |
|
|
|
param.put("region_id", mstObj.getString("start_region_id")); |
|
|
|
param.put("is_full", mstObj.getString("is_full")); |
|
|
|
param.put("stewing_time", mstObj.getString("stewing_time")); |
|
|
|
param.put("producetask_id", mstObj.getString("producetask_id")); |
|
|
|
param.put("io_type", mstObj.getString("io_type")); |
|
|
|
// String iostorinv_id = mstObj.getString("iostorinv_id");
|
|
|
|
// String bill_code = mstObj.getString("bill_code");
|
|
|
|
// String bill_type_scode = mstObj.getString("bill_type");
|
|
|
|
String next_point_code = jsonTask.getString("next_point_code"); |
|
|
|
String start_point_code = jsonTask.getString("start_point_code"); |
|
|
|
// JSONObject param = new JSONObject();
|
|
|
|
// param.put("material_id", mstObj.getString("material_id"));
|
|
|
|
// param.put("bill_code", bill_code);
|
|
|
|
// param.put("bill_type_scode", bill_type_scode);
|
|
|
|
// param.put("bill_id", iostorinv_id);
|
|
|
|
// param.put("qty_unit_id", mstObj.getString("qty_unit_id"));
|
|
|
|
// param.put("pcsn", mstObj.getString("pcsn"));
|
|
|
|
// param.put("change_qty", mstObj.getString("qty"));
|
|
|
|
// param.put("vehicle_code", mstObj.getString("vehicle_code"));
|
|
|
|
// param.put("region_id", mstObj.getString("start_region_id"));
|
|
|
|
// param.put("is_full", mstObj.getString("is_full"));
|
|
|
|
// param.put("stewing_time", mstObj.getString("stewing_time"));
|
|
|
|
// param.put("producetask_id", mstObj.getString("producetask_id"));
|
|
|
|
// param.put("io_type", mstObj.getString("io_type"));
|
|
|
|
|
|
|
|
PointServiceImpl pointService = SpringContextHolder.getBean(PointServiceImpl.class); |
|
|
|
PointDto nextPointDto = pointService.findByCode(next_point_code); |
|
|
@ -112,25 +114,40 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
if (ObjectUtil.isNull(startPointDto)) { |
|
|
|
throw new BadRequestException("未找到可用点位:" + start_point_code); |
|
|
|
} |
|
|
|
param.put("struct_id", nextPointDto.getPoint_id()); |
|
|
|
ivtService.addIvtFlow(param, IvtChangeTypeEnum.ADD_IVT_AND_CAN_USE); |
|
|
|
// 解锁点位
|
|
|
|
String vehicle_code = jsonTask.getString("vehicle_code"); |
|
|
|
|
|
|
|
// 如果终点区域为待检区,则需要添加库存
|
|
|
|
if (nextPointDto.getRegion_id().equals(1572481855792484352L)) { |
|
|
|
JSONObject struct = new JSONObject(); |
|
|
|
struct.put("stockrecord_id", IdUtil.getSnowflake(1, 1).nextId()); |
|
|
|
struct.put("struct_id", nextPointDto.getPoint_id()); |
|
|
|
struct.put("struct_code", nextPointDto.getPoint_code()); |
|
|
|
struct.put("struct_name", nextPointDto.getPoint_name()); |
|
|
|
struct.put("region_id", startPointDto.getRegion_id()); |
|
|
|
struct.put("quality_scode", "00");// 待检品
|
|
|
|
struct.put("instorage_time", DateUtil.now()); |
|
|
|
WQLObject.getWQLObject("st_ivt_structivt").insert(struct); |
|
|
|
} |
|
|
|
|
|
|
|
// param.put("struct_id", nextPointDto.getPoint_id());
|
|
|
|
// ivtService.addIvtFlow(param, IvtChangeTypeEnum.ADD_IVT_AND_CAN_USE);
|
|
|
|
// 解锁点位 将起点的点位状态写给终点
|
|
|
|
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); |
|
|
|
JSONObject endpointObj = pointTab.query("point_code='" + jsonTask.getString("next_point_code") + "'").uniqueResult(0); |
|
|
|
endpointObj.put("lock_type", "00"); |
|
|
|
endpointObj.put("point_status", "02"); |
|
|
|
endpointObj.put("vehicle_code", vehicle_code); |
|
|
|
endpointObj.put("vehicle_type", jsonTask.getString("vehicle_type")); |
|
|
|
pointTab.update(endpointObj); |
|
|
|
taskTab.update(jsonTask); |
|
|
|
JSONObject startPointObj = pointTab.query("point_code='" + start_point_code + "'").uniqueResult(0); |
|
|
|
JSONObject endPointObj = pointTab.query("point_code='" + next_point_code + "'").uniqueResult(0); |
|
|
|
|
|
|
|
// 起点写给终点
|
|
|
|
endPointObj.put("lock_type", "00"); |
|
|
|
String pointStatus = startPointObj.getString("point_status"); |
|
|
|
endPointObj.put("point_status", pointStatus); |
|
|
|
pointTab.update(endPointObj); |
|
|
|
|
|
|
|
/* JSONObject startPointObj = pointTab.query("point_code='" + jsonTask.getString("start_point_code") + "'").uniqueResult(0); |
|
|
|
// 起点置空
|
|
|
|
startPointObj.put("lock_type", "00"); |
|
|
|
startPointObj.put("point_status", "00"); |
|
|
|
startPointObj.put("vehicle_code", ""); |
|
|
|
pointTab.update(startPointObj); |
|
|
|
taskTab.update(jsonTask);*/ |
|
|
|
|
|
|
|
// 更新任务
|
|
|
|
taskTab.update(jsonTask); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -186,44 +203,48 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public String createTask(JSONObject form) { |
|
|
|
//请求参数 载具、起点、终点
|
|
|
|
String vehicle_code = form.getString("vehicle_code"); |
|
|
|
String vehicle_type = form.getString("vehicle_type"); |
|
|
|
String start_point_code = form.getString("start_point_code"); |
|
|
|
String next_point_code = form.getString("next_point_code"); |
|
|
|
String next_point_code = form.getString("next_point_code");; |
|
|
|
|
|
|
|
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
|
|
WQLObject iosTable = WQLObject.getWQLObject("ST_IVT_regionIO"); |
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(start_point_code)) { |
|
|
|
throw new BadRequestException("起点不能为空!"); |
|
|
|
} |
|
|
|
if (StrUtil.isEmpty(next_point_code)) { |
|
|
|
throw new BadRequestException("终点不能为空!"); |
|
|
|
} |
|
|
|
|
|
|
|
PointService pointService = SpringContextHolder.getBean(PointService.class); |
|
|
|
// 起点是空位不能搬
|
|
|
|
PointDto startPoint = pointService.findByCode(start_point_code); |
|
|
|
if (StrUtil.equals(startPoint.getPoint_status(), "00")) { |
|
|
|
throw new BadRequestException("起点是空位!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 终点不是不合格品区且不是空位不能搬
|
|
|
|
PointDto nextPoint = pointService.findByCode(next_point_code); |
|
|
|
if (!nextPoint.getRegion_id().equals(1572481902244401152L) && !StrUtil.equals(nextPoint.getPoint_status(), "00")) { |
|
|
|
throw new BadRequestException("终点不是空位!"); |
|
|
|
} |
|
|
|
|
|
|
|
//判断起点有没有未完成的指令
|
|
|
|
JSONObject beforTaskObj = taskTable. |
|
|
|
query("is_delete='0' and start_point_code='" + start_point_code + "' and task_status <>'" + TaskStatusEnum.FINISHED.getCode() + "'") |
|
|
|
.uniqueResult(0); |
|
|
|
if (ObjectUtil.isNotEmpty(beforTaskObj)) { |
|
|
|
throw new BadRequestException("存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!"); |
|
|
|
throw new BadRequestException("起点存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isEmpty(next_point_code)) { |
|
|
|
// 终点为空需要找终点
|
|
|
|
JSONObject param = new JSONObject(); |
|
|
|
param.put("start_point_code",start_point_code); |
|
|
|
JSONObject endPoint = this.findEndPoint(param); |
|
|
|
next_point_code = endPoint.getString("next_point_code"); |
|
|
|
} |
|
|
|
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|
|
|
|
|
|
|
//终点点加锁
|
|
|
|
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|
|
|
JSONObject endPointObj = pointTable.query("point_code='" + next_point_code + "'").uniqueResult(0); |
|
|
|
endPointObj.put("lock_type", "01"); |
|
|
|
pointTable.update(endPointObj); |
|
|
|
|
|
|
|
// 创建任务
|
|
|
|
PointService pointService = SpringContextHolder.getBean(PointService.class); |
|
|
|
|
|
|
|
JSONObject taskObj = new JSONObject(); |
|
|
|
CodeUtil.getNewCode("TASK_CODE"); |
|
|
|
String task_id = IdUtil.getSnowflake(1, 1).nextId() + ""; |
|
|
@ -231,18 +252,14 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
taskObj.put("taskdtl_id", task_id); |
|
|
|
taskObj.put("task_code", CodeUtil.getNewCode("TASK_CODE")); |
|
|
|
taskObj.put("task_type", "01"); |
|
|
|
taskObj.put("vehicle_type", vehicle_type); |
|
|
|
taskObj.put("taskdtl_type", "01"); |
|
|
|
taskObj.put("acs_task_type", "1"); |
|
|
|
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode()); |
|
|
|
taskObj.put("start_point_code", start_point_code); |
|
|
|
PointDto startPoint = pointService.findByCode(start_point_code); |
|
|
|
taskObj.put("start_area", startPoint.getRegion_id()); |
|
|
|
taskObj.put("request_param", form.toJSONString()); |
|
|
|
taskObj.put("next_point_code", next_point_code); |
|
|
|
PointDto nextPoint = pointService.findByCode(next_point_code); |
|
|
|
taskObj.put("next_area", nextPoint.getRegion_id()); |
|
|
|
taskObj.put("vehicle_code", vehicle_code); |
|
|
|
taskObj.put("handle_class", THIS_CLASS); |
|
|
|
taskObj.put("is_auto_issue", "1"); |
|
|
|
taskObj.put("create_name", SecurityUtils.getCurrentUsername()); |
|
|
@ -287,7 +304,7 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
* 2.豪凯线 --> 成品区 |
|
|
|
*/ |
|
|
|
String next_point_code = ""; |
|
|
|
if (StrUtil.equals(jsonStartRegion.getString("region_code"),RegionTypeEnum.GJQY.getCode())) { |
|
|
|
if (StrUtil.equals(jsonStartRegion.getString("region_code"), RegionTypeEnum.GJQY.getCode())) { |
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
map.put("flag", "2"); |
|
|
|
map.put("region_code", RegionTypeEnum.YSQA.getCode()); |
|
|
@ -295,7 +312,7 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonEndPoint)) throw new BadRequestException("仓位不足"); |
|
|
|
next_point_code = jsonEndPoint.getString("point_code"); |
|
|
|
} else if (StrUtil.equals(jsonStartRegion.getString("region_code"),RegionTypeEnum.HKQY.getCode())) { |
|
|
|
} else if (StrUtil.equals(jsonStartRegion.getString("region_code"), RegionTypeEnum.HKQY.getCode())) { |
|
|
|
JSONObject map = new JSONObject(); |
|
|
|
map.put("flag", "2"); |
|
|
|
map.put("region_code", RegionTypeEnum.CPQYA.getCode()); |
|
|
@ -306,7 +323,7 @@ public class SendMaterialTask extends AbstractAcsTask { |
|
|
|
} |
|
|
|
|
|
|
|
JSONObject resuft = new JSONObject(); |
|
|
|
resuft.put("next_point_code",next_point_code); |
|
|
|
resuft.put("next_point_code", next_point_code); |
|
|
|
return resuft; |
|
|
|
} |
|
|
|
|
|
|
|