From 3864491872b13794a78a2edbb8f54e4dc3f95f3c Mon Sep 17 00:00:00 2001 From: zhangzq <416432541@qq.com> Date: Fri, 20 Nov 2026 16:23:57 +0800 Subject: [PATCH] =?UTF-8?q?add:=E8=AF=AD=E9=9F=B3=E5=87=BA=E5=BA=93?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=87=E5=AE=9A=E4=BB=93=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/diy/ShallowFirstRuleHandler.java | 9 -- .../service/speech/VoiceCallbackService.java | 115 ++++++++++++++++-- .../speech/dto/OutboundTaskRequest.java | 2 + 3 files changed, 107 insertions(+), 19 deletions(-) diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/decision_manage/service/strategyConfig/decisioner/impl/diy/ShallowFirstRuleHandler.java b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/decision_manage/service/strategyConfig/decisioner/impl/diy/ShallowFirstRuleHandler.java index 2a0b1c3..004a173 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/decision_manage/service/strategyConfig/decisioner/impl/diy/ShallowFirstRuleHandler.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/decision_manage/service/strategyConfig/decisioner/impl/diy/ShallowFirstRuleHandler.java @@ -44,15 +44,6 @@ public class ShallowFirstRuleHandler extends Decisioner vechielDtos = - iStructattrService.collectVechicle(MapOf.of("material_id", strategyMater.getMaterial_id() - , "pcsn", strategyMater.getPcsn() - , "inv_code", param.getInv_code() - , "stor_code", param.getStor_code() - , "sect_code", param.getSect_code() - , "plan_qty", planQty - , "order_by", "case when ivt.row_num in (2,3) then 0 else 1 end asc, gro.update_time asc") - ); // vechielDtos需要在做一层过滤:如果分配到深货位且浅货位有货的,需要过滤 //1.先查所有淺货位库存 List shallowLocationVechielDtos = diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/VoiceCallbackService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/VoiceCallbackService.java index 71f369b..0e6ba8b 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/VoiceCallbackService.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/VoiceCallbackService.java @@ -48,13 +48,18 @@ import org.nl.wms.warehouse_manage.enums.IOSConstant; import org.nl.wms.warehouse_manage.enums.IOSEnum; import org.nl.wms.warehouse_manage.inAndOut.service.IInBillService; import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService; +import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv; import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInvDis; import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDisMapper; +import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvDtlMapper; +import org.nl.wms.warehouse_manage.inAndOut.service.dao.mapper.IOStorInvMapper; import org.nl.wms.warehouse_manage.inAndOut.service.dto.IOStorInvDisDto; +import org.nl.wms.warehouse_manage.inAndOut.service.dto.IOStorInvDtlDto; import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService; import org.nl.wms.warehouse_manage.service.IStIvtMoveinvService; import org.nl.wms.warehouse_manage.service.dao.GroupPlate; import org.nl.wms.warehouse_manage.service.dto.MoveInsertDto; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ByteArrayResource; @@ -69,10 +74,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; import static org.nl.wms.warehouse_manage.enums.IOSEnum.GROUP_PLATE_STATUS; @@ -101,6 +103,12 @@ public class VoiceCallbackService { private IOStorInvDisMapper ioStorInvDisMapper; @Resource private ISchBaseTaskService iSchBaseTaskService; + @Resource + private IOStorInvMapper ioStorInvMapper; + @Resource + private IMdPbGroupplateService iMdPbGroupPlateService; + @Resource + private IOStorInvDtlMapper ioStorInvDtlMapper; @Transactional @@ -248,11 +256,17 @@ public class VoiceCallbackService { tableData.add(row); bill.put("tableData", tableData); String iostorinvId = iOutBillService.insertDtl(bill); - // 自动分配:按出库策略从库存中分配载具(内部生成分配明细、锁定仓位、冻结库存) - JSONObject divParam = new JSONObject(); - divParam.put("iostorinv_id", iostorinvId); - divParam.put("sect_code", "LW01"); - iOutBillService.allDiv(divParam); + + if (StringUtils.isNotBlank(outboundTaskRequest.getLocationFrom())) { + // 语音指定出库 + manualDiv(iostorinvId, meMaterialbase.getMaterial_id(), outboundTaskRequest); + } else { + // 自动分配:按出库策略从库存中分配载具(内部生成分配明细、锁定仓位、冻结库存) + JSONObject divParam = new JSONObject(); + divParam.put("iostorinv_id", iostorinvId); + divParam.put("sect_code", "LW01"); + iOutBillService.allDiv(divParam); + } // 设置出库点并创建标准出库任务 STOutTask JSONObject pointParam = new JSONObject(); pointParam.put("iostorinv_id", iostorinvId); @@ -277,7 +291,88 @@ public class VoiceCallbackService { return resultJson; } - ; + public void manualDiv(String iostorinvId, String material_id, OutboundTaskRequest outboundTaskRequest) { + log.info("语音指定出库iostorinvId:{} material_id:{} outboundTaskRequest:{}", iostorinvId, material_id, outboundTaskRequest); + // 校验目标货位(语音指定从哪个货位出库) + List structattrVechielDtos = + iStructattrService.collectVechicle(MapOf.of("material_id", material_id + , "stor_code", "LW" + , "sect_code", "LW01" + , "struct_code", outboundTaskRequest.getLocationFrom() + , "plan_qty", outboundTaskRequest.getQty() + , "order_by", "gro.update_time asc") + ); + if (CollectionUtils.isEmpty(structattrVechielDtos)) { + throw new BadRequestException("库位" + outboundTaskRequest.getLocationFrom() + "无库存,无法出库"); + } + + StructattrVechielDto structattrVechielDto = structattrVechielDtos.get(0); + BigDecimal planQty = BigDecimal.valueOf(outboundTaskRequest.getQty()); + BigDecimal qty = structattrVechielDto.getQty(); + BigDecimal subQty = planQty.subtract(qty); + if (subQty.doubleValue() >= 0){ + if (CollectionUtils.isEmpty(structattrVechielDtos)) { + throw new BadRequestException("库位" + outboundTaskRequest.getLocationFrom() + "库存不足,无法出库"); + } + }else { + structattrVechielDto.setFrozen_qty(planQty); + } + StrategyStructMaterialVO materialVO = new StrategyStructMaterialVO(); + BeanUtils.copyProperties(structattrVechielDto,materialVO); + + //查询主表信息 + IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinvId); + //查询未分配明细 + JSONObject queryDtl = new JSONObject(); + queryDtl.put("iostorinv_id", iostorinvId); + List dtls = ioStorInvMapper.getIODtl(queryDtl); + IOStorInvDtlDto dtl = dtls.get(0); + //分配明细 + IOStorInvDis ioStorInvDis = new IOStorInvDis(); + ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); + ioStorInvDis.setIostorinv_id(iostorinvId); + ioStorInvDis.setIostorinvdtl_id(dtl.getIostorinvdtl_id()); + ioStorInvDis.setSeq_no("1"); + ioStorInvDis.setSect_id(materialVO.getSect_id()); + ioStorInvDis.setPcsn(materialVO.getPcsn()); + ioStorInvDis.setMaterial_id(dtl.getMaterial_id()); + ioStorInvDis.setMaterial_code(materialVO.getMaterial_code()); + ioStorInvDis.setSect_name(materialVO.getSect_name()); + ioStorInvDis.setSect_code(materialVO.getSect_code()); + ioStorInvDis.setStruct_id(materialVO.getStruct_id()); + ioStorInvDis.setStruct_name(materialVO.getStruct_name()); + ioStorInvDis.setStruct_code(materialVO.getStruct_code()); + ioStorInvDis.setStoragevehicle_code(materialVO.getStoragevehicle_code()); + ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("否")); + ioStorInvDis.setQty_unit_id(materialVO.getQty_unit_id()); + ioStorInvDis.setQty_unit_name(materialVO.getQty_unit_name()); + ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("未生成")); + ioStorInvDis.setPlan_qty(materialVO.getFrozen_qty()); + //锁定货位 + JSONObject lock_map = new JSONObject(); + lock_map.put("struct_code", structattrVechielDto.getStruct_code()); + lock_map.put("inv_id", ioStorInv.getIostorinv_id()); + lock_map.put("inv_code", ioStorInv.getBill_code()); + lock_map.put("inv_type", ioStorInv.getBill_type()); + lock_map.put("lock_type", IOSEnum.LOCK_TYPE.code("出库锁")); + iStructattrService.updateStatusByCode("0",lock_map); + //更新组盘表冻结数量状态(组盘表统一存物料编码, 分配明细的物料雪花ID需转换) + iMdPbGroupPlateService.update(new LambdaUpdateWrapper() + .set(GroupPlate::getFrozen_qty, structattrVechielDto.getFrozen_qty()) + .set(GroupPlate::getUpdate_time, DateUtil.now()) + .eq(GroupPlate::getStoragevehicle_code, structattrVechielDto.getStoragevehicle_code()) + .eq(GroupPlate::getPcsn, structattrVechielDto.getPcsn()) + .eq(GroupPlate::getMaterial_id, structattrVechielDto.getMaterial_id()) + .eq(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("入库"))); + //生成分配明细 + ioStorInvDisMapper.insert(ioStorInvDis); + + //更新详情 + dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); + dtl.setUnassign_qty(planQty.subtract(materialVO.getFrozen_qty())); + dtl.setAssign_qty(materialVO.getFrozen_qty()); + ioStorInvDtlMapper.updateById(dtl); + } /** * 语音场景仓库(与现有语音逻辑保持一致,使用 LW 冶炼库) diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/dto/OutboundTaskRequest.java b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/dto/OutboundTaskRequest.java index b27204f..560e5fb 100644 --- a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/dto/OutboundTaskRequest.java +++ b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/system_manage/service/speech/dto/OutboundTaskRequest.java @@ -14,4 +14,6 @@ public class OutboundTaskRequest { private String material; // 物料编码:需要出什么料 @JsonProperty("qty") private Integer qty; // 出库数量 + @JsonProperty("locationFrom") + private String locationFrom; // 取货点编号:从哪个位置出库 }