fix 拆码垛业务

This commit is contained in:
张江玮
2023-05-25 17:01:28 +08:00
parent 6d5a963c9a
commit b5d9419757
19 changed files with 727 additions and 202 deletions

View File

@@ -704,7 +704,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String unqualified_qty = jsonObject.getString("unqualified_qty");
if (StrUtil.isNotBlank(unqualified_qty) && !"0".equals(unqualified_qty)) {
workorder.put("unqualified_qty", unqualified_qty);
}
if (!"0".equals(workorder.getString("unqualified_qty"))) {
JSONObject regionIn = TaskUtils.buildRegionInFromWorkorder(workorder, RegionInType.FPRK);
WQLObject.getWQLObject("st_ivt_regionio").insert(regionIn);
}

View File

@@ -438,10 +438,13 @@ public class WorkorderServiceImpl implements WorkordeService {
String unqualified_qty = row.getString("unqualified_qty");
if (StrUtil.isNotBlank(unqualified_qty) && !"0".equals(unqualified_qty)) {
workorder.put("unqualified_qty", unqualified_qty);
}
if (!"0".equals(workorder.getString("unqualified_qty"))) {
JSONObject regionIn = TaskUtils.buildRegionInFromWorkorder(workorder, RegionInType.FPRK);
WQLObject.getWQLObject("st_ivt_regionio").insert(regionIn);
}
String qualified_qty = row.getString("qualified_qty");
if (StrUtil.isNotBlank(qualified_qty) && !"0".equals(qualified_qty)) {
workorder.put("qualified_qty", qualified_qty);

View File

@@ -84,11 +84,8 @@
)
ENDOPTION
OPTION 输入.region_code <> ""
device.region_code = 'HL'
device.region_code = 输入.region_code
ENDOPTION
OPTION 输入.region_code = ""
device.region_code IN ('YZ', 'FJ')
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF
@@ -177,7 +174,8 @@
material.b,
material.h,
material.w,
device.region_code
device.region_code,
workorder.vehicle_type
FROM
pdm_bd_workorder workorder
LEFT JOIN md_me_materialbase material ON workorder.material_id = material.material_id

View File

@@ -49,7 +49,7 @@ public class FJCallEmptyTask extends AbstractAcsTask {
null,
point.getString("point_code"),
null,
null,
work_order.getString("material_id"),
work_order.getString("vehicle_type"),
null,
TrueOrFalse.trueOrFalse(work_order.getString("is_urgent")) ? 50 : 1,
@@ -82,24 +82,18 @@ public class FJCallEmptyTask extends AbstractAcsTask {
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
JSONObject point = WQL
JSONObject bthc_point = WQL
.getWO("CALL_EMPTY_TASK")
.addParam("flag", "4")
.addParam("flag", "6")
.addParam("vehicle_type", task.getString("vehicle_type"))
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(point)) {
JSONArray request_param = new JSONArray();
request_param.add(point.getString("point_code"));
JSONObject result = wmsToAcsService.getTray(request_param);
if (!"200".equals(result.getString("status"))) {
continue;
}
if (ObjectUtil.isNotEmpty(bthc_point)) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point.getString("device_code"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code")));
task.put("point_code1", bthc_point.getString("device_code"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(bthc_point.getString("vehicle_code")));
task.put("group_id", bthc_point.getLongValue("vd_id"));
task.put("remark", "");
TaskUtils.addAutoUpdateColum(task);
task_table.update(task);
@@ -108,7 +102,38 @@ public class FJCallEmptyTask extends AbstractAcsTask {
update_point.put("lock_type", LockType.TASK_LOCKED.value());
update_point.put("task_code", task.getString("task_code"));
TaskUtils.addAutoUpdateColum(update_point);
point_table.update(update_point, "point_code = '" + point.getString("device_code") + "'");
point_table.update(update_point, "point_code = '" + bthc_point.getString("device_code") + "'");
} else {
JSONObject point = WQL
.getWO("CALL_EMPTY_TASK")
.addParam("flag", "4")
.addParam("vehicle_type", task.getString("vehicle_type"))
.process()
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(point)) {
JSONArray request_param = new JSONArray();
request_param.add(point.getString("point_code"));
JSONObject result = wmsToAcsService.getTray(request_param);
if (!"200".equals(result.getString("status"))) {
continue;
}
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point.getString("device_code"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code")));
task.put("material_id", "");
task.put("remark", "");
TaskUtils.addAutoUpdateColum(task);
task_table.update(task);
JSONObject update_point = new JSONObject();
update_point.put("lock_type", LockType.TASK_LOCKED.value());
update_point.put("task_code", task.getString("task_code"));
TaskUtils.addAutoUpdateColum(update_point);
point_table.update(update_point, "point_code = '" + point.getString("device_code") + "'");
}
}
}
}
@@ -177,14 +202,14 @@ public class FJCallEmptyTask extends AbstractAcsTask {
}
}
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);

View File

@@ -16,6 +16,7 @@
输入.flag TYPEAS s_string
输入.point_code TYPEAS s_string
输入.vehicle_type TYPEAS s_string
输入.material_id TYPEAS f_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -135,3 +136,25 @@
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "6"
QUERY
SELECT
point.*,
vd.vd_id
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
point.is_used = '1'
AND point.lock_type = '1'
AND point.region_code = 'BTHC'
AND point.point_type = '1'
AND point.point_status = '1'
AND point.vehicle_type = 输入.vehicle_type
AND vd.material_id = 输入.material_id
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -59,53 +59,39 @@ public class FJCallMaterialTask extends AbstractAcsTask {
form.getString("create_id"),
form.getString("create_name")
);
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);
JSONObject point1 = WQL
.getWO("CALL_MATERIAL_TASK")
.addParam("flag", "3")
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
return task.getString("task_code");
}
@Override
public void findStartPoint() {
WQLObject task_table = WQLObject.getWQLObject("sch_base_task");
JSONArray tasks = task_table
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_END.value() + "' AND handle_class = '" + FJCallMaterialTask.class.getName() + "'", "priority DESC, create_time ASC")
.getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(tasks)) {
if (ObjectUtil.isNotEmpty(point1)) {
point.put("lock_type", LockType.TASK_LOCKED.value());
point.put("task_code", task.getString("task_code"));
TaskUtils.addFormUpdateColum(point, form);
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
point_table.update(point);
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point1.getString("point_code"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(point1.getString("vehicle_code")));
task.put("material_id", point1.getString("material_id"));
task.put("group_id", point1.getString("vd_id"));
task.put("remark", "");
JSONObject point = WQL
.getWO("CALL_MATERIAL_TASK")
.addParam("flag", "3")
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
JSONObject point_update = new JSONObject();
point_update.put("lock_type", LockType.TASK_LOCKED.value());
point_update.put("task_code", task.getString("task_code"));
TaskUtils.addFormUpdateColum(point_update, form);
point_table.update(point_update, "point_id = " + point1.getLongValue("point_id"));
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("material_id", point.getString("material_id"));
task.put("group_id", point.getString("vd_id"));
task.put("remark", "");
TaskUtils.addAutoUpdateColum(task);
task_table.update(task);
WQLObject.getWQLObject("sch_base_task").insert(task);
JSONObject point_update = new JSONObject();
point_update.put("lock_type", LockType.TASK_LOCKED.value());
point_update.put("task_code", task.getString("task_code"));
TaskUtils.addAutoUpdateColum(point_update);
point_table.update(point_update, "point_id = " + point.getLongValue("point_id"));
}
}
return task.getString("task_code");
} else {
throw new BadRequestException("[" + point.get("point_code") + "] 的叫料任务未找到起点!");
}
}

View File

@@ -57,52 +57,38 @@ public class SZCallMaterialTask extends AbstractAcsTask {
form.getString("create_id"),
form.getString("create_name")
);
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);
JSONObject point1 = WQL
.getWO("CALL_MATERIAL_TASK")
.addParam("flag", "1")
.process()
.uniqueResult(0);
return task.getString("task_code");
}
@Override
public void findStartPoint() {
WQLObject task_table = WQLObject.getWQLObject("sch_base_task");
JSONArray tasks = task_table
.query("is_delete = '0' AND task_status = '" + TaskStatus.SURE_END.value() + "' AND handle_class = '" + SZCallMaterialTask.class.getName() + "'", "priority DESC, create_time ASC")
.getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(tasks)) {
if (ObjectUtil.isNotEmpty(point1)) {
WQLObject point_table = WQLObject.getWQLObject("sch_base_point");
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);
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point1.getString("point_code"));
task.put("material_id", point1.getString("material_id"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(point1.getString("vehicle_code")));
task.put("group_id", point1.getString("vd_id"));
task.put("remark", "");
JSONObject point = WQL
.getWO("CALL_MATERIAL_TASK")
.addParam("flag", "1")
.process()
.uniqueResult(0);
JSONObject point_update = new JSONObject();
point_update.put("lock_type", LockType.TASK_LOCKED.value());
point_update.put("task_code", task.getString("task_code"));
TaskUtils.addFormUpdateColum(point_update, form);
point_table.update(point_update, "point_id = " + point1.getLongValue("point_id"));
if (ObjectUtil.isNotEmpty(point)) {
task.put("task_status", TaskStatus.START_AND_END.value());
task.put("point_code1", point.getString("point_code"));
task.put("material_id", point.getString("material_id"));
task.put("vehicle_code", TaskUtils.formatVehicleCode(point.getString("vehicle_code")));
task.put("group_id", point.getString("vd_id"));
task.put("remark", "");
TaskUtils.addAutoUpdateColum(task);
task_table.update(task);
WQLObject.getWQLObject("sch_base_task").insert(task);
JSONObject point_update = new JSONObject();
point_update.put("lock_type", LockType.TASK_LOCKED.value());
point_update.put("task_code", task.getString("task_code"));
TaskUtils.addAutoUpdateColum(point_update);
point_table.update(point_update, "point_id = " + point.getLongValue("point_id"));
}
}
return task.getString("task_code");
} else {
throw new BadRequestException("[" + point.get("point_code") + "] 的叫料任务未找到起点!");
}
}
@@ -172,14 +158,14 @@ public class SZCallMaterialTask extends AbstractAcsTask {
}
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);

View File

@@ -8,6 +8,7 @@ import lombok.RequiredArgsConstructor;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.core.engine.object.WO;
import org.nl.wms.basedata.eum.TrueOrFalse;
import org.nl.wms.basedata.eum.VehicleType;
import org.nl.wms.sch.manage.*;
@@ -82,12 +83,19 @@ public class YZCallMaterialTask extends AbstractAcsTask {
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.getJSONObject(i);
JSONObject point = WQL
WO wo = WQL
.getWO("CALL_MATERIAL_TASK")
.addParam("flag", "4")
.addParam("material_id", task.getString("material_id"))
.process()
.uniqueResult(0);
.addParam("material_id", task.getString("material_id"));
JSONObject point2 = point_table.query("point_code = '" + task.getString("point_code2") + "'").uniqueResult(0);
if ("2".equals(point2.getString("point_type"))) {
wo.addParam("is_new", TrueOrFalse.TRUE.value());
} else if ("3".equals(point2.getString("point_type"))) {
wo.addParam("is_new", TrueOrFalse.FALSE.value());
}
JSONObject point = wo.process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(point)) {
task.put("task_status", TaskStatus.START_AND_END.value());

View File

@@ -15,6 +15,7 @@
#################################################
输入.flag TYPEAS s_string
输入.material_id TYPEAS f_string
输入.is_new TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -118,6 +119,7 @@
AND point.vehicle_code = vd.vehicle_code
AND vd.is_delete = '0'
LEFT JOIN md_me_materialbase mb1 ON vd.material_id = mb1.material_id
LEFT JOIN pdm_bd_workorder workorder ON vd.workorder_id = workorder.workorder_id
WHERE
point.is_used = '1'
AND point.lock_type = '1'
@@ -127,6 +129,9 @@
AND point.vehicle_type = '1'
AND mb1.material_id = 输入.material_id
AND vd.stand_status IN ('3', '4')
OPTION 输入.is_new <> ""
workorder.is_new = 输入.is_new
ENDOPTION
ORDER BY
vd.create_time ASC
ENDSELECT

View File

@@ -86,7 +86,7 @@ public class FJSendMaterialTask extends AbstractAcsTask {
form.getString("create_id"),
form.getString("create_name")
);
empty_task.put("table_fk_id", material_task.getLongValue("task_id"));
empty_task.put("task_group_id", material_task.getLongValue("task_id"));
WQLObject.getWQLObject("sch_base_task").insert(empty_task);
}
@@ -163,7 +163,7 @@ public class FJSendMaterialTask extends AbstractAcsTask {
JSONObject update_point = new JSONObject();
update_point.put("lock_type", LockType.TASK_LOCKED.value());
update_point.put("task_code", material_task.getString("task_code"));
update_point.put("task_code", empty_task.getString("task_code"));
TaskUtils.addAutoUpdateColum(update_point);
task_table.update(material_task);

View File

@@ -53,6 +53,8 @@
AND region_code = 'BCPHJ'
AND point_type = '1'
AND point_status = '0'
ORDER BY
point_code ASC
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -182,7 +182,7 @@ public class TaskUtils {
regionIn.put("cInvCode", regionInType.value() + material_code);
regionIn.put("iQuantity", String.format("%.3f", detail.getDoubleValue("vd_weight") / 1000));
regionIn.put("iNum", detail.getString("qty"));
regionIn.put("iinvexchrate", String.format("%.3f", detail.getDoubleValue("material_weight") / 1000));
regionIn.put("iinvexchrate", String.format("%.5f", detail.getDoubleValue("material_weight") / 1000));
regionIn.put("cBatch", cMocode);
return regionIn;
}
@@ -192,16 +192,16 @@ public class TaskUtils {
JSONObject regionIn = new JSONObject();
regionIn.put("id", IdUtil.getSnowflake(1L, 1L).nextId());
regionIn.put("cCode", CodeUtil.getNewCode("IN_STORE_CODE"));
regionIn.put("dDate", DateUtil.today());
regionIn.put("dDate", DateUtil.now());
regionIn.put("cVouchType", regionInType.label());
String material_code = detail.getString("material_code");
String cMocode = material_code.substring(11, 16);
regionIn.put("cMocode", cMocode);
regionIn.put("cInvCode", regionInType.value() + material_code);
int qty = detail.getIntValue("qty");
int qty = workorder.getIntValue("unqualified_qty");
regionIn.put("iNum", qty);
double material_weight = detail.getDoubleValue("material_weight") / 1000;
regionIn.put("iinvexchrate", String.format("%.3f", material_weight));
double material_weight = detail.getDoubleValue("material_weight");
regionIn.put("iinvexchrate", String.format("%.5f", material_weight / 1000));
regionIn.put("iQuantity", String.format("%.3f", qty * material_weight / 1000));
regionIn.put("cBatch", cMocode);
return regionIn;
@@ -212,14 +212,14 @@ public class TaskUtils {
JSONObject regionIn = new JSONObject();
regionIn.put("id", IdUtil.getSnowflake(1L, 1L).nextId());
regionIn.put("cCode", CodeUtil.getNewCode("IN_STORE_CODE"));
regionIn.put("dDate", DateUtil.today());
regionIn.put("dDate", DateUtil.now());
String material_code = detail.getString("material_code");
String cMocode = material_code.substring(11, 16);
regionIn.put("cMocode", cMocode);
regionIn.put("cInvCode", regionOutType.value() + material_code);
regionIn.put("iQuantity", String.format("%.3f", detail.getDoubleValue("vd_weight") / 1000));
regionIn.put("iNum", detail.getString("qty"));
regionIn.put("iinvexchrate", String.format("%.3f", detail.getDoubleValue("material_weight") / 1000));
regionIn.put("iinvexchrate", String.format("%.5f", detail.getDoubleValue("material_weight") / 1000));
regionIn.put("cBatch", cMocode);
return regionIn;
}

View File

@@ -65,7 +65,7 @@
pdm_bd_workorder workorder
LEFT JOIN md_me_materialbase material ON workorder.material_id = material.material_id
WHERE
workorder.vd_id = 输入.workorder_id
workorder.workorder_id = 输入.workorder_id
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -10,6 +10,8 @@ import org.junit.runner.RunWith;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.sch.manage.RegionInType;
import org.nl.wms.sch.task.util.TaskUtils;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -26,58 +28,6 @@ public class TempTest {
@Test
public void test01() {
JSONArray erp_materials = WQL.getWO("QMD_ME_MATERIAL").setDbname("dataSource1").addParam("flag", "2").process().getResultJSONArray(0);
if (ObjectUtil.isNotEmpty(erp_materials)) {
WQLObject material_table = WQLObject.getWQLObject("md_me_materialbase");
List<String> material_codes = material_table.query().getResultJSONArray(0).stream().map(o -> ((JSONObject) o).getString("material_code")).collect(Collectors.toList());
WQLObject dict_detail_table = WQLObject.getWQLObject("sys_dict_detail");
Long user_id = 1L;
String nick_name = "管理员";
String now = DateUtil.now();
erp_materials.forEach(o -> {
JSONObject erp_material = (JSONObject) o;
String material_code = erp_material.getString("cinvcode").substring(1);
if (!material_codes.contains(material_code)) {
JSONObject material = new JSONObject();
long id = IdUtil.getSnowflake(1L, 1L).nextId();
material.put("material_id", id);
material.put("material_code", material_code);
material.put("material_name", erp_material.getString("cinvname"));
material.put("weight", String.format("%.2f", erp_material.getDoubleValue("changerate") * 1000));
String qty = String.format("%.0f", erp_material.getDoubleValue("qty") * 1000);
material.put("qty", qty);
material.put("surplus_qty", qty);
String aux_qty = String.format("%.0f", erp_material.getDoubleValue("auxqty"));
material.put("aux_qty", aux_qty);
material.put("surplus_aux_qty", aux_qty);
material.put("order_code", erp_material.getString("free1"));
String furnace_code = material_code.substring(0, 2);
JSONObject furnace_name = dict_detail_table.query("name = 'furnace' AND value = '" + furnace_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(furnace_name)) {
material.put("furnace", furnace_name.getString("label"));
} else {
material.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.isNotEmpty(material_brick_type)) {
material.put("material_brick_type", material_brick_type.getString("label"));
} else {
material.put("material_brick_type", material_brick_code);
}
material.put("product_grade", erp_material.getString("free3"));
material.put("brick_type", erp_material.getString("free4"));
material.put("create_id", user_id);
material.put("create_name", nick_name);
material.put("create_time", now);
material_table.insert(material);
}
});
}
System.out.println(8.94 / 1000);
}
}