|
|
@ -25,9 +25,9 @@ import org.nl.wms.basedata_manage.service.dao.BsrealStorattr; |
|
|
|
import org.nl.wms.basedata_manage.service.dao.MdPbStoragevehicleinfo; |
|
|
|
import org.nl.wms.basedata_manage.service.dao.Structattr; |
|
|
|
import org.nl.wms.basedata_manage.service.dao.mapper.MdPbStoragevehicleinfoMapper; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.StrategyMater; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.StrategyStructParam; |
|
|
|
import org.nl.wms.basedata_manage.service.dto.StructattrChangeDto; |
|
|
|
import org.nl.wms.sch_manage.enums.StatusEnum; |
|
|
|
import org.nl.wms.sch_manage.service.dao.SchBaseTask; |
|
|
|
import org.nl.wms.sch_manage.service.util.tasks.StInTask; |
|
|
|
import org.nl.wms.warehouse_manage.enums.IOSConstant; |
|
|
@ -53,6 +53,7 @@ import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigInteger; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author dsh |
|
|
@ -327,11 +328,14 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) param.get("tableMater"); |
|
|
|
JSONObject mst = JSONObject.parseObject(JSON.toJSONString(param)); |
|
|
|
HashMap<String, String> map = rows.get(0); |
|
|
|
String iostorinvId = map.get("iostorinv_id"); |
|
|
|
String storagevehicleCode = map.get("storagevehicle_code"); |
|
|
|
//判断该分配明细是否已经分配货位
|
|
|
|
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id")) |
|
|
|
List<IOStorInvDis> disList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id, iostorinvId) |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code, storagevehicleCode) |
|
|
|
.isNull(IOStorInvDis::getStruct_code)); |
|
|
|
if (ioStorInvDis ==null){ |
|
|
|
if (CollectionUtils.isEmpty(disList)){ |
|
|
|
throw new BadRequestException("当前明细已经分配过库位"); |
|
|
|
} |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
@ -346,18 +350,23 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
//是否自动分配仓位
|
|
|
|
Boolean checked = mst.getBoolean("checked"); |
|
|
|
if (ObjectUtil.isNotEmpty(checked) && checked) { |
|
|
|
param.put("qty", map.get("plan_qty")); |
|
|
|
param.put("material_code", map.get("material_code")); |
|
|
|
param.put("pcsn", map.get("pcsn")); |
|
|
|
param.put("ioType", StatusEnum.STRATEGY_TYPE.code("入库")); |
|
|
|
//根据载具进行分配货位
|
|
|
|
List<StrategyMater> maters = new ArrayList<>(); |
|
|
|
for (IOStorInvDis dis : disList) { |
|
|
|
StrategyMater mater = new StrategyMater(); |
|
|
|
mater.setPcsn(dis.getPcsn()); |
|
|
|
mater.setMaterial_code(dis.getMaterial_code()); |
|
|
|
mater.setMaterial_id(dis.getMaterial_id()); |
|
|
|
mater.setQty(dis.getPlan_qty()); |
|
|
|
maters.add(mater); |
|
|
|
} |
|
|
|
List<Structattr> structattrs = iStructattrService.inBoundSectDiv( |
|
|
|
StrategyStructParam.builder() |
|
|
|
.ioType(param.getString("ioType")) |
|
|
|
.sect_code(param.getString("sect_code")) |
|
|
|
.stor_code(param.getString("stor_code")) |
|
|
|
.material_code(param.getString("material_code")) |
|
|
|
.qty(new BigDecimal(param.getString("qty"))) |
|
|
|
.pcsn(param.getString("pcsn")) |
|
|
|
.storagevehicle_code(param.getString("storagevehicle_code")) |
|
|
|
.strategyMaters(maters) |
|
|
|
.build()); |
|
|
|
Structattr struct = structattrs.get(0); |
|
|
|
sect_id = struct.getSect_id(); |
|
|
@ -386,7 +395,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
dis_map.put("struct_code", struct_code); |
|
|
|
dis_map.put("struct_name", struct_name); |
|
|
|
//锁定货位
|
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(map.get("iostorinv_id")); |
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(iostorinvId); |
|
|
|
JSONObject lock_map = new JSONObject(); |
|
|
|
lock_map.put("struct_code", struct_code); |
|
|
|
lock_map.put("inv_id", ioStorInv.getIostorinv_id()); |
|
|
@ -407,7 +416,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
.set(IOStorInvDis::getStruct_id,dis_map.getString("struct_id")) |
|
|
|
.set(IOStorInvDis::getStruct_code,dis_map.getString("struct_code")) |
|
|
|
.set(IOStorInvDis::getStruct_name,dis_map.getString("struct_name")) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id")) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,iostorinvId) |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code,storagevehicleCode) |
|
|
|
); |
|
|
|
//维护单据明细表里 分配数量
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
@ -418,11 +428,11 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
ioStorInvDtlMapper.updateById(jsonObject.toJavaObject(IOStorInvDtl.class)); |
|
|
|
//根据单据标识判断分配明细是否都已经分配完成
|
|
|
|
int disCount = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id, map.get("iostorinv_id")) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id, iostorinvId) |
|
|
|
.and(wrapper -> wrapper.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code, ""))); |
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
IOStorInv ios = new IOStorInv(); |
|
|
|
ios.setIostorinv_id(map.get("iostorinv_id")); |
|
|
|
ios.setIostorinv_id(iostorinvId); |
|
|
|
ios.setUpdate_optid(currentUserId); |
|
|
|
ios.setUpdate_optname(nickName); |
|
|
|
ios.setUpdate_time(now); |
|
|
@ -431,33 +441,6 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 根据库区策略获取仓位 |
|
|
|
* ioType 出入库类型 |
|
|
|
* sect_code 库区编码 |
|
|
|
* stor_code 仓库编码 |
|
|
|
* material_code 物料编码 |
|
|
|
* qty 计划数量 |
|
|
|
* pcsn 批次号 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Structattr getStructattr(JSONObject param) { |
|
|
|
List<Structattr> structattrs = iStructattrService.inBoundSectDiv( |
|
|
|
StrategyStructParam.builder() |
|
|
|
.ioType(param.getString("ioType")) |
|
|
|
.sect_code(param.getString("sect_code")) |
|
|
|
.stor_code(param.getString("stor_code")) |
|
|
|
.material_code(param.getString("material_code")) |
|
|
|
.qty(new BigDecimal(param.getString("qty"))) |
|
|
|
.pcsn(param.getString("pcsn")) |
|
|
|
.build()); |
|
|
|
if (CollectionUtils.isEmpty(structattrs)) { |
|
|
|
throw new BadRequestException("无可用货位"); |
|
|
|
} |
|
|
|
return structattrs.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void unDivStruct(Map whereJson) { |
|
|
@ -485,7 +468,8 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
.set(IOStorInvDis::getStruct_id,null) |
|
|
|
.set(IOStorInvDis::getStruct_code,null) |
|
|
|
.set(IOStorInvDis::getStruct_name,null) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,jo.get("iostorinvdis_id")) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,jo.get("iostorinv_id")) |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code,jo.get("storagevehicle_code")) |
|
|
|
); |
|
|
|
|
|
|
|
//维护单据明细表里 分配数量
|
|
|
@ -519,24 +503,20 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
HashMap<String, String> map = rows.get(0); |
|
|
|
|
|
|
|
//判断是否已经分配好货位
|
|
|
|
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id")) |
|
|
|
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,map.get("iostorinv_id")) |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code,map.get("storagevehicle_code")) |
|
|
|
.and(wrapper -> wrapper.isNotNull(IOStorInvDis::getStruct_code).or().ne(IOStorInvDis::getStruct_code,""))); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInvDis)){ |
|
|
|
if (CollectionUtils.isEmpty(ioStorInvDis)){ |
|
|
|
throw new BadRequestException("该明细还没分配货位,请先分配货位"); |
|
|
|
} |
|
|
|
|
|
|
|
//创建任务
|
|
|
|
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("PlacedLocation", ioStorInvDis.get(0).getStruct_code()); |
|
|
|
task_form.put("vehicle_code", map.get("storagevehicle_code")); |
|
|
|
// GroupPlate groupPlate = mdPbGroupplateMapper.selectOne(new LambdaQueryWrapper<>(GroupPlate.class)
|
|
|
|
// .eq(GroupPlate::getStoragevehicle_code,map.get("storagevehicle_code"))
|
|
|
|
// );
|
|
|
|
// task_form.put("group_id", groupPlate.getGroup_id());
|
|
|
|
StInTask stInTask = SpringContextHolder.getBean("STInTask"); |
|
|
|
|
|
|
|
String task_id = stInTask.create(task_form); |
|
|
@ -548,7 +528,15 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
dis.setTask_id(task_id); |
|
|
|
dis.setIs_issued(BaseDataEnum.IS_YES_NOT.code("是")); |
|
|
|
dis.setPoint_code(point_code); |
|
|
|
ioStorInvDisMapper.updateById(dis); |
|
|
|
//更新详情数据
|
|
|
|
ioStorInvDisMapper.update(dis,new LambdaUpdateWrapper<>(IOStorInvDis.class) |
|
|
|
.set(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("生成")) |
|
|
|
.set(IOStorInvDis::getTask_id,task_id) |
|
|
|
.set(IOStorInvDis::getIs_issued,BaseDataEnum.IS_YES_NOT.code("是")) |
|
|
|
.set(IOStorInvDis::getPoint_code,point_code) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id,map.get("iostorinv_id")) |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code,map.get("storagevehicle_code")) |
|
|
|
.ne(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成"))); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -633,77 +621,66 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void taskFinish(SchBaseTask task) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
List<IOStorInvDis> ioStorInvDis = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getTask_id,task.getTask_id()) |
|
|
|
); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInvDis)){ |
|
|
|
if (CollectionUtils.isEmpty(ioStorInvDis)){ |
|
|
|
throw new BadRequestException("未找到任务对应的分配明细"); |
|
|
|
} |
|
|
|
// 明细
|
|
|
|
IOStorInvDtl ioStorInvDtl = ioStorInvDtlMapper.selectById(ioStorInvDis.getIostorinvdtl_id()); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInvDtl)){ |
|
|
|
throw new BadRequestException("未找到明细"); |
|
|
|
} |
|
|
|
// 明细
|
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(ioStorInvDis.getIostorinv_id()); |
|
|
|
if (ObjectUtil.isEmpty(ioStorInv)){ |
|
|
|
throw new BadRequestException("未找到明细"); |
|
|
|
} |
|
|
|
// 完成当前分配明细
|
|
|
|
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()) |
|
|
|
); |
|
|
|
|
|
|
|
String iostorinvId = ioStorInvDis.get(0).getIostorinv_id(); |
|
|
|
String storagevehicleCode = ioStorInvDis.get(0).getStoragevehicle_code(); |
|
|
|
String structCode = ioStorInvDis.get(0).getStruct_code(); |
|
|
|
//解锁库位
|
|
|
|
JSONObject finish_map = new JSONObject(); |
|
|
|
finish_map.put("struct_code",ioStorInvDis.getStruct_code()); |
|
|
|
finish_map.put("storagevehicle_code",ioStorInvDis.getStoragevehicle_code()); |
|
|
|
finish_map.put("struct_code", structCode); |
|
|
|
finish_map.put("storagevehicle_code", storagevehicleCode); |
|
|
|
finish_map.put("inv_type", null); |
|
|
|
finish_map.put("inv_id", null); |
|
|
|
finish_map.put("inv_code", null); |
|
|
|
iStructattrService.updateStatusByCode("1",finish_map); |
|
|
|
//库存变动
|
|
|
|
StructattrChangeDto changeDto = StructattrChangeDto.builder() |
|
|
|
.inv(ioStorInv.getIostorinv_id()) |
|
|
|
.storagevehicleCode(ioStorInvDis.getStoragevehicle_code()) |
|
|
|
.structCode(ioStorInvDis.getStruct_code()).taskType(task.getConfig_code()).inBound(true).build(); |
|
|
|
.inv(iostorinvId) |
|
|
|
.storagevehicleCode(storagevehicleCode) |
|
|
|
.structCode(structCode).taskType(task.getConfig_code()).inBound(true).build(); |
|
|
|
iStructattrService.changeStruct(changeDto); |
|
|
|
|
|
|
|
// 查询该明细下是否还有未完成的分配明细
|
|
|
|
int countDis = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinvdtl_id,ioStorInvDis.getIostorinvdtl_id()) |
|
|
|
.ne(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成")) |
|
|
|
// 完成当前分配明细
|
|
|
|
Map<String, BigDecimal> dtlMap = new HashMap<>(); |
|
|
|
for (IOStorInvDis item : ioStorInvDis) { |
|
|
|
ioStorInvDisMapper.update(item,new LambdaUpdateWrapper<>(IOStorInvDis.class) |
|
|
|
.set(IOStorInvDis::getWork_status,IOSEnum.INBILL_DIS_STATUS.code("完成")) |
|
|
|
.set(IOStorInvDis::getReal_qty,item.getPlan_qty()) |
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,item.getIostorinvdis_id())); |
|
|
|
dtlMap.put(item.getIostorinvdtl_id(),item.getPlan_qty()); |
|
|
|
} |
|
|
|
//更新明细
|
|
|
|
for (String dtl_id : dtlMap.keySet()) { |
|
|
|
IOStorInvDtl invDtl = new IOStorInvDtl(); |
|
|
|
invDtl.setIostorinvdtl_id(dtl_id); |
|
|
|
invDtl.setReal_qty(dtlMap.get(dtl_id)); |
|
|
|
invDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成")); |
|
|
|
ioStorInvDtlMapper.updateById(invDtl); |
|
|
|
} |
|
|
|
// 查看明细是否全部完成
|
|
|
|
int countDtl = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) |
|
|
|
.eq(IOStorInvDtl::getIostorinv_id, iostorinvId) |
|
|
|
.ne(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("完成")) |
|
|
|
); |
|
|
|
// 如果分配明细全部完成则更新明细表状态
|
|
|
|
if (countDis == 0){ |
|
|
|
// 更新明细表状态
|
|
|
|
ioStorInvDtl.setReal_qty(ioStorInvDis.getPlan_qty()); |
|
|
|
ioStorInvDtl.setBill_status(IOSEnum.BILL_STATUS.code("完成")); |
|
|
|
ioStorInvDtlMapper.updateById(ioStorInvDtl); |
|
|
|
// 查看明细是否全部完成
|
|
|
|
int countDtl = ioStorInvDtlMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDtl.class) |
|
|
|
.eq(IOStorInvDtl::getIostorinv_id,ioStorInvDtl.getIostorinv_id()) |
|
|
|
.ne(IOStorInvDtl::getBill_status,IOSEnum.BILL_STATUS.code("完成")) |
|
|
|
// 如果明细全部完成则更新主表状态
|
|
|
|
if (countDtl == 0){ |
|
|
|
//更新主表状态
|
|
|
|
ioStorInvMapper.update(new 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,iostorinvId) |
|
|
|
); |
|
|
|
// 如果明细全部完成则更新主表状态
|
|
|
|
if (countDtl == 0){ |
|
|
|
//更新主表状态
|
|
|
|
ioStorInvMapper.update(new 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,ioStorInvDtl.getIostorinv_id()) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|