|
@@ -1290,7 +1290,6 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
isMachineRetuen = true;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if(isMachineRetuen){
|
|
|
//减去售后仓库不良品
|
|
|
ComplaintDetectInfo cdinfo = complaintDetectInfoList.get(0);
|
|
@@ -1331,40 +1330,60 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
SalesOrderItem salesOrderItem = new SalesOrderItem();
|
|
|
salesOrderItem.setItemOrderId(salesId);
|
|
|
List<SalesOrderItem> listOrderitem = salesOrderService.listSalesOrderItem(salesOrderItem);
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
for(SalesOrderItem item : listOrderitem){
|
|
|
- InventoryInfo info = inventoryMapper.getByInventoryByBar(item.getItemColorBar(),salesWarehouseId);
|
|
|
- if(info != null){
|
|
|
- if(info.getInventoryGoodProductNum() >= item.getItemNum()){
|
|
|
- info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() - item.getItemNum());
|
|
|
- info.setInventoryRecentRecord(sdf.format(new Date())+"出库"+item.getItemNum()+"件,订单号:"+item.getSalesOrderId());
|
|
|
- Integer flag = inventoryMapper.updateById(info);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("【出库】更新库存失败,库存修改失败。");
|
|
|
- }
|
|
|
- //添加日志
|
|
|
- InventoryLog inventoryLog = new InventoryLog();
|
|
|
- inventoryLog.setLogProductName(info.getInventoryProductName());
|
|
|
- inventoryLog.setLogProductBar(info.getInventoryProductBar());
|
|
|
- inventoryLog.setLogRemainingNum(item.getItemNum());
|
|
|
- inventoryLog.setLogType(2);
|
|
|
- inventoryLog.setLogOperationType(2);
|
|
|
- inventoryLog.setLogDesc(sdf.format(new Date())+"待发货标记出库"+item.getItemNum()+"件,订单号:"+item.getSalesOrderId());
|
|
|
- inventoryLog.setLogQualityType(1);
|
|
|
- inventoryLog.setLogWarehouseId(salesWarehouseId);
|
|
|
- flag = inventoryLogMapper.insert(inventoryLog);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("【出库】更新库存失败,增加库存记录失败。");
|
|
|
- }
|
|
|
- }else{
|
|
|
- throw new RuntimeException("【出库】更新库存失败,"+ warehouseName +"["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存不足。");
|
|
|
+ List<ProductCombinatInfo> listproduct = productMapper.combinatList(item.getItemProductId());
|
|
|
+ if(listOrderitem.size() > 0){
|
|
|
+ for(ProductCombinatInfo combinatInfo : listproduct){
|
|
|
+ invIne(item,orderWarehouse,combinatInfo);
|
|
|
}
|
|
|
}else{
|
|
|
- throw new RuntimeException("【出库】更新库存失败,未查询到库存信息,请确认“"+ warehouseName +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
+ invIne(item,orderWarehouse,null);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ public void invIne(SalesOrderItem item,OrderWarehouse orderWarehouse,ProductCombinatInfo combinatInfo){
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Integer combinatItemNum;
|
|
|
+ if(combinatInfo == null ){
|
|
|
+ combinatItemNum = 1;
|
|
|
+ }else{
|
|
|
+ combinatItemNum = combinatInfo.getCombinatItemNum();
|
|
|
+ item.setItemColorBar(productService.getProduceColor(combinatInfo.getCombinatItemColorId()).getColorBar());
|
|
|
+ }
|
|
|
+ InventoryInfo infos = inventoryMapper.getByInventoryByBar(item.getItemColorBar(),orderWarehouse.getWarehouseId());
|
|
|
+ if(infos != null){
|
|
|
+ if(infos.getInventoryGoodProductNum() >= (item.getItemNum() * combinatItemNum)){
|
|
|
+ infos.setInventoryGoodProductNum(infos.getInventoryGoodProductNum() - (item.getItemNum() * combinatItemNum));
|
|
|
+ infos.setInventoryRecentRecord(sdf.format(new Date())+"出库"+item.getItemNum()+"件,订单号:"+item.getSalesOrderId());
|
|
|
+ Integer flag = inventoryMapper.updateById(infos);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,库存修改失败。");
|
|
|
+ }
|
|
|
+ //添加日志
|
|
|
+ InventoryLog inventoryLog = new InventoryLog();
|
|
|
+ inventoryLog.setLogProductName(infos.getInventoryProductName());
|
|
|
+ inventoryLog.setLogProductBar(infos.getInventoryProductBar());
|
|
|
+ inventoryLog.setLogRemainingNum(item.getItemNum() * combinatItemNum);
|
|
|
+ inventoryLog.setLogType(2);
|
|
|
+ inventoryLog.setLogOperationType(2);
|
|
|
+ inventoryLog.setLogDesc(sdf.format(new Date())+"待发货标记出库"+item.getItemNum()+"件,订单号:"+item.getSalesOrderId());
|
|
|
+ inventoryLog.setLogQualityType(1);
|
|
|
+ inventoryLog.setLogWarehouseId(orderWarehouse.getWarehouseId());
|
|
|
+ flag = inventoryLogMapper.insert(inventoryLog);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,增加库存记录失败。");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,"+ orderWarehouse.getWarehouseName() +"["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存不足。");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("【出库】更新库存失败,未查询到库存信息,请确认“"+ orderWarehouse.getWarehouseName() +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
+ }
|
|
|
+ }
|
|
|
//标记未出库时返还库存
|
|
|
@Transactional
|
|
|
@Override
|
|
@@ -1378,38 +1397,54 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
SalesOrderItem salesOrderItem = new SalesOrderItem();
|
|
|
salesOrderItem.setItemOrderId(salesId);
|
|
|
List<SalesOrderItem> listOrderitem = salesOrderService.listSalesOrderItem(salesOrderItem);
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
for(SalesOrderItem item : listOrderitem){
|
|
|
- InventoryInfo info = inventoryMapper.getByInventoryByBar(item.getItemColorBar(),salesWarehouseId);
|
|
|
- if(info != null){
|
|
|
- info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() + item.getItemNum());
|
|
|
- info.setInventoryRecentRecord(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存"+item.getItemNum()+"件,订单号:"+item.getSalesOrderId());
|
|
|
- Integer flag = inventoryMapper.updateById(info);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("【返还库存】更新库存失败,库存修改失败。");
|
|
|
- }
|
|
|
- //添加日志
|
|
|
- InventoryLog inventoryLog = new InventoryLog();
|
|
|
- inventoryLog.setLogProductName(info.getInventoryProductName());
|
|
|
- inventoryLog.setLogProductBar(info.getInventoryProductBar());
|
|
|
- inventoryLog.setLogRemainingNum(item.getItemNum());
|
|
|
- inventoryLog.setLogType(1);
|
|
|
- inventoryLog.setLogOperationType(1);
|
|
|
- inventoryLog.setLogDesc(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存"+item.getItemNum()+"件,订单号:"+item.getSalesOrderId());
|
|
|
- inventoryLog.setLogQualityType(1);
|
|
|
- inventoryLog.setLogWarehouseId(salesWarehouseId);
|
|
|
- flag = inventoryLogMapper.insert(inventoryLog);
|
|
|
- if(flag < 1){
|
|
|
- throw new RuntimeException("【返还库存】更新库存失败,增加库存记录失败。");
|
|
|
+ List<ProductCombinatInfo> listproduct = productMapper.combinatList(item.getItemProductId());
|
|
|
+ if(listOrderitem.size() > 0){
|
|
|
+ for(ProductCombinatInfo combinatInfo : listproduct){
|
|
|
+ invTwo(item,orderWarehouse,combinatInfo);
|
|
|
}
|
|
|
}else{
|
|
|
- throw new RuntimeException("【返还库存】更新库存失败,未查询到库存信息,请确认“"+ warehouseName +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
+ invTwo(item,orderWarehouse,null);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private void invTwo(SalesOrderItem item,OrderWarehouse orderWarehouse,ProductCombinatInfo combinatInfo){
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Integer combinatItemNum;
|
|
|
+ if(combinatInfo == null ){
|
|
|
+ combinatItemNum = 1;
|
|
|
+ }else{
|
|
|
+ combinatItemNum = combinatInfo.getCombinatItemNum();
|
|
|
+ item.setItemColorBar(productService.getProduceColor(combinatInfo.getCombinatItemColorId()).getColorBar());
|
|
|
+ }
|
|
|
+ InventoryInfo info = inventoryMapper.getByInventoryByBar(item.getItemColorBar(),orderWarehouse.getWarehouseId());
|
|
|
+ if(info != null){
|
|
|
+ info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() + (item.getItemNum() * combinatItemNum));
|
|
|
+ info.setInventoryRecentRecord(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存"+(item.getItemNum() * combinatItemNum)+"件,订单号:"+item.getSalesOrderId());
|
|
|
+ Integer flag = inventoryMapper.updateById(info);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("【返还库存】更新库存失败,库存修改失败。");
|
|
|
+ }
|
|
|
+ //添加日志
|
|
|
+ InventoryLog inventoryLog = new InventoryLog();
|
|
|
+ inventoryLog.setLogProductName(info.getInventoryProductName());
|
|
|
+ inventoryLog.setLogProductBar(info.getInventoryProductBar());
|
|
|
+ inventoryLog.setLogRemainingNum((item.getItemNum() * combinatItemNum));
|
|
|
+ inventoryLog.setLogType(1);
|
|
|
+ inventoryLog.setLogOperationType(1);
|
|
|
+ inventoryLog.setLogDesc(sdf.format(new Date())+"删除/作废/标记未出库时订单返还库存"+(item.getItemNum() * combinatItemNum)+"件,订单号:"+item.getSalesOrderId());
|
|
|
+ inventoryLog.setLogQualityType(1);
|
|
|
+ inventoryLog.setLogWarehouseId(orderWarehouse.getWarehouseId());
|
|
|
+ flag = inventoryLogMapper.insert(inventoryLog);
|
|
|
+ if(flag < 1){
|
|
|
+ throw new RuntimeException("【返还库存】更新库存失败,增加库存记录失败。");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("【返还库存】更新库存失败,未查询到库存信息,请确认“"+ orderWarehouse.getWarehouseName() +"”是否有该产品["+ item.getItemProductName()+ "("+ item.getItemProductColor() +")" +"]库存信息。");
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public List<SalesOrderItem> getDeliverNum(SalesOrder salesOrder) {
|
|
|
return salesOrderMapper.getDeliverNum(salesOrder);
|
|
@@ -1463,36 +1498,17 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
//查询订单判断是否已出库
|
|
|
SalesOrder so = salesOrderMapper.getSalesOrderById(orderCorrectInfo.getItemOrderId());
|
|
|
if(so.getSalesDeliver() == 2){
|
|
|
- //返还库存
|
|
|
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- InventoryInfo info = inventoryMapper.getByInventoryByBar(orderItem.getItemColorBar(),so.getSalesWarehouseId());
|
|
|
- //添加日志
|
|
|
- InventoryLog inventoryLog = new InventoryLog();
|
|
|
- inventoryLog.setLogProductName(info.getInventoryProductName());
|
|
|
- inventoryLog.setLogProductBar(info.getInventoryProductBar());
|
|
|
- inventoryLog.setLogOperationType(1);
|
|
|
- inventoryLog.setLogQualityType(1);
|
|
|
- inventoryLog.setLogWarehouseId(1);
|
|
|
- if(orderItem.getItemNum() > salesOrderItem.getItemNum()){//原数量大于更正后数量
|
|
|
- info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() + (orderItem.getItemNum() - salesOrderItem.getItemNum()));
|
|
|
- info.setInventoryRecentRecord(sdf.format(new Date())+"更正订单返还库存:"+(orderItem.getItemNum() - salesOrderItem.getItemNum())+"件");
|
|
|
- inventoryLog.setLogRemainingNum(orderItem.getItemNum() - salesOrderItem.getItemNum());
|
|
|
- inventoryLog.setLogType(2);
|
|
|
- inventoryLog.setLogDesc(sdf.format(new Date())+"更正订单返还库存:"+(orderItem.getItemNum() - salesOrderItem.getItemNum())+"件");
|
|
|
- }else if(orderItem.getItemNum() < salesOrderItem.getItemNum()){
|
|
|
- if(info.getInventoryGoodProductNum() > (salesOrderItem.getItemNum() - orderItem.getItemNum())){
|
|
|
- info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() - (salesOrderItem.getItemNum() - orderItem.getItemNum()));
|
|
|
- info.setInventoryRecentRecord(sdf.format(new Date())+"更正订单减少库存:"+(orderItem.getItemNum() - salesOrderItem.getItemNum())+"件");
|
|
|
- inventoryLog.setLogRemainingNum(salesOrderItem.getItemNum() - orderItem.getItemNum());
|
|
|
- inventoryLog.setLogType(1);
|
|
|
- inventoryLog.setLogDesc(sdf.format(new Date())+"更正订单减少库存:"+(salesOrderItem.getItemNum() - orderItem.getItemNum())+"件");
|
|
|
- }else{
|
|
|
- return false;
|
|
|
+ //查询是否是组合产品
|
|
|
+ List<ProductCombinatInfo> listproduct = productMapper.combinatList(salesOrderItem.getItemProductId());
|
|
|
+ if(listproduct.size() > 0){
|
|
|
+ for(ProductCombinatInfo combinatInfo : listproduct){
|
|
|
+ correctInv(orderItem,salesOrderItem,so.getSalesWarehouseId(),combinatInfo);
|
|
|
}
|
|
|
-
|
|
|
+ }else{
|
|
|
+ correctInv(orderItem,salesOrderItem,so.getSalesWarehouseId(),null);
|
|
|
}
|
|
|
- inventoryMapper.updateById(info);
|
|
|
- inventoryLogMapper.insert(inventoryLog);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
//修改订单项数量
|
|
|
orderItem.setItemNum(salesOrderItem.getItemNum());
|
|
@@ -1506,6 +1522,49 @@ public class SalesOrderServiceImpl implements SalesOrderService {
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ private void correctInv(SalesOrderItem orderItem,SalesOrderItem salesOrderItem,Integer warehouseId,ProductCombinatInfo combinatInfo){
|
|
|
+ //返还库存
|
|
|
+ SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ Integer combinatItemNum;
|
|
|
+ if(combinatInfo == null ){
|
|
|
+ combinatItemNum = 0;
|
|
|
+ }else{
|
|
|
+ combinatItemNum = combinatInfo.getCombinatItemNum();
|
|
|
+ orderItem.setItemColorBar(productService.getProduceColor(combinatInfo.getCombinatItemColorId()).getColorBar());
|
|
|
+ }
|
|
|
+ InventoryInfo info = inventoryMapper.getByInventoryByBar(orderItem.getItemColorBar(),warehouseId);
|
|
|
+ //添加日志
|
|
|
+ InventoryLog inventoryLog = new InventoryLog();
|
|
|
+ inventoryLog.setLogProductName(info.getInventoryProductName());
|
|
|
+ inventoryLog.setLogProductBar(info.getInventoryProductBar());
|
|
|
+ inventoryLog.setLogOperationType(1);
|
|
|
+ inventoryLog.setLogQualityType(1);
|
|
|
+ inventoryLog.setLogWarehouseId(warehouseId);
|
|
|
+ if(orderItem.getItemNum() > salesOrderItem.getItemNum()){//原数量大于更正后数量
|
|
|
+
|
|
|
+ info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() + ((orderItem.getItemNum() * combinatItemNum) - (salesOrderItem.getItemNum() * combinatItemNum)));
|
|
|
+ info.setInventoryRecentRecord(sdf.format(new Date())+"更正订单返还库存:"+(orderItem.getItemNum() - salesOrderItem.getItemNum())+"件");
|
|
|
+ inventoryLog.setLogRemainingNum((orderItem.getItemNum() * combinatItemNum) - (salesOrderItem.getItemNum() * combinatItemNum));
|
|
|
+ inventoryLog.setLogType(2);
|
|
|
+ inventoryLog.setLogDesc(sdf.format(new Date())+"更正订单返还库存:"+(orderItem.getItemNum() - salesOrderItem.getItemNum())+"件");
|
|
|
+ }else if(orderItem.getItemNum() < salesOrderItem.getItemNum()){
|
|
|
+
|
|
|
+ if(info.getInventoryGoodProductNum() > ((salesOrderItem.getItemNum() * combinatItemNum) - (orderItem.getItemNum() * combinatItemNum))){
|
|
|
+ info.setInventoryGoodProductNum(info.getInventoryGoodProductNum() - ((salesOrderItem.getItemNum() * combinatItemNum) - (orderItem.getItemNum() * combinatItemNum)));
|
|
|
+ info.setInventoryRecentRecord(sdf.format(new Date())+"更正订单减少库存:"+((salesOrderItem.getItemNum() * combinatItemNum) - (orderItem.getItemNum() * combinatItemNum))+"件");
|
|
|
+ inventoryLog.setLogRemainingNum(((salesOrderItem.getItemNum() * combinatItemNum) - (orderItem.getItemNum() * combinatItemNum)));
|
|
|
+ inventoryLog.setLogType(1);
|
|
|
+ inventoryLog.setLogDesc(sdf.format(new Date())+"更正订单减少库存:"+((salesOrderItem.getItemNum() * combinatItemNum) - (orderItem.getItemNum() * combinatItemNum))+"件");
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("更正订单-减少库存修改订单项数量失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ inventoryMapper.updateById(info);
|
|
|
+ inventoryLogMapper.insert(inventoryLog);
|
|
|
+ }
|
|
|
//更正订单时返还库存
|
|
|
public boolean returnInventoryByItemId(Integer itemId){
|
|
|
SalesOrderItem salesOrderItem = new SalesOrderItem();
|