rev: 任务修改
This commit is contained in:
@@ -372,6 +372,12 @@
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<!--redisson-->
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<version>3.16.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Api(tags = "acs接收lms")
|
||||
@RequestMapping("/api/wms/task")
|
||||
@Slf4j
|
||||
@SaIgnore
|
||||
public class AcsToWmsController {
|
||||
private final AcsToWmsService acsToWmsService;
|
||||
|
||||
|
||||
@@ -246,13 +246,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
// 5.油漆线空盘入库: 调用空托盘入库处理类创建任务
|
||||
if (ObjectUtil.isEmpty(point_code)) throw new BadRequestException("点位不能为空");
|
||||
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
|
||||
if (ObjectUtil.isEmpty(vehicle_type)) throw new BadRequestException("载具类型不能为空");
|
||||
// if (ObjectUtil.isEmpty(vehicle_type)) throw new BadRequestException("载具类型不能为空");
|
||||
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("point_code1", point_code);
|
||||
param.put("qty", vehicle_num);
|
||||
param.put("vehicle_type", vehicle_type);
|
||||
param.put("vehicle_code", vehicle_code);
|
||||
// param.put("vehicle_type", vehicle_type);
|
||||
// param.put("vehicle_code", vehicle_code);
|
||||
// 创建任务
|
||||
YqxSendEmpVehicleTask taskBean = SpringContextHolder.getBean(YqxSendEmpVehicleTask.class);
|
||||
taskBean.createTask(param);
|
||||
|
||||
@@ -79,8 +79,6 @@ public class YqxhcqCallMaterialTask extends AbstractAcsTask {
|
||||
JSONObject taskObj = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
|
||||
// 物料点
|
||||
JSONObject material_point = pointTab.query("point_code = '" + taskObj.getString("point_code1") + "'").uniqueResult(0);
|
||||
// 等待点
|
||||
JSONObject wait_point = pointTab.query("point_code = '" + taskObj.getString("point_code3") + "'").uniqueResult(0);
|
||||
//任务取消
|
||||
if (StrUtil.equals(status, "0")) {
|
||||
// 取消删除任务
|
||||
@@ -106,6 +104,24 @@ public class YqxhcqCallMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
|
||||
if (StrUtil.equals(status, "2")) {
|
||||
//完成后
|
||||
// 物料点位解锁 并设置空位
|
||||
material_point.put("lock_type", "1");
|
||||
material_point.put("point_status", "1");
|
||||
material_point.put("material_id", "");
|
||||
material_point.put("vehicle_type", "");
|
||||
material_point.put("vehicle_code", "");
|
||||
pointTab.update(material_point);
|
||||
|
||||
// 油漆线缓存点位更新
|
||||
JSONObject yqx_point = pointTab.query("point_code = '" + taskObj.getString("point_code2") + "'").uniqueResult(0);
|
||||
yqx_point.put("point_status", "3");
|
||||
yqx_point.put("material_id", taskObj.getString("material_id"));
|
||||
yqx_point.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
yqx_point.put("material_qty", taskObj.getString("material_qty"));
|
||||
yqx_point.put("vehicle_qty", taskObj.getString("vehicle_qty"));
|
||||
pointTab.update(yqx_point);
|
||||
|
||||
// 更改任务状态为完成
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
@@ -114,8 +130,6 @@ public class YqxhcqCallMaterialTask extends AbstractAcsTask {
|
||||
|
||||
if (ObjectUtil.isEmpty(material_point)) return;
|
||||
|
||||
// JSONObject requestObj = task.getJSONObject("request_param");
|
||||
|
||||
//区域出入表【st_ivt_regionIO】
|
||||
WQLObject regionIoTab = WQLObject.getWQLObject("st_ivt_regionIO");
|
||||
JSONObject regionIoObj = new JSONObject();
|
||||
@@ -138,24 +152,6 @@ public class YqxhcqCallMaterialTask extends AbstractAcsTask {
|
||||
regionIoObj.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
regionIoObj.put("create_time", DateUtil.now());
|
||||
regionIoTab.insert(regionIoObj);
|
||||
|
||||
//完成后
|
||||
// 物料点位解锁 并设置空位
|
||||
material_point.put("lock_type", "1");
|
||||
material_point.put("point_status", "1");
|
||||
material_point.put("material_id", "");
|
||||
material_point.put("vehicle_type", "");
|
||||
material_point.put("vehicle_code", "");
|
||||
pointTab.update(material_point);
|
||||
|
||||
// 油漆线缓存点位更新
|
||||
JSONObject yqx_point = pointTab.query("point_code = '" + taskObj.getString("point_code2") + "'").uniqueResult(0);
|
||||
yqx_point.put("point_status", "3");
|
||||
yqx_point.put("material_id", taskObj.getString("material_id"));
|
||||
yqx_point.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
yqx_point.put("material_qty", taskObj.getString("material_qty"));
|
||||
yqx_point.put("vehicle_qty", taskObj.getString("vehicle_qty"));
|
||||
pointTab.update(yqx_point);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,23 +160,9 @@ public class YqxhcqCallMaterialTask extends AbstractAcsTask {
|
||||
public void autoCreate() {
|
||||
// 自动叫料
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
|
||||
// JSONArray allPoints = pointTab.query("region_code = 'YQXHCQ' AND lock_type = '1'" +
|
||||
// " AND is_used = '1' AND is_delete = '0'").getResultJSONArray(0);
|
||||
// String hcs = "";
|
||||
// for (int i = 0; i < allPoints.size(); i++) {
|
||||
// hcs = hcs + "'" + allPoints.getJSONObject(i).getString("point_code") + "'";
|
||||
// if (i < allPoints.size()) hcs = hcs + ",";
|
||||
// }
|
||||
// 限制只搬一次
|
||||
// JSONObject oneTask = taskTab.query("point_code2 in ('YQXHC01','YQXHC02','YQXHC03') AND " +
|
||||
// "is_delete='0' AND task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "' FOR UPDATE").uniqueResult(0);
|
||||
// if (ObjectUtil.isNotEmpty(oneTask)) return;
|
||||
// 找终点:四个缓存区按顺序获取一个
|
||||
JSONObject endPoint = WQL.getWO("YQX_AUTOTASK").addParamMap(MapOf.of("flag","1")).process().uniqueResult(0);
|
||||
// JSONObject endPoint = pointTab.query("region_code = 'YQXHCQ' AND point_status = '1' AND lock_type = '1'" +
|
||||
// " AND is_used = '1' AND is_delete = '0'", "point_code").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(endPoint)) return;
|
||||
String point_code2 = endPoint.getString("point_code");
|
||||
// 判断任务
|
||||
|
||||
@@ -74,25 +74,30 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
"' and col_num = '9'").uniqueResult(0);
|
||||
|
||||
jsonEmpWait.put("lock_type", "1");
|
||||
jsonEmpWait.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEmpWait);
|
||||
}
|
||||
jsonStart.put("lock_type", "1");
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
|
||||
// 更新终点(叠盘架状态)
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEnd);
|
||||
|
||||
} else {
|
||||
// 终点在供给线
|
||||
JSONObject jsonStart = pointTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
|
||||
jsonStart.put("lock_type", "1");
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
}
|
||||
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("remark", "已取消");
|
||||
taskTab.update(taskObj);
|
||||
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
jsonTask.put("remark", "已取消");
|
||||
jsonTask.put("update_time", DateUtil.now());
|
||||
taskTab.update(jsonTask);
|
||||
}
|
||||
|
||||
if (StrUtil.equals(status, "1")) {
|
||||
@@ -135,6 +140,7 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
"' and col_num = '9'").uniqueResult(0);
|
||||
|
||||
jsonEmpWait.put("lock_type", "1");
|
||||
jsonEmpWait.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEmpWait);
|
||||
}
|
||||
}
|
||||
@@ -144,12 +150,14 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
jsonStart.put("vehicle_type", "");
|
||||
jsonStart.put("vehicle_code", "");
|
||||
jsonStart.put("vehicle_qty", 0);
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
|
||||
// 更新终点(叠盘架状态)
|
||||
jsonEnd.put("vehicle_qty", NumberUtil.add(jsonEnd.getString("vehicle_qty"), jsonTask.getString("vehicle_qty")));
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("point_status", "2");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
jsonEnd.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
pointTab.update(jsonEnd);
|
||||
|
||||
@@ -157,6 +165,7 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
JSONObject jsonTask2 = taskTab.query("task_group_id = '" + jsonTask.getString("task_group_id") + "' and task_id <> '" + jsonTask.getString("task_id") + "'").uniqueResult(0);
|
||||
jsonTask2.put("point_code1", jsonEnd.getString("point_code"));
|
||||
jsonTask2.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
jsonTask2.put("update_time", DateUtil.now());
|
||||
taskTab.update(jsonTask2);
|
||||
} else {
|
||||
// 终点在供给线线: 更新起点(叠盘架)数量
|
||||
@@ -167,6 +176,7 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
jsonStart.put("point_status", "1");
|
||||
jsonStart.put("vehicle_type", "");
|
||||
}
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
}
|
||||
}
|
||||
@@ -187,17 +197,28 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
Map query = new HashMap<>();
|
||||
query.put("flag", "2");
|
||||
query.put("region_code", RegionTypeEnum.DPJQB.getCode());
|
||||
JSONArray array = WQL.getWO("QSCH_GjxCallEmpVehicleTask").addParamMap(query).process().getResultJSONArray(0);
|
||||
JSONArray array = WQL.getWO("QSCH_GjxCallEmpVehicleTask")
|
||||
.addParamMap(query)
|
||||
.process()
|
||||
.getResultJSONArray(0);
|
||||
PointUpdateUtil.updatePoint(array);
|
||||
|
||||
// 找叠盘架是否与对应的载具类型
|
||||
JSONObject jsonDpjStart = pointTab.query("region_code = '" + RegionTypeEnum.DPJQB.getCode() + "' and can_vehicle_type = '" + vehicle_type + "' and lock_type = '1' and is_used = '1' and is_delete = '0' and vehicle_qty <> '0'").uniqueResult(0);
|
||||
JSONObject jsonDpjStart = pointTab
|
||||
.query("region_code = '" + RegionTypeEnum.DPJQB.getCode() +
|
||||
"' and can_vehicle_type = '" + vehicle_type +
|
||||
"' and lock_type = '1' and is_used = '1' and is_delete = '0' and vehicle_qty <> '0'")
|
||||
.uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(jsonDpjStart)) {
|
||||
// todo
|
||||
// 判断叠盘架是否有任务 有就下一个任务 : 可以去除
|
||||
boolean is_point = this.isTask(jsonDpjStart.getString("point_code"));
|
||||
if (!is_point) continue;
|
||||
if (!is_point) {
|
||||
jsonTask.put("remark", "当前叠盘架有任务");
|
||||
taskTab.update(jsonTask);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 更新任务起点
|
||||
jsonTask.put("point_code1", jsonDpjStart.getString("point_code"));
|
||||
@@ -218,7 +239,6 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
boolean is_point = this.isTask(jsonDpjStart2.getString("point_code"));
|
||||
if (!is_point) continue;
|
||||
|
||||
// todo: 如何知道缓存位是否有空托盘
|
||||
// 找叠盘架暂存位是否有空托盘
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("flag", "1");
|
||||
@@ -314,7 +334,9 @@ public class GjxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
jsonEmpWait.put("lock_type", "2");
|
||||
pointTab.update(jsonEmpWait);
|
||||
} else {
|
||||
continue;
|
||||
// 没有找到空载具
|
||||
jsonTask.put("remark", "未找到空载具,查看是否被锁住或者托盘是否为空");
|
||||
taskTab.update(jsonTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,19 +70,23 @@ public class YqxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
"' and col_num = '9'").uniqueResult(0);
|
||||
|
||||
jsonEmpWait.put("lock_type", "1");
|
||||
jsonEmpWait.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEmpWait);
|
||||
}
|
||||
jsonStart.put("lock_type", "1");
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
|
||||
// 更新终点(叠盘架状态)
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEnd);
|
||||
|
||||
} else {
|
||||
// 终点在油漆线
|
||||
JSONObject jsonStart = pointTab.query("point_code = '" + point_code1 + "'").uniqueResult(0);
|
||||
jsonStart.put("lock_type", "1");
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
}
|
||||
|
||||
@@ -104,8 +108,6 @@ public class YqxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
* 2.终点为油漆线,更新起点载具数量
|
||||
*/
|
||||
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
|
||||
jsonTask.put("update_time", DateUtil.now());
|
||||
taskTab.update(jsonTask);
|
||||
|
||||
@@ -129,6 +131,7 @@ public class YqxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
"' and col_num = '9'").uniqueResult(0);
|
||||
|
||||
jsonEmpWait.put("lock_type", "1");
|
||||
jsonEmpWait.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonEmpWait);
|
||||
}
|
||||
}
|
||||
@@ -138,12 +141,14 @@ public class YqxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
jsonStart.put("vehicle_type", "");
|
||||
jsonStart.put("vehicle_code", "");
|
||||
jsonStart.put("vehicle_qty", 0);
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
|
||||
// 更新终点(叠盘架状态)
|
||||
jsonEnd.put("vehicle_qty", NumberUtil.add(jsonEnd.getString("vehicle_qty"),jsonTask.getString("vehicle_qty")));
|
||||
jsonEnd.put("lock_type", "1");
|
||||
jsonEnd.put("point_status", "2");
|
||||
jsonEnd.put("update_time", DateUtil.now());
|
||||
jsonEnd.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
pointTab.update(jsonEnd);
|
||||
|
||||
@@ -155,6 +160,7 @@ public class YqxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
}
|
||||
jsonTask2.put("point_code1", jsonEnd.getString("point_code"));
|
||||
jsonTask2.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
|
||||
jsonTask2.put("update_time", DateUtil.now());
|
||||
taskTab.update(jsonTask2);
|
||||
} else {
|
||||
// 终点在油漆线: 更新起点(叠盘架)数量
|
||||
@@ -165,6 +171,7 @@ public class YqxCallEmpVehicleTask extends AbstractAcsTask {
|
||||
jsonStart.put("point_status", "1");
|
||||
jsonStart.put("vehicle_type", "");
|
||||
}
|
||||
jsonStart.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonStart);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,13 @@ public class YqxCallMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("remark", "已取消");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
|
||||
// 点位解锁
|
||||
if (ObjectUtil.isEmpty(material_point)) return;
|
||||
material_point.put("lock_type", "1");
|
||||
material_point.put("update_time", DateUtil.now());
|
||||
pointTab.update(material_point);
|
||||
}
|
||||
|
||||
@@ -108,6 +110,7 @@ public class YqxCallMaterialTask extends AbstractAcsTask {
|
||||
material_point.put("material_id", "");
|
||||
material_point.put("vehicle_type", "");
|
||||
material_point.put("vehicle_code", "");
|
||||
material_point.put("update_time", DateUtil.now());
|
||||
pointTab.update(material_point);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,11 +51,13 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
|
||||
if (ObjectUtil.isNotEmpty(point_code3)) {
|
||||
JSONObject jsonPoint3 = pointTab.query("point_code ='" + point_code3 + "'").uniqueResult(0);
|
||||
jsonPoint3.put("point_status", "1");
|
||||
jsonPoint3.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonPoint3);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(point_code2)) {
|
||||
JSONObject jsonPoint2 = pointTab.query("point_code ='" + point_code2 + "'").uniqueResult(0);
|
||||
jsonPoint2.put("point_status", "1");
|
||||
jsonPoint2.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonPoint2);
|
||||
}
|
||||
taskTab.delete("task_id = '" + task_id + "'");
|
||||
@@ -86,6 +88,7 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
|
||||
point2.put("vehicle_type", "");
|
||||
point2.put("vehicle_code", "");
|
||||
point2.put("vehicle_qty", 0);
|
||||
point2.put("update_time", DateUtil.now());
|
||||
pointTab.update(point2);
|
||||
} else {
|
||||
point_code = jsonTask.getString("point_code2");
|
||||
@@ -100,6 +103,7 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
|
||||
endPoint.put("lock_type", "1");
|
||||
endPoint.put("vehicle_qty", vehicle_qty);
|
||||
endPoint.put("point_status", "2");
|
||||
endPoint.put("update_time", DateUtil.now());
|
||||
endPoint.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
pointTab.update(endPoint);
|
||||
} else {//非叠盘架
|
||||
@@ -108,6 +112,7 @@ public class HtSendEmpVehicleTask extends AbstractAcsTask {
|
||||
endPoint.put("vehicle_qty", jsonTask.getString("vehicle_qty"));
|
||||
endPoint.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
endPoint.put("point_status", "2");
|
||||
endPoint.put("update_time", DateUtil.now());
|
||||
pointTab.update(endPoint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,11 +49,13 @@ public class YqxSendEmpVehicleTask extends AbstractAcsTask {
|
||||
if (ObjectUtil.isNotEmpty(point_code3)) {
|
||||
JSONObject jsonPoint3 = pointTab.query("point_code ='" + point_code3 + "'").uniqueResult(0);
|
||||
jsonPoint3.put("point_status", "1");
|
||||
jsonPoint3.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonPoint3);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(point_code2)) {
|
||||
JSONObject jsonPoint2 = pointTab.query("point_code ='" + point_code2 + "'").uniqueResult(0);
|
||||
jsonPoint2.put("point_status", "1");
|
||||
jsonPoint2.put("update_time", DateUtil.now());
|
||||
pointTab.update(jsonPoint2);
|
||||
}
|
||||
taskTab.delete("task_id = '" + task_id + "'");
|
||||
@@ -84,6 +86,7 @@ public class YqxSendEmpVehicleTask extends AbstractAcsTask {
|
||||
point2.put("vehicle_type", "");
|
||||
point2.put("vehicle_code", "");
|
||||
point2.put("vehicle_qty", 0);
|
||||
point2.put("update_time", DateUtil.now());
|
||||
pointTab.update(point2);
|
||||
} else {
|
||||
point_code = jsonTask.getString("point_code2");
|
||||
@@ -98,6 +101,7 @@ public class YqxSendEmpVehicleTask extends AbstractAcsTask {
|
||||
endPoint.put("lock_type", "1");
|
||||
endPoint.put("vehicle_qty", vehicle_qty);
|
||||
endPoint.put("point_status", "2");
|
||||
endPoint.put("update_time", DateUtil.now());
|
||||
endPoint.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
pointTab.update(endPoint);
|
||||
} else {//非叠盘架
|
||||
@@ -106,6 +110,7 @@ public class YqxSendEmpVehicleTask extends AbstractAcsTask {
|
||||
endPoint.put("vehicle_qty", jsonTask.getString("vehicle_qty"));
|
||||
endPoint.put("vehicle_type", jsonTask.getString("vehicle_type"));
|
||||
endPoint.put("point_status", "2");
|
||||
endPoint.put("update_time", DateUtil.now());
|
||||
pointTab.update(endPoint);
|
||||
}
|
||||
}
|
||||
@@ -130,6 +135,11 @@ public class YqxSendEmpVehicleTask extends AbstractAcsTask {
|
||||
JSONObject workOrderObj = workOrderTab.query("device_code = '" + device_code + "' and order_status = '3' and is_delete ='0'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(workOrderObj)) throw new BadRequestException("该设备当前未生产或者已删除");
|
||||
|
||||
//任务表【SCH_BASE_Task】
|
||||
//判断当前点是否有未完成的任务
|
||||
JSONObject taskObj = taskTab.query("is_delete='0' and point_code1 = '" + point_code1 + "' and task_status <> '" + TaskStatusEnum.FINISHED.getCode() + "' FOR UPDATE").uniqueResult(0);
|
||||
if (ObjectUtil.isNotEmpty(taskObj)) throw new BadRequestException("当前点位" + point_code1 + "存在未完成的任务");
|
||||
|
||||
String vehicleType = workOrderObj.getString("vehicle_type");
|
||||
if (ObjectUtil.isEmpty(vehicleType)) throw new BadRequestException("载具类型不能为空");
|
||||
JSONObject jsonObject = pointTab.query("region_code = 'YQQY01' and point_type = '2' and can_vehicle_type = '" + vehicleType + "'").uniqueResult(0);
|
||||
@@ -146,7 +156,7 @@ public class YqxSendEmpVehicleTask extends AbstractAcsTask {
|
||||
.point_code1(startPointCode)
|
||||
.priority("8")
|
||||
.vehicle_code(form.getString("vehicle_code"))
|
||||
.vehicle_type(form.getString("vehicle_type"))
|
||||
.vehicle_type(vehicleType)
|
||||
.vehicle_qty(form.getIntValue("qty"))
|
||||
.handle_class(THIS_CLASS)
|
||||
.create_time(DateUtil.now())
|
||||
|
||||
@@ -20,12 +20,17 @@ import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.nl.wms.sch.tasks.AcsTaskDto;
|
||||
import org.nl.wms.sch.tasks.utils.PointUpdateUtil;
|
||||
import org.nl.wms.util.IdUtil;
|
||||
import org.nl.wms.util.RedissonUtils;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
|
||||
/**
|
||||
@@ -37,10 +42,10 @@ import java.util.List;
|
||||
public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
private final String THIS_CLASS = GjxSendMaterialTask.class.getName();
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateTaskStatus(JSONObject task, String status) {
|
||||
|
||||
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
|
||||
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject orderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
|
||||
@@ -57,12 +62,14 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("remark", "已取消");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
|
||||
String point_code2 = taskObj.getString("point_code2");
|
||||
if (ObjectUtil.isEmpty(point_code2)) return;
|
||||
JSONObject object = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
object.put("lock_type", "1");
|
||||
object.put("update_time", DateUtil.now());
|
||||
pointTab.update(object);
|
||||
}
|
||||
|
||||
@@ -75,33 +82,45 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
|
||||
if (StrUtil.equals(status, "2")) {
|
||||
//生产工单表【PDM_BD_WorkOrder】
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
|
||||
//完成后入库
|
||||
String point_code2 = taskObj.getString("point_code2");
|
||||
JSONObject requestObj = task.getJSONObject("request_param");
|
||||
JSONObject endPoint = pointTab.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||
//工单标识
|
||||
String workorder_id = requestObj.getString("material_info_id");
|
||||
JSONObject workorderObj = workOrderTab.query("workorder_id", workorder_id).uniqueResult(0);
|
||||
JSONObject order = orderTab.query("workorder_id = '" + workOrderId + "'").uniqueResult(0);
|
||||
|
||||
if (ObjectUtil.isNotEmpty(endPoint)) {
|
||||
if ( order.getString("workorder_type").equals("1")) {
|
||||
// 货梯口
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("lock_type", "1");
|
||||
param.put("point_status", "3");
|
||||
pointTab.update(param, "point_code = '" + point_code2 + "'");
|
||||
}
|
||||
// 点位解锁
|
||||
endPoint.put("lock_type", "1");
|
||||
endPoint.put("point_status", "3");
|
||||
endPoint.put("material_id", taskObj.getString("material_id"));
|
||||
endPoint.put("instorage_time", DateUtil.now());
|
||||
endPoint.put("pcsn", DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyyMMdd"));
|
||||
endPoint.put("ivt_qty", requestObj.getString("qty"));
|
||||
endPoint.put("standing_time", workorderObj.getString("standing_time"));
|
||||
endPoint.put("vehicle_code", taskObj.getString("vehicle_code"));
|
||||
endPoint.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
endPoint.put("update_time", DateUtil.now());
|
||||
pointTab.update(endPoint);
|
||||
}
|
||||
|
||||
// 更改任务状态为完成
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskObj.put("remark", "任务执行完成");
|
||||
taskTab.update(taskObj);
|
||||
|
||||
JSONObject order = orderTab.query("workorder_id = '" + workOrderId + "'").uniqueResult(0);
|
||||
if (order.getString("workorder_type").equals("1")) {
|
||||
// 货梯口
|
||||
String point_code2 = taskObj.getString("point_code2");
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("lock_type", "1");
|
||||
param.put("point_status", "3");
|
||||
pointTab.update(param, "point_code = '" + point_code2 + "'");
|
||||
}
|
||||
|
||||
|
||||
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");
|
||||
//生产工单表【PDM_BD_WorkOrder】
|
||||
WQLObject workOrderTab = WQLObject.getWQLObject("PDM_BD_WorkOrder");
|
||||
JSONObject workorderObj = workOrderTab.query("workorder_id", workorder_id).uniqueResult(0);
|
||||
|
||||
|
||||
//区域出入表【st_ivt_regionIO】
|
||||
WQLObject regionIoTab = WQLObject.getWQLObject("st_ivt_regionIO");
|
||||
JSONObject regionIoObj = new JSONObject();
|
||||
@@ -124,25 +143,6 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
regionIoObj.put("create_name", SecurityUtils.getCurrentNickName());
|
||||
regionIoObj.put("create_time", DateUtil.now());
|
||||
regionIoTab.insert(regionIoObj);
|
||||
|
||||
|
||||
//完成后入库
|
||||
// 点位解锁
|
||||
endPoint.put("lock_type", "1");
|
||||
endPoint.put("point_status", "3");
|
||||
endPoint.put("material_id", taskObj.getString("material_id"));
|
||||
endPoint.put("instorage_time", DateUtil.now());
|
||||
endPoint.put("pcsn", DateUtil.format(DateUtil.parse(DateUtil.today()), "yyyyMMdd"));
|
||||
endPoint.put("ivt_qty", requestObj.getString("qty"));
|
||||
endPoint.put("standing_time", workorderObj.getString("standing_time"));
|
||||
endPoint.put("vehicle_code", taskObj.getString("vehicle_code"));
|
||||
endPoint.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
pointTab.update(endPoint);
|
||||
//释放整列货位
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("lock_type", "1");
|
||||
pointTab.update(param, "task_id = '" + task_id + "'");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -237,14 +237,8 @@ public class GjxSendMaterialTask extends AbstractAcsTask {
|
||||
pointTab.update(point, "point_code = '" + firstRow.getString("point_code") + "'");
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
MDC.put("log_file_type", LokiLogType.DEFAULT.getDesc());
|
||||
log.info("异常日志:" + "第" + block_num + "块" + row_num + "排" + (col_num - 1) + "列被锁,重新安排一排.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
MDC.remove("log_file_type");
|
||||
}
|
||||
MDC.put("log_file_type", LokiLogType.DEFAULT.getDesc());
|
||||
log.info("异常日志:" + "第" + block_num + "块" + row_num + "排" + (col_num - 1) + "列被锁,重新安排一排.");
|
||||
// 下一列被锁住,给提示
|
||||
reminder = "第" + block_num + "块" + row_num + "排" + (col_num - 1) + "列被锁,重新安排一排.";
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ public class HkxSendMaterialTask extends AbstractAcsTask {
|
||||
}
|
||||
taskObj.put("task_status", TaskStatusEnum.FINISHED.getCode());
|
||||
taskObj.put("remark", "已取消");
|
||||
taskObj.put("update_time", DateUtil.now());
|
||||
taskTab.update(taskObj);
|
||||
}
|
||||
|
||||
@@ -119,6 +120,7 @@ public class HkxSendMaterialTask extends AbstractAcsTask {
|
||||
// 终点解锁
|
||||
point2Obj.put("lock_type", "1");
|
||||
point2Obj.put("point_status", "3");
|
||||
point2Obj.put("update_time", DateUtil.now());
|
||||
// 载具类型
|
||||
point2Obj.put("vehicle_type", taskObj.getString("vehicle_type"));
|
||||
pointTab.update(point2Obj);
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
AND '3' <> (SELECT p2.point_status FROM SCH_BASE_Point p2 WHERE p2.block_num = p.block_num AND p2.row_num = p.row_num
|
||||
AND p2.col_num = (SELECT MIN(p3.col_num) FROM SCH_BASE_Point p3 WHERE p3.block_num = p2.block_num AND p3.row_num = p2.row_num AND p3.is_used = '1' AND p3.is_delete = '0' AND p3.lock_type = '1'))
|
||||
ORDER BY block_num,row_num,col_num
|
||||
FOR UPDATE
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
@@ -35,8 +35,13 @@ public class PointUpdateUtil {
|
||||
pointObj2.put("point_status", vehicleNum.equals("0")?"1":"2");
|
||||
pointTable.update(pointObj2);
|
||||
} else if (pointObj2.getString("region_code").equals(RegionTypeEnum.SSX.getCode())) {
|
||||
String move = pointObj.getString("move");
|
||||
pointObj2.put("point_status", Integer.parseInt(move) + 1);
|
||||
String move = pointObj.getString("move"); // 0 1
|
||||
String mode = pointObj.getString("mode");
|
||||
if (mode.equals("2")) {
|
||||
pointObj2.put("point_status", Integer.parseInt(move) + 1);
|
||||
} else {
|
||||
pointObj2.put("point_status", "2");
|
||||
}
|
||||
pointTable.update(pointObj2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.nl.wms.util;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.redisson.api.RReadWriteLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2023/3/27 10:30
|
||||
*/
|
||||
public class RedissonUtils {
|
||||
/**
|
||||
*
|
||||
* @param supplier 业务代码
|
||||
* @param key
|
||||
* @param seconds 尝试获取锁的等待时间,允许为空
|
||||
*/
|
||||
@SneakyThrows
|
||||
public static void lock(Supplier supplier, String key, Integer seconds, Boolean isRead){
|
||||
RedissonClient redissonClient = SpringContextHolder.getBean(RedissonClient.class);
|
||||
RReadWriteLock readWriteLock = redissonClient.getReadWriteLock(key);
|
||||
Lock lock;
|
||||
if (isRead){
|
||||
lock = readWriteLock.readLock();
|
||||
}else {
|
||||
lock = readWriteLock.writeLock();
|
||||
}
|
||||
boolean isLock;
|
||||
if (seconds == null){
|
||||
isLock = lock.tryLock();
|
||||
}else {
|
||||
isLock = lock.tryLock(seconds, TimeUnit.SECONDS);
|
||||
}
|
||||
try {
|
||||
if (isLock){
|
||||
supplier.get();
|
||||
} else {
|
||||
throw new BadRequestException("当前业务 key:"+key+"正在锁定请稍后再试");
|
||||
}
|
||||
}finally {
|
||||
if (isLock){
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user