|
|
@ -17,6 +17,7 @@ import org.nl.common.exception.BadRequestException; |
|
|
|
import org.nl.common.utils.CodeUtil; |
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
|
import org.nl.config.IdUtil; |
|
|
|
import org.nl.config.SpringContextHolder; |
|
|
|
import org.nl.wms.basedata_manage.enums.BaseDataEnum; |
|
|
|
import org.nl.wms.basedata_manage.service.IBsrealStorattrService; |
|
|
|
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleextService; |
|
|
@ -25,12 +26,17 @@ import org.nl.wms.basedata_manage.service.dao.BsrealStorattr; |
|
|
|
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleext; |
|
|
|
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleextMapper; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.MdPbStoragevehicleextDto; |
|
|
|
import org.nl.wms.sch_manage.service.dao.SchBasePoint; |
|
|
|
import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper; |
|
|
|
import org.nl.wms.sch_manage.service.util.tasks.StInTask; |
|
|
|
import org.nl.wms.warehouse_management.enums.IOSConstant; |
|
|
|
import org.nl.wms.warehouse_management.enums.IOSEnum; |
|
|
|
import org.nl.wms.warehouse_management.service.IOutBillService; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.GroupPlate; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.IOStorInv; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.IOStorInvDis; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.IOStorInvDtl; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.mapper.GroupPlateMapper; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDisMapper; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvDtlMapper; |
|
|
|
import org.nl.wms.warehouse_management.service.dao.mapper.IOStorInvMapper; |
|
|
@ -75,6 +81,12 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
@Resource |
|
|
|
private IOStorInvDtlMapper ioStorInvDtlMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private GroupPlateMapper groupPlateMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private SchBasePointMapper schBasePointMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page, String[] stor_id, String[] bill_status, String[] bill_type) { |
|
|
@ -307,6 +319,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
List<MdPbStoragevehicleextDto> outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id); |
|
|
|
|
|
|
|
int seq_no = 1; |
|
|
|
double allocation_canuse_qty = 0; |
|
|
|
for (MdPbStoragevehicleextDto outAllocation : outAllocationList) { |
|
|
|
//分配明细
|
|
|
|
IOStorInvDis ioStorInvDis = new IOStorInvDis(); |
|
|
@ -329,10 +342,18 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
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.getCanuse_qty().doubleValue(); |
|
|
|
if (unassign_qty<0){ |
|
|
|
unassign_qty=0; |
|
|
|
} |
|
|
|
allocation_canuse_qty = allocation_canuse_qty + outAllocation.getCanuse_qty().doubleValue(); |
|
|
|
ioStorInvDis.setPlan_qty(outAllocation.getCanuse_qty()); |
|
|
|
|
|
|
|
//锁定货位
|
|
|
@ -368,7 +389,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
|
|
|
|
//更新详情
|
|
|
|
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
double assign_qty = dtl.getUnassign_qty().doubleValue() + dtl.getAssign_qty().doubleValue(); |
|
|
|
double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); |
|
|
|
dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); |
|
|
|
dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); |
|
|
|
ioStorInvDtlMapper.updateById(dtl); |
|
|
@ -513,6 +534,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
List<MdPbStoragevehicleextDto> outAllocationList = mdPbStoragevehicleextMapper.queryOutAllocation(pcsn,material_id); |
|
|
|
|
|
|
|
int seq_no = 1; |
|
|
|
double allocation_canuse_qty = 0; |
|
|
|
for (MdPbStoragevehicleextDto outAllocation : outAllocationList) { |
|
|
|
//分配明细
|
|
|
|
IOStorInvDis ioStorInvDis = new IOStorInvDis(); |
|
|
@ -535,10 +557,18 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
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.getCanuse_qty().doubleValue(); |
|
|
|
if (unassign_qty<0){ |
|
|
|
unassign_qty=0; |
|
|
|
} |
|
|
|
allocation_canuse_qty = allocation_canuse_qty + outAllocation.getCanuse_qty().doubleValue(); |
|
|
|
ioStorInvDis.setPlan_qty(outAllocation.getCanuse_qty()); |
|
|
|
|
|
|
|
//锁定货位
|
|
|
@ -574,7 +604,7 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
|
|
|
|
//更新详情
|
|
|
|
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
double assign_qty = dtl.getUnassign_qty().doubleValue() + dtl.getAssign_qty().doubleValue(); |
|
|
|
double assign_qty = allocation_canuse_qty + dtl.getAssign_qty().doubleValue(); |
|
|
|
dtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); |
|
|
|
dtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); |
|
|
|
ioStorInvDtlMapper.updateById(dtl); |
|
|
@ -676,4 +706,354 @@ public class OutBillServiceImpl extends ServiceImpl<IOStorInvMapper,IOStorInv> i |
|
|
|
ioStorInvMapper.updateById(ios); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<MdPbStoragevehicleextDto> queryAvailableInv(Map whereJson) { |
|
|
|
return mdPbStoragevehicleextMapper.queryAvailableInv(whereJson); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void manualDiv(JSONObject whereJson) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
JSONObject row = whereJson.getJSONObject("row"); |
|
|
|
JSONArray rows = whereJson.getJSONArray("rows"); |
|
|
|
|
|
|
|
String iostorinv_id = row.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); |
|
|
|
queryDtl.put("iostorinvdtl_id", row.getString("iostorinvdtl_id")); |
|
|
|
List<IOStorInvDtlDto> dtls = ioStorInvMapper.getIODtl(queryDtl); |
|
|
|
if (ObjectUtil.isEmpty(dtls)) { |
|
|
|
throw new BadRequestException("当前订单无可分配出库明细"); |
|
|
|
} |
|
|
|
|
|
|
|
for (IOStorInvDtlDto dtl:dtls){ |
|
|
|
double unassign_qty = dtl.getUnassign_qty().doubleValue(); |
|
|
|
//分配数量
|
|
|
|
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"); |
|
|
|
//分配明细
|
|
|
|
IOStorInvDis ioStorInvDis = new IOStorInvDis(); |
|
|
|
ioStorInvDis.setIostorinvdis_id(IdUtil.getStringId()); |
|
|
|
ioStorInvDis.setIostorinv_id(dtl.getIostorinv_id()); |
|
|
|
ioStorInvDis.setIostorinvdtl_id(dtl.getIostorinvdtl_id()); |
|
|
|
ioStorInvDis.setSeq_no((i+1)+""); |
|
|
|
ioStorInvDis.setSect_id(ivt.getString("sect_id")); |
|
|
|
ioStorInvDis.setPcsn(ivt.getString("pcsn")); |
|
|
|
ioStorInvDis.setMaterial_id(dtl.getMaterial_id()); |
|
|
|
ioStorInvDis.setSect_name(ivt.getString("sect_name")); |
|
|
|
ioStorInvDis.setSect_code(ivt.getString("sect_code")); |
|
|
|
ioStorInvDis.setStruct_id(ivt.getString("struct_id")); |
|
|
|
ioStorInvDis.setStruct_name(ivt.getString("struct_name")); |
|
|
|
ioStorInvDis.setStruct_code(ivt.getString("struct_code")); |
|
|
|
ioStorInvDis.setStoragevehicle_code(ivt.getString("storagevehicle_code")); |
|
|
|
ioStorInvDis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("否")); |
|
|
|
ioStorInvDis.setQty_unit_id(dtl.getQty_unit_id()); |
|
|
|
ioStorInvDis.setQty_unit_name(dtl.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;
|
|
|
|
// if (unassign_qty<0){
|
|
|
|
// unassign_qty=0;
|
|
|
|
// }
|
|
|
|
if (unassign_qty <= 0){ |
|
|
|
throw new BadRequestException("已全部分配完,未分配数量为0"); |
|
|
|
} |
|
|
|
unassign_qty = unassign_qty-canuse_qty; |
|
|
|
if (unassign_qty<0){ |
|
|
|
unassign_qty=0; |
|
|
|
} |
|
|
|
allocation_canuse_qty = allocation_canuse_qty + canuse_qty; |
|
|
|
ioStorInvDis.setPlan_qty(BigDecimal.valueOf(canuse_qty)); |
|
|
|
|
|
|
|
//锁定货位
|
|
|
|
JSONObject lock_map = new JSONObject(); |
|
|
|
lock_map.put("struct_code", ivt.getString("struct_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); |
|
|
|
|
|
|
|
//生成分配明细
|
|
|
|
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", ivt.getString("storagevehicle_code")); |
|
|
|
jsonIvt.put("material_id", dtl.getMaterial_id()); |
|
|
|
jsonIvt.put("pcsn", ivt.getString("pcsn")); |
|
|
|
jsonIvt.put("qty_unit_id", dtl.getQty_unit_id()); |
|
|
|
jsonIvt.put("qty_unit_name", dtl.getQty_unit_name()); |
|
|
|
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); |
|
|
|
updateIvtList.add(jsonIvt); |
|
|
|
iMdPbStoragevehicleextService.updateIvt(updateIvtList); |
|
|
|
} |
|
|
|
|
|
|
|
//更新详情
|
|
|
|
dtl.setBill_status(unassign_qty==0 ? IOSEnum.BILL_STATUS.code("分配完"): 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)); |
|
|
|
ioStorInvDtlMapper.updateById(dtl); |
|
|
|
} |
|
|
|
|
|
|
|
//更新主表
|
|
|
|
//根据单据标识判断明细是否都已经分配完成
|
|
|
|
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) |
|
|
|
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) |
|
|
|
.lt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) |
|
|
|
); |
|
|
|
|
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
IOStorInv ios = new IOStorInv(); |
|
|
|
ios.setIostorinv_id(iostorinv_id); |
|
|
|
ios.setUpdate_optid(currentUserId); |
|
|
|
ios.setUpdate_optname(nickName); |
|
|
|
ios.setUpdate_time(now); |
|
|
|
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
ioStorInvMapper.updateById(ios); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void oneCancel(JSONObject whereJson) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id"); |
|
|
|
|
|
|
|
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.le(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("生成")) |
|
|
|
.eq(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("否")) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,iostorinv_id) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,whereJson.getString("iostorinvdis_id")) |
|
|
|
); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInvDisList)){ |
|
|
|
throw new BadRequestException("不存在可取消的出库分配明细"); |
|
|
|
} |
|
|
|
|
|
|
|
for (IOStorInvDis ioStorInvDis:ioStorInvDisList){ |
|
|
|
|
|
|
|
//更新库存 减冻结加可用
|
|
|
|
List<JSONObject> updateIvtList = new ArrayList<>(); |
|
|
|
JSONObject jsonIvt = new JSONObject(); |
|
|
|
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_FROZEN_ADD_CANUSE); |
|
|
|
jsonIvt.put("storagevehicle_code", ioStorInvDis.getStoragevehicle_code()); |
|
|
|
jsonIvt.put("material_id", ioStorInvDis.getMaterial_id()); |
|
|
|
jsonIvt.put("pcsn", ioStorInvDis.getPcsn()); |
|
|
|
jsonIvt.put("qty_unit_id", ioStorInvDis.getQty_unit_id()); |
|
|
|
jsonIvt.put("qty_unit_name", ioStorInvDis.getQty_unit_name()); |
|
|
|
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); |
|
|
|
updateIvtList.add(jsonIvt); |
|
|
|
iMdPbStoragevehicleextService.updateIvt(updateIvtList); |
|
|
|
|
|
|
|
//解锁库位
|
|
|
|
JSONObject unlock_map = new JSONObject(); |
|
|
|
unlock_map.put("struct_code", ioStorInvDis.getStruct_code()); |
|
|
|
unlock_map.put("inv_type", null); |
|
|
|
unlock_map.put("inv_id", null); |
|
|
|
unlock_map.put("inv_code", null); |
|
|
|
iStructattrService.updateStatusByCode("2",unlock_map); |
|
|
|
|
|
|
|
//更新出库明细单状态
|
|
|
|
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(whereJson.getString("iostorinvdtl_id")); |
|
|
|
|
|
|
|
//取消分配计算 已分配 = 已分配 - 分配详情计划数量
|
|
|
|
// 未分配 = 计划分配 - 已分配
|
|
|
|
double assign_qty = ioStorInvDtl.getAssign_qty().doubleValue()-ioStorInvDis.getPlan_qty().doubleValue(); |
|
|
|
double unassign_qty = ioStorInvDtl.getUnassign_qty().doubleValue() + (ioStorInvDtl.getPlan_qty().doubleValue()-assign_qty); |
|
|
|
ioStorInvDtl.setAssign_qty(BigDecimal.valueOf(assign_qty)); |
|
|
|
ioStorInvDtl.setUnassign_qty(BigDecimal.valueOf(unassign_qty)); |
|
|
|
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("生成")); |
|
|
|
ioStorInvDtlMapper.updateById(ioStorInvDtl); |
|
|
|
|
|
|
|
//删除出入库单分配表
|
|
|
|
ioStorInvDisMapper.deleteById(ioStorInvDis.getIostorinvdis_id()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//更新主表
|
|
|
|
//根据单据标识判断明细是否都已经分配完成
|
|
|
|
int disCount = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) |
|
|
|
.eq(IOStorInvDtl::getIostorinv_id,iostorinv_id) |
|
|
|
.le(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("分配完")) |
|
|
|
.gt(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("生成")) |
|
|
|
); |
|
|
|
|
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
IOStorInv ios = new IOStorInv(); |
|
|
|
ios.setIostorinv_id(iostorinv_id); |
|
|
|
ios.setUpdate_optid(currentUserId); |
|
|
|
ios.setUpdate_optname(nickName); |
|
|
|
ios.setUpdate_time(now); |
|
|
|
ios.setBill_status(disCount>0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("生成")); |
|
|
|
ioStorInvMapper.updateById(ios); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void allSetPoint(JSONObject whereJson) { |
|
|
|
//出库点
|
|
|
|
String point_code = whereJson.getString("point_code"); |
|
|
|
|
|
|
|
if (StrUtil.isBlank(point_code)){ |
|
|
|
throw new BadRequestException("未选择出库点"); |
|
|
|
} |
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id"); |
|
|
|
|
|
|
|
//查询主表信息
|
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInv)) { |
|
|
|
throw new BadRequestException("未查到相关出库单"); |
|
|
|
} |
|
|
|
|
|
|
|
List<IOStorInvDis> ioStorInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,iostorinv_id) |
|
|
|
.eq(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("否")) |
|
|
|
.and(wrapper -> wrapper.isNotNull(IOStorInvDis::getStruct_code).ne(IOStorInvDis::getStruct_code,"")) |
|
|
|
); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInvDisList)){ |
|
|
|
throw new BadRequestException("当前没有可设置的分配明细"); |
|
|
|
} |
|
|
|
|
|
|
|
for (IOStorInvDis ioStorInvDis:ioStorInvDisList){ |
|
|
|
//创建任务
|
|
|
|
JSONObject task_form = new JSONObject(); |
|
|
|
task_form.put("task_type", "STInTask"); |
|
|
|
task_form.put("TaskCode",CodeUtil.getNewCode("TASK_CODE")); |
|
|
|
task_form.put("PickingLocation", point_code); |
|
|
|
task_form.put("PlacedLocation", ioStorInvDis.getStruct_code()); |
|
|
|
task_form.put("vehicle_code", ioStorInvDis.getStoragevehicle_code()); |
|
|
|
|
|
|
|
StInTask stInTask = SpringContextHolder.getBean("STInTask"); |
|
|
|
|
|
|
|
String task_id = stInTask.create(task_form); |
|
|
|
|
|
|
|
//分配明细表更新任务相关数据
|
|
|
|
IOStorInvDis dis = new IOStorInvDis(); |
|
|
|
dis.setIostorinvdis_id(ioStorInvDis.getIostorinvdis_id()); |
|
|
|
dis.setWork_status(IOSEnum.INBILL_DIS_STATUS.code("执行中")); |
|
|
|
dis.setTask_id(task_id); |
|
|
|
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是")); |
|
|
|
dis.setPoint_code(point_code); |
|
|
|
ioStorInvDisMapper.updateById(dis); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void confirm(JSONObject whereJson) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
String iostorinv_id = whereJson.getString("iostorinv_id"); |
|
|
|
|
|
|
|
//查询主表信息
|
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinv_id); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInv)) { |
|
|
|
throw new BadRequestException("未查到相关出库单"); |
|
|
|
} |
|
|
|
|
|
|
|
if (!IOSEnum.BILL_STATUS.code("分配完").equals(ioStorInv.getBill_status())){ |
|
|
|
throw new BadRequestException("主表状态必须为分配完!"); |
|
|
|
} |
|
|
|
|
|
|
|
//解锁原货位点位
|
|
|
|
List<IOStorInvDis> storInvDisList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,whereJson.get("iostorinv_id")) |
|
|
|
); |
|
|
|
|
|
|
|
for (IOStorInvDis ioStorInvDis: storInvDisList){ |
|
|
|
if (StrUtil.isNotBlank(ioStorInvDis.getStruct_code())){ |
|
|
|
//解绑仓位
|
|
|
|
JSONObject finish_map = new JSONObject(); |
|
|
|
finish_map.put("struct_code",ioStorInvDis.getStruct_code()); |
|
|
|
finish_map.put("storagevehicle_code",null); |
|
|
|
finish_map.put("inv_type", null); |
|
|
|
finish_map.put("inv_id", null); |
|
|
|
finish_map.put("inv_code", null); |
|
|
|
iStructattrService.updateStatusByCode("1",finish_map); |
|
|
|
|
|
|
|
//库存绑定到出库点。
|
|
|
|
schBasePointMapper.update(new SchBasePoint(),new LambdaUpdateWrapper<>(SchBasePoint.class) |
|
|
|
.set(SchBasePoint::getVehicle_code,ioStorInvDis.getStoragevehicle_code()) |
|
|
|
.set(SchBasePoint::getIos_id,ioStorInvDis.getIostorinvdis_id()) |
|
|
|
.eq(SchBasePoint::getPoint_code,ioStorInvDis.getPoint_code()) |
|
|
|
); |
|
|
|
|
|
|
|
//修改库存 减冻结加可用
|
|
|
|
List<JSONObject> updateIvtList = new ArrayList<>(); |
|
|
|
JSONObject jsonIvt = new JSONObject(); |
|
|
|
jsonIvt.put("type", IOSConstant.UPDATE_IVT_TYPE_SUB_FROZEN_ADD_CANUSE); |
|
|
|
jsonIvt.put("storagevehicle_code", ioStorInvDis.getStoragevehicle_code()); |
|
|
|
jsonIvt.put("material_id", ioStorInvDis.getMaterial_id()); |
|
|
|
jsonIvt.put("pcsn", ioStorInvDis.getPcsn()); |
|
|
|
jsonIvt.put("qty_unit_id", ioStorInvDis.getQty_unit_id()); |
|
|
|
jsonIvt.put("qty_unit_name", ioStorInvDis.getQty_unit_name()); |
|
|
|
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty()); |
|
|
|
updateIvtList.add(jsonIvt); |
|
|
|
iMdPbStoragevehicleextService.updateIvt(updateIvtList); |
|
|
|
} |
|
|
|
|
|
|
|
//更新详情数据
|
|
|
|
ioStorInvDisMapper.update(ioStorInvDis,new LambdaUpdateWrapper<>(IOStorInvDis.class) |
|
|
|
.set(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成")) |
|
|
|
.set(IOStorInvDis::getReal_qty,ioStorInvDis.getPlan_qty()) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,ioStorInvDis.getIostorinvdis_id()) |
|
|
|
.ne(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成")) |
|
|
|
); |
|
|
|
|
|
|
|
ioStorInvDtlMapper.update(new IOStorInvDtl(),new LambdaUpdateWrapper<>(IOStorInvDtl.class) |
|
|
|
.set(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("完成")) |
|
|
|
.set(IOStorInvDtl::getReal_qty,ioStorInvDis.getPlan_qty()) |
|
|
|
.eq(IOStorInvDtl::getIostorinvdtl_id,ioStorInvDis.getIostorinvdtl_id()) |
|
|
|
.ne(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("完成")) |
|
|
|
); |
|
|
|
|
|
|
|
//更新组盘记录表
|
|
|
|
groupPlateMapper.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()) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
//更新主表状态
|
|
|
|
ioStorInvMapper.update(ioStorInv,new LambdaUpdateWrapper<>(IOStorInv.class) |
|
|
|
.set(IOStorInv::getBill_status,IOSEnum.BILL_STATUS.code("完成")) |
|
|
|
.set(IOStorInv::getConfirm_optid,currentUserId) |
|
|
|
.set(IOStorInv::getConfirm_optname,nickName) |
|
|
|
.set(IOStorInv::getConfirm_time,now) |
|
|
|
.eq(IOStorInv::getIostorinv_id,whereJson.get("iostorinv_id")) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|