浏览代码

出库优化

xian 4 年之前
父节点
当前提交
1cf0310eab

+ 35 - 34
watero-rst-core/src/main/java/com.iamberry.rst.core/fm/InventoryInfo.java

@@ -10,43 +10,44 @@ import java.util.Date;
 public class InventoryInfo implements Serializable{
     private static final long serialVersionUID = 4067885659182190574L;
     private Integer inventoryId;
-    private String inventoryProductName;//产品名称
-    private String inventoryProductBar;//产品sku
-    private Integer inventoryRemainingNum;//库存剩余数量
-    private Integer inventoryState;//1.正在使用 2.暂停使用
-    private String inventoryDesc;//备注
-    private Date inventoryCreateTime;//创建时间
-    private Date inventoryUpdateTime;//修改时间
-    private Integer inventoryProductColorId;//产品颜色id
-    private Integer inventoryGoodProductNum;//良品数量
-    private Integer inventoryDefectiveProductNum;//不良品数量
-    private String inventoryRecentRecord;//最近记录
-    private String productTypeName;//产品类型
-    private String productNumber;//产品型号
-    private String productAbbreviation;//产品简称
-    private String productColorName;//颜色名称
-    private Integer inventoryMomentumNum;//待发数量
-    private Integer operationType;//操作类型 1出库 2 入库
-    private Integer qualityType;//产品质量类型 1良品 2 不良品
-    private Integer operationNum;//操作数量
-    private Integer productTypeId;//产品类型id
-
-    private Integer warehouseId;//仓库ID
-    private String warehouseName;//仓库名称
-
-    private Integer logType;//类型1.采购 2.发货 3.次品
-    private Integer productIsCombination;//是否组合产品 1.否。2是
-    /**
-     * 是否查询实物库存,如果确定,则不查询仓库的其他产品
-     */
+    private String inventoryProductName;            //产品名称
+    private String inventoryProductBar;             //产品sku
+    private Integer inventoryRemainingNum;          //库存剩余数量
+    private Integer inventoryState;                 //1.正在使用 2.暂停使用
+    private String inventoryDesc;                   //备注
+    private Date inventoryCreateTime;               //创建时间
+    private Date inventoryUpdateTime;               //修改时间
+    private Integer inventoryProductColorId;        //产品颜色id
+    private Integer inventoryGoodProductNum;        //良品数量
+    private Integer inventoryDefectiveProductNum;   //不良品数量
+    private String inventoryRecentRecord;           //最近记录
+    private String productTypeName;                 //产品类型
+    private String productNumber;                   //产品型号
+    private String productAbbreviation;             //产品简称
+    private String productColorName;                //颜色名称
+    private Integer inventoryMomentumNum;           //待发数量
+    private Integer operationType;                  //操作类型 1出库 2 入库
+    private Integer qualityType;                    //产品质量类型 1良品 2 不良品
+    private Integer operationNum;                   //操作数量
+    private Integer productTypeId;                  //产品类型id
+    private Integer warehouseId;                    //仓库ID
+    private String warehouseName;                   //仓库名称
+    private Integer logType;                        //类型1.采购 2.发货 3.次品
+    private Integer productIsCombination;           //是否组合产品 1.否。2是
+    /** 是否查询实物库存,如果确定,则不查询仓库的其他产品 */
     private Integer isEntityInventory;
-
-    /**
-     * 接收前端传递的事务库存id
-     */
+    /** 接收前端传递的事务库存id */
     private Integer[] ids;
-
     private String inventoryIDS;
+    private InventoryLog inventoryLog;              // 变动库存时生成的库存变动记录
+
+    public InventoryLog getInventoryLog() {
+        return inventoryLog;
+    }
+
+    public void setInventoryLog(InventoryLog inventoryLog) {
+        this.inventoryLog = inventoryLog;
+    }
 
     public String getInventoryIDS() {
         return inventoryIDS;

+ 4 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/InventoryServiceImpl.java

@@ -60,7 +60,11 @@ public class InventoryServiceImpl implements InventoryService {
     }
 
     @Override
+    @Transactional(rollbackFor = {Exception.class}, isolation = Isolation.REPEATABLE_READ)
     public Integer updateById(InventoryInfo inventoryInfo) {
+        if (inventoryInfo.getInventoryLog() != null) {
+            inventoryLogMapper.insert(inventoryInfo.getInventoryLog());
+        }
         return inventoryMapper.updateById(inventoryInfo);
     }
 

+ 3 - 3
watero-rst-service/src/main/java/com/iamberry/rst/service/cm/SalesOrderServiceImpl.java

@@ -1487,12 +1487,12 @@ public class SalesOrderServiceImpl implements SalesOrderService {
                 throw new RuntimeException("出库失败。维修库存调整失败");
             }
         }else{
-            //正常库存出库(包含正常销售与售后)
+            // 正常库存出库(包含正常销售与售后)
             SalesOrder so = salesOrderMapper.getSalesOrderById(salesOrder.getSalesId());SalesOrderItem salesOrderItem = new SalesOrderItem();
             salesOrderItem.setItemOrderId(so.getSalesId());
             List<SalesOrderItem> listOrderitem = salesOrderService.listSalesOrderItem(salesOrderItem);
             if(salesOrder.getSalesDeliver() == 2){
-                //标记出库,修改库存
+                // 标记出库,修改库存
                 // 如果已出库则返还库存
                 for (SalesOrderItem soi:listOrderitem) {
                     InventoryInfo inventoryInfo2 = new InventoryInfo();
@@ -1501,7 +1501,7 @@ public class SalesOrderServiceImpl implements SalesOrderService {
                     inventoryInfo2.setInventoryProductBar(soi.getItemColorBar());
                     inventoryInfo2.setWarehouseId(so.getSalesWarehouseId());
                     //类型1.采购 2.发货 3.次品
-                    inventoryInfo2.setLogType(1);
+                    inventoryInfo2.setLogType(2);
                     //产品质量类型 1良品 2 不良品
                     inventoryInfo2.setQualityType(1);
                     inventoryInfo2.setInventoryRecentRecord("出库-订单号:"+ so.getSalesDealCode());

+ 2 - 17
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AwaitSendController.java

@@ -759,23 +759,8 @@ public class AwaitSendController {
             rj.setResultMsg("出货失败,请输入物流单号");
             return rj;
         }
-
-        SalesOrder salesOrder = null;
-        try{
-            salesOrder = salesOrderService.getSalesOrderByPostNum(postNum);
-        }catch (Exception e){
-            e.printStackTrace();
-            /*//修改库存信息
-            if(updateInventory(salesOrder.getSalesId())){
-                rj = ResponseJson.getSUCCESS();
-                rj.setResultMsg("物流单号("+ postNum +")出库成功。");
-                return rj;
-            }else{
-                rj.setResultMsg("出货失败,请检查该物流单号("+postNum+")和订单状态是否为已发货,产品库存是否充足。");
-                return rj;
-            }*/
-
-        }
+        // 校验订单信息
+        SalesOrder salesOrder = salesOrderService.getSalesOrderByPostNum(postNum);
         if(salesOrder == null){
             rj.setResultMsg("出货失败,该物流单号("+postNum+")未查询到订单。");
             return rj;

+ 20 - 13
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/InventoryController.java

@@ -205,8 +205,10 @@ public class InventoryController {
         SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         InventoryLog inventoryLog = new InventoryLog();
         InventoryInfo info = inventoryService.getByInventoryId(inventoryInfo.getInventoryId());
-        if(inventoryInfo.getOperationType() == 1){//出库
-                if(inventoryInfo.getQualityType() == 1){//良品
+        if(inventoryInfo.getOperationType() == 1){
+                //出库
+                if(inventoryInfo.getQualityType() == 1){
+                    //良品
                     if(info.getInventoryGoodProductNum() >= inventoryInfo.getOperationNum()){
                         info.setInventoryGoodProductNum(info.getInventoryGoodProductNum()-inventoryInfo.getOperationNum());
                         info.setInventoryRecentRecord(sdf.format(new Date())+"良品出库:"+inventoryInfo.getOperationNum()+"件");
@@ -218,7 +220,8 @@ public class InventoryController {
                         msg.setReturnCode(502);
                         return msg;
                     }
-                }else{//不良品
+                }else{
+                    //不良品
                     if(info.getInventoryDefectiveProductNum() >= inventoryInfo.getOperationNum()){
                         info.setInventoryDefectiveProductNum(info.getInventoryDefectiveProductNum()-inventoryInfo.getOperationNum());
                         info.setInventoryRecentRecord(sdf.format(new Date())+"不良品出库:"+inventoryInfo.getOperationNum()+"件");
@@ -235,8 +238,10 @@ public class InventoryController {
 
 
 
-        }else if(inventoryInfo.getOperationType() == 2){//入库
-            if(inventoryInfo.getQualityType() == 1){//良品
+        }else if(inventoryInfo.getOperationType() == 2){
+            //入库
+            if(inventoryInfo.getQualityType() == 1){
+                //良品
                 info.setInventoryGoodProductNum(info.getInventoryGoodProductNum()+inventoryInfo.getOperationNum());
                 info.setInventoryRecentRecord(sdf.format(new Date())+"良品入库:"+inventoryInfo.getOperationNum()+"件");
                 inventoryLog.setLogType(1);
@@ -251,20 +256,22 @@ public class InventoryController {
             }
             inventoryLog.setLogOperationType(1);
         }
-        Integer num = inventoryService.updateById(info);
+        // 生成库存记录
+        inventoryLog.setLogCreateTime(new Date());
+        inventoryLog.setLogProductBar(info.getInventoryProductBar());
+        inventoryLog.setLogProductName(info.getInventoryProductName());
+        inventoryLog.setLogDesc(inventoryInfo.getInventoryDesc());
+        inventoryLog.setLogWarehouseId(1);
+        inventoryLog.setLogRemainingNum(inventoryInfo.getOperationNum());
+        info.setInventoryLog(inventoryLog);
+        // 保存记录
+        int num = inventoryService.updateById(info);
         if (num < 1) {
             msg.setResultCode(500);
             msg.setReturnCode(501);
         } else {
             msg.setResultCode(200);
             msg.setReturnCode(200);
-            inventoryLog.setLogCreateTime(new Date());
-            inventoryLog.setLogProductBar(info.getInventoryProductBar());
-            inventoryLog.setLogProductName(info.getInventoryProductName());
-            inventoryLog.setLogDesc(inventoryInfo.getInventoryDesc());
-            inventoryLog.setLogWarehouseId(1);
-            inventoryLog.setLogRemainingNum(inventoryInfo.getOperationNum());
-            inventoryLogService.insert(inventoryLog);
         }
         return msg;
     }

+ 2 - 2
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inventory/inventory_list.ftl

@@ -119,11 +119,11 @@
                                 <i class="Hui-iconfont">出库</i>
                             </a>
                             <a style="text-decoration:none" href="javascript:;" title="出入库统计"
-                               onclick="getInventoryLog('出入库统计','${path}/admin/inventory/countInventoryByDate?logProductBar=${info.inventoryProductBar!''}&logWarehouseId=${info.warehouseId!''}');">
+                               onclick="getInventoryLog('出入库统计','${path}/admin/inventory/countInventoryByDate?logProductBar=${(info.inventoryProductBar)!}&logWarehouseId=${(info.warehouseId)!}');">
                                 <i class="Hui-iconfont">出入库统计</i>
                             </a>
                             <a style="text-decoration:none" href="javascript:;" title="出入库记录"
-                               onclick="getInventoryLog('出入库记录',${path}/admin/inventory/select_inventoryLog_list?logProductBar=${info.inventoryProductBar!''}&logWarehouseId=${info.warehouseId!''}');">
+                               onclick="getInventoryLog('出入库记录','${path}/admin/inventory/select_inventoryLog_list?logProductBar=${(info.inventoryProductBar)!}&logWarehouseId=${(info.warehouseId)!}');">
                                 <i class="Hui-iconfont">出入库记录</i>
                             </a>
                             </#if>