rev 混料工单

This commit is contained in:
张江玮
2023-05-08 09:49:27 +08:00
parent 6dfaa6130f
commit 43d06b019e
24 changed files with 1133 additions and 316 deletions

View File

@@ -31,20 +31,15 @@ public class MaterialDetailDto implements Serializable {
*/
private String material_name;
/**
* 订单编号
*/
private String order_number;
private String furnace;
/**
* 客户名称
*/
private String customer_name;
private String material_brick_type;
/**
* 产品名称
*/
private String product_name;
private String bom_code;
private String order_code;
private String customer_code;
/**
* 产品牌号
@@ -85,4 +80,6 @@ public class MaterialDetailDto implements Serializable {
* 修改时间
*/
private String update_time;
private String is_delete;
}

View File

@@ -55,4 +55,6 @@ public class MaterialbaseDto implements Serializable {
private String is_used;
private Double weight;
private String material_type;
}

View File

@@ -2,9 +2,11 @@
package org.nl.wms.basedata.service.impl;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.WQL;
import org.nl.wms.basedata.service.MaterialDetailService;
import org.nl.wms.basedata.service.dto.MaterialDetailDto;
import org.springframework.stereotype.Service;
@@ -12,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Pageable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -38,10 +41,10 @@ public class MaterialDetailServiceImpl implements MaterialDetailService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
WQLObject wo = WQLObject.getWQLObject("md_me_material_detail");
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_delete = '0'", "update_time desc");
final JSONObject json = rb.pageResult();
return json;
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
return WQL.getWO("QMD_ME_MATERIAL_DETAIL").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "md.create_time DESC");
}
@Override
@@ -82,9 +85,6 @@ public class MaterialDetailServiceImpl implements MaterialDetailService {
dto.setMaterial_id(IdUtil.getSnowflake(1, 1).nextId());
dto.setCreate_id(currentUserId);
dto.setCreate_name(nickName);
dto.setUpdate_optid(currentUserId);
dto.setUpdate_optname(nickName);
dto.setUpdate_time(now);
dto.setCreate_time(now);
WQLObject wo = WQLObject.getWQLObject("md_me_material_detail");

View File

@@ -50,6 +50,7 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
map.put("search", name);
map.put("material_type", MapUtil.getStr(whereJson, "material_type"));
return WQL.getWO("QMD_ME_MATERIAL").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time DESC");
}
@@ -104,11 +105,11 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
dto.setMaterial_id(id);
dto.setCreate_id(currentUserId);
dto.setCreate_name(nickName);
dto.setUpdate_optid(currentUserId);
dto.setCreate_time(now);
JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto));
wo.insert(json);
// 解析物料编码 ZLMCZ1001C122211GM001BD20-8
// 解析物料编码
JSONObject material_detail = new JSONObject();
material_detail.put("material_id", id);
material_detail.put("material_code", material_code);
@@ -118,22 +119,40 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
if (ObjectUtil.isEmpty(furnace_name)) {
throw new BadRequestException("物料编码解析错误:未知炉型!");
}
material_detail.put("product_name", furnace_name.getString("label") + "镁碳砖");
material_detail.put("order_number", material_code.substring(11, 16));
material_detail.put("customer_name", material_code.substring(16, 21));
material_detail.put("furnace", furnace_code);
String material_brick_code = material_code.substring(2, 5);
JSONObject material_brick_type = dict_detail_table.query("name = 'material_brick_type' AND value = '" + material_brick_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(material_brick_type)) {
throw new BadRequestException("物料编码解析错误:未知物料砖类型!");
}
material_detail.put("material_brick_type", material_brick_code);
String bom_code = material_code.substring(5, 11);
JSONObject bom = new JSONObject();
bom.put("material_id", IdUtil.getSnowflake(1, 1).nextId());
bom.put("material_code", bom_code);
bom.put("material_type", "2");
bom.put("create_id", currentUserId);
bom.put("create_name", nickName);
bom.put("create_time", now);
JSONObject old_bom = wo.query("material_code = '" + bom_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(old_bom)) {
wo.insert(bom);
}
material_detail.put("bom_code", bom_code);
material_detail.put("order_code", material_code.substring(11, 16));
material_detail.put("customer_code", material_code.substring(16, 21));
String product_grade_code = material_code.substring(21, 23);
JSONObject product_grade = dict_detail_table.query("name = 'product_grade' AND value = '" + product_grade_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(product_grade)) {
throw new BadRequestException("物料编码解析错误:未知牌号!");
}
material_detail.put("product_grade", product_grade.getString("label"));
material_detail.put("product_grade", product_grade_code);
material_detail.put("brick_type", material_code.substring(23));
material_detail.put("create_id", currentUserId);
material_detail.put("create_name", nickName);
material_detail.put("create_time", now);
material_detail.put("update_optid", currentUserId);
material_detail.put("update_optname", nickName);
material_detail.put("update_time", now);
WQLObject.getWQLObject("md_me_material_detail").insert(material_detail);
}

View File

@@ -18,6 +18,7 @@
输入.class_code TYPEAS s_string
输入.idssql TYPEAS f_string
输入.classIds TYPEAS f_string
输入.material_type TYPEAS f_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -50,11 +51,10 @@
WHERE
is_delete = '0'
OPTION 输入.search <> ""
(
mb.material_code like '%' 输入.search '%'
OR
mb.material_name like '%' 输入.search '%'
)
ENDOPTION
OPTION 输入.material_type <> ""
mb.material_type = 输入.material_type
ENDOPTION
ENDSELECT
ENDPAGEQUERY

View File

@@ -0,0 +1,56 @@
[交易说明]
交易名: 物料详情分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
md.*,
d1.label AS 'furnace_name',
d2.label AS 'material_brick_type_name',
d3.label AS 'product_grade_name'
FROM
md_me_material_detail md
LEFT JOIN sys_dict_detail d1 ON d1.`value` = md.furnace AND d1.`name` = 'furnace'
LEFT JOIN sys_dict_detail d2 ON d2.`value` = md.material_brick_type AND d2.`name` = 'material_brick_type'
LEFT JOIN sys_dict_detail d3 ON d3.`value` = md.product_grade AND d3.`name` = 'product_grade'
WHERE
md.is_delete = '0'
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -225,16 +225,49 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
switch (type) {
case "1":
// 送料
String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code"));
if ("0000".equals(vehicle_code)) {
throw new BadRequestException("载具编码不能为空!");
}
method_param.put("vehicle_code", vehicle_code);
switch (region) {
case HL:
JSONObject workorder = TaskUtils.hasWorkOrder(point);
method_param.put("workorder", workorder);
String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code"));
if ("0000".equals(vehicle_code)) {
throw new BadRequestException("载具编码不能为空!");
}
method_param.put("vehicle_code", vehicle_code);
String weight = param.getString("weight");
if (StrUtil.isBlank(weight)) {
throw new BadRequestException("重量不能为空!");
}
String is_full = param.getString("is_full");
if (StrUtil.isBlank(is_full)) {
throw new BadRequestException("是否满垛不能为空!");
}
WQLObject vd_table = WQLObject.getWQLObject("st_ivt_vehicle_detail");
JSONObject vd_update = new JSONObject();
vd_update.put("is_delete", "1");
vd_update.put("update_optid", ACSSystem.id);
vd_update.put("update_optname", ACSSystem.nick_name);
String now = DateUtil.now();
vd_update.put("update_time", now);
vd_table.update(vd_update, "vehicle_type = '1' AND vehicle_code = '" + vehicle_code + "' AND is_delete = '0'");
JSONObject vd = new JSONObject();
vd.put("vd_id", IdUtil.getSnowflake(1L, 1L).nextId());
vd.put("vehicle_type", VehicleType.CUP.value());
vd.put("vehicle_code", vehicle_code);
vd.put("material_id", workorder.getString("material_id"));
vd.put("weight", weight);
vd.put("is_full", is_full);
vd.put("workorder_id", workorder.getString("workorder_id"));
vd.put("point_code", point_code);
vd.put("create_id", ACSSystem.id);
vd.put("create_name", ACSSystem.nick_name);
vd.put("create_time", now);
vd.put("is_in_kiln", "0");
vd.put("stand_status", "2");
vd_table.insert(vd);
method_param.put("vd", vd);
task_code = hlSendMaterialTask.createTask(method_param);
break;
case YZ:
@@ -243,8 +276,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
task_code = yzSendMaterialTask.createTask(method_param);
break;
case SZ:
WQLObject vd_table = WQLObject.getWQLObject("st_ivt_vehicle_detail");
JSONObject vd = vd_table
vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code"));
if ("0000".equals(vehicle_code)) {
throw new BadRequestException("载具编码不能为空!");
}
method_param.put("vehicle_code", vehicle_code);
vd_table = WQLObject.getWQLObject("st_ivt_vehicle_detail");
vd = vd_table
.query("is_delete = '0' AND vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'")
.uniqueResult(0);
if (ObjectUtil.isEmpty(vd)) {
@@ -281,11 +319,11 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
break;
case "3":
// 送空
vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code"));
String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code"));
if ("0000".equals(vehicle_code)) {
vehicle_code = point.getString("vehicle_code");
if (StrUtil.isBlank(vehicle_code) || "0000".equals(vehicle_code)) {
throw new BadRequestException("未知载具编码!");
throw new BadRequestException("载具编码不能为空");
}
}
method_param.put("vehicle_code", vehicle_code);
@@ -307,19 +345,17 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
// 叫空
switch (region) {
case HL:
String device_code = point.getString("device_code");
workorder = WQLObject
.getWQLObject("pdm_bd_workorder")
.query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'")
.query("is_delete = '0' AND device_code = '" + point.getString("device_code") + "' AND order_status = '3'")
.uniqueResult(0);
method_param.put("workorder", workorder);
task_code = hlCallEmptyTask.createTask(method_param);
break;
case YZ:
device_code = point.getString("device_code");
workorder = WQLObject
.getWQLObject("pdm_bd_workorder")
.query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'")
.query("is_delete = '0' AND device_code = '" + point.getString("device_code") + "' AND order_status = '3'")
.uniqueResult(0);
method_param.put("workorder", workorder);
task_code = yzCallEmptyTask.createTask(method_param);

View File

@@ -46,7 +46,7 @@ public class DeviceServiceImpl implements DeviceService {
if (!StrUtil.isEmpty(search)) {
map.put("search", "%" + search + "%");
}
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "device.device_code");
JSONObject json = WQL.getWO("PDM_BI_DEVICE01").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "device.device_model ASC, device.device_code ASC");
return json;
}

View File

@@ -1,6 +1,7 @@
package org.nl.wms.sch.task.call.empty;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
@@ -36,17 +37,17 @@ public class HLCallEmptyTask extends AbstractAcsTask {
}
}
@Override
public String createTask(JSONObject form) {
JSONObject point = form.getJSONObject("point");
TaskUtils.isEmptyPoint(point);
TaskUtils.isLocked(point);
JSONObject work_order = TaskUtils.hasWorkOrder(point);
JSONObject work_order = form.getJSONObject("workorder");
int priority = 1;
if (ObjectUtil.isNotEmpty(work_order)) {
priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1;
}
JSONObject task = TaskUtils.buildTask(
"混料叫空托盘",
"混料叫空",
TaskType.CALL_EMPTY.value(),
TaskStatus.SURE_END.value(),
null,
@@ -55,7 +56,7 @@ public class HLCallEmptyTask extends AbstractAcsTask {
null,
VehicleType.CUP.value(),
null,
TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1,
priority,
HLCallEmptyTask.class.getName(),
form.getString("create_mode"),
form.getString("request_param"),
@@ -64,10 +65,14 @@ public class HLCallEmptyTask extends AbstractAcsTask {
);
WQLObject.getWQLObject("sch_base_task").insert(task);
point.put("lock_type", LockType.TASK_LOCKED.value());
point.put("task_code", task.getString("task_code"));
TaskUtils.addFormUpdateColum(point, form);
WQLObject.getWQLObject("sch_base_point").update(point);
return task.getString("task_code");
}
@Override
public void findStartPoint() {
WQLObject task_table = WQLObject.getWQLObject("sch_base_task");
@@ -75,34 +80,35 @@ public class HLCallEmptyTask extends AbstractAcsTask {
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_END.value() + "' AND handle_class = '" + HLCallEmptyTask.class.getName() + "'", "priority DESC, create_time ASC")
.getResultJSONArray(0);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
if (ObjectUtil.isNotEmpty(tasks)) {
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
JSONObject point = WQL
.getWO("CALL_EMPTY_TASK")
.addParam("flag", "1")
.addParam("vehicle_type", task.getString("vehicle_type"))
.process()
.uniqueResult(0);
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
if (ObjectUtil.isNotEmpty(point)) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point.getString("point_code"));
task.put("vehicle_code", point.getString("vehicle_code"));
task.put("remark", "");
task_table.update(task);
JSONObject point = WQL
.getWO("CALL_EMPTY_TASK")
.addParam("flag", "5")
.process()
.uniqueResult(0);
point.put("lock_type", LockType.TASK_LOCKED.value());
point_table.update(point);
} else {
task.put("remark", "未找到合适的叫空载具点位!");
task_table.update(task);
if (ObjectUtil.isNotEmpty(point)) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point.getString("point_code"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code")));
task.put("remark", "");
TaskUtils.addAutoUpdateColum(task);
task_table.update(task);
point.put("lock_type", LockType.TASK_LOCKED.value());
point.put("task_code", task.getString("task_code"));
TaskUtils.addAutoUpdateColum(point);
point_table.update(point);
}
}
}
}
@Override
public void forceFinish(String task_id) {
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0);
@@ -112,7 +118,7 @@ public class HLCallEmptyTask extends AbstractAcsTask {
this.finishTask(task, OperationType.MANUAL);
}
@Override
public void cancel(String task_id) {
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0);
@@ -122,7 +128,6 @@ public class HLCallEmptyTask extends AbstractAcsTask {
this.cancelTask(task, OperationType.MANUAL);
}
public void cancelTask(JSONObject task, OperationType operation_type) {
if (task.getIntValue("task_status") < Integer.parseInt(TaskStatus.FINISHED.value())) {
task.put("task_status", TaskStatus.CANCELLED.value());
@@ -134,41 +139,47 @@ public class HLCallEmptyTask extends AbstractAcsTask {
WQLObject.getWQLObject("sch_base_task").update(task);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
JSONObject point1 = point_table.query("point_code = '" + task.getString("point_code1") + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(point1)
&& LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point1);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point1);
String point_code1 = task.getString("point_code1");
if (StrUtil.isNotBlank(point_code1)) {
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(point1)
&& LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point1);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point1);
}
point_table.update(point1);
}
point_table.update(point1);
}
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
String point_code2 = task.getString("point_code2");
if (StrUtil.isNotBlank(point_code2)) {
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
}
point_table.update(point2, "point_code = '" + point_code2 + "'");
}
point_table.update(point2, "point_code = '" + task.getString("point_code2") + "'");
}
}
public void finishTask(JSONObject task, OperationType operation_type) {
public void finishTask(JSONObject task, OperationType operation_type) {
int current_task_status = task.getIntValue("task_status");
if (current_task_status < Integer.parseInt(TaskStatus.FINISHED.value())) {
if (operation_type == OperationType.MANUAL
&& current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) {
&& current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) {
throw new BadRequestException("只能手动完成 [确认起点和终点] 之后的任务!");
}
task.put("task_status", TaskStatus.FINISHED.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(task);
@@ -178,30 +189,43 @@ public class HLCallEmptyTask extends AbstractAcsTask {
WQLObject.getWQLObject("sch_base_task").update(task);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
JSONObject point1 = point_table.query("point_code = '" + task.getString("point_code1") + "'").uniqueResult(0);
if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
point1.put("vehicle_type", "");
point1.put("vehicle_code", "");
point1.put("point_status", PointStatus.EMPTY.value());
TaskUtils.addCurrentUpdateColum(point1);
point_table.update(point1);
String point_code1 = task.getString("point_code1");
if (StrUtil.isNotBlank(point_code1)) {
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(point1)) {
if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
point1.put("vehicle_type", "");
point1.put("vehicle_code", "");
point1.put("point_status", PointStatus.EMPTY.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point1);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point1);
}
point_table.update(point1);
}
}
}
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
point2.put("vehicle_type", task.getString("vehicle_type"));
point2.put("vehicle_code", task.getString("vehicle_code"));
point2.put("point_status", PointStatus.NOT_EMPTY.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
String point_code2 = task.getString("point_code2");
if (StrUtil.isNotBlank(point_code2)) {
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
point2.put("vehicle_type", task.getString("vehicle_type"));
point2.put("vehicle_code", task.getString("vehicle_code"));
point2.put("point_status", PointStatus.NOT_EMPTY.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
}
point_table.update(point2, "point_code = '" + point_code2 + "'");
}
point_table.update(point2, "point_code = '" + task.getString("point_code2") + "'");
}
}
}

View File

@@ -113,3 +113,24 @@
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
point.*
FROM
sch_base_point point
LEFT JOIN st_ivt_vehicle_detail vd ON point.vehicle_type = vd.vehicle_type
AND point.vehicle_code = vd.vehicle_code
AND vd.is_delete = '0'
WHERE
is_used = '1'
AND lock_type = '1'
AND region_code = 'KLHJ'
AND point_type = '1'
AND point_status = '1'
AND point.vehicle_type = '1'
AND vd.vd_id IS NULL
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -52,7 +52,7 @@ public class FJSendMaterialTask extends AbstractAcsTask {
TaskStatus.SURE_START.value(),
point.getString("point_code"),
null,
null,
vd.getLong("vd_id"),
vd.getString("material_id"),
vd.getString("vehicle_type"),
vd.getString("vehicle_code"),
@@ -67,7 +67,7 @@ public class FJSendMaterialTask extends AbstractAcsTask {
if (TrueOrFalse.trueOrFalse(vd.getString("is_full"))) {
JSONObject pn = TaskUtils.buildPN(PickType.CP, vd.getLongValue("qty"), vd.getLongValue("workorder_id"));
WQLObject.getWQLObject("das_produce_number").insert(pn);
material_task.put("group_id", pn.getLong("data_id"));
material_task.put("table_fk_id", pn.getLong("data_id"));
JSONObject empty_task = TaskUtils.buildTask(
"分拣区叫空",
@@ -243,7 +243,7 @@ public class FJSendMaterialTask extends AbstractAcsTask {
point_table.update(point2, "point_code = '" + point_code2 + "'");
}
String data_id = task.getString("group_id");
String data_id = task.getString("table_fk_id");
if (TaskType.SEND_MATERIAL.value().equals(task.getString("task_type"))
&& StrUtil.isNotBlank(data_id)) {
WQLObject.getWQLObject("das_produce_number").delete("data_id = " + data_id);

View File

@@ -1,6 +1,7 @@
package org.nl.wms.sch.task.send.material;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
@@ -8,11 +9,10 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.basedata.eum.TrueOrFalse;
import org.nl.wms.basedata.eum.VehicleType;
import org.nl.wms.common.PickType;
import org.nl.wms.sch.manage.*;
import org.nl.wms.sch.task.util.TaskUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
/**
* 辽宁晟华混料 送料入库 任务类
@@ -38,74 +38,95 @@ public class HLSendMaterialTask extends AbstractAcsTask {
}
}
@Override
public String createTask(JSONObject form) {
JSONObject point = form.getJSONObject("point");
JSONObject work_order = form.getJSONObject("workorder");
int priority = TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1;
JSONObject vd = form.getJSONObject("vd");
TaskUtils.isLocked(point);
JSONObject work_order = TaskUtils.hasWorkOrder(point);
String vehicle_code = form.getString("vehicle_code");
if ("0000".equals(vehicle_code)) {
throw new BadRequestException("载具编码不能为空!");
}
// todo 组盘
JSONObject pn = TaskUtils.buildPN(PickType.YL, vd.getLongValue("qty"), vd.getLongValue("workorder_id"));
WQLObject.getWQLObject("das_produce_number").insert(pn);
JSONObject task = TaskUtils.buildTask(
"混料送料入库",
"混料送料",
TaskType.SEND_MATERIAL.value(),
TaskStatus.SURE_START.value(),
point.getString("point_code"),
null,
null,
work_order.getString("material_id"),
VehicleType.CUP.value(),
vehicle_code,
TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1,
vd.getLong("vd_id"),
vd.getString("material_id"),
vd.getString("vehicle_type"),
vd.getString("vehicle_code"),
priority,
HLSendMaterialTask.class.getName(),
form.getString("create_mode"),
form.getString("request_param"),
form.getString("create_id"),
form.getString("create_name")
);
task.put("table_fk_id", pn.getLong("data_id"));
WQLObject.getWQLObject("sch_base_task").insert(task);
point.put("lock_type", LockType.TASK_LOCKED.value());
point.put("task_code", task.getString("task_code"));
TaskUtils.addFormUpdateColum(point, form);
WQLObject.getWQLObject("sch_base_point").update(point);
return task.getString("task_code");
}
@Override
public void findNextPoint() {
WQLObject task_table = WQLObject.getWQLObject("sch_base_task");
JSONArray tasks = task_table
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_START.value() + "' AND handle_class = '" + YZSendMaterialTask.class.getName() + "'", "priority DESC, create_time ASC")
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_START.value() + "' AND handle_class = '" + HLSendMaterialTask.class.getName() + "'", "priority DESC, create_time ASC")
.getResultJSONArray(0);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
if (ObjectUtil.isNotEmpty(tasks)) {
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
JSONObject point = WQL
.getWO("SEND_MATERIAL_TASK")
.addParam("flag", "1")
.process()
.uniqueResult(0);
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
if (ObjectUtil.isNotEmpty(point)) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code2", point.getString("point_code"));
task.put("remark", "");
task_table.update(task);
JSONObject point1 = point_table.query("point_code = '" + task.getString("point_code1") + "'").uniqueResult(0);
JSONObject point2 = null;
if (ObjectUtil.isNotEmpty(point1) && "2".equals(point1.getString("point_type"))) {
point2 = WQL
.getWO("SEND_MATERIAL_TASK")
.addParam("flag", "4")
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
}
point.put("lock_type", LockType.TASK_LOCKED.value());
point.put("task_code", task.getString("task_code"));
point_table.update(point);
if (ObjectUtil.isEmpty(point2)) {
point2 = WQL
.getWO("SEND_MATERIAL_TASK")
.addParam("flag", "5")
.process()
.uniqueResult(0);
}
if (ObjectUtil.isNotEmpty(point2)) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code2", point2.getString("point_code"));
task.put("remark", "");
TaskUtils.addAutoUpdateColum(task);
task_table.update(task);
point2.put("lock_type", LockType.TASK_LOCKED.value());
point2.put("task_code", task.getString("task_code"));
TaskUtils.addAutoUpdateColum(point2);
point_table.update(point2);
}
}
}
}
@Override
public void forceFinish(String task_id) {
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0);
@@ -115,7 +136,7 @@ public class HLSendMaterialTask extends AbstractAcsTask {
this.finishTask(task, OperationType.MANUAL);
}
@Override
public void cancel(String task_id) {
JSONObject task = WQLObject.getWQLObject("sch_base_task").query("task_id = " + task_id).uniqueResult(0);
@@ -125,7 +146,7 @@ public class HLSendMaterialTask extends AbstractAcsTask {
this.cancelTask(task, OperationType.MANUAL);
}
public void cancelTask(JSONObject task, OperationType operation_type) {
if (task.getIntValue("task_status") < Integer.parseInt(TaskStatus.FINISHED.value())) {
task.put("task_status", TaskStatus.CANCELLED.value());
@@ -137,40 +158,49 @@ public class HLSendMaterialTask extends AbstractAcsTask {
WQLObject.getWQLObject("sch_base_task").update(task);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
JSONObject point1 = point_table.query("point_code = '" + task.getString("point_code1") + "'").uniqueResult(0);
if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point1);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point1);
String point_code1 = task.getString("point_code1");
if (StrUtil.isNotBlank(point_code1)) {
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0);
if (LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point1);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point1);
}
point_table.update(point1);
}
point_table.update(point1);
}
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
String point_code2 = task.getString("point_code2");
if (StrUtil.isNotBlank(point_code2)) {
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
}
point_table.update(point2, "point_code = '" + point_code2 + "'");
}
point_table.update(point2, "point_code = '" + task.getString("point_code2") + "'");
WQLObject.getWQLObject("das_produce_number").delete("data_id = " + task.getLongValue("table_fk_id"));
}
}
public void finishTask(JSONObject task, OperationType operation_type) {
public void finishTask(JSONObject task, OperationType operation_type) {
int current_task_status = task.getIntValue("task_status");
if (current_task_status < Integer.parseInt(TaskStatus.FINISHED.value())) {
if (operation_type == OperationType.MANUAL
&& current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) {
&& current_task_status < Integer.parseInt(TaskStatus.START_AND_END.value())) {
throw new BadRequestException("只能手动完成 [确认起点和终点] 之后的任务!");
}
task.put("task_status", TaskStatus.FINISHED.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(task);
@@ -180,31 +210,42 @@ public class HLSendMaterialTask extends AbstractAcsTask {
WQLObject.getWQLObject("sch_base_task").update(task);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
JSONObject point1 = point_table.query("point_code = '" + task.getString("point_code1") + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(point1)
&& LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
point1.put("vehicle_type", "");
point1.put("vehicle_code", "");
point1.put("point_status", PointStatus.EMPTY.value());
TaskUtils.addCurrentUpdateColum(point1);
point_table.update(point1);
String point_code1 = task.getString("point_code1");
if (StrUtil.isNotBlank(point_code1)) {
JSONObject point1 = point_table.query("point_code = '" + point_code1 + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(point1)
&& LockType.TASK_LOCKED.value().equals(point1.getString("lock_type"))
&& task.getString("task_code").equals(point1.getString("task_code"))) {
point1.put("lock_type", LockType.UNLOCKED.value());
point1.put("task_code", "");
point1.put("vehicle_type", "");
point1.put("vehicle_code", "");
point1.put("point_status", PointStatus.EMPTY.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point1);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point1);
}
point_table.update(point1);
}
}
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
point2.put("vehicle_type", task.getString("vehicle_type"));
point2.put("vehicle_code", task.getString("vehicle_code"));
point2.put("point_status", PointStatus.NOT_EMPTY.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
String point_code2 = task.getString("point_code2");
if (StrUtil.isNotBlank(point_code2)) {
JSONObject point2 = new JSONObject();
point2.put("lock_type", LockType.UNLOCKED.value());
point2.put("task_code", "");
point2.put("vehicle_type", task.getString("vehicle_type"));
point2.put("vehicle_code", task.getString("vehicle_code"));
point2.put("point_status", PointStatus.NOT_EMPTY.value());
if (operation_type == OperationType.AUTO) {
TaskUtils.addACSUpdateColum(point2);
} else if (operation_type == OperationType.MANUAL) {
TaskUtils.addCurrentUpdateColum(point2);
}
point_table.update(point2, "point_code = '" + point_code2 + "'");
}
point_table.update(point2, "point_code = '" + task.getString("point_code2") + "'");
}
}
}

View File

@@ -46,7 +46,7 @@ public class SZSendMaterialTask extends AbstractAcsTask {
TaskStatus.SURE_START.value(),
point.getString("point_code"),
null,
null,
vd.getLong("vd_id"),
vd.getString("material_id"),
vd.getString("vehicle_type"),
vd.getString("vehicle_code"),

View File

@@ -53,7 +53,7 @@ public class YZSendMaterialTask extends AbstractAcsTask {
TaskStatus.SURE_START.value(),
point.getString("point_code"),
null,
pn.getLongValue("data_id"),
vd.getLong("vd_id"),
vd.getString("material_id"),
vd.getString("vehicle_type"),
vd.getString("vehicle_code"),
@@ -64,6 +64,7 @@ public class YZSendMaterialTask extends AbstractAcsTask {
form.getString("create_id"),
form.getString("create_name")
);
task.put("table_fk_id", pn.getLong("data_id"));
WQLObject.getWQLObject("sch_base_task").insert(task);
point.put("lock_type", LockType.TASK_LOCKED.value());
@@ -172,7 +173,7 @@ public class YZSendMaterialTask extends AbstractAcsTask {
point_table.update(point2, "point_code = '" + point_code2 + "'");
}
WQLObject.getWQLObject("das_produce_number").delete("data_id = " + task.getLongValue("group_id"));
WQLObject.getWQLObject("das_produce_number").delete("data_id = " + task.getLongValue("table_fk_id"));
}
}

View File

@@ -16,6 +16,7 @@
输入.flag TYPEAS s_string
输入.is_full TYPEAS s_string
输入.vehicle_type TYPEAS s_string
输入.material_id TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -98,3 +99,40 @@
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
point.*
FROM
sch_base_point point
JOIN pdm_bi_device device ON point.device_code = device.device_code
LEFT JOIN pdm_bd_workorder workorder ON device.device_id = workorder.device_id AND workorder.order_status = '3'
LEFT JOIN md_me_materialbase mb1 ON workorder.material_id = mb1.material_id AND mb1.material_type = '1'
LEFT JOIN md_me_material_detail md1 ON mb1.material_id = md1.material_id
LEFT JOIN md_me_materialbase mb2 ON md1.bom_code = mb2.material_code AND mb2.material_type = '2'
WHERE
point.is_used = '1'
AND point.lock_type = '1'
AND point.region_code = 'KLHJ'
AND point.point_type = '2'
AND point.point_status = '0'
AND mb2.material_id = 输入.material_id
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
*
FROM
sch_base_point
WHERE
is_used = '1'
AND lock_type = '1'
AND region_code = 'KLHJ'
AND point_type = '1'
AND point_status = '0'
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -2,11 +2,9 @@ package org.nl.test;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -21,9 +19,22 @@ public class PointTest {
@Test
public void test01() {
String pattern = "^\\d+$";
System.out.println("ddd".matches(pattern));
System.out.println("0010".matches(pattern));
System.out.println("1232d".matches(pattern));
JSONObject point = new JSONObject();
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
String now = DateUtil.now();
for (int i = 0; i < 48; i++) {
point.put("point_id", IdUtil.getSnowflake(1L, 1L).nextId());
point.put("point_code", "KLHW" + String.format("%02d", i + 1));
point.put("point_name", "困料货位" + (i + 1));
point.put("region_id", "1643186988158947328");
point.put("region_code", "KLHJ");
point.put("region_name", "困料货架");
point.put("point_type", "1");
point.put("lock_type", "1");
point.put("create_id", 1);
point.put("create_name", "管理员");
point.put("create_time", now);
point_table.insert(point);
}
}
}