|
|
@ -24,8 +24,11 @@ import org.nl.wms.basedata_manage.enums.BaseDataEnum; |
|
|
|
import org.nl.wms.basedata_manage.service.IBsrealStorattrService; |
|
|
|
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.StructattrVechielDto; |
|
|
|
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.StrategyStructMaterialVO; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.StrategyStructParam; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.StructattrChangeDto; |
|
|
|
import org.nl.wms.pda.ios_manage.service.PdaIosOutService; |
|
|
|
import org.nl.wms.sch_manage.enums.TaskStatus; |
|
|
@ -345,59 +348,59 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void allDiv(JSONObject whereJson) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
String sectCode = whereJson.getString("sect_code"); |
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id"); |
|
|
|
|
|
|
|
//查询主表信息
|
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInv)) { |
|
|
|
throw new BadRequestException("查不到出库单信息"); |
|
|
|
} |
|
|
|
|
|
|
|
//查询生成和未分配完的明细
|
|
|
|
JSONObject queryDtl = new JSONObject(); |
|
|
|
queryDtl.put("bill_status", IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
queryDtl.put("unassign_flag", BaseDataEnum.IS_YES_NOT.code("是")); |
|
|
|
queryDtl.put("iostorinv_id", iostorinv_id); |
|
|
|
List<IOStorInvDtlDto> dtls = ioStorInvMapper.getIODtl(queryDtl); |
|
|
|
// List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDtl.class)
|
|
|
|
// .le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完"))
|
|
|
|
// .gt(IOStorInvDtl::getUnassign_qty,0)
|
|
|
|
// .eq(IOStorInvDtl::getIostorinv_id, iostorinv_id));
|
|
|
|
if (ObjectUtil.isEmpty(dtls)) { |
|
|
|
throw new BadRequestException("当前订单无可分配出库明细"); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < dtls.size(); i++) { |
|
|
|
IOStorInvDtlDto dtl = dtls.get(i); |
|
|
|
double unassign_qty = dtl.getUnassign_qty().doubleValue(); |
|
|
|
BigDecimal unassign_qty = dtl.getUnassign_qty(); |
|
|
|
String pcsn = dtl.getPcsn(); |
|
|
|
String material_id = dtl.getMaterial_id(); |
|
|
|
String material_code = dtl.getMaterial_code(); |
|
|
|
// 根据物料和批次号查询库存可用
|
|
|
|
BigDecimal canuseSum = mdPbStoragevehicleextMapper.queryCanuseSum(pcsn,material_id); |
|
|
|
if (ObjectUtil.isEmpty(canuseSum) || canuseSum.doubleValue()<unassign_qty){ |
|
|
|
throw new BadRequestException("物料编号:"+ dtl.getMaterial_code() +"出库分配数量不满足"); |
|
|
|
} |
|
|
|
/* |
|
|
|
* 分配规则: |
|
|
|
* 1.按批次先进先出 |
|
|
|
* 2.相同批次载具量小优先 |
|
|
|
*/ |
|
|
|
//出库分配查询货位信息
|
|
|
|
List<MdPbStoragevehicleextDto> outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id); |
|
|
|
List<StrategyStructMaterialVO> structMaterials = iStructattrService.outBoundSectDiv( |
|
|
|
StrategyStructParam.builder() |
|
|
|
.qty(unassign_qty) |
|
|
|
.pcsn(pcsn) |
|
|
|
.material_code(material_code) |
|
|
|
.material_id(material_id) |
|
|
|
.stor_code(ioStorInv.getStor_code()) |
|
|
|
.sect_code(sectCode) |
|
|
|
.build() |
|
|
|
); |
|
|
|
int seq_no = 1; |
|
|
|
double allocation_canuse_qty = 0; |
|
|
|
for (MdPbStoragevehicleextDto outAllocation : outAllocationList) { |
|
|
|
BigDecimal allocation_canuse_qty=BigDecimal.ZERO; |
|
|
|
for (StrategyStructMaterialVO outAllocation : structMaterials) { |
|
|
|
//分配明细
|
|
|
|
IOStorInvDis ioStorInvDis = new IOStorInvDis(); |
|
|
|
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); |
|
|
|
ioStorInvDis.setIostorinvdis_id(org.nl.common.utils.IdUtil.getStringId()); |
|
|
|
ioStorInvDis.setIostorinv_id(dtl.getIostorinv_id()); |
|
|
|
ioStorInvDis.setIostorinvdtl_id(dtl.getIostorinvdtl_id()); |
|
|
|
ioStorInvDis.setSeq_no((seq_no++)+""); |
|
|
|
ioStorInvDis.setSect_id(outAllocation.getSect_id()); |
|
|
|
ioStorInvDis.setPcsn(outAllocation.getPcsn()); |
|
|
|
ioStorInvDis.setMaterial_id(material_id); |
|
|
|
ioStorInvDis.setMaterial_code(material_code); |
|
|
|
ioStorInvDis.setMaterial_id(outAllocation.getMaterial_id()); |
|
|
|
ioStorInvDis.setMaterial_code(outAllocation.getMaterial_code()); |
|
|
|
ioStorInvDis.setSect_name(outAllocation.getSect_name()); |
|
|
|
ioStorInvDis.setSect_code(outAllocation.getSect_code()); |
|
|
|
ioStorInvDis.setStruct_id(outAllocation.getStruct_id()); |
|
|
@ -408,20 +411,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> |
|
|
|
ioStorInvDis.setQty_unit_id(outAllocation.getQty_unit_id()); |
|
|
|
ioStorInvDis.setQty_unit_name(outAllocation.getQty_unit_name()); |
|
|
|
ioStorInvDis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("未生成")); |
|
|
|
// 未分配数量 - 该库位上的可用数量 < 0 目前做整出
|
|
|
|
// double canuse_qty = outAllocation.getCanuse_qty().doubleValue();
|
|
|
|
// if (unassign_qty-canuse_qty>=0){
|
|
|
|
// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(canuse_qty));
|
|
|
|
// }else {
|
|
|
|
// ioStorInvDis.setPlan_qty(BigDecimal.valueOf(unassign_qty));
|
|
|
|
// }
|
|
|
|
// unassign_qty = unassign_qty-canuse_qty;
|
|
|
|
unassign_qty = unassign_qty - outAllocation.getQty().doubleValue(); |
|
|
|
if (unassign_qty < 0) { |
|
|
|
unassign_qty = 0; |
|
|
|
} |
|
|
|
allocation_canuse_qty = allocation_canuse_qty + outAllocation.getQty().doubleValue(); |
|
|
|
ioStorInvDis.setPlan_qty(outAllocation.getQty()); |
|
|
|
ioStorInvDis.setPlan_qty(outAllocation.getFrozen_qty()); |
|
|
|
//锁定货位
|
|
|
|
JSONObject lock_map = new JSONObject(); |
|
|
|
lock_map.put("struct_code", outAllocation.getStruct_code()); |
|
|
@ -429,33 +419,34 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> |
|
|
|
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); |
|
|
|
iStructattrService.updateStatusByCode("0",lock_map); |
|
|
|
//更新组盘表冻结数量状态
|
|
|
|
LambdaUpdateWrapper<GroupPlate> updateWrapper = new LambdaUpdateWrapper<GroupPlate>() |
|
|
|
.set(GroupPlate::getFrozen_qty, outAllocation.getFrozen_qty()) |
|
|
|
.set(GroupPlate::getUpdate_time, now) |
|
|
|
.eq(GroupPlate::getStoragevehicle_code, outAllocation.getStoragevehicle_code()) |
|
|
|
.eq(GroupPlate::getMaterial_id, outAllocation.getMaterial_id()) |
|
|
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库")); |
|
|
|
if (StringUtils.isNotEmpty(outAllocation.getPcsn())){ |
|
|
|
updateWrapper.eq(GroupPlate::getPcsn, outAllocation.getPcsn()); |
|
|
|
} |
|
|
|
iMdPbGroupPlateService.update(updateWrapper); |
|
|
|
//生成分配明细
|
|
|
|
ioStorInvDisMapper.insert(ioStorInvDis); |
|
|
|
//更新库存 加冻结减可用
|
|
|
|
List<JSONObject> updateIvtList = new ArrayList<>(); |
|
|
|
JSONObject jsonIvt = new JSONObject(); |
|
|
|
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_ADD_FROZEN); |
|
|
|
jsonIvt.put("storagevehicle_code", outAllocation.getStoragevehicle_code()); |
|
|
|
jsonIvt.put("material_id", outAllocation.getMaterial_id()); |
|
|
|
jsonIvt.put("pcsn", outAllocation.getPcsn()); |
|
|
|
jsonIvt.put("qty_unit_id", outAllocation.getQty_unit_id()); |
|
|
|
jsonIvt.put("qty_unit_name", outAllocation.getQty_unit_name()); |
|
|
|
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); |
|
|
|
updateIvtList.add(jsonIvt); |
|
|
|
iMdPbGroupPlateService.updateIvt(updateIvtList); |
|
|
|
allocation_canuse_qty = allocation_canuse_qty.add(outAllocation.getFrozen_qty()); |
|
|
|
//分配完成 结束分配
|
|
|
|
if (unassign_qty==0){ |
|
|
|
unassign_qty=unassign_qty.subtract(allocation_canuse_qty); |
|
|
|
if (unassign_qty.doubleValue() <= 0){ |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
//更新详情
|
|
|
|
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); |
|
|
|
dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); |
|
|
|
dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); |
|
|
|
dtl.setUnassign_qty(unassign_qty); |
|
|
|
dtl.setAssign_qty(dtl.getAssign_qty().add(allocation_canuse_qty)); |
|
|
|
ioStorInvDtlMapper.updateById(dtl); |
|
|
|
} |
|
|
|
|
|
|
|
//更新主表
|
|
|
|
//根据单据标识判断明细是否都已经分配完成
|
|
|
|
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) |
|
|
@ -808,7 +799,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> |
|
|
|
double allocation_canuse_qty = 0; |
|
|
|
for (int i = 0; i < rows.size(); i++){ |
|
|
|
JSONObject ivt = rows.getJSONObject(i); |
|
|
|
double canuse_qty = ivt.getDoubleValue("canuse_qty"); |
|
|
|
double canuse_qty = ivt.getDoubleValue("qty"); |
|
|
|
//分配明细
|
|
|
|
IOStorInvDis ioStorInvDis = new IOStorInvDis(); |
|
|
|
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); |
|
|
@ -1172,12 +1163,14 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> |
|
|
|
dtlSet.add(ioStorInvDis.getIostorinvdtl_id()); |
|
|
|
|
|
|
|
//更新组盘记录表
|
|
|
|
mdPbGroupplateMapper.update(new GroupPlate(),new LambdaUpdateWrapper<>(GroupPlate.class) |
|
|
|
.set(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("出库")) |
|
|
|
.eq(GroupPlate::getPcsn,ioStorInvDis.getPcsn()) |
|
|
|
.eq(GroupPlate::getMaterial_id,ioStorInvDis.getMaterial_id()) |
|
|
|
.eq(GroupPlate::getStoragevehicle_code,ioStorInvDis.getStoragevehicle_code()) |
|
|
|
); |
|
|
|
LambdaUpdateWrapper<GroupPlate> updateWrapper = new LambdaUpdateWrapper<>(GroupPlate.class) |
|
|
|
.set(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("出库")) |
|
|
|
.eq(GroupPlate::getMaterial_id, ioStorInvDis.getMaterial_id()) |
|
|
|
.eq(GroupPlate::getStoragevehicle_code, ioStorInvDis.getStoragevehicle_code()); |
|
|
|
if (StringUtils.isNotEmpty(ioStorInvDis.getPcsn())){ |
|
|
|
updateWrapper.eq(GroupPlate::getPcsn, ioStorInvDis.getPcsn()); |
|
|
|
} |
|
|
|
mdPbGroupplateMapper.update(new GroupPlate(),updateWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
//更新出库明细单状态
|
|
|
|