add:语音出库支持指定仓位

This commit is contained in:
2026-11-20 16:23:57 +08:00
parent 589fc24bc2
commit 3864491872
3 changed files with 107 additions and 19 deletions

View File

@@ -44,15 +44,6 @@ public class ShallowFirstRuleHandler extends Decisioner<StrategyStructMaterialVO
StrategyMater strategyMater = maters.get(0);
BigDecimal planQty = strategyMater.getQty();
// 浅位优先排序: 浅货位(row 2/3)排前, 同优先级内按组盘时间先进先出
List<StructattrVechielDto> 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<StructattrVechielDto> shallowLocationVechielDtos =

View File

@@ -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<StructattrVechielDto> 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<IOStorInvDtlDto> 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<GroupPlate>()
.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 冶炼库)

View File

@@ -14,4 +14,6 @@ public class OutboundTaskRequest {
private String material; // 物料编码:需要出什么料
@JsonProperty("qty")
private Integer qty; // 出库数量
@JsonProperty("locationFrom")
private String locationFrom; // 取货点编号:从哪个位置出库
}