liujiankang 6 år sedan
förälder
incheckning
d019cc1691

+ 117 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/fm/InventoryInfo.java

@@ -17,6 +17,19 @@ public class InventoryInfo implements Serializable{
     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
 
     public Integer getInventoryId() {
         return inventoryId;
@@ -81,4 +94,108 @@ public class InventoryInfo implements Serializable{
     public void setInventoryUpdateTime(Date inventoryUpdateTime) {
         this.inventoryUpdateTime = inventoryUpdateTime;
     }
+
+    public Integer getInventoryProductColorId() {
+        return inventoryProductColorId;
+    }
+
+    public void setInventoryProductColorId(Integer inventoryProductColorId) {
+        this.inventoryProductColorId = inventoryProductColorId;
+    }
+
+    public Integer getInventoryGoodProductNum() {
+        return inventoryGoodProductNum;
+    }
+
+    public void setInventoryGoodProductNum(Integer inventoryGoodProductNum) {
+        this.inventoryGoodProductNum = inventoryGoodProductNum;
+    }
+
+    public Integer getInventoryDefectiveProductNum() {
+        return inventoryDefectiveProductNum;
+    }
+
+    public void setInventoryDefectiveProductNum(Integer inventoryDefectiveProductNum) {
+        this.inventoryDefectiveProductNum = inventoryDefectiveProductNum;
+    }
+
+    public String getInventoryRecentRecord() {
+        return inventoryRecentRecord;
+    }
+
+    public void setInventoryRecentRecord(String inventoryRecentRecord) {
+        this.inventoryRecentRecord = inventoryRecentRecord;
+    }
+
+    public String getProductTypeName() {
+        return productTypeName;
+    }
+
+    public void setProductTypeName(String productTypeName) {
+        this.productTypeName = productTypeName;
+    }
+
+    public String getProductNumber() {
+        return productNumber;
+    }
+
+    public void setProductNumber(String productNumber) {
+        this.productNumber = productNumber;
+    }
+
+    public String getProductAbbreviation() {
+        return productAbbreviation;
+    }
+
+    public void setProductAbbreviation(String productAbbreviation) {
+        this.productAbbreviation = productAbbreviation;
+    }
+
+    public String getProductColorName() {
+        return productColorName;
+    }
+
+    public void setProductColorName(String productColorName) {
+        this.productColorName = productColorName;
+    }
+
+    public Integer getInventoryMomentumNum() {
+        return inventoryMomentumNum;
+    }
+
+    public void setInventoryMomentumNum(Integer inventoryMomentumNum) {
+        this.inventoryMomentumNum = inventoryMomentumNum;
+    }
+
+    public Integer getOperationType() {
+        return operationType;
+    }
+
+    public void setOperationType(Integer operationType) {
+        this.operationType = operationType;
+    }
+
+    public Integer getQualityType() {
+        return qualityType;
+    }
+
+    public void setQualityType(Integer qualityType) {
+        this.qualityType = qualityType;
+    }
+
+    public Integer getOperationNum() {
+        return operationNum;
+    }
+
+    public void setOperationNum(Integer operationNum) {
+        this.operationNum = operationNum;
+    }
+
+    public Integer getProductTypeId() {
+        return productTypeId;
+    }
+
+    public void setProductTypeId(Integer productTypeId) {
+        this.productTypeId = productTypeId;
+    }
 }

+ 9 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/fm/InventoryLog.java

@@ -19,6 +19,7 @@ public class InventoryLog implements Serializable {
     private String logDesc;//备注
     private Date logCreateTime;//创建时间
     private Date logUpdateTime;//修改时间
+    private Integer logQualityType;//1.良品 2不良品
 
     private String logWarehouseName;//仓库名称
 
@@ -109,4 +110,12 @@ public class InventoryLog implements Serializable {
     public void setLogWarehouseName(String logWarehouseName) {
         this.logWarehouseName = logWarehouseName;
     }
+
+    public Integer getLogQualityType() {
+        return logQualityType;
+    }
+
+    public void setLogQualityType(Integer logQualityType) {
+        this.logQualityType = logQualityType;
+    }
 }

+ 6 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/cm/InventoryService.java

@@ -21,4 +21,10 @@ public interface InventoryService {
      * 获取库存信息列表
      */
     Integer updateById(InventoryInfo inventoryInfo);
+    /**
+     * 根据69码获取单个库存信息
+     * @param inventoryProductBar
+     * @return
+     */
+    InventoryInfo getByInventoryByBar(String inventoryProductBar);
 }

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

@@ -38,4 +38,9 @@ public class InventoryServiceImpl implements InventoryService {
     public Integer updateById(InventoryInfo inventoryInfo) {
         return inventoryMapper.updateById(inventoryInfo);
     }
+
+    @Override
+    public InventoryInfo getByInventoryByBar(String inventoryProductBar) {
+        return inventoryMapper.getByInventoryByBar(inventoryProductBar);
+    }
 }

+ 6 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/InventoryMapper.java

@@ -15,6 +15,12 @@ public interface InventoryMapper {
      */
     InventoryInfo getByInventoryId(Integer inventoryId);
     /**
+     * 根据69码获取单个库存信息
+     * @param inventoryProductBar
+     * @return
+     */
+    InventoryInfo getByInventoryByBar(String inventoryProductBar);
+    /**
      * 获取库存信息列表
      */
     List<InventoryInfo> listByInventoryId(InventoryInfo inventoryInfo);

+ 11 - 3
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/inventoryLogMapper.xml

@@ -12,6 +12,7 @@
     <result column="log_desc" property="logDesc" jdbcType="VARCHAR" />
     <result column="log_create_time" property="logCreateTime" jdbcType="TIMESTAMP" />
     <result column="log_update_time" property="logUpdateTime" jdbcType="TIMESTAMP" />
+    <result column="log_quality_type" property="logQualityType" jdbcType="INTEGER" />
   </resultMap>
   <sql id="Base_Column_List" >
     logId,
@@ -23,7 +24,8 @@
     logOperationType,
     logDesc,
     logCreateTime,
-    logUpdateTime
+    logUpdateTime,
+    log_quality_type
   </sql>
   <select id="getByInventoryLogId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
@@ -43,6 +45,7 @@
     log_desc as logDesc,
     log_create_time as logCreateTime,
     log_update_time as logUpdateTime,
+    log_quality_type as logQualityType,
     warehouse_name as logWarehouseName
     from
     tb_rst_fm_inventory_log il
@@ -97,6 +100,9 @@
       <if test="logDesc != null and logDesc != ''" >
         log_desc = #{logDesc,jdbcType=VARCHAR},
       </if>
+      <if test="logQualityType != null and logQualityType != ''" >
+        log_quality_type = #{logQualityType,jdbcType=VARCHAR},
+      </if>
     </set>
     where logId = #{logId,jdbcType=INTEGER}
   </update>
@@ -111,7 +117,8 @@
     log_operation_type,
     log_desc,
     log_create_time,
-    log_update_time
+    log_update_time,
+    log_quality_type
     )
     values (
     #{logProductName,jdbcType=VARCHAR},
@@ -122,7 +129,8 @@
     #{logOperationType,jdbcType=INTEGER},
     #{logDesc,jdbcType=VARCHAR},
     #{logCreateTime,jdbcType=TIMESTAMP},
-    #{logUpdateTime,jdbcType=TIMESTAMP}
+    #{logUpdateTime,jdbcType=TIMESTAMP},
+    #{logQualityType,jdbcType=TIMESTAMP}
     )
   </insert>
 

+ 142 - 16
watero-rst-service/src/main/java/com/iamberry/rst/service/fm/mapper/inventoryMapper.xml

@@ -10,6 +10,15 @@
     <result column="inventory_desc" property="inventoryDesc" jdbcType="VARCHAR" />
     <result column="inventory_create_time" property="inventoryCreateTime" jdbcType="TIMESTAMP" />
     <result column="inventory_update_time" property="inventoryUpdateTime" jdbcType="TIMESTAMP" />
+    <result column="inventory_product_color_id" property="inventoryProductColorId" jdbcType="INTEGER" />
+    <result column="inventory_good_product_num" property="inventoryGoodProductNum" jdbcType="INTEGER" />
+    <result column="inventory_defective_product_num" property="inventoryDefectiveProductNum" jdbcType="INTEGER" />
+    <result column="inventory_recent_record" property="inventoryRecentRecord" jdbcType="VARCHAR" />
+    <result column="type_name" property="productTypeName" jdbcType="VARCHAR" />
+    <result column="product_number" property="productNumber" jdbcType="VARCHAR" />
+    <result column="product_abbreviation" property="productAbbreviation" jdbcType="VARCHAR" />
+    <result column="color_name" property="productColorName" jdbcType="VARCHAR" />
+    <result column="inventoryMomentumNum" property="inventoryMomentumNum" jdbcType="VARCHAR" />
   </resultMap>
   <sql id="Base_Column_List" >
     inventory_id,
@@ -19,38 +28,104 @@
     inventory_state,
     inventory_desc,
     inventory_create_time,
-    inventory_update_time
+    inventory_update_time,
+    inventory_product_color_id,
+    inventory_good_product_num,
+    inventory_defective_product_num,
+    inventory_recent_record
   </sql>
   <select id="getByInventoryId" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select 
-    <include refid="Base_Column_List" />
-    from tb_rst_fm_inventory
+    fi.inventory_id,
+    fi.inventory_product_name,
+    fi.inventory_product_bar,
+    fi.inventory_remaining_num,
+    fi.inventory_state,
+    fi.inventory_desc,
+    fi.inventory_create_time,
+    fi.inventory_update_time,
+    fi.inventory_product_color_id,
+    fi.inventory_good_product_num,
+    fi.inventory_defective_product_num,
+    fi.inventory_recent_record,
+    pt.type_name,
+    pi.product_number,
+    pi.product_abbreviation,
+    pc.color_name,
+    imn.inventoryMomentumNum
+    from tb_rst_fm_inventory fi
+    LEFT jOIN tb_rst_product_color pc on fi.inventory_product_color_id  = pc.color_id
+    LEFT jOIN tb_rst_product_info pi on pc.color_product_id  = pi.product_id
+    LEFT jOIN tb_rst_product_type pt on pi.product_type  = pt.type_id
+    LEFT jOIN (SELECT
+    SUM(soi.item_num) as inventoryMomentumNum,
+    item_color_id as colorId
+    FROM
+    tb_rst_sales_order_info oi
+    LEFT JOIN tb_rst_sales_order_item soi on soi.item_order_id = oi.sales_id
+
+    WHERE
+    oi.sales_shipping_status IN (0,3,11)
+    GROUP BY soi.item_color_id
+    ) imn on imn.colorId  = pc.color_id
     where inventory_id = #{inventoryId,jdbcType=INTEGER}
   </select>
   <select id="listByInventoryId" resultMap="BaseResultMap" parameterType="InventoryInfo" >
     select
-    inventory_id,
-    inventory_product_name,
-    inventory_product_bar,
-    inventory_remaining_num,
-    inventory_state,
-    inventory_desc,
-    inventory_create_time,
-    inventory_update_time
+    fi.inventory_id,
+    fi.inventory_product_name,
+    fi.inventory_product_bar,
+    fi.inventory_remaining_num,
+    fi.inventory_state,
+    fi.inventory_desc,
+    fi.inventory_create_time,
+    fi.inventory_update_time,
+    fi.inventory_product_color_id,
+    fi.inventory_good_product_num,
+    fi.inventory_defective_product_num,
+    fi.inventory_recent_record,
+    pt.type_name,
+    pi.product_number,
+    pi.product_abbreviation,
+    pc.color_name,
+    imn.inventoryMomentumNum
     from
-    tb_rst_fm_inventory
+    tb_rst_fm_inventory fi
+    LEFT jOIN tb_rst_product_color pc on fi.inventory_product_color_id  = pc.color_id
+    LEFT jOIN tb_rst_product_info pi on pc.color_product_id  = pi.product_id
+    LEFT jOIN tb_rst_product_type pt on pi.product_type  = pt.type_id
+    LEFT jOIN (SELECT
+    SUM(soi.item_num) as inventoryMomentumNum,
+    item_color_id as colorId
+    FROM
+    tb_rst_sales_order_info oi
+    LEFT JOIN tb_rst_sales_order_item soi on soi.item_order_id = oi.sales_id
+
+    WHERE
+    oi.sales_shipping_status IN (0,3,11)
+    GROUP BY soi.item_color_id
+    ) imn on imn.colorId  = pc.color_id
     <where>
       <if test="inventoryId != null and inventoryId != ''">
-        inventory_id = #{inventoryId}
+        fi.inventory_id = #{inventoryId}
       </if>
       <if test="inventoryProductName != null and inventoryProductName != ''">
-        and inventory_product_name like CONCAT('%',#{inventoryProductName},'%')
+        and fi.inventory_product_name like CONCAT('%',#{inventoryProductName},'%')
       </if>
       <if test="inventoryProductBar != null and inventoryProductBar != ''">
-        and inventory_product_bar = #{inventoryProductBar}
+        and fi.inventory_product_bar = #{inventoryProductBar}
       </if>
       <if test="inventoryState != null and inventoryState != ''">
-        and inventory_state = #{inventoryState}
+        and fi.inventory_state = #{inventoryState}
+      </if>
+      <if test="productTypeId != null and productTypeId != ''">
+        and pt.type_id = #{productTypeId}
+      </if>
+      <if test="productColorName != null and productColorName != ''">
+        and pc.color_name like  CONCAT ('%',#{productColorName},'%')
+      </if>
+      <if test="inventoryProductBar != null and inventoryProductBar != ''">
+        and pc.color_bar = #{inventoryProductBar}
       </if>
     </where>
   </select>
@@ -73,7 +148,58 @@
       <if test="inventoryDesc != null and inventoryDesc != ''" >
         inventory_desc = #{inventoryDesc,jdbcType=VARCHAR},
       </if>
+      <if test="inventoryProductColorId != null and inventoryProductColorId != ''" >
+        inventory_product_color_id = #{inventoryProductColorId,jdbcType=INTEGER},
+      </if>
+      <if test="inventoryGoodProductNum != null" >
+        inventory_good_product_num = #{inventoryGoodProductNum,jdbcType=INTEGER},
+      </if>
+      <if test="inventoryDefectiveProductNum != null" >
+        inventory_defective_product_num = #{inventoryDefectiveProductNum,jdbcType=INTEGER},
+      </if>
+      <if test="inventoryRecentRecord != null and inventoryRecentRecord != ''" >
+        inventory_recent_record = #{inventoryRecentRecord,jdbcType=INTEGER},
+      </if>
+
     </set>
     where inventory_id = #{inventoryId,jdbcType=INTEGER}
   </update>
+
+  <select id="getByInventoryByBar" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+    select
+    fi.inventory_id,
+    fi.inventory_product_name,
+    fi.inventory_product_bar,
+    fi.inventory_remaining_num,
+    fi.inventory_state,
+    fi.inventory_desc,
+    fi.inventory_create_time,
+    fi.inventory_update_time,
+    fi.inventory_product_color_id,
+    fi.inventory_good_product_num,
+    fi.inventory_defective_product_num,
+    fi.inventory_recent_record,
+    pt.type_name,
+    pi.product_number,
+    pi.product_abbreviation,
+    pc.color_name,
+    imn.inventoryMomentumNum
+    from tb_rst_fm_inventory fi
+    LEFT jOIN tb_rst_product_color pc on fi.inventory_product_color_id  = pc.color_id
+    LEFT jOIN tb_rst_product_info pi on pc.color_product_id  = pi.product_id
+    LEFT jOIN tb_rst_product_type pt on pi.product_type  = pt.type_id
+    LEFT jOIN (SELECT
+    SUM(soi.item_num) as inventoryMomentumNum,
+    item_color_id as colorId
+    FROM
+    tb_rst_sales_order_info oi
+    LEFT JOIN tb_rst_sales_order_item soi on soi.item_order_id = oi.sales_id
+
+    WHERE
+    oi.sales_shipping_status IN (0,3,11)
+    GROUP BY soi.item_color_id
+    ) imn on imn.colorId  = pc.color_id
+    where fi.inventory_product_bar = #{inventoryProductBar,jdbcType=INTEGER}
+  </select>
+
 </mapper>

+ 55 - 10
watero-rst-web/src/main/java/com/iamberry/rst/controllers/order/AwaitSendController.java

@@ -2,6 +2,8 @@ package com.iamberry.rst.controllers.order;
 
 import com.alibaba.fastjson.JSONObject;
 import com.iamberry.rst.core.cm.*;
+import com.iamberry.rst.core.fm.InventoryInfo;
+import com.iamberry.rst.core.fm.InventoryLog;
 import com.iamberry.rst.core.order.*;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.core.pts.PtsBatch;
@@ -59,8 +61,10 @@ public class AwaitSendController {
     private CustomerService customerService;
     @Autowired
     private CmRelationService cmRelationService;
-
-
+    @Autowired
+    private InventoryService inventoryService;
+    @Autowired
+    private InventoryLogService inventoryLogService;
     private static final Logger LOGGER = LoggerFactory.getLogger(AwaitSendController.class);
 
 
@@ -542,9 +546,16 @@ public class AwaitSendController {
                 rj.setResultMsg("出货失败,请检查该物流单号("+postNum+")和订单状态是否为已发货。");
                 return rj;
             }
-            rj = ResponseJson.getSUCCESS();
-            rj.setResultMsg("物流单号("+ postNum +")出库成功。");
-            return rj;
+            //修改库存信息
+            if(updateInventory(salesOrder.getSalesId())){
+                rj = ResponseJson.getSUCCESS();
+                rj.setResultMsg("物流单号("+ postNum +")出库成功。");
+                return rj;
+            }else{
+                rj.setResultMsg("出货失败,请检查该物流单号("+postNum+")和订单状态是否为已发货,产品库存是否充足。");
+                return rj;
+            }
+
         }
         if(salesOrder == null){
             rj.setResultMsg("出货失败,该物流单号("+postNum+")未查询到订单。");
@@ -561,15 +572,49 @@ public class AwaitSendController {
         salesOrder.setSalesDeliver(2);
         Integer flag = salesOrderService.updateDeliver(salesOrder);
         if(flag < 1){
-            rj.setResultMsg("出货失败,请检查该物流单号("+postNum+")和订单状态。");
+            rj.setResultMsg("出货失败,请检查该物流单号("+postNum+")和订单状态,产品库存是否充足。");
             return rj;
         }
         //查询出库的产品项
         List<SalesOrderItem> itemList = salesOrderService.selectSalesOrderItemList(salesOrder.getSalesId());
-        rj = ResponseJson.getSUCCESS();
-        rj.setResultMsg("物流单号("+ postNum +")出库成功。");
-        rj.addResponseKeyValue("itemList",itemList);
-        return rj;
+        //修改库存信息
+        if(updateInventory(salesOrder.getSalesId())){
+            rj = ResponseJson.getSUCCESS();
+            rj.setResultMsg("物流单号("+ postNum +")出库成功。");
+            rj.addResponseKeyValue("itemList",itemList);
+            return rj;
+        }else{
+            rj.setResultMsg("出货失败,请检查该物流单号("+postNum+")和订单状态是否为已发货,产品库存是否充足。");
+            return rj;
+        }
+    }
+
+    public boolean updateInventory(Integer salesId){
+        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 = inventoryService.getByInventoryByBar(item.getItemColorBar());
+            if(info.getInventoryDefectiveProductNum() >= item.getItemNum()){
+                info.setInventoryDefectiveProductNum(info.getInventoryDefectiveProductNum() - item.getItemNum());
+                info.setInventoryRecentRecord(sdf.format(new Date())+"出库:"+item.getItemNum()+"件");
+                inventoryService.updateById(info);
+                //添加日志
+                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()+"件");
+                inventoryLog.setLogQualityType(1);
+                inventoryLogService.insert(inventoryLog);
+            }else{
+                return false;
+            }
+        }
+        return true;
     }
 
     /**

+ 66 - 18
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/InventoryController.java

@@ -3,10 +3,13 @@ package com.iamberry.rst.controllers.pts;
 import com.iamberry.rst.core.fm.InventoryInfo;
 import com.iamberry.rst.core.fm.InventoryLog;
 import com.iamberry.rst.core.fm.WarehouseInfo;
+import com.iamberry.rst.core.order.ProductColor;
+import com.iamberry.rst.core.order.ProductType;
 import com.iamberry.rst.core.page.PageRequest;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.faces.cm.InventoryLogService;
 import com.iamberry.rst.faces.cm.InventoryService;
+import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.utils.StitchAttrUtil;
 import com.iamberry.wechat.tools.ResponseJson;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -18,6 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.servlet.ModelAndView;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -30,6 +34,8 @@ public class InventoryController {
     private InventoryService inventoryService;
     @Autowired
     private InventoryLogService inventoryLogService;
+    @Autowired
+    private ProductService productService;
 
     /**
      * 查询库存列表信息
@@ -53,8 +59,14 @@ public class InventoryController {
         StringBuilder url = new StringBuilder("/admin/inventory/select_inventory_list?pageSize=" + pageSize);
         // 封装请求数据
         PageRequest<InventoryInfo> pageRequest = new PageRequest<>(inventoryInfo, pageNO, pageSize, pageTotal == null);
-        // 查询订单列表
+        // 查询库存列表
         PagedResult<InventoryInfo> result = inventoryService.listByInventoryId(pageRequest);
+        ProductColor color = new ProductColor();
+        List<ProductColor> productColorList = productService.listProduceColor(color);
+        mv.addObject("productColorList",productColorList);
+        ProductType productType = new ProductType();
+        List<ProductType> productTypeList = productService.listProductType(productType);
+        mv.addObject("productTypeList",productTypeList);
         long total = 0;
         if (pageTotal == null) {
             total = result.getPages();
@@ -97,9 +109,9 @@ public class InventoryController {
             total = pageTotal;
             result.setPages(total);
         }
-        //查询所有仓库
+        /*//查询所有仓库
         List<WarehouseInfo> warehouseList = inventoryLogService.listFactoryInfo();
-        mv.addObject("warehouseList",warehouseList);
+        mv.addObject("warehouseList",warehouseList);*/
         StitchAttrUtil.getSa().setModelAndView(inventoryLog, mv, "/admin/Inventory/select_InventoryLog_list", result);
         return mv;
     }
@@ -133,34 +145,71 @@ public class InventoryController {
     @ResponseBody
     @RequiresPermissions("signclosed:select:signclosed")
     @RequestMapping(value = "/update_num")
-    public ResponseJson updateRemark(HttpServletRequest request,InventoryInfo inventoryInfo,Integer operationType,Integer type){
+    public ResponseJson updateRemark(HttpServletRequest request,InventoryInfo inventoryInfo){
         ResponseJson msg = new ResponseJson();
         if(inventoryInfo == null){
             msg.setResultCode(500);
             msg.setReturnCode(500);
             return msg;
         }
+        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         InventoryLog inventoryLog = new InventoryLog();
         InventoryInfo info = inventoryService.getByInventoryId(inventoryInfo.getInventoryId());
-        if(operationType == 1){//增加
-            info.setInventoryRemainingNum(info.getInventoryRemainingNum()+inventoryInfo.getInventoryRemainingNum());
+        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()+"件");
+                        inventoryLog.setLogType(2);
+                        inventoryLog.setLogQualityType(1);
+                    }else{
+                        msg.setResultCode(500);
+                        msg.setReturnCode(502);
+                        return msg;
+                    }
+                }else{//不良品
+                    if(info.getInventoryDefectiveProductNum() >= inventoryInfo.getOperationNum()){
+                        info.setInventoryDefectiveProductNum(info.getInventoryDefectiveProductNum()-inventoryInfo.getOperationNum());
+                        info.setInventoryRecentRecord(sdf.format(new Date())+"不良品出库:"+inventoryInfo.getOperationNum()+"件");
+                        inventoryLog.setLogType(3);
+                        inventoryLog.setLogQualityType(2);
+                    }else{
+                        msg.setResultCode(500);
+                        msg.setReturnCode(502);
+                        return msg;
+                    }
+                }
+                inventoryLog.setLogOperationType(2);
+
+
+
+        }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);
+                inventoryLog.setLogQualityType(1);
+            }else{//不良品
+                info.setInventoryDefectiveProductNum(info.getInventoryDefectiveProductNum()+inventoryInfo.getOperationNum());
+                info.setInventoryRecentRecord(sdf.format(new Date())+"不良品入库:"+inventoryInfo.getOperationNum()+"件");
+                inventoryLog.setLogType(3);
+                inventoryLog.setLogQualityType(2);
+            }
             inventoryLog.setLogOperationType(1);
-        }else if(operationType == 2){//减少
-            info.setInventoryRemainingNum(info.getInventoryRemainingNum()-inventoryInfo.getInventoryRemainingNum());
-            inventoryLog.setLogOperationType(2);
         }
-        Integer num = inventoryService.updateById(inventoryInfo);
+        Integer num = inventoryService.updateById(info);
         if (num < 1) {
             msg.setResultCode(500);
-            msg.setReturnCode(500);
+            msg.setReturnCode(501);
         } else {
             msg.setResultCode(200);
             msg.setReturnCode(200);
             inventoryLog.setLogCreateTime(new Date());
             inventoryLog.setLogProductBar(info.getInventoryProductBar());
             inventoryLog.setLogProductName(info.getInventoryProductName());
-            inventoryLog.setLogType(type);
+            inventoryLog.setLogDesc(inventoryInfo.getInventoryDesc());
             inventoryLog.setLogWarehouseId(inventoryInfo.getInventoryId());
+            inventoryLog.setLogRemainingNum(inventoryInfo.getOperationNum());
             inventoryLogService.insert(inventoryLog);
         }
         return msg;
@@ -172,18 +221,17 @@ public class InventoryController {
      *
      * @return
      */
+    @ResponseBody
     @RequiresPermissions("signclosed:update:signclosed")
     @RequestMapping(value = "/to_update_inventory")
-    public ModelAndView toUpdateInventory(HttpServletRequest request,Integer inventoryId) {
+    public ModelAndView toUpdateInventory(HttpServletRequest request,Integer inventoryId,Integer operationType) {
         ModelAndView mv = new ModelAndView("cm/inventory/update_inventory");
         if(inventoryId == null){
             return mv;
         }
-        //查询所有仓库
-        List<WarehouseInfo> warehouseList = inventoryLogService.listFactoryInfo();
-        InventoryInfo info = inventoryService.getByInventoryId(inventoryId);
-        mv.addObject("warehouseList",warehouseList);
-        mv.addObject("info",info);
+        InventoryInfo inventoryInfo = inventoryService.getByInventoryId(inventoryId);
+        mv.addObject("inventoryInfo",inventoryInfo);
+        mv.addObject("operationType",operationType);
         return mv;
     }
 

+ 22 - 10
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inventory/inventoryLog_list.ftl

@@ -52,10 +52,10 @@
         </select>
              <select class="my-select" name="logOperationType" style="height: 30px;width: 150px">
              <option value ="">选择操作类型</option>
-             <option value ="1" <#if logOperationType??><#if logOperationType == 1>selected="selected"</#if></#if>>增加</option>
-             <option value ="2" <#if logOperationType??><#if logOperationType == 2>selected="selected"</#if></#if>>减少</option>
+             <option value ="1" <#if logOperationType??><#if logOperationType == 1>selected="selected"</#if></#if>>入库</option>
+             <option value ="2" <#if logOperationType??><#if logOperationType == 2>selected="selected"</#if></#if>>出库</option>
         </select>
-        <select id="logWarehouseId" name="logWarehouseId" class="select" style="width: 120px;">
+        <#--<select id="logWarehouseId" name="logWarehouseId" class="select" style="width: 120px;">
         <#if (warehouseList?size > 0)>
             <#list warehouseList as info>
                 <#if logWarehouseId??>
@@ -65,7 +65,8 @@
                 </#if>
             </#list>
         </#if>
-        </select>
+        </select>-->
+            <input type="hidden" value="${logProductBar!''}" name="logProductBar">
         <button style="cursor:pointer;" type="submit" class="my-btn-search">搜索</button>
         </form>
     </div>
@@ -75,9 +76,10 @@
             <tr class="text-c">
                 <th width="100">产品名称</th>
                 <th width="100">产品sku</th>
-                <th width="100">仓库名称</th>
+                <#--<th width="100">仓库名称</th>-->
                 <th width="100">变动数量</th>
                 <th width="100">类型</th>
+                <th width="100">质量类型</th>
                 <th width="100">操作类型</th>
                 <th width="100">备注</th>
             </tr>
@@ -88,7 +90,7 @@
                 <tr>
                     <td class="text-c" width="100">${info.logProductName!}</td>
                     <td class="text-c" width="100">${info.logProductBar!}</td>
-                    <td class="text-c" width="100">${info.logWarehouseName!}</td>
+                    <#--<td class="text-c" width="100">${info.logWarehouseName!}</td>-->
                     <td class="text-c" width="100">${info.logRemainingNum!}</td>
                     <td class="text-c" width="100">
                         <#if info.logType == 1>
@@ -102,11 +104,21 @@
                         </#if>
                     </td>
                     <td class="text-c" width="100">
-                        <#if info.logType == 1>
-                            增加
+                        <#if info.logOperationType == 1>
+                            入库
                         </#if>
-                        <#if info.logType == 2>
-                            减少
+                        <#if info.logOperationType == 2>
+                            出库
+                        </#if>
+                    </td>
+                    <td class="text-c" width="100">
+                        <#if info.logQualityType??>
+                            <#if info.logQualityType == 1>
+                                良品
+                            </#if>
+                            <#if info.logQualityType == 2>
+                                不良品
+                            </#if>
                         </#if>
                     </td>
                     <td class="text-c" width="100">${info.logDesc!}</td>

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

@@ -40,9 +40,9 @@
 <div class="page-container">
     <div class="text-c">
         <form name="form1" action="${path}/admin/inventory/select_inventory_list" method="post">
-            <select id="inventoryProductBar" name="inventoryProductBar" class="select" style="width: 120px;">
-            <#if (productList?size > 0)>
-                <#list productList as product>
+            <#--<select id="inventoryProductBar" name="inventoryProductBar" class="select" style="width: 120px;">
+            <#if (productColorList?size > 0)>
+                <#list productColorList as product>
                     <#if inventoryProductBar??>
                         <option value="${product.colorBar!""}" <#if product.colorBar == inventoryProductBar>selected</#if>>${product.productName!""}</option>
                     <#else >
@@ -54,7 +54,18 @@
 
             <select id="productColorId" name="productColorId" class="select" style="width: 120px;">
 
-            </select>
+            </select>-->
+            <select class="my-select" name="productTypeId" style="height: 30px;width: 150px">
+                    <option value ="">选择产品类型</option>
+                <#if (productTypeList?size > 0)>
+                    <#list productTypeList as typeList>
+                        <option value ="${typeList.typeId!}" <#if productTypeId??><#if productTypeId == typeList.typeId>selected="selected"</#if></#if>>${typeList.typeName!}</option>
+                    </#list>
+                </#if>
+             </select>
+                <input class="my-input" style="width: 100px;height: 29px;" type="text" name="inventoryProductName" value="${inventoryProductName!}" placeholder="产品名称"/>
+                <input class="my-input" style="width: 100px;height: 29px;" type="text" name="productColorName" value="${productColorName!}" placeholder="产品颜色"/>
+                <input class="my-input" style="width: 100px;height: 29px;" type="text" name="inventoryProductBar" value="${inventoryProductBar!}" placeholder="产品69码"/>
             <button style="cursor:pointer;" type="submit" class="my-btn-search">搜索</button>
         </form>
     </div>
@@ -62,45 +73,52 @@
         <table class="table table-border table-bordered table-bg table-hover table-sort">
             <thead>
             <tr class="text-c">
+                <th width="100">产品类型</th>
                 <th width="100">产品名称</th>
-                <th width="160">产品sku</th>
-                <th width="120">库存剩余数量</th>
-                <th width="120">状态</th>
-                <th width="200">备注</th>
-                <th width="50">操作</th>
+                <#--<th width="100">产品型号</th>-->
+                <th width="100">产品简称</th>
+                <th width="100">产品颜色</th>
+                <th width="100">产品69码</th>
+                <th width="100">待发数量</th>
+                <th width="100">良品数量</th>
+                <th width="100">不良品数量</th>
+                <th width="100">最近记录</th>
+                <th width="100">操作</th>
             </tr>
             </thead>
             <tbody id="listid">
             <#if (page.dataList?size > 0)>
                 <#list page.dataList as info>
                 <tr>
+                    <td class="text-c" width="100">${info.productTypeName!}</td>
                     <td class="text-c" width="100">${info.inventoryProductName!}</td>
+                    <#--<td class="text-c" width="100">${info.productNumber!}</td>-->
+                    <td class="text-c" width="100">${info.productAbbreviation!}</td>
+                    <td class="text-c" width="100">${info.productColorName!}</td>
                     <td class="text-c" width="100">${info.inventoryProductBar!}</td>
-                    <td class="text-c" width="100">${info.inventoryRemainingNum!}</td>
-                    <td class="text-c" width="100">
-                    <#if info.inventoryState == 1>
-                        正在使用
-                    </#if>
-                    <#if info.inventoryState == 2>
-                        暂停使用
-                    </#if>
-                    </td>
-                    <td class="text-c" width="100">${info.inventoryDesc!}</td>
+                    <td class="text-c" width="100">${info.inventoryMomentumNum!}</td>
+                    <td class="text-c" width="100">${info.inventoryGoodProductNum!}</td>
+                    <td class="text-c" width="100">${info.inventoryDefectiveProductNum!}</td>
+                    <td class="text-c" width="100">${info.inventoryRecentRecord!}</td>
                     <!-- 遍历操作 -->
                     <td class="td-manage text-c">
                         <a style="text-decoration:none" href="javascript:;" title="增加库存"
-                           onclick="add_remark('增加库存','${path}/admin/inventory/to_update_inventory?inventoryId=${info.inventoryId!''}','570','450');">
-                            <i class="Hui-iconfont">&#xe600;</i>
+                           onclick="update('增加库存','${path}/admin/inventory/to_update_inventory?inventoryId=${info.inventoryId!''}&operationType=2','570','450');">
+                            <i class="Hui-iconfont">入库</i>
                         </a>
                         <a style="text-decoration:none" href="javascript:;" title="减少库存"
-                           onclick="add_remark('减少库存','${path}/admin/inventory/to_update_inventory?inventoryId=${info.inventoryId!''}','570','450');">
-                            <i class="Hui-iconfont">&#xe6a1;</i>
+                           onclick="update('减少库存','${path}/admin/inventory/to_update_inventory?inventoryId=${info.inventoryId!''}&operationType=1','570','450');">
+                            <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!''}');">
+                            <i class="Hui-iconfont">出入库记录</i>
                         </a>
                     </td>
                 </tr>
                 </#list>
             <#else >
-            <tr><td class="td-manage text-c" colspan = "6">暂时没有库存信息</td></tr>
+            <tr><td class="td-manage text-c" colspan = "11">暂时没有库存信息</td></tr>
             </#if>
             </tbody>
         </table>
@@ -110,17 +128,15 @@
 <#include "/base/page_util.ftl">
 <script type="text/javascript" src="${path}/common/lib/jquery.PrintArea/jquery.PrintArea.js"></script>
 <script type="text/javascript">
-    /**
-     * 进入查询问题描述信息页面
-     */
-    function getDescribeInfo(customerId) {
-        layer_show("问题描述","${path}/admin/customer/_question_describe?customerId="+customerId,"800","500");
-    }
-    /*转入品检*/
-    function into_complaint(title,url,w,h){
+    /*修改*/
+    function update(title,url,w,h){
         layer_show(title,url,w,h);
     }
-    $(function(){
+    function getInventoryLog(url) {
+        location.href = url;
+    }
+
+    /*$(function(){
         getProduct($("#productId").children('option:selected').val())
     });
     //查询产品颜色信息
@@ -153,7 +169,7 @@
                 layer.msg('添加错误',{icon: 5,time:1000});
             }
         });
-    }
+    }*/
 </script>
 </body>
 </html>

+ 143 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/cm/inventory/update_inventory.ftl

@@ -0,0 +1,143 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta name="renderer" content="webkit|ie-comp|ie-stand">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
+    <meta http-equiv="Cache-Control" content="no-siteapp" />
+<#include "/base/add_base.ftl">
+    <title>修改库存数量</title>
+    <style>
+        .my-title{font-weight: 500;padding-left: 15px;position: relative;}
+        .my-title:after{content: '';position: absolute;left: 0;top:12%;width: 3px;height: 80%;background: #32a3d8;}
+        .my-input{padding: 8px 5px;width: 80%;border:1px solid rgba(0,0,0,.1);}
+        .my-input-date{padding: 8px 10px;border:1px solid rgba(0,0,0,.1);width: 80%;background: url(http://s.iamberry.com/images/rili-1.png) 98.5% center no-repeat; background-size:auto 50%;}
+        .input-box{margin: 18px 0;}
+        .input-dic{float: left;margin:5px 10px 0 0;font-size: 12px;}
+        .add-list{list-style-type: none;padding: 10px;background-color: #f5f5f5;width: 60%;float: left;margin: 0;}
+        .add-list>li{margin: 10px 0;}
+        .my-textarea{padding: 5px 10px;width: 80%;border:1px solid rgba(0,0,0,.1);}
+        .my-btn-reset{padding: 10px 20px;width: 150px; background-color: #fff;color: #32a3d8;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
+        .my-btn-submit{padding: 10px 20px;width: 150px; background-color: #32a3d8;color: #fff;border: 1px solid #32a3d8;cursor:pointer;margin: 10px 10px 0 10px;}
+        .my-select{border: 1px solid rgba(0,0,0,.1);padding:6px 50px 6px 15px;height: 34px; -webkit-appearance:none;appearance:none;background: url(/common/images/pts/select-11.png) right center no-repeat;background-size:auto 100%;}
+        input[type=radio]{-webkit-appearance:none;appearance:none;background: url(/common/images/pts/radio-1.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
+        input[type=radio]:checked{-webkit-appearance:none;appearance:none;background: url(/common/images/pts/radio-2.png) center center no-repeat;background-size:auto 100%;width: 20px;height: 20px;margin-right: 10px;}
+    </style>
+    <meta name="keywords" content="${path}">
+    <meta name="description" content="H-ui.admin v3.0,是一款由国人开发的轻量级扁平化网站后台模板,完全免费开源的网站后台管理系统模版,适合中小型CMS后台系统。">
+</head>
+<body>
+<article class="page-container">
+    <form class="form form-horizontal" id="form-admin-add">
+        <div class="row cl">
+            <div class="formControls col-12 col-sm-12">
+                <strong>寄回状态</strong>
+                <div class="radio-box">
+                    <input type="radio" id="tel-b1" name="operationType" value="1" <#if operationType == 1>checked</#if>>
+                    <label for="tel-b1">出库</label>
+                </div>
+                <div class="radio-box">
+                    <input type="radio" id="tel-b2" name="operationType" value="2" <#if operationType == 2>checked</#if>>
+                    <label for="tel-b2">入库</label>
+                </div>
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="formControls col-12 col-sm-12">
+                <strong>质量类型</strong>
+                <div class="radio-box">
+                    <input type="radio" id="tel-b1" name="qualityType" checked value="1">
+                    <label for="tel-b1">良品</label>
+                </div>
+                <div class="radio-box">
+                    <input type="radio" id="tel-b2" name="qualityType" value="2">
+                    <label for="tel-b2">不良品</label>
+                </div>
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="formControls col-12 col-sm-12">
+                <strong>操作产品</strong>
+                <div class="radio-box">
+                    <span>${inventoryInfo.inventoryProductName!''}(${inventoryInfo.productColorName!''})</span><br>
+                </div>
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="formControls col-12 col-sm-12">
+                <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>
+                <div class="radio-box" style="color: #6d6d72;">
+                    <span id="inventoryGoodProductNumId">良品库存剩余:${inventoryInfo.inventoryGoodProductNum!''}</span>&nbsp;&nbsp;&nbsp;
+                    <span id="inventoryDefectiveProductNumId">不良品库存剩余:${inventoryInfo.inventoryDefectiveProductNum!''}</span>
+                </div>
+            </div>
+        </div>
+        <div class="row cl" style="position: relative;" >
+            <div class="formControls col-12 col-sm-12">
+                <strong>操作数量</strong>
+                <div class="radio-box">
+                    <input type="text" style="width: 244px;" class="input-text" value="" placeholder="请输入本次入库、出库数量" id="operationNum" name="operationNum">
+                </div>
+            </div>
+        </div>
+        <div class="row cl">
+            <div class="formControls col-12 col-sm-12">
+                <strong>操作备注</strong>
+                <div class="radio-box">
+                    <textarea type="text" placeholder="" id="inventoryDesc" name="inventoryDesc" style="width: 244px;height: 80px;"></textarea>
+                </div>
+            </div>
+        </div>
+        <input type="hidden" value="${inventoryInfo.inventoryId!''}" id="inventoryId" name="inventoryId">
+
+        <div style="text-align:center;" >
+            <button type="button" class="my-btn-submit" onclick="update();">确认提交</button>
+        </div>
+
+    </form>
+</article>
+<script type="text/javascript" src="${path}/common/lib/My97DatePicker/4.8/WdatePicker.js"></script>
+<script type="text/javascript">
+
+    /**
+     * 修改库存
+     */
+    function update(){
+        var operationType = parseInt($("input[name='operationType']:checked").val());
+        var qualityType = parseInt($("input[name='qualityType']:checked").val());
+        var operationNum = cufte($("#operationNum").val());
+        var inventoryDesc = cufte($("#inventoryDesc").val());
+        var inventoryId = cufte($("#inventoryId").val());
+        $.ajax('${path}/admin/inventory/update_num?dates=' + new Date().getTime(), {
+            data: {
+                "operationType":operationType,
+                "qualityType":qualityType,
+                "operationNum" : operationNum,
+                "inventoryDesc" : inventoryDesc,
+                "inventoryId" : inventoryId
+            },
+            dataType: 'json',
+            type: 'post',
+            timeout: 15000,
+            success: function(dt) {
+                if (dt.returnCode === 200) {
+                    layer.msg('操作成功',{icon: 1,time:1000},function () {
+                        window.parent.location.reload();
+                        var index = parent.layer.getFrameIndex(window.name);
+                        parent.layer.close(index)
+                    });
+                }else if(dt.returnCode === 502){
+                    layer.msg('剩余库存不足',{icon: 5,time:1000});
+                }
+
+            },
+            error: function(xhr, type, errorThrown) {
+                layer.msg("操作失败,请重试!", {icon: 5, time: 3000});
+            }
+        });
+    }
+
+</script>
+</body>
+</html>