|
|
|
@@ -142,6 +142,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName();
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName();
|
|
|
|
String now = DateUtil.now();
|
|
|
|
String now = DateUtil.now();
|
|
|
|
BigDecimal total_qty = new BigDecimal(BigInteger.ZERO);
|
|
|
|
BigDecimal total_qty = new BigDecimal(BigInteger.ZERO);
|
|
|
|
|
|
|
|
int row_size = 0;
|
|
|
|
JSONObject io_mst = new JSONObject();
|
|
|
|
JSONObject io_mst = new JSONObject();
|
|
|
|
String iostorinv_id = IdUtil.getStringId();
|
|
|
|
String iostorinv_id = IdUtil.getStringId();
|
|
|
|
String bill_code = CodeUtil.getNewCode("IN_STORE_CODE");
|
|
|
|
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_id", whereJson.get("stor_id"));
|
|
|
|
io_mst.put("stor_code", stor_code);
|
|
|
|
io_mst.put("stor_code", stor_code);
|
|
|
|
io_mst.put("stor_name", stor_name);
|
|
|
|
io_mst.put("stor_name", stor_name);
|
|
|
|
io_mst.put("detail_count", rows.size());
|
|
|
|
|
|
|
|
io_mst.put("remark", whereJson.get("remark"));
|
|
|
|
io_mst.put("remark", whereJson.get("remark"));
|
|
|
|
io_mst.put("bill_status", whereJson.get("bill_status"));
|
|
|
|
io_mst.put("bill_status", whereJson.get("bill_status"));
|
|
|
|
io_mst.put("create_mode", IOSEnum.CREATE_MODE.code("PC产生"));
|
|
|
|
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++) {
|
|
|
|
for (int i = 0; i < rows.size(); i++) {
|
|
|
|
HashMap<String, Object> row = rows.get(i);
|
|
|
|
HashMap<String, Object> row = rows.get(i);
|
|
|
|
JSONObject ioStorInvDtl = new JSONObject();
|
|
|
|
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.putAll(row);
|
|
|
|
ioStorInvDtl.put("iostorinvdtl_id", IdUtil.getStringId());
|
|
|
|
ioStorInvDtl.put("iostorinvdtl_id", IdUtil.getStringId());
|
|
|
|
ioStorInvDtl.put("iostorinv_id", iostorinv_id);
|
|
|
|
ioStorInvDtl.put("iostorinv_id", iostorinv_id);
|
|
|
|
@@ -199,10 +206,19 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
|
|
|
}
|
|
|
|
}
|
|
|
|
IOStorInvDtl invDtl = ioStorInvDtl.toJavaObject(IOStorInvDtl.class);
|
|
|
|
IOStorInvDtl invDtl = ioStorInvDtl.toJavaObject(IOStorInvDtl.class);
|
|
|
|
ioStorInvDtlMapper.insert(invDtl);
|
|
|
|
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();
|
|
|
|
JSONObject dis = new JSONObject();
|
|
|
|
dis.put("iostorinvdis_id", IdUtil.getStringId());
|
|
|
|
dis.put("iostorinvdis_id", IdUtil.getStringId());
|
|
|
|
dis.put("iostorinv_id", iostorinv_id);
|
|
|
|
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("seq_no", 1);
|
|
|
|
dis.put("material_id", row.get("material_id"));
|
|
|
|
dis.put("material_id", row.get("material_id"));
|
|
|
|
dis.put("material_code", row.get("material_code"));
|
|
|
|
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));
|
|
|
|
ioStorInvDisMapper.insert(dis.toJavaObject(IOStorInvDis.class));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
io_mst.put("total_qty", total_qty);
|
|
|
|
io_mst.put("total_qty", total_qty);
|
|
|
|
|
|
|
|
io_mst.put("detail_count", row_size);
|
|
|
|
ioStorInvMapper.insert(io_mst.toJavaObject(IOStorInv.class));
|
|
|
|
ioStorInvMapper.insert(io_mst.toJavaObject(IOStorInv.class));
|
|
|
|
return iostorinv_id;
|
|
|
|
return iostorinv_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -327,11 +344,10 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void divStruct(JSONObject param) {
|
|
|
|
public void divStruct(JSONObject param) {
|
|
|
|
Assert.noNullElements(new Object[]{param.getString("stor_code"), param.getString("sect_code")}, "参数异常");
|
|
|
|
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));
|
|
|
|
JSONObject mst = JSONObject.parseObject(JSON.toJSONString(param));
|
|
|
|
HashMap<String, String> map = rows.get(0);
|
|
|
|
JSONObject map = param.getJSONObject("dis_row");
|
|
|
|
String iostorinvId = map.get("iostorinv_id");
|
|
|
|
String iostorinvId = map.getString("iostorinv_id");
|
|
|
|
String storagevehicleCode = map.get("storagevehicle_code");
|
|
|
|
String storagevehicleCode = map.getString("storagevehicle_code");
|
|
|
|
//判断该分配明细是否已经分配货位
|
|
|
|
//判断该分配明细是否已经分配货位
|
|
|
|
List<IOStorInvDis> disList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
List<IOStorInvDis> disList = ioStorInvDisMapper.selectList(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
.eq(IOStorInvDis::getIostorinv_id, iostorinvId)
|
|
|
|
.eq(IOStorInvDis::getIostorinv_id, iostorinvId)
|
|
|
|
@@ -377,18 +393,17 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
|
|
|
struct_id = struct.getStruct_id();
|
|
|
|
struct_id = struct.getStruct_id();
|
|
|
|
struct_code = struct.getStruct_code();
|
|
|
|
struct_code = struct.getStruct_code();
|
|
|
|
struct_name = struct.getStruct_name();
|
|
|
|
struct_name = struct.getStruct_name();
|
|
|
|
} else
|
|
|
|
} else {
|
|
|
|
{
|
|
|
|
Structattr structattr = iStructattrService.findById(map.getString("struct_id"));
|
|
|
|
Structattr structattr = iStructattrService.findById(map.get("struct_id"));
|
|
|
|
|
|
|
|
MdPbStoragevehicleinfo mdPbStoragevehicleinfo = mdPbStoragevehicleinfoMapper.selectOne(new LambdaQueryWrapper<>(MdPbStoragevehicleinfo.class)
|
|
|
|
MdPbStoragevehicleinfo mdPbStoragevehicleinfo = mdPbStoragevehicleinfoMapper.selectOne(new LambdaQueryWrapper<>(MdPbStoragevehicleinfo.class)
|
|
|
|
.eq(MdPbStoragevehicleinfo::getStoragevehicle_code, map.get("storagevehicle_code"))
|
|
|
|
.eq(MdPbStoragevehicleinfo::getStoragevehicle_code, map.get("storagevehicle_code"))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
sect_id = map.get("sect_id");
|
|
|
|
sect_id = map.getString("sect_id");
|
|
|
|
sect_code = map.get("sect_code");
|
|
|
|
sect_code = map.getString("sect_code");
|
|
|
|
sect_name = map.get("sect_name");
|
|
|
|
sect_name = map.getString("sect_name");
|
|
|
|
struct_id = map.get("struct_id");
|
|
|
|
struct_id = map.getString("struct_id");
|
|
|
|
struct_code = map.get("struct_code");
|
|
|
|
struct_code = map.getString("struct_code");
|
|
|
|
struct_name = map.get("struct_name");
|
|
|
|
struct_name = map.getString("struct_name");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject dis_map = new JSONObject();
|
|
|
|
JSONObject dis_map = new JSONObject();
|
|
|
|
dis_map.put("sect_id", sect_id);
|
|
|
|
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));
|
|
|
|
List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<IOStorInvDtl>().in(IOStorInvDtl::getIostorinvdtl_id, dtlCollect));
|
|
|
|
for (IOStorInvDtl dtl : dtls) {
|
|
|
|
for (IOStorInvDtl dtl : dtls) {
|
|
|
|
int disQtySum = disList.stream().filter(dis -> dis.getIostorinvdtl_id().equals(dtl.getIostorinvdtl_id())).mapToInt(value -> value.getPlan_qty().intValue()).sum();
|
|
|
|
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(dtl.getAssign_qty().add(BigDecimal.valueOf(disQtySum)));
|
|
|
|
dtl.setAssign_qty(BigDecimal.valueOf(disQtySum));
|
|
|
|
dtl.setUnassign_qty(dtl.getPlan_qty().subtract(dtl.getAssign_qty()));
|
|
|
|
dtl.setUnassign_qty(BigDecimal.valueOf(0));
|
|
|
|
dtl.setBill_status(dtl.getUnassign_qty().compareTo(BigDecimal.valueOf(0)) > 0 ? IOSEnum.BILL_STATUS.code("分配中") : IOSEnum.BILL_STATUS.code("分配完"));
|
|
|
|
ioStorInvDtlMapper.updateById(dtl);
|
|
|
|
ioStorInvDtlMapper.updateById(dtl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//根据单据标识判断分配明细是否都已经分配完成
|
|
|
|
//根据单据标识判断分配明细是否都已经分配完成
|
|
|
|
@@ -449,14 +464,12 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void unDivStruct(Map whereJson) {
|
|
|
|
public void unDivStruct(JSONObject whereJson) {
|
|
|
|
|
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId();
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName();
|
|
|
|
String nickName = SecurityUtils.getCurrentNickName();
|
|
|
|
String now = DateUtil.now();
|
|
|
|
String now = DateUtil.now();
|
|
|
|
|
|
|
|
JSONObject jo = whereJson.getJSONObject("dis_row");
|
|
|
|
ArrayList<HashMap> rows = (ArrayList<HashMap>) whereJson.get("tableMater");
|
|
|
|
|
|
|
|
HashMap<String, String> jo = rows.get(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//解锁原货位点位
|
|
|
|
//解锁原货位点位
|
|
|
|
JSONObject unlock_map = new JSONObject();
|
|
|
|
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"))
|
|
|
|
.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();
|
|
|
|
List<String> dtlCollect = disList.stream().map(IOStorInvDis::getIostorinvdtl_id).collect(Collectors.toList());
|
|
|
|
jsonObject.put("iostorinvdtl_id",jo.get("iostorinvdtl_id"));
|
|
|
|
List<IOStorInvDtl> dtls = ioStorInvDtlMapper.selectList(new LambdaQueryWrapper<IOStorInvDtl>().in(IOStorInvDtl::getIostorinvdtl_id, dtlCollect));
|
|
|
|
jsonObject.put("bill_status",IOSEnum.BILL_STATUS.code("生成"));
|
|
|
|
for (IOStorInvDtl dtl : dtls) {
|
|
|
|
jsonObject.put("assign_qty","0");
|
|
|
|
int disQtySum = disList.stream().filter(dis -> dis.getIostorinvdtl_id().equals(dtl.getIostorinvdtl_id())).mapToInt(value -> value.getPlan_qty().intValue()).sum();
|
|
|
|
jsonObject.put("unassign_qty",jo.get("plan_qty"));
|
|
|
|
dtl.setAssign_qty(dtl.getAssign_qty().subtract(BigDecimal.valueOf(disQtySum)));
|
|
|
|
ioStorInvDtlMapper.updateById(jsonObject.toJavaObject(IOStorInvDtl.class));
|
|
|
|
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)
|
|
|
|
int disCount = ioStorInvDisMapper.selectCount(new LambdaQueryWrapper<>(IOStorInvDis.class)
|
|
|
|
@@ -493,7 +517,7 @@ public class InBillServiceImpl extends ServiceImpl<IOStorInvMapper, IOStorInv> i
|
|
|
|
|
|
|
|
|
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
// 根据分配货位情况 更新主表单据状态
|
|
|
|
IOStorInv ios = new IOStorInv();
|
|
|
|
IOStorInv ios = new IOStorInv();
|
|
|
|
ios.setIostorinv_id(jo.get("iostorinv_id"));
|
|
|
|
ios.setIostorinv_id(jo.getString("iostorinv_id"));
|
|
|
|
ios.setUpdate_optid(currentUserId);
|
|
|
|
ios.setUpdate_optid(currentUserId);
|
|
|
|
ios.setUpdate_optname(nickName);
|
|
|
|
ios.setUpdate_optname(nickName);
|
|
|
|
ios.setUpdate_time(now);
|
|
|
|
ios.setUpdate_time(now);
|
|
|
|
|