|
|
@ -142,6 +142,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
BigDecimal total_qty = new BigDecimal(BigInteger.ZERO); |
|
|
|
int row_size = 0; |
|
|
|
JSONObject io_mst = new JSONObject(); |
|
|
|
String iostorinv_id = IdUtil.getStringId(); |
|
|
|
String bill_code = CodeUtil.getNewCode("IN_STORE_CODE"); |
|
|
@ -156,7 +157,6 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
io_mst.put("stor_id", whereJson.get("stor_id")); |
|
|
|
io_mst.put("stor_code", stor_code); |
|
|
|
io_mst.put("stor_name", stor_name); |
|
|
|
io_mst.put("detail_count", rows.size()); |
|
|
|
io_mst.put("remark", whereJson.get("remark")); |
|
|
|
io_mst.put("bill_status", whereJson.get("bill_status")); |
|
|
|
io_mst.put("create_mode", IOSEnum.CREATE_MODE.code("PC产生")); |
|
|
@ -174,6 +174,13 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
for (int i = 0; i < rows.size(); i++) { |
|
|
|
HashMap<String, Object> row = rows.get(i); |
|
|
|
JSONObject ioStorInvDtl = new JSONObject(); |
|
|
|
//判断是否存在相同批次、相同物料的物料明细存在
|
|
|
|
IOStorInvDtl dtl_dto = ioStorInvDtlMapper.selectOne(new LambdaQueryWrapper<IOStorInvDtl>() |
|
|
|
.eq(IOStorInvDtl::getMaterial_code, row.get("material_code")) |
|
|
|
.eq(IOStorInvDtl::getPcsn, row.get("pcsn")) |
|
|
|
.eq(IOStorInvDtl::getBill_status, IOSEnum.BILL_STATUS.code("生成")) |
|
|
|
.eq(IOStorInvDtl::getIostorinv_id, iostorinv_id)); |
|
|
|
if (ObjectUtil.isEmpty(dtl_dto)) { |
|
|
|
ioStorInvDtl.putAll(row); |
|
|
|
ioStorInvDtl.put("iostorinvdtl_id", IdUtil.getStringId()); |
|
|
|
ioStorInvDtl.put("iostorinv_id", iostorinv_id); |
|
|
@ -199,10 +206,19 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
} |
|
|
|
IOStorInvDtl invDtl = ioStorInvDtl.toJavaObject(IOStorInvDtl.class); |
|
|
|
ioStorInvDtlMapper.insert(invDtl); |
|
|
|
row_size++; |
|
|
|
} else { |
|
|
|
Double qty = new Double(String.valueOf(row.get("qty"))); |
|
|
|
dtl_dto.setUnassign_qty(dtl_dto.getUnassign_qty().add(new BigDecimal(qty))); |
|
|
|
dtl_dto.setPlan_qty(dtl_dto.getPlan_qty().add(new BigDecimal(qty))); |
|
|
|
total_qty = total_qty.add(new BigDecimal(qty)); |
|
|
|
ioStorInvDtlMapper.updateById(dtl_dto); |
|
|
|
} |
|
|
|
|
|
|
|
JSONObject dis = new JSONObject(); |
|
|
|
dis.put("iostorinvdis_id", IdUtil.getStringId()); |
|
|
|
dis.put("iostorinv_id", iostorinv_id); |
|
|
|
dis.put("iostorinvdtl_id", ioStorInvDtl.getString("iostorinvdtl_id")); |
|
|
|
dis.put("iostorinvdtl_id", ObjectUtil.isEmpty(dtl_dto) ? ioStorInvDtl.getString("iostorinvdtl_id") : dtl_dto.getIostorinvdtl_id()); |
|
|
|
dis.put("seq_no", 1); |
|
|
|
dis.put("material_id", row.get("material_id")); |
|
|
|
dis.put("material_code", row.get("material_code")); |
|
|
@ -216,6 +232,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
ioStorInvDisMapper.insert(dis.toJavaObject(IOStorInvDis.class)); |
|
|
|
} |
|
|
|
io_mst.put("total_qty", total_qty); |
|
|
|
io_mst.put("detail_count", row_size); |
|
|
|
ioStorInvMapper.insert(io_mst.toJavaObject(IOStorInv.class)); |
|
|
|
return iostorinv_id; |
|
|
|
} |
|
|
@ -327,11 +344,10 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
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); |
|
|
|
String iostorinvId = map.get("iostorinv_id"); |
|
|
|
String storagevehicleCode = map.get("storagevehicle_code"); |
|
|
|
JSONObject map = param.getJSONObject("dis_row"); |
|
|
|
String iostorinvId = map.getString("iostorinv_id"); |
|
|
|
String storagevehicleCode = map.getString("storagevehicle_code"); |
|
|
|
//判断该分配明细是否已经分配货位
|
|
|
|
List<IOStorInvDis> disList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
|
.eq(IOStorInvDis::getIostorinv_id, iostorinvId) |
|
|
@ -377,18 +393,17 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
struct_id = struct.getStruct_id(); |
|
|
|
struct_code = struct.getStruct_code(); |
|
|
|
struct_name = struct.getStruct_name(); |
|
|
|
} else |
|
|
|
{ |
|
|
|
Structattr structattr = iStructattrService.findById(map.get("struct_id")); |
|
|
|
} else { |
|
|
|
Structattr structattr = iStructattrService.findById(map.getString("struct_id")); |
|
|
|
MdPbStoragevehicleinfo mdPbStoragevehicleinfo = mdPbStoragevehicleinfoMapper.selectOne(new LambdaQueryWrapper<>(MdPbStoragevehicleinfo.class) |
|
|
|
.eq(MdPbStoragevehicleinfo::getStoragevehicle_code, map.get("storagevehicle_code")) |
|
|
|
); |
|
|
|
sect_id = map.get("sect_id"); |
|
|
|
sect_code = map.get("sect_code"); |
|
|
|
sect_name = map.get("sect_name"); |
|
|
|
struct_id = map.get("struct_id"); |
|
|
|
struct_code = map.get("struct_code"); |
|
|
|
struct_name = map.get("struct_name"); |
|
|
|
sect_id = map.getString("sect_id"); |
|
|
|
sect_code = map.getString("sect_code"); |
|
|
|
sect_name = map.getString("sect_name"); |
|
|
|
struct_id = map.getString("struct_id"); |
|
|
|
struct_code = map.getString("struct_code"); |
|
|
|
struct_name = map.getString("struct_name"); |
|
|
|
} |
|
|
|
JSONObject dis_map = new JSONObject(); |
|
|
|
dis_map.put("sect_id", sect_id); |
|
|
@ -427,9 +442,9 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<IOStorInvDtl>().in(IOStorInvDtl::getIostorinvdtl_id, dtlCollect)); |
|
|
|
for (IOStorInvDtl dtl : dtls) { |
|
|
|
int disQtySum = disList.stream().filter(dis -> dis.getIostorinvdtl_id().equals(dtl.getIostorinvdtl_id())).mapToInt(value -> value.getPlan_qty().intValue()).sum(); |
|
|
|
dtl.setBill_status(IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
dtl.setAssign_qty(BigDecimal.valueOf(disQtySum)); |
|
|
|
dtl.setUnassign_qty(BigDecimal.valueOf(0)); |
|
|
|
dtl.setAssign_qty(dtl.getAssign_qty().add(BigDecimal.valueOf(disQtySum))); |
|
|
|
dtl.setUnassign_qty(dtl.getPlan_qty().subtract(dtl.getAssign_qty())); |
|
|
|
dtl.setBill_status(dtl.getUnassign_qty().compareTo(BigDecimal.valueOf(0)) > 0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完")); |
|
|
|
ioStorInvDtlMapper.updateById(dtl); |
|
|
|
} |
|
|
|
//根据单据标识判断分配明细是否都已经分配完成
|
|
|
@ -449,14 +464,12 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void unDivStruct(Map whereJson) { |
|
|
|
public void unDivStruct(JSONObject whereJson) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableMater"); |
|
|
|
HashMap<String, String> jo = rows.get(0); |
|
|
|
JSONObject jo = whereJson.getJSONObject("dis_row"); |
|
|
|
|
|
|
|
//解锁原货位点位
|
|
|
|
JSONObject unlock_map = new JSONObject(); |
|
|
@ -478,13 +491,24 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code, jo.get("storagevehicle_code")) |
|
|
|
); |
|
|
|
|
|
|
|
//更新组盘表状态
|
|
|
|
mdPbGroupplateService.update(new LambdaUpdateWrapper<GroupPlate>() |
|
|
|
.set(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("组盘")) |
|
|
|
.eq(GroupPlate::getStoragevehicle_code, jo.get("storagevehicle_code")) |
|
|
|
.eq(GroupPlate::getStatus, IOSEnum.GROUP_PLATE_STATUS.code("入库"))); |
|
|
|
|
|
|
|
List<IOStorInvDis> disList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<IOStorInvDis>().eq(IOStorInvDis::getIostorinv_id, jo.get("iostorinv_id")) |
|
|
|
.eq(IOStorInvDis::getStoragevehicle_code, jo.get("storagevehicle_code"))); |
|
|
|
//维护单据明细表里分配数量
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("iostorinvdtl_id",jo.get("iostorinvdtl_id")); |
|
|
|
jsonObject.put("bill_status",IOSEnum.BILL_STATUS.code("生成")); |
|
|
|
jsonObject.put("assign_qty","0"); |
|
|
|
jsonObject.put("unassign_qty",jo.get("plan_qty")); |
|
|
|
ioStorInvDtlMapper.updateById(jsonObject.toJavaObject(IOStorInvDtl.class)); |
|
|
|
List<String> dtlCollect = disList.stream().map(IOStorInvDis::getIostorinvdtl_id).collect(Collectors.toList()); |
|
|
|
List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<IOStorInvDtl>().in(IOStorInvDtl::getIostorinvdtl_id, dtlCollect)); |
|
|
|
for (IOStorInvDtl dtl : dtls) { |
|
|
|
int disQtySum = disList.stream().filter(dis -> dis.getIostorinvdtl_id().equals(dtl.getIostorinvdtl_id())).mapToInt(value -> value.getPlan_qty().intValue()).sum(); |
|
|
|
dtl.setAssign_qty(dtl.getAssign_qty().subtract(BigDecimal.valueOf(disQtySum))); |
|
|
|
dtl.setUnassign_qty(dtl.getPlan_qty().subtract(dtl.getAssign_qty())); |
|
|
|
dtl.setBill_status(dtl.getUnassign_qty().compareTo(dtl.getPlan_qty()) == 0 ? IOSEnum.BILL_STATUS.code("生成") : IOSEnum.BILL_STATUS.code("分配中")); |
|
|
|
ioStorInvDtlMapper.updateById(dtl); |
|
|
|
} |
|
|
|
|
|
|
|
//根据单据标识判断分配明细是否都已经分配完成
|
|
|
|
int disCount = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class) |
|
|
@ -493,7 +517,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i |
|
|
|
|
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
IOStorInv ios = new IOStorInv(); |
|
|
|
ios.setIostorinv_id(jo.get("iostorinv_id")); |
|
|
|
ios.setIostorinv_id(jo.getString("iostorinv_id")); |
|
|
|
ios.setUpdate_optid(currentUserId); |
|
|
|
ios.setUpdate_optname(nickName); |
|
|
|
ios.setUpdate_time(now); |
|
|
|