Commit 8bac25a4 by ice

修改转单功能中调拨根据调出库区的不同进行分单

parent fa2be4e5
......@@ -199,63 +199,68 @@ public class StockTransferController {
String username = sysUser.getUsername();
judgeInvId(jsonArray);
JSONArray jsonArr = getJSONArray(jsonArray);
//根据调入库存不同进行分组
//根据调出库区、调入库存不同进行分组
List<JSONArrayModel> list = jsonArr.toJavaList(JSONArrayModel.class);
Map<String,List<JSONArrayModel>> jsonMap = list.stream().collect(Collectors.groupingBy(JSONArrayModel::getIn_inv_id));
Set set = jsonMap.entrySet();
for(Iterator iterator = set.iterator();iterator.hasNext();){
String orderNumber = propertiesServer.generateFlowingWater("WAR_TRANSFER_NUMBER");
Map.Entry entry = (Map.Entry) iterator.next();
List<JSONArrayModel> jsonObjectList = (List<JSONArrayModel>) entry.getValue();
Inventory inventory = getInventory(jsonObjectList.get(0).getIn_inv_id());
WarTransfer warTransfer = new WarTransfer();
warTransfer.setId(UuidUtil.get32UUIDString());
warTransfer.setInvCode(jsonObjectList.get(0).getInv_code());
warTransfer.setInvName(jsonObjectList.get(0).getInv_id());
warTransfer.setInSubinvCode("");
warTransfer.setSubinvCode(jsonObjectList.get(0).getSubinv_code());
warTransfer.setInInvCode(inventory.getInvCode());
warTransfer.setInInvName(inventory.getId());
warTransfer.setCreateBy(username);
warTransfer.setCreateTime(time);
warTransfer.setUpdateBy(username);
warTransfer.setUpdateTime(time);
warTransfer.setOrgId(map.get("sys_org_code"));
warTransfer.setSysOrgCode(map.get("sys_org_code"));
warTransfer.setOrderNumber(orderNumber);
warTransfer.setOrderStatus("new");
if(jsonObjectList.get(0).getInv_id().equals(jsonObjectList.get(0).getIn_inv_id())){
warTransfer.setOrderType("SUBINVENTORY_TRANSFER");
}else{
warTransfer.setOrderType("OTHERINVENTORY_TRANSFER");
}
warTransfer.setDeliveryName("");
warTransfer.setRequestorId("");
List<WarTransferLine> warTransferLineList = new ArrayList<>();
for (int i = 0; i < jsonObjectList.size(); i++) {
JSONArrayModel jsonArrayModel = jsonObjectList.get(i);
Integer balance = Integer.valueOf(jsonArrayModel.getBalance());
Integer quantity = Integer.valueOf(jsonArrayModel.getQuantity());
if(quantity.compareTo(balance)>0){
throw ErrorEnum.Error.createException("转单失败,存在调拨数量大于库存现有量!");
Map<String, Map<String, List<JSONArrayModel>>> jsonMap = list.stream().collect(Collectors.groupingBy(JSONArrayModel::getSubinv_id,Collectors.groupingBy(JSONArrayModel::getIn_inv_id)));
Set firstSet = jsonMap.entrySet();
for(Iterator firstIterator = firstSet.iterator();firstIterator.hasNext();) {
Map.Entry firstEntry = (Map.Entry) firstIterator.next();
Map<String, List<JSONArrayModel>> listMap = (Map<String, List<JSONArrayModel>>) firstEntry.getValue();
Set secondSet = listMap.entrySet();
for (Iterator secondIterator = secondSet.iterator(); secondIterator.hasNext();) {
Map.Entry secondEntry = (Map.Entry) secondIterator.next();
List<JSONArrayModel> jsonObjectList = (List<JSONArrayModel>) secondEntry.getValue();
String orderNumber = propertiesServer.generateFlowingWater("WAR_TRANSFER_NUMBER");
Inventory inventory = getInventory(jsonObjectList.get(0).getIn_inv_id());
WarTransfer warTransfer = new WarTransfer();
warTransfer.setId(UuidUtil.get32UUIDString());
warTransfer.setInvCode(jsonObjectList.get(0).getInv_code());
warTransfer.setInvName(jsonObjectList.get(0).getInv_id());
warTransfer.setInSubinvCode("");
warTransfer.setSubinvCode(jsonObjectList.get(0).getSubinv_code());
warTransfer.setInInvCode(inventory.getInvCode());
warTransfer.setInInvName(inventory.getId());
warTransfer.setCreateBy(username);
warTransfer.setCreateTime(time);
warTransfer.setUpdateBy(username);
warTransfer.setUpdateTime(time);
warTransfer.setOrgId(map.get("sys_org_code"));
warTransfer.setSysOrgCode(map.get("sys_org_code"));
warTransfer.setOrderNumber(orderNumber);
warTransfer.setOrderStatus("new");
if (jsonObjectList.get(0).getInv_id().equals(jsonObjectList.get(0).getIn_inv_id())) {
warTransfer.setOrderType("SUBINVENTORY_TRANSFER");
} else {
warTransfer.setOrderType("OTHERINVENTORY_TRANSFER");
}
warTransfer.setDeliveryName("");
warTransfer.setRequestorId("");
List<WarTransferLine> warTransferLineList = new ArrayList<>();
for (int i = 0; i < jsonObjectList.size(); i++) {
JSONArrayModel jsonArrayModel = jsonObjectList.get(i);
Integer balance = Integer.valueOf(jsonArrayModel.getBalance());
Integer quantity = Integer.valueOf(jsonArrayModel.getQuantity());
if (quantity.compareTo(balance) > 0) {
throw ErrorEnum.Error.createException("转单失败,存在调拨数量大于库存现有量!");
}
WarTransferLine warTransferLine = new WarTransferLine();
warTransferLine.setId(UuidUtil.get32UUIDString());
warTransferLine.setLineNumber(String.valueOf(i + 1));
warTransferLine.setSubinvCode(jsonArrayModel.getSubinv_code());
warTransferLine.setSubinvName(jsonArrayModel.getSubinv_name());
warTransferLine.setLocatorCode(jsonArrayModel.getLocator_code());
warTransferLine.setItemId(jsonArrayModel.getItem_id());
warTransferLine.setItemCode(jsonArrayModel.getItem_code());
warTransferLine.setItemName(jsonArrayModel.getItem_name());
warTransferLine.setUnitCode(jsonArrayModel.getUnit_code());
warTransferLine.setUnitPrice(jsonArrayModel.getPurchase_price());
warTransferLine.setQuantity(jsonArrayModel.getQuantity());
warTransferLine.setAttribute1(jsonArrayModel.getBalance());
warTransferLineList.add(warTransferLine);
}
WarTransferLine warTransferLine = new WarTransferLine();
warTransferLine.setId(UuidUtil.get32UUIDString());
warTransferLine.setLineNumber(String.valueOf(i+1));
warTransferLine.setSubinvCode(jsonArrayModel.getSubinv_code());
warTransferLine.setSubinvName(jsonArrayModel.getSubinv_name());
warTransferLine.setLocatorCode(jsonArrayModel.getLocator_code());
warTransferLine.setItemId(jsonArrayModel.getItem_id());
warTransferLine.setItemCode(jsonArrayModel.getItem_code());
warTransferLine.setItemName(jsonArrayModel.getItem_name());
warTransferLine.setUnitCode(jsonArrayModel.getUnit_code());
warTransferLine.setUnitPrice(jsonArrayModel.getPurchase_price());
warTransferLine.setQuantity(jsonArrayModel.getQuantity());
warTransferLine.setAttribute1(jsonArrayModel.getBalance());
warTransferLineList.add(warTransferLine);
transferService.saveMain(warTransfer, warTransferLineList);
orderNumList.add(orderNumber);
}
transferService.saveMain(warTransfer,warTransferLineList);
orderNumList.add(orderNumber);
}
return orderNumList;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment