From cf8e8459f9fdb5e58922631dd47906e6fce3b21a Mon Sep 17 00:00:00 2001 From: liuxy Date: Sun, 25 Aug 2024 10:47:03 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E7=AB=8B=E5=BA=93=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E5=A4=84=E7=90=86=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage_manage/ios/enums/TASKEnum.java | 2 +- .../util/impl/OutBussManageServiceImpl.java | 269 ++++++++++++++++++ .../util/service/OutBussManageService.java | 8 + .../acs/service/impl/AcsToWmsServiceImpl.java | 20 +- 4 files changed, 297 insertions(+), 2 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/enums/TASKEnum.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/enums/TASKEnum.java index 4f996dda8..7f142812e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/enums/TASKEnum.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/enums/TASKEnum.java @@ -24,7 +24,7 @@ public enum TASKEnum { VEHICLE_TYPE(MapOf.of("托盘入库", "010705", "托盘出库", "010706")), // 成品任务类型 - PROUD_TYPE(MapOf.of("成品入库", "010703", "成品出库", "010711")), + PROUD_TYPE(MapOf.of("成品入库", "010703", "成品出库", "010711", "立库转库", "010709")), ; private Map code; diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/OutBussManageServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/OutBussManageServiceImpl.java index fe859dca0..a05808581 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/OutBussManageServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/impl/OutBussManageServiceImpl.java @@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import org.nl.b_lms.sch.task.dao.SchBaseTask; +import org.nl.b_lms.sch.task.service.IschBaseTaskService; import org.nl.b_lms.storage_manage.database.service.IBstIvtBoxinfoService; import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo; import org.nl.b_lms.storage_manage.ios.enums.IOSEnum; @@ -83,6 +85,12 @@ public class OutBussManageServiceImpl implements OutBussManageService { @Autowired private IBstIvtBoxinfoService iBstIvtBoxinfoService; + /* + * 任务服务 + */ + @Autowired + private IschBaseTaskService ischBaseTaskService; + @Override @Transactional public void lockStruct(List param, JSONObject json) { @@ -627,4 +635,265 @@ public class OutBussManageServiceImpl implements OutBussManageService { } } + + @Override + @Transactional + public JSONObject taskExceptional(JSONObject jsonObject) { + // 判断是 正常出库转库任务 还是 异常出库转库任务 + // 仓位表 + WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr"); + + SchBaseTask taskDao = ischBaseTaskService.getOne( + new QueryWrapper().lambda() + .eq(SchBaseTask::getTask_code, jsonObject.getString("task_code")) + ); + + JSONObject jsonPointOne = attrTab.query("struct_code = '" + taskDao.getPoint_code1() + "'").uniqueResult(0); + JSONObject jsonPointTwo = attrTab.query("struct_code = '" + taskDao.getPoint_code2() + "'").uniqueResult(0); + + // 需要返回的仓位 + JSONObject result; + if (jsonPointOne.getString("lock_type").equals(IOSEnum.LOCK_TYPE.code("出库异常锁")) + && jsonPointTwo.getString("lock_type").equals(IOSEnum.LOCK_TYPE.code("出库异常锁")) + ) { + // 异常出库转库任务 + result = unusualMove(jsonObject); + } else { + // 正常出库转库任务 + result = normalMove(jsonObject); + } + + return result; + } + + /** + * 异常出库转库任务 + * @param jsonObject {task_code : 任务编码} + * @return JSONObject 仓位对象 + */ + private JSONObject unusualMove(JSONObject jsonObject) { + /* + * 1.更新原仓位为满入异常锁 + * 2.重新分配货位 + * 3.更新任务终点 + */ + // 仓位表 + WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr"); + // 子卷包装关系 + WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + // 物料信息 + WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); + + SchBaseTask taskDao = ischBaseTaskService.getOne( + new QueryWrapper().lambda() + .eq(SchBaseTask::getTask_code, jsonObject.getString("task_code")) + ); + + + // 查询物料信息 + JSONObject jsonSub = subTab.query("package_box_sn = '" + taskDao.getVehicle_code() + "'").uniqueResult(0); + JSONObject jsonMater = materTab.query("material_code = '" + jsonSub.getString("product_name") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonMater)) { + throw new BadRequestException("物料编码【"+jsonSub.getString("product_name")+"】信息不存在!"); + } + + // 1.更新原仓位为满入异常锁 + JSONObject jsonPoint = attrTab.query("struct_code = '" + taskDao.getPoint_code2() + "'").uniqueResult(0); + jsonPoint.put("lock_type", IOSEnum.LOCK_TYPE.code("货位异常锁")); + jsonPoint.put("remark", "立库转库-满入/浅货位阻挡异常锁定!"); + jsonPoint.put("task_code", ""); + jsonPoint.put("inv_type", ""); + jsonPoint.put("inv_id", ""); + jsonPoint.put("inv_code", ""); + attrTab.update(jsonPoint); + + // 2.重新分配货位 + // 组织查询移入仓位数据 + JSONObject moveParam = new JSONObject(); + moveParam.put("stor_id", IOSEnum.STOR_ID.code("二期")); + moveParam.put("sect_id", RegionTypeEnum.TWO_BZC01.getId()); + moveParam.put("box_no", taskDao.getVehicle_code()); + moveParam.put("material_id", jsonMater.getString("material_id")); + + //根据木箱高度,判断入库仓位的高度、 + String height = ""; + String heightLevel1 = iSysParamService.findByCode("height_level_1").getValue(); + String heightLevel2 = iSysParamService.findByCode("height_level_2").getValue(); + + // 查询木箱信息 + BstIvtBoxinfo boxDao = iBstIvtBoxinfoService.getOne( + new QueryWrapper().lambda() + .eq(BstIvtBoxinfo::getBox_no, taskDao.getVehicle_code()) + ); + if (ObjectUtil.isEmpty(boxDao)) { + throw new BadRequestException("木箱号为【"+taskDao.getVehicle_code()+"】的木箱信息不存在!"); + } + + String box_high = boxDao.getBox_high(); + if (Integer.parseInt(box_high) <= Integer.parseInt(heightLevel1)) { + height = "('1','2','3')"; + } else if (Integer.parseInt(box_high) > Integer.parseInt(heightLevel1) && Integer.parseInt(box_high) <= Integer.parseInt(heightLevel2)) { + height = "('2','3')"; + } else { + height = "('3')"; + } + + moveParam.put("height", height); + moveParam.put("vehicle_type", boxDao.getVehicle_type()); + // 移库巷道 + moveParam.put("move_block_num",jsonPoint.getString("block_num")); + JSONObject jsonMove = inBussManageService.getOneStruct(moveParam); + if (ObjectUtil.isEmpty(jsonMove)) { + throw new BadRequestException("当前【"+jsonPoint.getString("block_num")+"】号巷道没有可用仓位!"); + } + + // 更新新仓位状态 + jsonMove.put("lock_type",IOSEnum.LOCK_TYPE.code("出库异常锁")); + jsonMove.put("inv_code", taskDao.getVehicle_code()); + attrTab.update(jsonMove); + + // 3.更新任务终点 + taskDao.setPoint_code2(jsonMove.getString("struct_code")); + taskDao.setRemark("转库满入或浅货位有货!"); + ischBaseTaskService.updateById(taskDao); + + return jsonMove; + } + + /** + * 正常出库转库任务 + * @param jsonObject {task_code : 任务编码} + * @return JSONObject 仓位对象 + */ + public JSONObject normalMove(JSONObject jsonObject) { + /* + * 1.锁定原货位 + * 2.重新找新货位 - 更新库存 + * 3.更新单据相关数据 + * 4.更新任务终点 + */ + // 仓位表 + WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr"); + // 移库单明细 + WQLObject moveDtlTab = WQLObject.getWQLObject("st_ivt_moveinvdtl"); + // 移库单主表 + WQLObject moveMstTab = WQLObject.getWQLObject("st_ivt_moveinv"); + // 子卷包装关系 + WQLObject subTab = WQLObject.getWQLObject("pdm_bi_subpackagerelation"); + // 物料信息 + WQLObject materTab = WQLObject.getWQLObject("md_me_materialbase"); + + // 1.锁定原货位 + SchBaseTask taskDao = ischBaseTaskService.getOne( + new QueryWrapper().lambda() + .eq(SchBaseTask::getTask_code, jsonObject.getString("task_code")) + ); + + // 查询对应单据 + JSONObject jsonMoveDtl = moveDtlTab.query("task_id = '" + taskDao.getTask_id() + "'").uniqueResult(0); + JSONObject jsonMoveMst = moveMstTab.query("moveinv_id = '" + jsonMoveDtl.getString("moveinv_id") + "' AND bill_status <> '99'") + .uniqueResult(0); + if (ObjectUtil.isEmpty(jsonMoveMst)) { + throw new BadRequestException("未找到任务号为【"+taskDao.getTask_code()+"】的移库单,请检查数据!"); + } + + // 查询物料信息 + JSONObject jsonSub = subTab.query("package_box_sn = '" + taskDao.getVehicle_code() + "'").uniqueResult(0); + JSONObject jsonMater = materTab.query("material_code = '" + jsonSub.getString("product_name") + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(jsonMater)) { + throw new BadRequestException("物料编码【"+jsonSub.getString("product_name")+"】信息不存在!"); + } + + // 标记原货位为货位异常锁-并更新库存 + JSONObject jsonAttr = attrTab.query("struct_code = '" + taskDao.getPoint_code2() + "'").uniqueResult(0); + jsonAttr.put("lock_type", IOSEnum.LOCK_TYPE.code("未锁定")); + attrTab.update(jsonAttr); + + //更新原仓位库存 + JSONObject jsonParam = new JSONObject(); + jsonParam.put("struct_id", jsonAttr.getString("struct_id")); + jsonParam.put("material_id", jsonMater.getString("material_id")); + jsonParam.put("pcsn", jsonMoveDtl.getString("pcsn")); + jsonParam.put("change_qty", jsonMoveDtl.getString("qty")); + jsonParam.put("inv_id", jsonMoveMst.getString("moveinv_id")); + jsonParam.put("bill_code", jsonMoveMst.getString("bill_code")); + jsonParam.put("quality_scode", IOSEnum.QUALITY_SCODE.code("合格品")); + storPublicService.IOStor(jsonParam, IOSEnum.IVT_CHANGE.code("减待入")); + + jsonAttr.put("lock_type", IOSEnum.LOCK_TYPE.code("货位异常锁")); + jsonAttr.put("remark", "立库转库-满入/浅货位阻挡异常锁定!"); + jsonAttr.put("task_code", ""); + jsonAttr.put("inv_type", ""); + jsonAttr.put("inv_id", ""); + jsonAttr.put("inv_code", ""); + attrTab.update(jsonAttr); + + // 2.重新分配货位 + // 组织查询移入仓位数据 + JSONObject moveParam = new JSONObject(); + moveParam.put("stor_id", jsonMoveMst.getString("stor_id")); + moveParam.put("sect_id", RegionTypeEnum.TWO_BZC01.getId()); + moveParam.put("box_no", taskDao.getVehicle_code()); + moveParam.put("material_id", jsonMater.getString("material_id")); + + //根据木箱高度,判断入库仓位的高度、 + String height = ""; + String heightLevel1 = iSysParamService.findByCode("height_level_1").getValue(); + String heightLevel2 = iSysParamService.findByCode("height_level_2").getValue(); + + // 查询木箱信息 + BstIvtBoxinfo boxDao = iBstIvtBoxinfoService.getOne( + new QueryWrapper().lambda() + .eq(BstIvtBoxinfo::getBox_no, taskDao.getVehicle_code()) + ); + if (ObjectUtil.isEmpty(boxDao)) { + throw new BadRequestException("木箱号为【"+taskDao.getVehicle_code()+"】的木箱信息不存在!"); + } + + String box_high = boxDao.getBox_high(); + if (Integer.parseInt(box_high) <= Integer.parseInt(heightLevel1)) { + height = "('1','2','3')"; + } else if (Integer.parseInt(box_high) > Integer.parseInt(heightLevel1) && Integer.parseInt(box_high) <= Integer.parseInt(heightLevel2)) { + height = "('2','3')"; + } else { + height = "('3')"; + } + + moveParam.put("height", height); + moveParam.put("vehicle_type", boxDao.getVehicle_type()); + // 移库巷道 + moveParam.put("move_block_num",jsonAttr.getString("block_num")); + JSONObject jsonMove = inBussManageService.getOneStruct(moveParam); + if (ObjectUtil.isEmpty(jsonMove)) { + throw new BadRequestException("当前【"+jsonAttr.getString("block_num")+"】号巷道没有可用仓位!"); + } + + // 更新新移入货位锁类型,更新库存 + JSONObject jsonParam2 = new JSONObject(); + jsonParam2.put("struct_id", jsonMove.getString("struct_id")); + jsonParam2.put("material_id", jsonMater.getString("material_id")); + jsonParam2.put("pcsn", jsonMoveDtl.getString("pcsn")); + jsonParam2.put("change_qty", jsonMoveDtl.getString("qty")); + jsonParam2.put("quality_scode", IOSEnum.QUALITY_SCODE.code("合格品")); + jsonParam2.put("inv_id", jsonMoveMst.getString("moveinv_id")); + jsonParam2.put("bill_code", jsonMoveMst.getString("bill_code")); + jsonParam2.put("bill_type_scode", jsonMoveMst.getString("bill_code")); + jsonParam2.put("qty_unit_id", jsonMoveDtl.getString("qty_unit_id")); + storPublicService.IOStor(jsonParam2, IOSEnum.IVT_CHANGE.code("加待入")); + + jsonMove.put("lock_type", IOSEnum.LOCK_TYPE.code("移入锁")); + attrTab.update(jsonMove); + + // 3.更新单据相关数据 + jsonMoveDtl.put("turnin_struct_id", jsonMove.getString("struct_id")); + jsonMoveDtl.put("turnin_struct_code", jsonMove.getString("struct_code")); + jsonMoveDtl.put("turnin_struct_name", jsonMove.getString("struct_name")); + moveDtlTab.update(jsonMoveDtl); + + // 4.更新任务终点 + taskDao.setPoint_code2(jsonMove.getString("struct_code")); + taskDao.setRemark("转库满入或浅货位有货!"); + ischBaseTaskService.updateById(taskDao); + return jsonMove; + } } diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/service/OutBussManageService.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/service/OutBussManageService.java index 8c5926b29..ee2d23362 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/service/OutBussManageService.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/storage_manage/ios/service/iostorInv/util/service/OutBussManageService.java @@ -73,4 +73,12 @@ public interface OutBussManageService { */ void createMove2(List list, Consumer allTransactionConsumer); + /** + * 任务异常处理(1.满入 2.浅货位有货-放货时) + * @param whereJson { + * task_code : 任务编码 + * } + * @return point_code: 货位编码 + */ + JSONObject taskExceptional(JSONObject whereJson); } diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java index ccfd10a46..3341c2711 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java @@ -153,6 +153,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { private final IPdmBiSlittingproductionplanService slittingproductionplanService; + private final OutBussManageService outBussManageService; + /** * task_id:任务标识 @@ -2285,10 +2287,26 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { log.info("deviceApplyExceptional返回参数:---------------------------------------------" + result.toString()); return result; } + } else if (taskDao.getTask_type().equals(TASKEnum.PROUD_TYPE.code("立库转库"))) { + // 立库转库:满入、浅货位有货-放货时 + if (type.equals("1") || type.equals("4")) { + point_code = outBussManageService.taskExceptional(whereJson); + } else if (type.equals("2")) { + // 立库转库空出 + taskDao.setRemark("【空出】请检查货位库存!"); + taskDao.setCar_no("【空出】请检查货位库存!"); + taskService.updateById(taskDao); + result.put("status", HttpStatus.OK.value()); + result.put("message", "【立库转库】空出,任务跳过处理!"); + result.put("point_code", ""); + result.put("vehicle_code", ""); + log.info("deviceApplyExceptional返回参数:---------------------------------------------" + result.toString()); + return result; + } } if (!type.equals("3") && ObjectUtil.isEmpty(point_code)) { - throw new BadRequestException("仓位为空!"); + throw new BadRequestException("立库异常任务处理失败,仓位为空!"); } result.put("status", HttpStatus.OK.value());