|
|
@ -14,9 +14,7 @@ import org.nl.modules.system.util.CodeUtil; |
|
|
|
import org.nl.modules.wql.WQL; |
|
|
|
import org.nl.modules.wql.core.bean.WQLObject; |
|
|
|
import org.nl.wms.sch.SchTaskDto; |
|
|
|
import org.nl.wms.sch.manage.AbstractAcsTask; |
|
|
|
import org.nl.wms.sch.manage.TaskStatusEnum; |
|
|
|
import org.nl.wms.sch.manage.UpdateTaskStatusEnum; |
|
|
|
import org.nl.wms.sch.manage.*; |
|
|
|
import org.nl.wms.sch.tasks.AcsTaskDto; |
|
|
|
import org.nl.wms.util.IdUtil; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -77,9 +75,13 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void updateTaskStatus(JSONObject task, String status) { |
|
|
|
/** |
|
|
|
* 工单没有载具类型,混碾下料根据工单新旧物料区分。 |
|
|
|
*/ |
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
|
|
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); |
|
|
|
WQLObject materialTab = WQLObject.getWQLObject("MD_ME_MaterialBase"); |
|
|
|
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder"); //生产工单表【PDM_BD_WorkOrder】
|
|
|
|
|
|
|
|
String task_id = task.getString("task_id"); |
|
|
|
JSONObject taskObj = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0); |
|
|
@ -91,9 +93,9 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
throw new BadRequestException("已完成不能取消!"); |
|
|
|
} |
|
|
|
String point_code2 = taskObj.getString("point_code2"); |
|
|
|
if (ObjectUtil.isEmpty(point_code2)) { |
|
|
|
if (ObjectUtil.isNotEmpty(point_code2)) { // 防止未找到终点而取消任务空指针
|
|
|
|
JSONObject endPoint = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0); |
|
|
|
endPoint.put("lock_type", "1"); |
|
|
|
endPoint.put("lock_type", PointEnum.LOCK_TYPE_FALSE.getCode()); |
|
|
|
pointTab.update(endPoint); |
|
|
|
} |
|
|
|
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode()); |
|
|
@ -118,13 +120,17 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
taskTab.update(taskObj); |
|
|
|
|
|
|
|
String point_code2 = taskObj.getString("point_code2"); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(point_code2)) return; // 防止未找到终点而完成任务空指针
|
|
|
|
|
|
|
|
JSONObject point2Obj = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0); |
|
|
|
JSONObject requestObj = task.getJSONObject("request_param"); |
|
|
|
// 工单标识
|
|
|
|
String workorder_id = requestObj.getString("material_info_id"); |
|
|
|
//生产工单表【PDM_BD_WorkOrder】
|
|
|
|
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder"); |
|
|
|
JSONObject workorderObj = workOrderTab.query("workorder_id", workorder_id).uniqueResult(0); |
|
|
|
String workorder_id = taskObj.getString("material_info_id"); |
|
|
|
JSONObject workorderObj = workOrderTab.query("workorder_id = '" + workorder_id + "'").uniqueResult(0); |
|
|
|
// 物料
|
|
|
|
JSONObject materialObj = materialTab.query("material_id = '" + workorderObj.getString("material_id") + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isEmpty(materialObj)) throw new BadRequestException("物料不存在!"); |
|
|
|
|
|
|
|
// 区域出入表【st_ivt_regionIO】
|
|
|
|
WQLObject regionIoTab = WQLObject.getWQLObject("st_ivt_regionIO"); |
|
|
@ -132,40 +138,39 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
regionIoObj.put("iostorinv_id", IdUtil.getLongId()); |
|
|
|
regionIoObj.put("bill_code", CodeUtil.getNewCode("IN_STORE_CODE")); |
|
|
|
regionIoObj.put("buss_date", DateUtil.today()); |
|
|
|
regionIoObj.put("io_type", "1"); |
|
|
|
regionIoObj.put("io_type", RegionIOEnum.IO_TYPE_IN.getCode()); |
|
|
|
regionIoObj.put("region_id", point2Obj.getString("region_id")); |
|
|
|
regionIoObj.put("region_code", point2Obj.getString("region_code")); |
|
|
|
regionIoObj.put("region_name", point2Obj.getString("region_name")); |
|
|
|
regionIoObj.put("material_id", taskObj.getString("material_id")); |
|
|
|
regionIoObj.put("vehicle_code", taskObj.getString("vehicle_code")); |
|
|
|
regionIoObj.put("qty", requestObj.getString("qty")); |
|
|
|
regionIoObj.put("bill_status", "3"); |
|
|
|
regionIoObj.put("is_new", workorderObj.getString("is_new")); |
|
|
|
regionIoObj.put("bill_status", RegionIOEnum.BILL_STATUS_FINISH.getCode()); |
|
|
|
regionIoObj.put("start_point_code", taskObj.getString("point_code1")); |
|
|
|
regionIoObj.put("end_point_code", taskObj.getString("point_code3")); |
|
|
|
regionIoObj.put("create_mode", "2"); |
|
|
|
regionIoObj.put("end_point_code", taskObj.getString("point_code2")); |
|
|
|
regionIoObj.put("create_mode", RegionIOEnum.CREATE_MODE_ACS.getCode()); |
|
|
|
regionIoObj.put("pcsn", DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyyMMdd")); |
|
|
|
regionIoObj.put("create_id", SecurityUtils.getCurrentUserId()); |
|
|
|
regionIoObj.put("create_name", SecurityUtils.getCurrentNickName()); |
|
|
|
regionIoObj.put("create_time", DateUtil.now()); |
|
|
|
regionIoTab.insert(regionIoObj); |
|
|
|
|
|
|
|
JSONObject materialObj = materialTab.query("material_id = '" + workorderObj.getString("material_id") + "'").uniqueResult(0); |
|
|
|
if (ObjectUtil.isEmpty(materialObj)) throw new BadRequestException("物料不存在!"); |
|
|
|
|
|
|
|
//完成后入库
|
|
|
|
point2Obj.put("instorage_time", taskObj.getString("create_time")); // 入库时间为任务生成的时间
|
|
|
|
point2Obj.put("pcsn", DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyyMMdd")); |
|
|
|
point2Obj.put("ivt_qty", requestObj.getString("qty")); |
|
|
|
point2Obj.put("standing_time", materialObj.getString("standing_time")); |
|
|
|
point2Obj.put("warn_time", materialObj.getString("standing_time")); |
|
|
|
point2Obj.put("warn_time", materialObj.getString("warn_time")); |
|
|
|
point2Obj.put("material_id", workorderObj.getString("material_id")); |
|
|
|
point2Obj.put("vehicle_type", workorderObj.getString("vehicle_type")); |
|
|
|
point2Obj.put("vehicle_type", workorderObj.getString("is_new")); // 工单的新旧物料
|
|
|
|
point2Obj.put("vehicle_code", taskObj.getString("vehicle_code")); |
|
|
|
point2Obj.put("vehicle_qty", "1"); // 入库为1个载具
|
|
|
|
point2Obj.put("is_full", requestObj.getString("is_full")); |
|
|
|
|
|
|
|
// 终点解锁
|
|
|
|
point2Obj.put("lock_type", "1"); |
|
|
|
point2Obj.put("point_status", "3"); |
|
|
|
point2Obj.put("lock_type", PointEnum.LOCK_TYPE_FALSE.getCode()); |
|
|
|
point2Obj.put("point_status", PointEnum.POINT_STATUS_HAVE_MATERIAL.getCode()); |
|
|
|
pointTab.update(point2Obj); |
|
|
|
} |
|
|
|
} |
|
|
@ -181,7 +186,7 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
String vehicle_code = form.getString("vehicle_code"); |
|
|
|
String qty = form.getString("qty"); |
|
|
|
String is_full = form.getString("is_full"); |
|
|
|
String weight = form.getString("weight"); |
|
|
|
String weight = form.getString("weight"); // 未存
|
|
|
|
//任务表【SCH_BASE_Task】
|
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
|
|
//判断当前点是否有未完成的任务
|
|
|
@ -230,13 +235,15 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
public void findNextPoint() { |
|
|
|
/** |
|
|
|
* 根据业务找到相应的终点 |
|
|
|
* 高速混碾机下料先找高速压制机旁边的三个困料位,没有位置则去公共货架 |
|
|
|
* 普通混碾机下料直接送到公共困料货架 |
|
|
|
*/ |
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
|
|
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); |
|
|
|
JSONArray taskArr = taskTab.query("handle_class = '" + THIS_CLASS + "'and is_delete = '0' and task_status = '2'").getResultJSONArray(0); |
|
|
|
for (int i = 0; i < taskArr.size(); i++) { |
|
|
|
JSONObject taskObj = taskArr.getJSONObject(i); |
|
|
|
String vehicle_type = taskObj.getString("vehicle_type");//混碾载具类型新旧料?
|
|
|
|
String vehicle_type = taskObj.getString("vehicle_type");//混碾载具类型新旧料? 工單不提供载具类型
|
|
|
|
JSONObject param1 = new JSONObject(); |
|
|
|
param1.put("flag", "1"); |
|
|
|
param1.put("region_code", "KLHJ"); |
|
|
@ -255,11 +262,9 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
|
|
|
|
//锁住终点
|
|
|
|
endPoint.put("task_id", taskObj.getString("task_id")); |
|
|
|
endPoint.put("lock_type", "2"); |
|
|
|
endPoint.put("lock_type", PointEnum.LOCK_TYPE_TRUE.getCode()); |
|
|
|
pointTab.update(endPoint); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -278,7 +283,7 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
|
|
JSONObject taskObj = taskTab.query("task_id = '" + task_id + "' and is_delete = '0' and task_status <> " + TaskStatusEnum.FINISHED.getCode()).uniqueResult(0); |
|
|
|
if (ObjectUtil.isNotEmpty(taskObj)) |
|
|
|
this.updateTaskStatus(taskObj,"2"); |
|
|
|
this.updateTaskStatus(taskObj, UpdateTaskStatusEnum.FORCEFINISH.getCode()); |
|
|
|
else { |
|
|
|
throw new BadRequestException("未找到该任务或者任务已完成!"); |
|
|
|
} |
|
|
@ -294,7 +299,7 @@ public class HnSendMaterialTask extends AbstractAcsTask { |
|
|
|
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task"); |
|
|
|
JSONObject taskObj = taskTab.query("task_id = '" + task_id + "' and is_delete = '0' and task_status <> " + TaskStatusEnum.FINISHED.getCode()).uniqueResult(0); |
|
|
|
if (ObjectUtil.isNotEmpty(taskObj)) |
|
|
|
this.updateTaskStatus(taskObj,"0"); |
|
|
|
this.updateTaskStatus(taskObj,UpdateTaskStatusEnum.CANCEL.getCode()); |
|
|
|
else { |
|
|
|
throw new BadRequestException("未找到该任务或者任务已完成!"); |
|
|
|
} |
|
|
|