|
|
|
|
@@ -27,6 +27,7 @@ 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.StrategyStructParam;
|
|
|
|
|
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
|
|
|
|
|
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
|
|
|
|
|
import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper;
|
|
|
|
|
@@ -39,19 +40,19 @@ 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;
|
|
|
|
|
import org.nl.wms.warehouse_management.service.dao.mapper.*;
|
|
|
|
|
import org.nl.wms.warehouse_management.service.dto.GroupPlateDto;
|
|
|
|
|
import org.nl.wms.warehouse_management.service.dto.IOStorInvDisDto;
|
|
|
|
|
import org.nl.wms.warehouse_management.service.dto.IOStorInvDtlDto;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@@ -80,14 +81,11 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
@Resource
|
|
|
|
|
private MdPbStoragevehicleinfoMapper mdPbStoragevehicleinfoMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private SchBasePointMapper schBasePointMapper;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private IMdPbStoragevehicleextService iMdPbStoragevehicleextService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private GroupPlateMapper groupPlateMapper;
|
|
|
|
|
private MdPbGroupplateServiceImpl mdPbGroupplateService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public IPage<IOStorInv> pageQuery(Map whereJson, PageQuery page) {
|
|
|
|
|
@@ -143,7 +141,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName();
|
|
|
|
|
String now = DateUtil.now();
|
|
|
|
|
double total_qty = 0;
|
|
|
|
|
BigDecimal total_qty = new BigDecimal(BigInteger.ZERO);
|
|
|
|
|
JSONObject io_mst = new JSONObject();
|
|
|
|
|
String iostorinv_id = IdUtil.getStringId();
|
|
|
|
|
String bill_code = CodeUtil.getNewCode("IN_STORE_CODE");
|
|
|
|
|
@@ -174,7 +172,6 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
Long deptId = SecurityUtils.getDeptId();
|
|
|
|
|
io_mst.put("sysdeptid", deptId + "");
|
|
|
|
|
io_mst.put("syscompanyid", deptId + "");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < rows.size(); i++) {
|
|
|
|
|
HashMap<String, Object> row = rows.get(i);
|
|
|
|
|
JSONObject ioStorInvDtl = new JSONObject();
|
|
|
|
|
@@ -183,6 +180,7 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
ioStorInvDtl.put("iostorinv_id",iostorinv_id);
|
|
|
|
|
ioStorInvDtl.put("seq_no",(i + 1)+"");
|
|
|
|
|
ioStorInvDtl.put("material_id",row.get("material_id"));
|
|
|
|
|
ioStorInvDtl.put("material_code",row.get("material_code"));
|
|
|
|
|
ioStorInvDtl.put("Pcsn",row.get("pcsn"));
|
|
|
|
|
ioStorInvDtl.put("bill_status",IOSEnum.BILL_STATUS.code("生成"));
|
|
|
|
|
ioStorInvDtl.put("qty_unit_id",row.get("qty_unit_id"));
|
|
|
|
|
@@ -190,9 +188,10 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
ioStorInvDtl.put("source_bill_type",row.get("ext_type"));
|
|
|
|
|
ioStorInvDtl.put("source_bill_code",row.get("ext_code"));
|
|
|
|
|
ioStorInvDtl.put("assign_qty","0");
|
|
|
|
|
ioStorInvDtl.put("unassign_qty",row.get("plan_qty"));
|
|
|
|
|
ioStorInvDtl.put("plan_qty",row.get("plan_qty"));
|
|
|
|
|
total_qty += Double.parseDouble(row.get("qty").toString());
|
|
|
|
|
ioStorInvDtl.put("unassign_qty",row.get("qty"));
|
|
|
|
|
ioStorInvDtl.put("plan_qty",row.get("qty"));
|
|
|
|
|
Double qty = new Double(String.valueOf(row.get("qty")));
|
|
|
|
|
total_qty = total_qty.add(new BigDecimal(qty));
|
|
|
|
|
|
|
|
|
|
//判断该载具编号是否已经存在库内
|
|
|
|
|
Structattr structattr = iStructattrService.getOne(new LambdaQueryWrapper<>(Structattr.class).eq(Structattr::getStoragevehicle_code,row.get("storagevehicle_code")));
|
|
|
|
|
@@ -208,14 +207,14 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
dis.put("iostorinvdtl_id", ioStorInvDtl.getString("iostorinvdtl_id"));
|
|
|
|
|
dis.put("seq_no", 1);
|
|
|
|
|
dis.put("material_id", row.get("material_id"));
|
|
|
|
|
dis.put("material_code", row.get("material_code"));
|
|
|
|
|
dis.put("pcsn", row.get("pcsn"));
|
|
|
|
|
dis.put("storagevehicle_code", row.get("storagevehicle_code"));
|
|
|
|
|
dis.put("work_status", IOSEnum.INBILL_DIS_STATUS.code("未生成"));
|
|
|
|
|
dis.put("is_issued", BaseDataEnum.IS_YES_NOT.code("否"));
|
|
|
|
|
dis.put("qty_unit_id", row.get("qty_unit_id"));
|
|
|
|
|
dis.put("qty_unit_name", row.get("qty_unit_name"));
|
|
|
|
|
dis.put("plan_qty", row.get("plan_qty"));
|
|
|
|
|
|
|
|
|
|
dis.put("plan_qty", row.get("qty"));
|
|
|
|
|
ioStorInvDisMapper.insert(dis.toJavaObject(IOStorInvDis.class));
|
|
|
|
|
}
|
|
|
|
|
io_mst.put("total_qty", total_qty);
|
|
|
|
|
@@ -328,47 +327,42 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void divStruct(Map whereJson) {
|
|
|
|
|
|
|
|
|
|
public void divStruct(JSONObject param) {
|
|
|
|
|
Assert.noNullElements(new Object[]{param.getString("stor_code"),param.getString("sect_code")},"参数异常");
|
|
|
|
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) param.get("tableMater");
|
|
|
|
|
JSONObject mst = JSONObject.parseObject(JSON.toJSONString(param));
|
|
|
|
|
HashMap<String, String> map = rows.get(0);
|
|
|
|
|
//判断该分配明细是否已经分配货位
|
|
|
|
|
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id"))
|
|
|
|
|
.isNull(IOStorInvDis::getStruct_code));
|
|
|
|
|
if (ioStorInvDis ==null){
|
|
|
|
|
throw new BadRequestException("当前明细已经分配过库位");
|
|
|
|
|
}
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName();
|
|
|
|
|
String now = DateUtil.now();
|
|
|
|
|
|
|
|
|
|
String sect_id = "";
|
|
|
|
|
String sect_code = "";
|
|
|
|
|
String sect_name = "";
|
|
|
|
|
String struct_id = "";
|
|
|
|
|
String struct_code = "";
|
|
|
|
|
String struct_name = "";
|
|
|
|
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableMater");
|
|
|
|
|
JSONObject whereJson2 = JSONObject.parseObject(JSON.toJSONString(whereJson));
|
|
|
|
|
HashMap<String, String> map = rows.get(0);
|
|
|
|
|
|
|
|
|
|
//判断该分配明细是否已经分配货位
|
|
|
|
|
IOStorInvDis ioStorInvDis = ioStorInvDisMapper.selectOne(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id"))
|
|
|
|
|
.and(wrapper-> wrapper.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code,"")));
|
|
|
|
|
if (ObjectUtil.isEmpty(ioStorInvDis)){
|
|
|
|
|
throw new BadRequestException("该明细已经分配过货位,无法继续分配!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Boolean checked = whereJson2.getBoolean("checked");
|
|
|
|
|
//是否自动分配仓位
|
|
|
|
|
Boolean checked = mst.getBoolean("checked");
|
|
|
|
|
if (ObjectUtil.isNotEmpty(checked) && checked) {
|
|
|
|
|
JSONObject jo_form = new JSONObject();
|
|
|
|
|
Structattr struct = new Structattr();
|
|
|
|
|
if (whereJson.containsKey("sect_id")) {
|
|
|
|
|
jo_form.put("sect_id", whereJson.get("sect_id"));
|
|
|
|
|
jo_form.put("storagevehicle_code", map.get("storagevehicle_code"));
|
|
|
|
|
struct = this.autoDis(jo_form);
|
|
|
|
|
} else {
|
|
|
|
|
throw new BadRequestException("请选择需要分配的库区!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(struct)) {
|
|
|
|
|
throw new BadRequestException("未查询到适用仓位!");
|
|
|
|
|
List<Structattr> structattrs = iStructattrService.inBoundSectDiv(
|
|
|
|
|
StrategyStructParam.builder()
|
|
|
|
|
.sect_code(param.getString("sect_code"))
|
|
|
|
|
.stor_code(param.getString("stor_code"))
|
|
|
|
|
.material_code(map.get("material_code"))
|
|
|
|
|
.qty(new BigDecimal(String.valueOf(map.get("plan_qty"))))
|
|
|
|
|
.pcsn(map.get("pcsn"))
|
|
|
|
|
.build());
|
|
|
|
|
if (CollectionUtils.isEmpty(structattrs)){
|
|
|
|
|
throw new BadRequestException("无可用货位");
|
|
|
|
|
}
|
|
|
|
|
Structattr struct = structattrs.get(0);
|
|
|
|
|
sect_id = struct.getSect_id();
|
|
|
|
|
sect_code = struct.getSect_code();
|
|
|
|
|
sect_name = struct.getSect_name();
|
|
|
|
|
@@ -376,7 +370,6 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
struct_code = struct.getStruct_code();
|
|
|
|
|
struct_name = struct.getStruct_name();
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Structattr structattr = iStructattrService.findById(map.get("struct_id"));
|
|
|
|
|
MdPbStoragevehicleinfo mdPbStoragevehicleinfo = mdPbStoragevehicleinfoMapper.selectOne(new LambdaQueryWrapper<>(MdPbStoragevehicleinfo.class)
|
|
|
|
|
.eq(MdPbStoragevehicleinfo::getStoragevehicle_code,map.get("storagevehicle_code"))
|
|
|
|
|
@@ -401,7 +394,6 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
dis_map.put("struct_id", struct_id);
|
|
|
|
|
dis_map.put("struct_code", struct_code);
|
|
|
|
|
dis_map.put("struct_name", struct_name);
|
|
|
|
|
|
|
|
|
|
//锁定货位
|
|
|
|
|
IOStorInv ioStorInv = ioStorInvMapper.selectById(map.get("iostorinv_id"));
|
|
|
|
|
JSONObject lock_map = new JSONObject();
|
|
|
|
|
@@ -411,7 +403,11 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
lock_map.put("inv_type", ioStorInv.getBill_type());
|
|
|
|
|
lock_map.put("lock_type", IOSEnum.LOCK_TYPE.code("入库锁"));
|
|
|
|
|
iStructattrService.updateStatusByCode("0",lock_map);
|
|
|
|
|
|
|
|
|
|
//更新组盘表状态
|
|
|
|
|
mdPbGroupplateService.update(new LambdaUpdateWrapper<GroupPlate>()
|
|
|
|
|
.set(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
|
|
|
|
.eq(GroupPlate::getStoragevehicle_code,map.get("storagevehicle_code"))
|
|
|
|
|
.eq(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("组盘")));
|
|
|
|
|
// 更新分配明细表
|
|
|
|
|
ioStorInvDisMapper.update(dis_map.toJavaObject(IOStorInvDis.class),new LambdaUpdateWrapper<>(IOStorInvDis.class)
|
|
|
|
|
.set(IOStorInvDis::getSect_id,dis_map.getString("sect_id"))
|
|
|
|
|
@@ -422,7 +418,6 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
.set(IOStorInvDis::getStruct_name,dis_map.getString("struct_name"))
|
|
|
|
|
.eq(IOStorInvDis::getIostorinvdis_id,map.get("iostorinvdis_id"))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//维护单据明细表里 分配数量
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("iostorinvdtl_id",map.get("iostorinvdtl_id"));
|
|
|
|
|
@@ -430,12 +425,10 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
jsonObject.put("assign_qty",map.get("plan_qty"));
|
|
|
|
|
jsonObject.put("unassign_qty","0");
|
|
|
|
|
ioStorInvDtlMapper.updateById(jsonObject.toJavaObject(IOStorInvDtl.class));
|
|
|
|
|
|
|
|
|
|
//根据单据标识判断分配明细是否都已经分配完成
|
|
|
|
|
int disCount = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
|
.eq(IOStorInvDis::getIostorinv_id,map.get("iostorinv_id"))
|
|
|
|
|
.and(wrapper -> wrapper.isNull(IOStorInvDis::getStruct_code).or().eq(IOStorInvDis::getStruct_code,"")));
|
|
|
|
|
|
|
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
|
IOStorInv ios = new IOStorInv();
|
|
|
|
|
ios.setIostorinv_id(map.get("iostorinv_id"));
|
|
|
|
|
@@ -599,14 +592,13 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
.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_code,ioStorInvDis.getMaterial_code())
|
|
|
|
|
.eq(GroupPlate::getStoragevehicle_code,ioStorInvDis.getStoragevehicle_code())
|
|
|
|
|
);
|
|
|
|
|
// //更新组盘记录表
|
|
|
|
|
// mdPbGroupplateService.update(new GroupPlate(),new LambdaUpdateWrapper<>(GroupPlate.class)
|
|
|
|
|
// .set(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
|
|
|
|
// .eq(GroupPlate::getPcsn,ioStorInvDis.getPcsn())
|
|
|
|
|
// .eq(GroupPlate::getMaterial_code,ioStorInvDis.getMaterial_code())
|
|
|
|
|
// .eq(GroupPlate::getStoragevehicle_code,ioStorInvDis.getStoragevehicle_code())
|
|
|
|
|
// );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新主表状态
|
|
|
|
|
@@ -663,15 +655,6 @@ public class RawAssistIStorServiceImpl extends ServiceImpl<IOStorInvMapper, IOSt
|
|
|
|
|
jsonIvt.put("change_qty", ioStorInvDis.getPlan_qty());
|
|
|
|
|
updateIvtList.add(jsonIvt);
|
|
|
|
|
iMdPbStoragevehicleextService.updateIvt(updateIvtList);
|
|
|
|
|
|
|
|
|
|
//更新组盘记录表
|
|
|
|
|
groupPlateMapper.update(new GroupPlate(),new LambdaUpdateWrapper<>(GroupPlate.class)
|
|
|
|
|
.set(GroupPlate::getStatus,IOSEnum.GROUP_PLATE_STATUS.code("入库"))
|
|
|
|
|
.eq(GroupPlate::getPcsn,ioStorInvDis.getPcsn())
|
|
|
|
|
.eq(GroupPlate::getMaterial_code,ioStorInvDis.getMaterial_code())
|
|
|
|
|
.eq(GroupPlate::getStoragevehicle_code,ioStorInvDis.getStoragevehicle_code())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 查询该明细下是否还有未完成的分配明细
|
|
|
|
|
int countDis = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
|
.eq(IOStorInvDis::getIostorinvdtl_id,ioStorInvDis.getIostorinvdtl_id())
|
|
|
|
|
|