opt:倒冲领料优化
This commit is contained in:
@@ -44,6 +44,10 @@ import org.nl.wms.sch_manage.service.core.tasks.VehicleOutTask;
|
|||||||
import org.nl.wms.warehouse_manage.enums.IOSConstant;
|
import org.nl.wms.warehouse_manage.enums.IOSConstant;
|
||||||
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||||
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
|
import org.nl.wms.warehouse_manage.inAndOut.service.IOutBillService;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.IStInventoryService;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.param.impl.InFinishParam;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutFinishParam;
|
||||||
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||||
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||||
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv;
|
import org.nl.wms.warehouse_manage.inAndOut.service.dao.IOStorInv;
|
||||||
@@ -101,9 +105,8 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
|||||||
*/
|
*/
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISectattrService iSectattrService;
|
private ISectattrService iSectattrService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPmStockReturnService iPmStockReturnService;
|
private IStInventoryService iStInventoryService;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -224,8 +227,6 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
|||||||
public PdaResponse directConfirm(LineSideDto param) {
|
public PdaResponse directConfirm(LineSideDto param) {
|
||||||
//创建出库单/明细/分配
|
//创建出库单/明细/分配
|
||||||
List<WorkOrderBomItem> workOrderBomItems = mesApi.workOrderMaterialList(param.getSrcBillNo());
|
List<WorkOrderBomItem> workOrderBomItems = mesApi.workOrderMaterialList(param.getSrcBillNo());
|
||||||
|
|
||||||
// workOrderBomItem -> workOrderBomItem.getBomQty().multiply(param.getReportedQty())
|
|
||||||
final List<String> materials = workOrderBomItems.stream().map(WorkOrderBomItem::getMaterialCode).collect(Collectors.toList());
|
final List<String> materials = workOrderBomItems.stream().map(WorkOrderBomItem::getMaterialCode).collect(Collectors.toList());
|
||||||
Map<String, MdMeMaterialbase> materialMap = iMdMeMaterialbaseService
|
Map<String, MdMeMaterialbase> materialMap = iMdMeMaterialbaseService
|
||||||
.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||||
@@ -235,7 +236,7 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
|||||||
));
|
));
|
||||||
final Structattr struct = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
final Structattr struct = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||||
.eq(Structattr::getStoragevehicle_code, param.getStorageVehicleCode()));
|
.eq(Structattr::getStoragevehicle_code, param.getStorageVehicleCode()));
|
||||||
if (struct ==null){
|
if (struct ==null ||StringUtils.isEmpty(param.getStorageVehicleCode())){
|
||||||
throw new BadRequestException("当前虚拟仓库未绑定"+param.getStorageVehicleCode());
|
throw new BadRequestException("当前虚拟仓库未绑定"+param.getStorageVehicleCode());
|
||||||
}
|
}
|
||||||
final List<GroupPlate> groupInventory = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
final List<GroupPlate> groupInventory = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||||
@@ -250,100 +251,39 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
|||||||
BigDecimal::add
|
BigDecimal::add
|
||||||
));
|
));
|
||||||
//创建出库单据
|
//创建出库单据
|
||||||
|
String status = StockReturnStatusEnum.TODO.getCode();
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
String nickName = SecurityUtils.getCurrentNickName();
|
String nickName = SecurityUtils.getCurrentNickName();
|
||||||
//主单
|
|
||||||
//明细
|
|
||||||
int seq = 1;
|
int seq = 1;
|
||||||
BigDecimal totalQty = BigDecimal.ZERO;
|
BigDecimal totalQty = BigDecimal.ZERO;
|
||||||
//TODO:需要校验库存够不够
|
IOStorInv ioStorInv = new IOStorInv();
|
||||||
//校bom qty与系统库存
|
ioStorInv.setIostorinv_id(IdUtil.getStringId());
|
||||||
final Map<String, String> errorMap = new HashMap<>();
|
ioStorInv.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE"));
|
||||||
|
ioStorInv.setIo_type(IOSEnum.IO_TYPE.code("出库"));
|
||||||
|
ioStorInv.setBill_type(IOSEnum.BILL_TYPE.code("生产出库"));
|
||||||
|
ioStorInv.setBiz_date(DateUtil.today());
|
||||||
|
ioStorInv.setStor_code(struct.getStor_code());
|
||||||
|
ioStorInv.setStor_name(struct.getStor_name());
|
||||||
|
ioStorInv.setStor_id(struct.getStor_id());
|
||||||
|
ioStorInv.setDetail_count(materials.size());
|
||||||
|
ioStorInv.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||||
|
ioStorInv.setCreate_mode(IOSEnum.CREATE_MODE.code("终端产生"));
|
||||||
|
ioStorInv.setInput_optid(currentUserId);
|
||||||
|
ioStorInv.setInput_optname(nickName);
|
||||||
|
ioStorInv.setInput_time(now);
|
||||||
|
ioStorInv.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||||
|
ioStorInv.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||||
|
final List<IOStorInvDtl> ioStorInvDtls = new ArrayList<>();
|
||||||
|
final List<IOStorInvDis> iOStorInvDiss = new ArrayList<>();
|
||||||
|
final List<ReceiveOutRequest.Entrys> entrys = new ArrayList<>();
|
||||||
|
List<OutFinishParam> outFinsParams = new ArrayList<>();
|
||||||
|
|
||||||
for (WorkOrderBomItem bomItem : workOrderBomItems) {
|
for (WorkOrderBomItem bomItem : workOrderBomItems) {
|
||||||
final String materialCode = bomItem.getMaterialCode();
|
final String materialCode = bomItem.getMaterialCode();
|
||||||
final BigDecimal bomQty = bomItem.getBomQty();
|
final BigDecimal bomQty = bomItem.getBomQty();
|
||||||
final BigDecimal qty = bomQty.multiply(param.getReportedQty());
|
final BigDecimal qty = bomQty.multiply(param.getReportedQty());
|
||||||
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
|
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
|
||||||
System.out.println("物料 " + materialCode + "实际库存:" + actualQty + ",需求数量:" + qty);
|
|
||||||
if (qty.compareTo(actualQty) > 0) {
|
|
||||||
errorMap.put(materialCode,"库存" + actualQty + "需求" + qty);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
IOStorInv ioStorInv = null;
|
|
||||||
if (org.springframework.util.CollectionUtils.isEmpty(errorMap)){
|
|
||||||
ioStorInv = new IOStorInv();
|
|
||||||
ioStorInv.setIostorinv_id(IdUtil.getStringId());
|
|
||||||
ioStorInv.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE"));
|
|
||||||
ioStorInv.setIo_type(IOSEnum.IO_TYPE.code("出库"));
|
|
||||||
ioStorInv.setBill_type(IOSEnum.BILL_TYPE.code("生产出库"));
|
|
||||||
ioStorInv.setBiz_date(DateUtil.today());
|
|
||||||
ioStorInv.setStor_code(struct.getStor_code());
|
|
||||||
ioStorInv.setStor_name(struct.getStor_name());
|
|
||||||
ioStorInv.setStor_id(struct.getStor_id());
|
|
||||||
ioStorInv.setDetail_count(materials.size());
|
|
||||||
ioStorInv.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
|
||||||
ioStorInv.setCreate_mode(IOSEnum.CREATE_MODE.code("终端产生"));
|
|
||||||
ioStorInv.setInput_optid(currentUserId);
|
|
||||||
ioStorInv.setInput_optname(nickName);
|
|
||||||
ioStorInv.setInput_time(now);
|
|
||||||
ioStorInv.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
|
|
||||||
ioStorInv.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
|
||||||
}
|
|
||||||
|
|
||||||
final List<ReceiveOutRequest.Entrys> entrys = new ArrayList<>();
|
|
||||||
final List<IOStorInvDtl> ioStorInvDtls = new ArrayList<>();
|
|
||||||
final List<IOStorInvDis> iOStorInvDiss = new ArrayList<>();
|
|
||||||
String status = StockReturnStatusEnum.ERROR.getCode();
|
|
||||||
for (WorkOrderBomItem bomItem : workOrderBomItems) {
|
|
||||||
final String materialCode = bomItem.getMaterialCode();
|
|
||||||
final BigDecimal bomQty = bomItem.getBomQty();
|
|
||||||
final BigDecimal qty = bomQty.multiply(param.getReportedQty());
|
|
||||||
if (org.springframework.util.CollectionUtils.isEmpty(errorMap)){
|
|
||||||
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
|
||||||
ioStorInvDtl.setIostorinv_id(ioStorInv.getIostorinv_id());
|
|
||||||
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
|
|
||||||
ioStorInvDtl.setSeq_no(String.valueOf(seq));
|
|
||||||
ioStorInvDtl.setMaterial_code(materialCode);
|
|
||||||
ioStorInvDtl.setMaterial_id(materialMap.get(materialCode).getMaterial_id());
|
|
||||||
ioStorInvDtl.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id());
|
|
||||||
ioStorInvDtl.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name());
|
|
||||||
ioStorInvDtl.setPcsn("1");
|
|
||||||
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
|
||||||
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
|
|
||||||
final BigDecimal assignQty = qty.min(actualQty);
|
|
||||||
ioStorInvDtl.setAssign_qty(assignQty);
|
|
||||||
ioStorInvDtl.setPlan_qty(qty);
|
|
||||||
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
|
|
||||||
ioStorInvDtl.setSource_bill_code(param.getWorkOrder());
|
|
||||||
ioStorInvDtl.setSource_bill_type("work_order");
|
|
||||||
ioStorInvDtls.add(ioStorInvDtl);
|
|
||||||
totalQty.add(assignQty);
|
|
||||||
// 分配
|
|
||||||
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
|
||||||
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
|
||||||
ioStorInvDis.setIostorinv_id(ioStorInv.getIostorinv_id()); // 修正变量名
|
|
||||||
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
|
|
||||||
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
|
|
||||||
ioStorInvDis.setMaterial_id(materialMap.get(materialCode).getMaterial_id()); // 从 materialMap 获取
|
|
||||||
ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量
|
|
||||||
ioStorInvDis.setSect_code(param.getSectCode());
|
|
||||||
ioStorInvDis.setPcsn("1"); // 或者根据实际情况从 materialMap 获取
|
|
||||||
ioStorInvDis.setStoragevehicle_code(param.getStorageVehicleCode()); // 假设从 param 获取
|
|
||||||
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
|
|
||||||
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
|
|
||||||
ioStorInvDis.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id()); // 从 materialMap 获取
|
|
||||||
ioStorInvDis.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name()); // 从 materialMap 获取
|
|
||||||
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
|
|
||||||
ioStorInvDis.setReal_qty(assignQty);
|
|
||||||
iOStorInvDiss.add(ioStorInvDis);
|
|
||||||
//更新组盘记录表
|
|
||||||
mdPbGroupplateMapper.update(new GroupPlate(), new LambdaUpdateWrapper<>(GroupPlate.class)
|
|
||||||
.set(GroupPlate::getQty,actualQty.subtract(assignQty))
|
|
||||||
.eq(GroupPlate::getStoragevehicle_code, param.getStorageVehicleCode())
|
|
||||||
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ReceiveOutRequest.Entrys entry = new ReceiveOutRequest.Entrys();
|
ReceiveOutRequest.Entrys entry = new ReceiveOutRequest.Entrys();
|
||||||
entry.setSeq(Integer.valueOf(bomItem.getItemNo()));
|
entry.setSeq(Integer.valueOf(bomItem.getItemNo()));
|
||||||
entry.setMaterialno(materialCode);
|
entry.setMaterialno(materialCode);
|
||||||
@@ -354,16 +294,81 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
|||||||
entry.setSrcbillno(param.getSrcBillNo());
|
entry.setSrcbillno(param.getSrcBillNo());
|
||||||
entry.setSrcbillid(param.getSrcBillId());
|
entry.setSrcbillid(param.getSrcBillId());
|
||||||
entry.setSrcbillentryid(bomItem.getItemId());
|
entry.setSrcbillentryid(bomItem.getItemId());
|
||||||
entrys.add(entry);
|
if (qty.compareTo(actualQty) > 0) {
|
||||||
|
status = StockReturnStatusEnum.FAIL.getCode();
|
||||||
|
entry.setStatus(StockReturnStatusEnum.TODO.getCode());
|
||||||
|
entry.setRemark(materialCode+"WMS库存不足:当前" + actualQty + "需求" + qty.intValue());
|
||||||
|
entrys.add(entry);
|
||||||
|
}else {
|
||||||
|
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
||||||
|
ioStorInvDtl.setIostorinv_id(ioStorInv.getIostorinv_id());
|
||||||
|
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
|
||||||
|
ioStorInvDtl.setSeq_no(String.valueOf(seq));
|
||||||
|
ioStorInvDtl.setMaterial_code(materialCode);
|
||||||
|
ioStorInvDtl.setMaterial_id(materialMap.get(materialCode).getMaterial_id());
|
||||||
|
ioStorInvDtl.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id());
|
||||||
|
ioStorInvDtl.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name());
|
||||||
|
ioStorInvDtl.setPcsn("1");
|
||||||
|
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||||
|
ioStorInvDtl.setAssign_qty(qty);
|
||||||
|
ioStorInvDtl.setPlan_qty(qty);
|
||||||
|
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
|
||||||
|
ioStorInvDtl.setSource_bill_code(param.getWorkOrder());
|
||||||
|
ioStorInvDtl.setSource_bill_type("work_order");
|
||||||
|
ioStorInvDtls.add(ioStorInvDtl);
|
||||||
|
totalQty.add(qty);
|
||||||
|
// 分配
|
||||||
|
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||||
|
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
||||||
|
ioStorInvDis.setIostorinv_id(ioStorInv.getIostorinv_id()); // 修正变量名
|
||||||
|
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
|
||||||
|
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
|
||||||
|
ioStorInvDis.setMaterial_id(materialMap.get(materialCode).getMaterial_id()); // 从 materialMap 获取
|
||||||
|
ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量
|
||||||
|
ioStorInvDis.setSect_code(param.getSectCode());
|
||||||
|
ioStorInvDis.setStruct_code(struct.getStruct_code());
|
||||||
|
ioStorInvDis.setPcsn("1"); // 或者根据实际情况从 materialMap 获取
|
||||||
|
ioStorInvDis.setStoragevehicle_code(param.getStorageVehicleCode()); // 假设从 param 获取
|
||||||
|
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
|
||||||
|
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||||
|
ioStorInvDis.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id()); // 从 materialMap 获取
|
||||||
|
ioStorInvDis.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name()); // 从 materialMap 获取
|
||||||
|
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
|
||||||
|
ioStorInvDis.setReal_qty(qty);
|
||||||
|
iOStorInvDiss.add(ioStorInvDis);
|
||||||
|
//更新组盘记录表
|
||||||
|
outFinsParams.add(OutFinishParam.builder()
|
||||||
|
.storagevehicleCode(param.getStorageVehicleCode())
|
||||||
|
.changeQty(qty)
|
||||||
|
.sectCode(param.getSectCode())
|
||||||
|
.structCode(struct.getStruct_code())
|
||||||
|
.materialCode(materialCode)
|
||||||
|
.build());
|
||||||
|
if (actualQty.subtract(qty).intValue() > 0 ){
|
||||||
|
mdPbGroupplateMapper.update(new GroupPlate(), new LambdaUpdateWrapper<GroupPlate>()
|
||||||
|
.set(GroupPlate::getQty,actualQty.subtract(qty))
|
||||||
|
.eq(GroupPlate::getMaterial_code,materialCode)
|
||||||
|
.eq(GroupPlate::getStoragevehicle_code, param.getStorageVehicleCode())
|
||||||
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
||||||
|
);
|
||||||
|
}else {
|
||||||
|
mdPbGroupplateMapper.delete(new LambdaUpdateWrapper<GroupPlate>()
|
||||||
|
.eq(GroupPlate::getMaterial_code,materialCode)
|
||||||
|
.eq(GroupPlate::getStoragevehicle_code, param.getStorageVehicleCode())
|
||||||
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库")));
|
||||||
|
}
|
||||||
|
entry.setRemark("等待回传EAS");
|
||||||
|
entry.setStatus(StockReturnStatusEnum.FAIL.getCode());
|
||||||
|
entrys.add(entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(ioStorInvDtls)){
|
||||||
if (ioStorInv!=null){
|
|
||||||
status = StockReturnStatusEnum.TODO.getCode();
|
|
||||||
ioStorInv.setTotal_qty(totalQty);
|
|
||||||
ioStorInvMapper.insert(ioStorInv);
|
ioStorInvMapper.insert(ioStorInv);
|
||||||
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
|
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
|
||||||
ioStorInvDisMapper.batchSave(iOStorInvDiss);
|
ioStorInvDisMapper.batchSave(iOStorInvDiss);
|
||||||
|
iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReceiveOutRequest receiveOutRequest = new ReceiveOutRequest();
|
ReceiveOutRequest receiveOutRequest = new ReceiveOutRequest();
|
||||||
receiveOutRequest.setOrgno(param.getOrgNo());
|
receiveOutRequest.setOrgno(param.getOrgNo());
|
||||||
receiveOutRequest.setSn(param.getSn());
|
receiveOutRequest.setSn(param.getSn());
|
||||||
@@ -380,7 +385,7 @@ public class PdaIosOutServiceImpl implements PdaIosOutService {
|
|||||||
receiveOutRequest.setDeptno("01.09.14.02");
|
receiveOutRequest.setDeptno("01.09.14.02");
|
||||||
receiveOutRequest.setEntrys(entrys);
|
receiveOutRequest.setEntrys(entrys);
|
||||||
ReceiveOutReturn entity = receiveOutReturnService.saveFromRequest(
|
ReceiveOutReturn entity = receiveOutReturnService.saveFromRequest(
|
||||||
receiveOutRequest, status, null,ioStorInv==null?null:ioStorInv.getBill_code(),param.getReportParam(),errorMap);
|
receiveOutRequest, status, null,CollectionUtils.isEmpty(ioStorInvDtls)?null:ioStorInv.getBill_code(),param.getReportParam());
|
||||||
return PdaResponse.requestOk();
|
return PdaResponse.requestOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,12 +173,12 @@ public class PmReturnServiceImpl extends ServiceImpl<PmReturnMapper, PmReturn> i
|
|||||||
final List<PmReturnDto> request = new ArrayList<>();
|
final List<PmReturnDto> request = new ArrayList<>();
|
||||||
request.add(param);
|
request.add(param);
|
||||||
wmsToZDWmdService.syncReturnOrder(request);
|
wmsToZDWmdService.syncReturnOrder(request);
|
||||||
final List<InFinishParam> addInvParams = new ArrayList<>();
|
|
||||||
InFinishParam addParam = new InFinishParam();
|
InFinishParam addParam = new InFinishParam();
|
||||||
List<OutFinishParam> outFinsParams = new ArrayList<>();
|
List<OutFinishParam> outFinsParams = new ArrayList<>();
|
||||||
//查询线边仓库对应虚拟货位
|
//查询线边仓库对应虚拟货位
|
||||||
final Structattr one = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
final Structattr one = iStructattrService.getOne(new LambdaQueryWrapper<Structattr>()
|
||||||
.eq(Structattr::getSect_code, param.getSourceHouseCode()));
|
.eq(Structattr::getSect_code, param.getSourceHouseCode()));
|
||||||
|
final List<InFinishParam> addInvParams = new ArrayList<>();
|
||||||
outFinsParams.add(OutFinishParam.builder()
|
outFinsParams.add(OutFinishParam.builder()
|
||||||
.storagevehicleCode(one.getStoragevehicle_code())
|
.storagevehicleCode(one.getStoragevehicle_code())
|
||||||
.changeQty(param.getQty())
|
.changeQty(param.getQty())
|
||||||
|
|||||||
@@ -162,10 +162,15 @@ public class StInventoryServiceImpl implements IStInventoryService {
|
|||||||
queryWrapper.eq(GroupPlate::getPcsn, outFinishParam.getPcsn());
|
queryWrapper.eq(GroupPlate::getPcsn, outFinishParam.getPcsn());
|
||||||
}
|
}
|
||||||
GroupPlate groupPlate = iMdPbGroupplateService.getOne(queryWrapper);
|
GroupPlate groupPlate = iMdPbGroupplateService.getOne(queryWrapper);
|
||||||
|
final BigDecimal force_qty = groupPlate.getFrozen_qty().subtract(outFinishParam.getChangeQty());
|
||||||
if (groupPlate.getQty().subtract(outFinishParam.getChangeQty()).intValue() <= 0){
|
if (groupPlate.getQty().subtract(outFinishParam.getChangeQty()).intValue() <= 0){
|
||||||
iMdPbGroupplateService.removeById(groupPlate.getGroup_id());
|
iMdPbGroupplateService.removeById(groupPlate.getGroup_id());
|
||||||
}else {
|
}else {
|
||||||
groupPlate.setFrozen_qty(BigDecimal.ZERO.min(groupPlate.getFrozen_qty().subtract(outFinishParam.getChangeQty())));
|
final BigDecimal forceQty = force_qty;
|
||||||
|
if (force_qty.intValue()< 0 ){
|
||||||
|
log.error("冻结数量为附属"+groupPlate.getStoragevehicle_code()+"_"+ groupPlate.getMaterial_code());
|
||||||
|
}
|
||||||
|
groupPlate.setFrozen_qty(BigDecimal.ZERO.max(forceQty));
|
||||||
groupPlate.setQty(groupPlate.getQty().subtract(outFinishParam.getChangeQty()));
|
groupPlate.setQty(groupPlate.getQty().subtract(outFinishParam.getChangeQty()));
|
||||||
groupPlate.setUpdate_id(SecurityUtils.getCurrentUserId());
|
groupPlate.setUpdate_id(SecurityUtils.getCurrentUserId());
|
||||||
groupPlate.setUpdate_name(SecurityUtils.getCurrentNickName());
|
groupPlate.setUpdate_name(SecurityUtils.getCurrentNickName());
|
||||||
@@ -178,7 +183,7 @@ public class StInventoryServiceImpl implements IStInventoryService {
|
|||||||
stIvtStructivtflow.setChange_qty(BigDecimal.ZERO);
|
stIvtStructivtflow.setChange_qty(BigDecimal.ZERO);
|
||||||
stIvtStructivtflow.setQty(groupPlate.getQty());
|
stIvtStructivtflow.setQty(groupPlate.getQty());
|
||||||
stIvtStructivtflow.setChange_qty(outFinishParam.getChangeQty());
|
stIvtStructivtflow.setChange_qty(outFinishParam.getChangeQty());
|
||||||
stIvtStructivtflow.setFrozen_qty(groupPlate.getFrozen_qty());
|
stIvtStructivtflow.setFrozen_qty(force_qty);
|
||||||
stIvtStructivtflow.setVehicle_code(outFinishParam.getStoragevehicleCode());
|
stIvtStructivtflow.setVehicle_code(outFinishParam.getStoragevehicleCode());
|
||||||
stIvtStructivtflow.setStor_code(outFinishParam.getStorCode());
|
stIvtStructivtflow.setStor_code(outFinishParam.getStorCode());
|
||||||
stIvtStructivtflow.setSect_code(outFinishParam.getSectCode());
|
stIvtStructivtflow.setSect_code(outFinishParam.getSectCode());
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public interface IReceiveOutReturnService extends IService<ReceiveOutReturn> {
|
|||||||
|
|
||||||
void delete(Set<Long> ids);
|
void delete(Set<Long> ids);
|
||||||
|
|
||||||
ReceiveOutReturn saveFromRequest(ReceiveOutRequest request, String status, String remark, String workOrder, String reportParam, Map<String,String> errorInfo);
|
ReceiveOutReturn saveFromRequest(ReceiveOutRequest request, String status, String remark, String workOrder, String reportParam);
|
||||||
|
|
||||||
void updateUploadResult(Long id, String status, String remark);
|
void updateUploadResult(Long id, String status, String remark);
|
||||||
|
|
||||||
|
|||||||
@@ -8,16 +8,41 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.common.exception.BadRequestException;
|
import org.nl.common.exception.BadRequestException;
|
||||||
|
import org.nl.common.utils.CodeUtil;
|
||||||
|
import org.nl.common.utils.IdUtil;
|
||||||
import org.nl.common.utils.SecurityUtils;
|
import org.nl.common.utils.SecurityUtils;
|
||||||
|
import org.nl.wms.basedata_manage.enums.BaseDataEnum;
|
||||||
|
import org.nl.wms.basedata_manage.service.IBsrealStorattrService;
|
||||||
|
import org.nl.wms.basedata_manage.service.IMdMeMaterialbaseService;
|
||||||
|
import org.nl.wms.basedata_manage.service.ISectattrService;
|
||||||
|
import org.nl.wms.basedata_manage.service.IStructattrService;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.BsrealStorattr;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.MdMeMaterialbase;
|
||||||
|
import org.nl.wms.basedata_manage.service.dao.Sectattr;
|
||||||
import org.nl.wms.ext_manage.api.EasApi;
|
import org.nl.wms.ext_manage.api.EasApi;
|
||||||
import org.nl.wms.ext_manage.api.request.QueryEasStockRequest;
|
import org.nl.wms.ext_manage.api.request.QueryEasStockRequest;
|
||||||
import org.nl.wms.ext_manage.api.request.ReceiveOutRequest;
|
import org.nl.wms.ext_manage.api.request.ReceiveOutRequest;
|
||||||
import org.nl.wms.ext_manage.api.response.QueryEasStockResponse;
|
import org.nl.wms.ext_manage.api.response.QueryEasStockResponse;
|
||||||
|
import org.nl.wms.ext_manage.mes.service.dto.WorkOrderBomItem;
|
||||||
import org.nl.wms.ext_manage.service.WmsToErpService;
|
import org.nl.wms.ext_manage.service.WmsToErpService;
|
||||||
import org.nl.wms.ext_manage.util.ErpUtil;
|
import org.nl.wms.ext_manage.util.ErpUtil;
|
||||||
|
import org.nl.wms.warehouse_manage.enums.IOSEnum;
|
||||||
|
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.IOStorInvDtl;
|
||||||
|
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.inventory.IStInventoryService;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.enums.InventoryChangeType;
|
||||||
|
import org.nl.wms.warehouse_manage.inventory.core.param.impl.OutFinishParam;
|
||||||
|
import org.nl.wms.warehouse_manage.service.IMdPbGroupplateService;
|
||||||
|
import org.nl.wms.warehouse_manage.service.dao.GroupPlate;
|
||||||
|
import org.nl.wms.warehouse_manage.service.dao.mapper.MdPbGroupplateMapper;
|
||||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturn;
|
||||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturnDetail;
|
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dao.ReceiveOutReturnDetail;
|
||||||
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutReturnDto;
|
import org.nl.wms.warehouse_manage.stockReturn.receiveOutRetur.dto.ReceiveOutReturnDto;
|
||||||
@@ -35,10 +60,8 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.function.Function;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -47,6 +70,25 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ReceiveOutReturnDetailMapper receiveOutReturnDetailMapper;
|
private ReceiveOutReturnDetailMapper receiveOutReturnDetailMapper;
|
||||||
|
@Resource
|
||||||
|
private IMdMeMaterialbaseService iMdMeMaterialbaseService;
|
||||||
|
@Resource
|
||||||
|
private IBsrealStorattrService iBsrealStorattrService;
|
||||||
|
@Resource
|
||||||
|
private IMdPbGroupplateService iMdPbGroupplateService;
|
||||||
|
@Resource
|
||||||
|
private MdPbGroupplateMapper mdPbGroupplateMapper;
|
||||||
|
@Resource
|
||||||
|
private ISectattrService iSectattrService;
|
||||||
|
@Resource
|
||||||
|
private IOStorInvMapper ioStorInvMapper;
|
||||||
|
@Autowired
|
||||||
|
private IOStorInvDtlMapper ioStorInvDtlMapper;
|
||||||
|
@Resource
|
||||||
|
private IOStorInvDisMapper ioStorInvDisMapper;
|
||||||
|
@Autowired
|
||||||
|
private IStInventoryService iStInventoryService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EasApi easApi;
|
private EasApi easApi;
|
||||||
|
|
||||||
@@ -138,7 +180,7 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public ReceiveOutReturn saveFromRequest(ReceiveOutRequest request, String status, String remark, String ioBillCode,String reportParam,Map<String,String> errorMap) {
|
public ReceiveOutReturn saveFromRequest(ReceiveOutRequest request, String status, String remark, String ioBillCode,String reportParam) {
|
||||||
ReceiveOutReturn entity = new ReceiveOutReturn();
|
ReceiveOutReturn entity = new ReceiveOutReturn();
|
||||||
entity.setOrgno(request.getOrgno());
|
entity.setOrgno(request.getOrgno());
|
||||||
entity.setBillno(request.getBillno());
|
entity.setBillno(request.getBillno());
|
||||||
@@ -159,12 +201,12 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
|||||||
entity.setCreatedBy(SecurityUtils.getCurrentUsername());
|
entity.setCreatedBy(SecurityUtils.getCurrentUsername());
|
||||||
entity.setReportParam(reportParam);
|
entity.setReportParam(reportParam);
|
||||||
this.save(entity);
|
this.save(entity);
|
||||||
saveRequestDetails(entity.getId(), request.getEntrys(), status, remark,errorMap);
|
saveRequestDetails(entity.getId(), request.getEntrys());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void saveRequestDetails(Long returnId, List<ReceiveOutRequest.Entrys> entrys, String status, String remark,Map<String,String> errorMap) {
|
private void saveRequestDetails(Long returnId, List<ReceiveOutRequest.Entrys> entrys) {
|
||||||
if (entrys == null || entrys.isEmpty()) {
|
if (entrys == null || entrys.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -184,11 +226,11 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
|||||||
detail.setEntrycomment(entry.getEntrycomment());
|
detail.setEntrycomment(entry.getEntrycomment());
|
||||||
detail.setAuxptyno(entry.getAuxptyno());
|
detail.setAuxptyno(entry.getAuxptyno());
|
||||||
detail.setTracknumber(entry.getTracknumber());
|
detail.setTracknumber(entry.getTracknumber());
|
||||||
detail.setRemark(errorMap.get(entry.getMaterialno()));
|
detail.setRemark(entry.getRemark());
|
||||||
detail.setLotnumber(entry.getLotnumber());
|
detail.setLotnumber(entry.getLotnumber());
|
||||||
detail.setStockerno(entry.getStockerno());
|
detail.setStockerno(entry.getStockerno());
|
||||||
detail.setStockername(entry.getStockername());
|
detail.setStockername(entry.getStockername());
|
||||||
detail.setStatus(status);
|
detail.setStatus(entry.getStatus());
|
||||||
detail.setUpdateTime(now);
|
detail.setUpdateTime(now);
|
||||||
receiveOutReturnDetailMapper.insert(detail);
|
receiveOutReturnDetailMapper.insert(detail);
|
||||||
}
|
}
|
||||||
@@ -275,19 +317,144 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
|||||||
if (entity == null) {throw new BadRequestException("回传记录不存在");}
|
if (entity == null) {throw new BadRequestException("回传记录不存在");}
|
||||||
Boolean sucess = Boolean.TRUE;
|
Boolean sucess = Boolean.TRUE;
|
||||||
final Long id = entity.getId();
|
final Long id = entity.getId();
|
||||||
|
final List<String> statusSet = new ArrayList<>();
|
||||||
|
statusSet.add(StockReturnStatusEnum.TODO.getCode());
|
||||||
|
statusSet.add(StockReturnStatusEnum.FAIL.getCode());
|
||||||
List<ReceiveOutReturnDetail> details = receiveOutReturnDetailMapper.selectList(new LambdaQueryWrapper<ReceiveOutReturnDetail>()
|
List<ReceiveOutReturnDetail> details = receiveOutReturnDetailMapper.selectList(new LambdaQueryWrapper<ReceiveOutReturnDetail>()
|
||||||
.eq(ReceiveOutReturnDetail::getReturnId, id)
|
.eq(ReceiveOutReturnDetail::getReturnId, id)
|
||||||
.and(wrapper -> wrapper.ne(ReceiveOutReturnDetail::getStatus, StockReturnStatusEnum.SUCESS.getCode())
|
.in(ReceiveOutReturnDetail::getStatus, statusSet)
|
||||||
.or()
|
|
||||||
.isNull(ReceiveOutReturnDetail::getStatus))
|
|
||||||
.orderByAsc(ReceiveOutReturnDetail::getSeq)
|
.orderByAsc(ReceiveOutReturnDetail::getSeq)
|
||||||
.orderByAsc(ReceiveOutReturnDetail::getId));
|
.orderByAsc(ReceiveOutReturnDetail::getId));
|
||||||
|
|
||||||
if (details.isEmpty()) {
|
if (details.isEmpty()) {
|
||||||
this.refreshUploadResult(id,sucess);
|
this.refreshUploadResult(id,sucess);
|
||||||
}else {
|
}else {
|
||||||
//TODO:增加库存校验
|
final ReceiveOutReturnDetail detail1 = details.get(0);
|
||||||
final String warehouseno = details.get(0).getWarehouseno();
|
final Sectattr sectattr = iSectattrService.findByCode(detail1.getWarehouseno());
|
||||||
|
final BsrealStorattr storattr = iBsrealStorattrService.findById(sectattr.getStor_id());
|
||||||
|
final Set<String> materials = details.stream().map(ReceiveOutReturnDetail::getMaterialno).collect(Collectors.toSet());
|
||||||
|
Map<String, MdMeMaterialbase> materialMap = iMdMeMaterialbaseService
|
||||||
|
.list(new LambdaQueryWrapper<MdMeMaterialbase>()
|
||||||
|
.in(MdMeMaterialbase::getMaterial_code,materials))
|
||||||
|
.stream()
|
||||||
|
.collect(Collectors.toMap(MdMeMaterialbase::getMaterial_code, Function.identity()
|
||||||
|
));
|
||||||
|
//线边6。007对应VTP0008后期修改
|
||||||
|
final List<GroupPlate> groupInventory = iMdPbGroupplateService.list(new LambdaQueryWrapper<GroupPlate>()
|
||||||
|
.eq(GroupPlate::getStoragevehicle_code, "VTP0008")
|
||||||
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
||||||
|
.in(GroupPlate::getMaterial_code, materials));
|
||||||
|
//没库存的话WMS不扣,EAS扣
|
||||||
|
Map<String, BigDecimal> groupInventoryMap = groupInventory.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
GroupPlate::getMaterial_code,
|
||||||
|
GroupPlate::getQty,
|
||||||
|
BigDecimal::add
|
||||||
|
));
|
||||||
|
//创建出库单据
|
||||||
|
String now = DateUtil.now();
|
||||||
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
String nickName = SecurityUtils.getCurrentNickName();
|
||||||
|
int seq = 1;
|
||||||
|
BigDecimal totalQty = BigDecimal.ZERO;
|
||||||
|
IOStorInv ioStorInv = new IOStorInv();
|
||||||
|
ioStorInv.setIostorinv_id(IdUtil.getStringId());
|
||||||
|
ioStorInv.setBill_code(CodeUtil.getNewCode("OUT_STORE_CODE"));
|
||||||
|
ioStorInv.setIo_type(IOSEnum.IO_TYPE.code("出库"));
|
||||||
|
ioStorInv.setBill_type(IOSEnum.BILL_TYPE.code("生产出库"));
|
||||||
|
ioStorInv.setBiz_date(DateUtil.today());
|
||||||
|
ioStorInv.setStor_code(storattr.getStor_code());
|
||||||
|
ioStorInv.setStor_name(storattr.getStor_name());
|
||||||
|
ioStorInv.setStor_id(storattr.getStor_id());
|
||||||
|
ioStorInv.setDetail_count(materials.size());
|
||||||
|
ioStorInv.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||||
|
ioStorInv.setCreate_mode(IOSEnum.CREATE_MODE.code("终端产生"));
|
||||||
|
ioStorInv.setInput_optid(currentUserId);
|
||||||
|
ioStorInv.setInput_optname(nickName);
|
||||||
|
ioStorInv.setInput_time(now);
|
||||||
|
ioStorInv.setIs_delete(BaseDataEnum.IS_YES_NOT.code("否"));
|
||||||
|
ioStorInv.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||||
|
final List<IOStorInvDtl> ioStorInvDtls = new ArrayList<>();
|
||||||
|
final List<IOStorInvDis> iOStorInvDiss = new ArrayList<>();
|
||||||
|
final List<ReceiveOutReturnDetail> entrys = new ArrayList<>();
|
||||||
|
List<OutFinishParam> outFinsParams = new ArrayList<>();
|
||||||
|
for (ReceiveOutReturnDetail detail : details) {
|
||||||
|
final String materialCode = detail.getMaterialno();
|
||||||
|
final BigDecimal qty = detail.getQty();
|
||||||
|
final BigDecimal actualQty = groupInventoryMap.get(materialCode) == null?BigDecimal.ZERO:groupInventoryMap.get(materialCode);
|
||||||
|
if (qty.compareTo(actualQty) > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entrys.add(detail);
|
||||||
|
//待回传的说明还没做库存变动
|
||||||
|
if (detail.getStatus().equals(StockReturnStatusEnum.FAIL.getCode())){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
||||||
|
ioStorInvDtl.setIostorinv_id(ioStorInv.getIostorinv_id());
|
||||||
|
ioStorInvDtl.setIostorinvdtl_id(IdUtil.getStringId());
|
||||||
|
ioStorInvDtl.setSeq_no(String.valueOf(seq));
|
||||||
|
ioStorInvDtl.setMaterial_code(materialCode);
|
||||||
|
ioStorInvDtl.setMaterial_id(materialMap.get(materialCode).getMaterial_id());
|
||||||
|
ioStorInvDtl.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id());
|
||||||
|
ioStorInvDtl.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name());
|
||||||
|
ioStorInvDtl.setPcsn("1");
|
||||||
|
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成"));
|
||||||
|
ioStorInvDtl.setAssign_qty(qty);
|
||||||
|
ioStorInvDtl.setPlan_qty(qty);
|
||||||
|
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
|
||||||
|
ioStorInvDtl.setSource_bill_code(mst.getBillno());
|
||||||
|
ioStorInvDtl.setSource_bill_type("work_order");
|
||||||
|
ioStorInvDtls.add(ioStorInvDtl);
|
||||||
|
totalQty.add(qty);
|
||||||
|
// 分配
|
||||||
|
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||||
|
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId());
|
||||||
|
ioStorInvDis.setIostorinv_id(ioStorInv.getIostorinv_id()); // 修正变量名
|
||||||
|
ioStorInvDis.setIostorinvdtl_id(ioStorInvDtl.getIostorinvdtl_id()); // 从对象获取,而不是从 JSON
|
||||||
|
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
|
||||||
|
ioStorInvDis.setMaterial_id(materialMap.get(materialCode).getMaterial_id()); // 从 materialMap 获取
|
||||||
|
ioStorInvDis.setMaterial_code(materialCode); // 直接使用变量
|
||||||
|
ioStorInvDis.setSect_code(sectattr.getSect_code());
|
||||||
|
ioStorInvDis.setStruct_code("6.007.V");
|
||||||
|
ioStorInvDis.setPcsn("1"); // 或者根据实际情况从 materialMap 获取
|
||||||
|
ioStorInvDis.setStoragevehicle_code("VTP0008"); // 假设从 param 获取
|
||||||
|
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("完成"));
|
||||||
|
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||||
|
ioStorInvDis.setQty_unit_id(materialMap.get(materialCode).getQty_unit_id()); // 从 materialMap 获取
|
||||||
|
ioStorInvDis.setQty_unit_name(materialMap.get(materialCode).getQty_unit_name()); // 从 materialMap 获取
|
||||||
|
ioStorInvDis.setPlan_qty(qty); // 直接使用 qty 变量
|
||||||
|
ioStorInvDis.setReal_qty(qty);
|
||||||
|
iOStorInvDiss.add(ioStorInvDis);
|
||||||
|
//更新组盘记录表
|
||||||
|
outFinsParams.add(OutFinishParam.builder()
|
||||||
|
.storagevehicleCode("VTP0008")
|
||||||
|
.changeQty(qty)
|
||||||
|
.sectCode(sectattr.getSect_code())
|
||||||
|
.structCode("6.007.V")
|
||||||
|
.materialCode(materialCode)
|
||||||
|
.build());
|
||||||
|
if (actualQty.subtract(qty).intValue() > 0 ){
|
||||||
|
mdPbGroupplateMapper.update(new GroupPlate(), new LambdaUpdateWrapper<GroupPlate>()
|
||||||
|
.set(GroupPlate::getQty,actualQty.subtract(qty))
|
||||||
|
.eq(GroupPlate::getMaterial_code, materialCode)
|
||||||
|
.eq(GroupPlate::getStoragevehicle_code, "VTP0008")
|
||||||
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
||||||
|
);
|
||||||
|
}else {
|
||||||
|
mdPbGroupplateMapper.delete(new LambdaUpdateWrapper<GroupPlate>()
|
||||||
|
.eq(GroupPlate::getMaterial_code, materialCode)
|
||||||
|
.eq(GroupPlate::getStoragevehicle_code, "VTP0008")
|
||||||
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!CollectionUtils.isEmpty(ioStorInvDtls)){
|
||||||
|
ioStorInvMapper.insert(ioStorInv);
|
||||||
|
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
|
||||||
|
ioStorInvDisMapper.batchSave(iOStorInvDiss);
|
||||||
|
iStInventoryService.changeInventory(InventoryChangeType.OUT_FINS, outFinsParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String warehouseno = entrys.get(0).getWarehouseno();
|
||||||
final QueryEasStockRequest easStockRequest = new QueryEasStockRequest();
|
final QueryEasStockRequest easStockRequest = new QueryEasStockRequest();
|
||||||
easStockRequest.setOrgno("01.09.14");
|
easStockRequest.setOrgno("01.09.14");
|
||||||
easStockRequest.setWarehouseno(warehouseno);
|
easStockRequest.setWarehouseno(warehouseno);
|
||||||
@@ -300,20 +467,19 @@ public class ReceiveOutReturnServiceImpl extends ServiceImpl<ReceiveOutReturnMap
|
|||||||
(existing, replacement) -> existing // 如果有重复物料号,保留第一个
|
(existing, replacement) -> existing // 如果有重复物料号,保留第一个
|
||||||
));
|
));
|
||||||
// 筛选出库存数量 >= 需求数量的 ReceiveOutReturnDetail
|
// 筛选出库存数量 >= 需求数量的 ReceiveOutReturnDetail
|
||||||
List<ReceiveOutReturnDetail> satisfiedList = details.stream()
|
List<ReceiveOutReturnDetail> satisfiedList = entrys.stream()
|
||||||
.filter(detail -> {
|
.filter(detail -> {
|
||||||
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
||||||
return stockQty != null && stockQty.compareTo(detail.getQty()) >= 0;
|
return stockQty != null && stockQty.compareTo(detail.getQty()) >= 0;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
// 不满足条件的列表(库存不足)
|
//不满足条件的列表(库存不足)
|
||||||
List<ReceiveOutReturnDetail> unsatisfiedList = details.stream()
|
List<ReceiveOutReturnDetail> unsatisfiedList = entrys.stream()
|
||||||
.filter(detail -> {
|
.filter(detail -> {
|
||||||
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
BigDecimal stockQty = stockMap.get(detail.getMaterialno());
|
||||||
return stockQty == null || stockQty.compareTo(detail.getQty()) < 0;
|
return stockQty == null || stockQty.compareTo(detail.getQty()) < 0;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
final String now = DateUtil.now();
|
|
||||||
if (!CollectionUtils.isEmpty(unsatisfiedList)){
|
if (!CollectionUtils.isEmpty(unsatisfiedList)){
|
||||||
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
receiveOutReturnDetailMapper.update(null,new LambdaUpdateWrapper<ReceiveOutReturnDetail>()
|
||||||
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.FAIL.getCode())
|
.set(ReceiveOutReturnDetail::getStatus,StockReturnStatusEnum.FAIL.getCode())
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
:disabled="uploadFlag"
|
:disabled="uploadFlag"
|
||||||
@click="upload"
|
@click="upload"
|
||||||
>
|
>
|
||||||
回传
|
回传EAS
|
||||||
</el-button>
|
</el-button>
|
||||||
</crudOperation>
|
</crudOperation>
|
||||||
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange" @select="handleSelectionChange">
|
<el-table ref="table" v-loading="crud.loading" :data="crud.data" size="mini" style="width: 100%" @selection-change="crud.selectionChangeHandler" @current-change="handleCurrentChange" @select="handleSelectionChange">
|
||||||
|
|||||||
Reference in New Issue
Block a user