代码更新
This commit is contained in:
@@ -117,7 +117,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
public String againApply(String task_id) {
|
||||
log.info("输入参数:" + task_id);
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonTask)) throw new BadRequestException("任务已删除或已完成!");
|
||||
|
||||
String point_code = "";
|
||||
String message = "";
|
||||
|
||||
@@ -32,6 +32,8 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
//任务步骤描述:task_step 1-创建,2-确定起点,3-确定终点,4-起点终点确认,
|
||||
// 5-下发,6-执行,7-二次申请,8-执行,9-完成,10-取消
|
||||
|
||||
private final String THIS_CLASS = GjxSendMaterialTask.class.getName();
|
||||
|
||||
@@ -51,17 +53,17 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
if (StrUtil.equals(taskObj.getString("task_status"), TaskStatusEnum.FINISHED.getCode())) {
|
||||
throw new BadRequestException("已完成不能取消!");
|
||||
}
|
||||
String point_code2 = taskObj.getString("point_code2");
|
||||
String point_code3 = taskObj.getString("point_code3");
|
||||
//说明未二次申请过
|
||||
if (ObjectUtil.isEmpty(point_code3)) {
|
||||
JSONObject json = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
json.put("lock_type", "1");
|
||||
pointTab.update(json);
|
||||
}
|
||||
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("remark", "已取消");
|
||||
taskTab.update(taskObj);
|
||||
|
||||
//释放相关电位信息
|
||||
JSONObject param1 = new JSONObject();
|
||||
param1.put("lock_type", "1");
|
||||
param1.put("task_id", "");
|
||||
param1.put("material_id", "");
|
||||
pointTab.update(param1, "task_id = '" + taskObj.getString("task_id") + "'");
|
||||
}
|
||||
|
||||
if ("1".equals(status)) {
|
||||
@@ -73,13 +75,23 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
|
||||
if (StrUtil.equals(status, "2")) {
|
||||
|
||||
//判断状态,
|
||||
if (StrUtil.equals("2", taskObj.getString("task_status"))) {
|
||||
// 更改任务状态为完成
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
return;
|
||||
}
|
||||
// 更改任务状态为完成
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
|
||||
String point_code3 = taskObj.getString("point_code3");
|
||||
JSONObject point3Obj = pointTab.query("point_code = '" + point_code3 + "'").uniqueResult(0);
|
||||
|
||||
String point_code2 = taskObj.getString("point_code2");
|
||||
JSONObject endPoint = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
JSONObject requestObj = task.getJSONObject("request_param");
|
||||
//工单标识
|
||||
String workorder_id = requestObj.getString("material_info_id");
|
||||
@@ -87,8 +99,6 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
|
||||
JSONObject workorderObj = workOrderTab.query("workorder_id", workorder_id).uniqueResult(0);
|
||||
|
||||
JSONObject point3 = pointTab.query("point_code = '" + point_code3 + "'").uniqueResult(0);
|
||||
|
||||
|
||||
//区域出入表【st_ivt_regionIO】
|
||||
WQLObject regionIoTab = WQLObject.getWQLObject("st_ivt_regionIO");
|
||||
@@ -97,9 +107,9 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
regionIoObj.put("bill_code", CodeUtil.getNewCode("IN_STORE_CODE"));
|
||||
regionIoObj.put("buss_date", DateUtil.today());
|
||||
regionIoObj.put("io_type", "1");
|
||||
regionIoObj.put("region_id", point3.getString("region_id"));
|
||||
regionIoObj.put("region_code", point3.getString("region_code"));
|
||||
regionIoObj.put("region_name", point3.getString("region_name"));
|
||||
regionIoObj.put("region_id", endPoint.getString("region_id"));
|
||||
regionIoObj.put("region_code", endPoint.getString("region_code"));
|
||||
regionIoObj.put("region_name", endPoint.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"));
|
||||
@@ -119,12 +129,12 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt");
|
||||
JSONObject ivtObj = new JSONObject();
|
||||
ivtObj.put("stockrecord_id", IdUtil.getLongId());
|
||||
ivtObj.put("point_id", point3Obj.getString("point_id"));
|
||||
ivtObj.put("point_code", point3Obj.getString("point_code"));
|
||||
ivtObj.put("point_name", point3Obj.getString("point_name"));
|
||||
ivtObj.put("region_id", point3Obj.getString("region_id"));
|
||||
ivtObj.put("region_code", point3Obj.getString("region_code"));
|
||||
ivtObj.put("region_name", point3Obj.getString("region_name"));
|
||||
ivtObj.put("point_id", endPoint.getString("point_id"));
|
||||
ivtObj.put("point_code", endPoint.getString("point_code"));
|
||||
ivtObj.put("point_name", endPoint.getString("point_name"));
|
||||
ivtObj.put("region_id", endPoint.getString("region_id"));
|
||||
ivtObj.put("region_code", endPoint.getString("region_code"));
|
||||
ivtObj.put("region_name", endPoint.getString("region_name"));
|
||||
ivtObj.put("instorage_time", DateUtil.now());
|
||||
ivtObj.put("pcsn", DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyyMMdd"));
|
||||
ivtObj.put("ivt_qty", requestObj.getString("qty"));
|
||||
@@ -133,19 +143,26 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
ivtTab.insert(ivtObj);
|
||||
|
||||
// 点位解锁
|
||||
point3Obj.put("lock_type", "1");
|
||||
point3Obj.put("point_status", "3");
|
||||
pointTab.update(point3Obj);
|
||||
endPoint.put("lock_type", "1");
|
||||
endPoint.put("point_status", "3");
|
||||
endPoint.put("material_id", taskObj.getString("material_id"));
|
||||
pointTab.update(endPoint);
|
||||
//释放整列货位
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("lock_type", "1");
|
||||
pointTab.update(param, "task_id = '" + task_id + "'");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findNextPoint() {
|
||||
//判断共挤线是否有执行中的任务,如果任务数>=3,则不生成任务
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
/*
|
||||
* 根据业务找对应的终点
|
||||
*/
|
||||
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++) {
|
||||
@@ -159,31 +176,51 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
param1.put("vehicle_type", "%" + vehicle_type + "%");
|
||||
//1、查找库区类是否有响应的载具类型和对应的物料
|
||||
JSONObject json1 = WQL.getWO("QSCH_gjxSendMaterial_01").addParamMap(param1).process().uniqueResult(0);
|
||||
|
||||
|
||||
//判断是否有到同一列的相同物料SKU的AGV任务,如果有,则等待
|
||||
JSONArray taskIngs = taskTab.query("is_delete='0' and material_id = '" + material_id + "' and (task_status = '4' or task_status = '5' or task_status = '6' )").getResultJSONArray(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(taskIngs)) {
|
||||
JSONObject taskIng = taskIngs.getJSONObject(0);
|
||||
if (ObjectUtil.isNotEmpty(taskIng) && ObjectUtil.isNotEmpty(json1)) {
|
||||
JSONObject point2 = pointTab.query("point_code = '" + taskIng.getString("point_code2") + "'").uniqueResult(0);
|
||||
if (StrUtil.equals(point2.getString("block_num"), json1.getString("block_num"))
|
||||
&& StrUtil.equals(point2.getString("col_num"), json1.getString("col_num"))) {
|
||||
taskObj.put("remark", "相应列有AGV在工作,等待执行!");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(json1)) {
|
||||
Integer block_num = json1.getInteger("block_num");
|
||||
Integer row_num = json1.getInteger("row_num");
|
||||
Integer col_num = json1.getInteger("col_num");
|
||||
|
||||
//拿到第一排
|
||||
JSONObject firstRow = pointTab.query("block_num = '" + block_num + "' and col_num = '" + col_num + "' and row_num ='1'").uniqueResult(0);
|
||||
JSONObject firstRow = pointTab.query("block_num = '" + block_num + "' and col_num = '" + col_num + "' and row_num ='" + (row_num - 1) + "'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(firstRow)) throw new BadRequestException("数据错误,请校验!");
|
||||
taskObj.put("point_code2", firstRow.getString("point_code"));
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
//需要设置等待点
|
||||
if (row_num > 2) {
|
||||
//二楼终点追加任务
|
||||
taskObj.put("acs_task_type", "4");
|
||||
} else if (row_num == 2) {
|
||||
//二楼普通任务
|
||||
taskObj.put("acs_task_type", "2");
|
||||
}
|
||||
//把物料信(SKU)息更新到点位上
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("material_id", taskObj.getString("material_id"));
|
||||
pointTab.update(param, "block_num = '" + block_num + "' and row_num = '" + (row_num-1) + "' and col_num = '" + col_num + "'");
|
||||
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
//二楼普通任务
|
||||
taskTab.update(taskObj);
|
||||
//锁住相关货位
|
||||
JSONObject point = new JSONObject();
|
||||
point.put("lock_type", "2");
|
||||
point.put("task_id", taskObj.getString("task_id"));
|
||||
pointTab.update(point, "block_num = '" + block_num + "' and col_num = '" + col_num + "' and row_num <= '" + (row_num - 1) + "'");
|
||||
|
||||
} else {//找空位入
|
||||
if (ObjectUtil.isNotEmpty(taskIngs) && taskIngs.size() > 1) {
|
||||
taskObj.put("remark", "相应列有AGV在工作,等待执行!");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject param2 = new JSONObject();
|
||||
param2.put("flag", "2");
|
||||
param2.put("region_code", "YSQA01");
|
||||
@@ -197,12 +234,18 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
} else {
|
||||
Integer block_num = json2.getInteger("block_num");
|
||||
Integer col_num = json2.getInteger("col_num");
|
||||
JSONObject firstRow = pointTab.query("block_num = '" + block_num + "' and col_num = '" + col_num + "' and row_num ='1'").uniqueResult(0);
|
||||
JSONObject firstRow = pointTab.query("block_num = '" + block_num + "' and col_num = '" + col_num + "' and row_num ='9'").uniqueResult(0);
|
||||
taskObj.put("point_code2", firstRow.getString("point_code"));
|
||||
//二楼终点追加任务
|
||||
taskObj.put("acs_task_type", "4");
|
||||
//二楼普通任务
|
||||
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
//锁住相关货位
|
||||
JSONObject point = new JSONObject();
|
||||
point.put("lock_type", "2");
|
||||
point.put("task_id", taskObj.getString("task_id"));
|
||||
pointTab.update(point, "block_num = '" + block_num + "' and col_num = '" + col_num + "' and row_num <= '" + 9 + "'");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,16 +254,18 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
|
||||
@Override
|
||||
public List<AcsTaskDto> addTask() {
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
/*
|
||||
* 下发给ACS时需要特殊处理
|
||||
*/
|
||||
JSONArray arr = WQLObject.getWQLObject("SCH_BASE_Task").query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0'").getResultJSONArray(0);
|
||||
JSONArray arr = taskTab.query("handle_class = '" + THIS_CLASS + "' and task_status = '" + TaskStatusEnum.START_AND_POINT.getCode() + "' and is_delete ='0'").getResultJSONArray(0);
|
||||
|
||||
ArrayList<AcsTaskDto> acsTaskArr = new ArrayList<>();
|
||||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject json = arr.getJSONObject(i);
|
||||
|
||||
//养生A区发给ACS需要新的点位(2101-03-1----->21011-03-1)
|
||||
String point_code = json.getString("point_code3");
|
||||
String point_code = json.getString("point_code2");
|
||||
String newPoint = point_code.substring(0, 4) + "1" + point_code.substring(4, 9);
|
||||
|
||||
AcsTaskDto dto = AcsTaskDto.builder()
|
||||
@@ -271,6 +316,7 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
.task_name("共挤线满料")
|
||||
.task_status(TaskStatusEnum.SURE_START.getCode())
|
||||
.point_code1(point_code1)
|
||||
.acs_task_type("2")//2楼AGV普通任务
|
||||
.vehicle_code(vehicle_code)
|
||||
.material_qty(qty)
|
||||
.material_info_id(workOrderObj.getLong("workorder_id"))
|
||||
@@ -292,9 +338,13 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
@Override
|
||||
public void forceFinish(String task_id) {
|
||||
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))
|
||||
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");
|
||||
} else {
|
||||
throw new BadRequestException("任务已删除或者已完成!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -303,6 +353,7 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
|
||||
}
|
||||
|
||||
//TODO 暂时不用二次申请
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public String againApply(String task_id) {
|
||||
@@ -315,28 +366,22 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_Point"); // 点位表
|
||||
|
||||
JSONObject taskObj = taskTab.query("task_id ='" + task_id + "'").uniqueResult(0);
|
||||
JSONObject jsonPoint2 = pointTab.query("point_code = '" + taskObj.getString("point_code2") + "'").uniqueResult(0);
|
||||
|
||||
// 根据 区域、块、列找到第一个有物料的货位
|
||||
JSONObject jsonOnePoint = pointTab.query("region_id = '" + jsonPoint2.getString("region_id") +
|
||||
"' and block_num = '" + jsonPoint2.getString("block_num") +
|
||||
"' and col_num = '" + jsonPoint2.getString("col_num") +
|
||||
"' and point_status = '1' order by row_num desc").uniqueResult(0);
|
||||
JSONObject jsonPoint3 = pointTab.query("point_code = '" + taskObj.getString("point_code3") + "'").uniqueResult(0);
|
||||
//提前更新这列货位状态,方便生成往这列的任务
|
||||
jsonPoint3.put("point_status", "3");
|
||||
jsonPoint3.put("material_id", taskObj.getString("material_id"));
|
||||
pointTab.update(jsonPoint3);
|
||||
//释放相关货位
|
||||
JSONObject point = new JSONObject();
|
||||
point.put("lock_type", "1");
|
||||
point.put("task_id", "");
|
||||
pointTab.update(point, "task_id = '" + taskObj.getString("task_id") + "'");
|
||||
|
||||
if (ObjectUtil.isEmpty(jsonOnePoint)) throw new BadRequestException("该列库存状态有误,请检查!");
|
||||
|
||||
taskObj.put("point_code3", jsonOnePoint.getString("point_code"));
|
||||
taskObj.put("remark", "二次申请货位");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
|
||||
//养生A区发给ACS需要新的点位(2101-03-1----->21011-03-1)
|
||||
String point_code = jsonOnePoint.getString("point_code");
|
||||
String point_code = taskObj.getString("point_code3");
|
||||
String newPoint = point_code.substring(0, 4) + "1" + point_code.substring(4, 9);
|
||||
|
||||
// 点位上锁
|
||||
jsonOnePoint.put("lock_type", "2");
|
||||
pointTab.update(jsonOnePoint);
|
||||
return newPoint;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@
|
||||
p.row_num,
|
||||
p.col_num
|
||||
FROM
|
||||
|
||||
SCH_BASE_Point p
|
||||
where p.is_used = '1'
|
||||
AND is_delete = '0'
|
||||
AND lock_type = '1'
|
||||
AND p.row_num >1
|
||||
and p.point_status='1'
|
||||
where
|
||||
p.is_used = '1'
|
||||
AND is_delete = '0'
|
||||
AND lock_type = '1'
|
||||
AND point_status = '3'
|
||||
and row_num>1
|
||||
OPTION 输入.material_id <> ""
|
||||
p.material_id = 输入.material_id
|
||||
ENDOPTION
|
||||
@@ -67,7 +67,7 @@
|
||||
OPTION 输入.vehicle_type <> ""
|
||||
p.can_vehicle_type like 输入.vehicle_type
|
||||
ENDOPTION
|
||||
ORDER BY block_num,row_num
|
||||
ORDER BY block_num,col_num,row_num
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user