diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/rest/PdaController.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/rest/PdaController.java index 1907350..72110b3 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/rest/PdaController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/rest/PdaController.java @@ -221,4 +221,54 @@ public class PdaController { pdaService.inKiln(vehicle_code, type); return PdaUtils.buildSuccessResultJSON(null); } + + @PostMapping("/vehicleBind") + @Log("载具绑定") + @ApiOperation("载具绑定") + @PdaAnnotation + public JSONObject vehicleBind(@RequestBody JSONObject param) { + String point_code = param.getString("point_code"); + if (StrUtil.isBlank(point_code)) { + throw new BadRequestException("点位不能为空!"); + } + String vehicle_type = param.getString("vehicle_type"); + if (StrUtil.isBlank(vehicle_type)) { + throw new BadRequestException("载具类型不能为空!"); + } + String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code")); + if ("0000".equals(vehicle_code)) { + throw new BadRequestException("载具编码不能为空!"); + } + + pdaService.vehicleBind(point_code, vehicle_type, vehicle_code); + return PdaUtils.buildSuccessResultJSON(null); + } + + @PostMapping("/vehicleUnbind") + @Log("载具解绑") + @ApiOperation("载具解绑") + @PdaAnnotation + public JSONObject vehicleUnbind(@RequestBody JSONObject param) { + String point_code = param.getString("point_code"); + if (StrUtil.isBlank(point_code)) { + throw new BadRequestException("点位不能为空!"); + } + + pdaService.vehicleUnbind(point_code); + return PdaUtils.buildSuccessResultJSON(null); + } + + @PostMapping("/callDefective") + @Log("呼叫次品料") + @ApiOperation("呼叫次品料") + @PdaAnnotation + public JSONObject callDefective(@RequestBody JSONObject param) { + String device_code = param.getString("device_code"); + if (StrUtil.isBlank(device_code)) { + throw new BadRequestException("设备不能为空!"); + } + + pdaService.callDefective(device_code, param.toJSONString()); + return PdaUtils.buildSuccessResultJSON(null); + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/PdaService.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/PdaService.java index 24e61b1..8e4bc53 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/PdaService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/PdaService.java @@ -89,7 +89,7 @@ public interface PdaService { * 困料管理 * * @param vehicle_code 载具编码 - * @param type 操作类型 + * @param type 操作类型 */ void standStatus(String vehicle_code, String type); @@ -97,7 +97,30 @@ public interface PdaService { * 入窑管理 * * @param vehicle_code 载具编码 - * @param type 操作类型 + * @param type 操作类型 */ void inKiln(String vehicle_code, String type); + + /** + * 载具绑定 + * + * @param point_code 点位编码 + * @param vehicle_type 载具类型 + * @param vehicle_code 载具编码 + */ + void vehicleBind(String point_code, String vehicle_type, String vehicle_code); + + /** + * 载具解绑 + * + * @param point_code 点位编码 + */ + void vehicleUnbind(String point_code); + + /** + * 呼叫次品料 + * + * @param device_code 设备编码 + */ + void callDefective(String device_code, String request_param); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/impl/PdaServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/impl/PdaServiceImpl.java index 0e8a2fb..b2553b9 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/impl/PdaServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/service/impl/PdaServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; @@ -17,7 +16,6 @@ import org.nl.wms.basedata.eum.TrueOrFalse; import org.nl.wms.basedata.eum.VehicleType; import org.nl.wms.ext.acs.service.WmsToAcsService; import org.nl.wms.pda.service.PdaService; -import org.nl.wms.sch.manage.ACSSystem; import org.nl.wms.sch.manage.CreateMode; import org.nl.wms.sch.manage.PointStatus; import org.nl.wms.sch.manage.Region; @@ -89,6 +87,13 @@ public class PdaServiceImpl implements PdaService { .addParam("where", "('YZ', 'FJ')") .process() .getResultJSONArray(0); + case "vehicle_bind": + case "vehicle_unbind": + return WQL + .getWO("PDA") + .addParam("flag", "1") + .process() + .getResultJSONArray(0); default: throw new BadRequestException("未知功能!"); } @@ -222,6 +227,14 @@ public class PdaServiceImpl implements PdaService { default: throw new BadRequestException(region.label() + "没有叫空点位!"); } + case "vehicle_bind": + case "vehicle_unbind": + return WQL + .getWO("PDA") + .addParam("flag", "2") + .addParam("region_code", region_code) + .process() + .getResultJSONArray(0); default: throw new BadRequestException("未知功能!"); } @@ -229,11 +242,23 @@ public class PdaServiceImpl implements PdaService { @Override public JSONArray device(String func) { - return WQL - .getWO("PDA") - .addParam("flag", "3") - .process() - .getResultJSONArray(0); + switch (func) { + case "unqualified_report": + return WQL + .getWO("PDA") + .addParam("flag", "3") + .process() + .getResultJSONArray(0); + case "call_defective": + return WQL + .getWO("PDA") + .addParam("flag", "3") + .addParam("region_code", "YZ") + .process() + .getResultJSONArray(0); + default: + throw new BadRequestException("未知功能!"); + } } @Override @@ -330,12 +355,13 @@ public class PdaServiceImpl implements PdaService { put("device_code", device_code); }}); }}); + JSONObject device = WQLObject.getWQLObject("acs_device").query("device_code = '" + device_code + "'").uniqueResult(0); if (!"200".equals(result.getString("status"))) { - throw new BadRequestException("[" + device_code + "] ACS未返回设备信息!"); + throw new BadRequestException("[" + device.getString("device_name") + "] ACS未返回设备信息!"); } JSONArray data = result.getJSONArray("data"); if (ObjectUtil.isEmpty(data)) { - throw new BadRequestException("[" + device_code + "] ACS未返回设备信息!"); + throw new BadRequestException("[" + device.getString("device_name") + "] ACS未返回设备信息!"); } String mix_num = data.getJSONObject(0).getString("mix_num"); if (StrUtil.isBlank(mix_num)) { @@ -538,4 +564,54 @@ public class PdaServiceImpl implements PdaService { TaskUtils.addCurrentUpdateColum(vehicle_update); WQLObject.getWQLObject("st_ivt_vehicle_detail").update(vehicle_update, "vehicle_type = '2' AND vehicle_code = '" + vehicle_code + "'"); } + + @Override + public void vehicleBind(String point_code, String vehicle_type, String vehicle_code) { + JSONObject point_update = new JSONObject(); + point_update.put("point_status", PointStatus.NOT_EMPTY.value()); + point_update.put("vehicle_type", vehicle_type); + point_update.put("vehicle_code", vehicle_code); + TaskUtils.addCurrentUpdateColum(point_update); + WQLObject.getWQLObject("sch_base_point").update(point_update, "point_code = '" + point_code + "'"); + } + + @Override + public void vehicleUnbind(String point_code) { + JSONObject point_update = new JSONObject(); + point_update.put("point_status", PointStatus.EMPTY.value()); + point_update.put("vehicle_type", ""); + point_update.put("vehicle_code", ""); + TaskUtils.addCurrentUpdateColum(point_update); + WQLObject.getWQLObject("sch_base_point").update(point_update, "point_code = '" + point_code + "'"); + } + + @Override + public void callDefective(String device_code, String request_param) { + JSONObject device = WQLObject.getWQLObject("pdm_bi_device").query("is_used = '1' AND is_delete = '0' AND device_code = '" + device_code + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(device)) { + throw new BadRequestException("[" + device_code + "] 不存在或未启用!"); + } + + JSONObject point = WQLObject.getWQLObject("sch_base_point").query("region_code = 'YZ' AND point_type = '3' AND device_code LIKE '%" + device_code + "%'").uniqueResult(0); + if (ObjectUtil.isEmpty(point)) { + throw new BadRequestException("[" + device.getString("device_name") + "] 未找到次品料对接位!"); + } + + JSONObject workorder = WQLObject + .getWQLObject("pdm_bd_workorder") + .query("is_delete = '0' AND device_code = '" + device_code + "' AND order_status = '3'") + .uniqueResult(0); + if (ObjectUtil.isEmpty(workorder)) { + throw new BadRequestException("[" + point.getString("point_code") + "] 所属设备 [" + device_code + "] 未开始生产!"); + } + + JSONObject method_param = new JSONObject(); + method_param.put("workorder", workorder); + method_param.put("point", point); + method_param.put("create_mode", CreateMode.SCCJ.value()); + method_param.put("request_param", request_param); + method_param.put("create_id", SecurityUtils.getCurrentUserId()); + method_param.put("create_name", SecurityUtils.getCurrentNickName()); + yzCallMaterialTask.createTask(method_param); + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/wql/PDA.wql b/lms/nladmin-system/src/main/java/org/nl/wms/pda/wql/PDA.wql index b4eafe8..a503a58 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/wql/PDA.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/wql/PDA.wql @@ -48,7 +48,10 @@ FROM sch_base_region WHERE - region_code IN 输入.where + 1 = 1 + OPTION 输入.where <> "" + region_code IN 输入.where + ENDOPTION ORDER BY create_time ASC ENDSELECT @@ -65,7 +68,9 @@ WHERE is_used = '1' AND region_code = 输入.region_code - AND point_type IN 输入.point_type + OPTION 输入.point_type <> "" + point_type IN 输入.point_type + ENDOPTION ORDER BY point_code ASC ENDSELECT @@ -81,6 +86,9 @@ pdm_bi_device WHERE is_workorder = '1' + OPTION 输入.region_code <> "" + region_code = 输入.region_code + ENDOPTION ORDER BY device_code ASC ENDSELECT diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/MPS_PRODUCEDURE001.wql b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/MPS_PRODUCEDURE001.wql index 765dd83..b42486a 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/MPS_PRODUCEDURE001.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pdm/wql/MPS_PRODUCEDURE001.wql @@ -70,10 +70,14 @@ find_in_set( ShiftOrder.order_status, 输入.order_status) ENDOPTION OPTION 输入.begin_time <> "" - ShiftOrder.realproducestart_date >= 输入.begin_time + ShiftOrder.realproducestart_date IS NOT NULL + AND ShiftOrder.realproducestart_date <> '' + AND ShiftOrder.realproducestart_date >= 输入.begin_time ENDOPTION OPTION 输入.end_time <> "" - ShiftOrder.realproduceend_date <= 输入.end_time + ShiftOrder.realproduceend_date IS NOT NULL + AND ShiftOrder.realproducestart_date <> '' + AND ShiftOrder.realproduceend_date <= 输入.end_time ENDOPTION OPTION 输入.produceorder_code <> "" ShiftOrder.workorder_code like 输入.produceorder_code diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/GTKCallEmptyTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/GTKCallEmptyTask.java index bbed5c9..fd10acc 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/GTKCallEmptyTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/call/empty/GTKCallEmptyTask.java @@ -138,14 +138,14 @@ public class GTKCallEmptyTask 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); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java index 0492a3e..ea5190d 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/empty/FJSendEmptyTask.java @@ -98,11 +98,6 @@ public class FJSendEmptyTask extends AbstractAcsTask { 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); } } } @@ -156,19 +151,6 @@ public class FJSendEmptyTask extends AbstractAcsTask { point_table.update(point1); } } - - 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 + "'"); - } } } @@ -210,19 +192,6 @@ public class FJSendEmptyTask extends AbstractAcsTask { point_table.update(point1); } } - - 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 + "'"); - } } } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java index 0e035e7..0427665 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/FJSendMaterialTask.java @@ -324,6 +324,19 @@ public class FJSendMaterialTask extends AbstractAcsTask { param.add(info); wmsToAcsService.writeVehicle(param); } + + JSONObject workorder = WQL + .getWO("SEND_MATERIAL_TASK") + .addParam("flag", "7") + .addParam("vd_id", task.getString("group_id")) + .process() + .uniqueResult(0); + + JSONObject workorder_update = new JSONObject(); + workorder_update.put("real_qty", workorder.getIntValue("real_qty") + workorder.getIntValue("qty")); + workorder_update.put("qualified_qty", workorder.getIntValue("qualified_qty") + workorder.getIntValue("qty")); + TaskUtils.addACSUpdateColum(workorder_update); + WQLObject.getWQLObject("pdm_bd_workorder").update(workorder_update, "workorder_id = " + workorder.getString("workorder_id")); } } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java index fb6c85c..795c0d2 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/HLSendMaterialTask.java @@ -93,7 +93,11 @@ public class HLSendMaterialTask extends AbstractAcsTask { 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"))) { + JSONObject workorder = WQL.getWO("SEND_MATERIAL_TASK").addParam("flag", "8").addParam("vd_id", task.getString("group_id")).process().uniqueResult(0); + if (ObjectUtil.isNotEmpty(point1) + && "2".equals(point1.getString("point_type")) + && ObjectUtil.isNotEmpty(workorder) + && "1".equals(workorder.getString("is_new"))) { point2 = WQL .getWO("SEND_MATERIAL_TASK") .addParam("flag", "4") diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java index 305121e..8b0a66e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/YZSendMaterialTask.java @@ -231,6 +231,19 @@ public class YZSendMaterialTask extends AbstractAcsTask { } point_table.update(point2, "point_code = '" + point_code2 + "'"); } + + JSONObject workorder = WQL + .getWO("SEND_MATERIAL_TASK") + .addParam("flag", "7") + .addParam("vd_id", task.getString("group_id")) + .process() + .uniqueResult(0); + + JSONObject workorder_update = new JSONObject(); + workorder_update.put("real_qty", workorder.getIntValue("real_qty") + workorder.getIntValue("qty")); + workorder_update.put("qualified_qty", workorder.getIntValue("qualified_qty") + workorder.getIntValue("qty")); + TaskUtils.addACSUpdateColum(workorder_update); + WQLObject.getWQLObject("pdm_bd_workorder").update(workorder_update, "workorder_id = " + workorder.getString("workorder_id")); } } } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/wql/SEND_MATERIAL_TASK.wql b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/wql/SEND_MATERIAL_TASK.wql index b2ed933..4d94fa2 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/wql/SEND_MATERIAL_TASK.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/sch/task/send/material/wql/SEND_MATERIAL_TASK.wql @@ -156,8 +156,10 @@ QUERY SELECT vd.weight, + vd.qty, workorder.workorder_id, - workorder.real_qty + workorder.real_qty, + workorder.qualified_qty FROM st_ivt_vehicle_detail vd LEFT JOIN pdm_bd_workorder workorder ON vd.workorder_id = workorder.workorder_id @@ -166,3 +168,16 @@ ENDSELECT ENDQUERY ENDIF + + IF 输入.flag = "8" + QUERY + SELECT + workorder.* + FROM + st_ivt_vehicle_detail vd + LEFT JOIN pdm_bd_workorder workorder ON vd.workorder_id = workorder.workorder_id + WHERE + vd.vd_id = 输入.vd_id + ENDSELECT + ENDQUERY + ENDIF