Sfoglia il codice sorgente

Merge branch 'master' of http://git.iamberry.com/hexiugang/iamberry-common-parent

# Conflicts:
#	watero-rst-web/src/main/webapp/WEB-INF/views/order/salesOrder/add_order.ftl
liujiankang 5 anni fa
parent
commit
9998ac3d22

+ 9 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/order/ProductColor.java

@@ -60,6 +60,7 @@ public class ProductColor implements Serializable {
     private String colorIds;       //颜色id
     private String[] colorIdStr;       //颜色id
     private String colorlabel;       //标签(导入订单用)
+    private Integer inventoryGoodProductNum;       //产品良品库存数量
 
     public String getProductName() {
         return productName;
@@ -253,6 +254,14 @@ public class ProductColor implements Serializable {
         this.colorlabel = colorlabel;
     }
 
+    public Integer getInventoryGoodProductNum() {
+        return inventoryGoodProductNum;
+    }
+
+    public void setInventoryGoodProductNum(Integer inventoryGoodProductNum) {
+        this.inventoryGoodProductNum = inventoryGoodProductNum;
+    }
+
     @Override
     public String toString() {
         return "ProductColor{" +

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

@@ -211,7 +211,8 @@
     inventory_product_color_id,
     inventory_good_product_num,
     inventory_defective_product_num,
-    inventory_recent_record)
+    inventory_recent_record,
+    warehouse_id)
      VALUES
       (
       #{inventoryId},
@@ -223,7 +224,8 @@
     #{inventoryProductColorId},
     #{inventoryGoodProductNum},
     #{inventoryDefectiveProductNum},
-    #{inventoryRecentRecord}
+    #{inventoryRecentRecord},
+    #{warehouseId}
     )
   </insert>
 </mapper>

+ 54 - 10
watero-rst-service/src/main/java/com/iamberry/rst/service/product/ProductServiceImpl.java

@@ -1,6 +1,7 @@
 package com.iamberry.rst.service.product;
 
 import com.github.pagehelper.PageHelper;
+import com.iamberry.rst.core.fm.InventoryInfo;
 import com.iamberry.rst.core.order.Product;
 import com.iamberry.rst.core.order.ProductAreaRela;
 import com.iamberry.rst.core.order.ProductColor;
@@ -8,6 +9,7 @@ import com.iamberry.rst.core.order.ProductType;
 import com.iamberry.rst.core.page.PagedResult;
 import com.iamberry.rst.core.product.Gift;
 import com.iamberry.rst.core.product.OrderGift;
+import com.iamberry.rst.faces.cm.InventoryService;
 import com.iamberry.rst.faces.product.ProductService;
 import com.iamberry.rst.service.product.mapper.ProductAreaRelaMapper;
 import com.iamberry.rst.service.product.mapper.ProductColorMapper;
@@ -34,7 +36,8 @@ public class ProductServiceImpl implements ProductService {
     private ProductColorMapper productColorMapper;
     @Autowired
     private ProductAreaRelaMapper productAreaRelaMapper;
-
+    @Autowired
+    private InventoryService inventoryService;
     @Override
     public List<OrderGift> listGift() {
         return productMapper.listGift(new OrderGift());
@@ -200,12 +203,32 @@ public class ProductServiceImpl implements ProductService {
         List<ProductColor> productColorList = product.getColorList();
         for (ProductColor productColor : productColorList) {
             productColor.setColorProductId(product.getProductId());
+            flag = productColorMapper.save(productColor);
+            if(flag < 1){
+                throw new RuntimeException("添加颜色集合失败");
+            }
+            if(productColor.getInventoryGoodProductNum() != null && productColor.getInventoryGoodProductNum() > 0){
+                InventoryInfo inventoryInfo = new InventoryInfo();
+                inventoryInfo.setInventoryProductColorId(productColor.getColorId());
+                inventoryInfo.setInventoryProductName(product.getProductName());
+                inventoryInfo.setInventoryProductBar(productColor.getColorBar());
+                inventoryInfo.setInventoryRemainingNum(10000);
+                inventoryInfo.setInventoryState(1);
+                inventoryInfo.setWarehouseId(1);
+                inventoryInfo.setInventoryGoodProductNum(productColor.getInventoryGoodProductNum());
+                inventoryInfo.setInventoryDefectiveProductNum(0);
+                if(inventoryService.getByInventoryByBar(productColor.getColorBar(),1) !=null){
+                    throw new RuntimeException("添加产品库存失败");
+                }
+                if(inventoryService.insert(inventoryInfo) < 1){
+                    throw new RuntimeException("添加产品库存失败");
+                }
+                inventoryInfo.setWarehouseId(2);
+                if(inventoryService.insert(inventoryInfo) < 1){
+                    throw new RuntimeException("添加产品售后仓库库存失败");
+                }
+            }
         }
-        flag = productColorMapper.saveList(productColorList);
-        if(flag < 1){
-            throw new RuntimeException("添加颜色集合失败");
-        }
-
         //添加产品区域使用
         if(product.getProductAreaRelaList() != null && product.getProductAreaRelaList().size() > 0){
             for (ProductAreaRela productAreaRela:product.getProductAreaRelaList()) {
@@ -278,10 +301,31 @@ public class ProductServiceImpl implements ProductService {
         if(addProductColorList.size() > 0){
             for (ProductColor productColor : addProductColorList) {
                 productColor.setColorProductId(product.getProductId());
-            }
-            flag = productColorMapper.saveList(addProductColorList);
-            if(flag < 1){
-                throw new RuntimeException("添加颜色集合失败");
+                flag = productColorMapper.save(productColor);
+                if(flag < 1){
+                    throw new RuntimeException("添加颜色集合失败");
+                }
+                if(productColor.getInventoryGoodProductNum() != null && productColor.getInventoryGoodProductNum() > 0){
+                    InventoryInfo inventoryInfo = new InventoryInfo();
+                    inventoryInfo.setInventoryProductColorId(productColor.getColorId());
+                    inventoryInfo.setInventoryProductName(product.getProductName());
+                    inventoryInfo.setInventoryProductBar(productColor.getColorBar());
+                    inventoryInfo.setInventoryRemainingNum(10000);
+                    inventoryInfo.setInventoryState(1);
+                    inventoryInfo.setWarehouseId(1);
+                    inventoryInfo.setInventoryGoodProductNum(productColor.getInventoryGoodProductNum());
+                    inventoryInfo.setInventoryDefectiveProductNum(0);
+                    if(inventoryService.getByInventoryByBar(productColor.getColorBar(),1) !=null){
+                        throw new RuntimeException("添加产品库存失败");
+                    }
+                    if(inventoryService.insert(inventoryInfo) < 1){
+                        throw new RuntimeException("添加产品库存失败");
+                    }
+                    inventoryInfo.setWarehouseId(2);
+                    if(inventoryService.insert(inventoryInfo) < 1){
+                        throw new RuntimeException("添加产品售后仓库库存失败");
+                    }
+                }
             }
         }
         //添加颜色 -end

+ 6 - 2
watero-rst-service/src/main/java/com/iamberry/rst/service/product/mapper/productColorMapper.xml

@@ -15,6 +15,7 @@
         <result    column="color_update_time"    property="colorUpdateTime" />
         <result    column="color_is_machine"    property="colorIsMachine" />
         <result    column="color_is_weight"    property="colorIsWeight" />
+        <result    column="inventory_good_product_num"    property="inventoryGoodProductNum" />
     </resultMap>
     <sql    id="Base_List" >
         t.color_id,
@@ -35,8 +36,10 @@
     </sql>
     <select id="getProductColorList" resultMap="BaseResultMap" parameterType="ProductColor" >
         select
-        <include refid="Base_List" />
+        <include refid="Base_List" />,
+        i.inventory_good_product_num
         from tb_rst_product_color t
+        LEFT JOIN tb_rst_fm_inventory i on i.inventory_product_color_id = t.color_id
         <where>
             <if test="colorId != null ">
                 AND t.color_id = #{colorId}
@@ -57,6 +60,7 @@
                 AND t.color_status = #{colorStatus}
             </if >
         </where>
+        group By t.color_id
     </select>
     <select id="getProductColorById" resultMap="BaseResultMap" parameterType="Integer" >
         select
@@ -70,7 +74,7 @@
         from tb_rst_product_color t
         where t.color_bar= #{colorBar}
     </select>
-    <insert id="save" parameterType="ProductColor" >
+    <insert id="save" parameterType="ProductColor"  useGeneratedKeys="true"  keyProperty="colorId" >
         insert into
         tb_rst_product_color
         (

+ 26 - 19
watero-rst-web/src/main/java/com/iamberry/rst/controllers/pts/InventoryController.java

@@ -268,32 +268,39 @@ public class InventoryController {
         mv.addObject("operationType",operationType);
         return mv;
     }
+
     /**
-     * 添加产品数据到库存表
+     * 添加产品良品库存
      *
      * @return
      */
     @ResponseBody
-    @RequestMapping(value = "/addInventory")
-    public String toUpdateInventory(HttpServletRequest request,Integer colorId) {
-        ProductColor color = new ProductColor();
-        color.setColorId(colorId);
-        List<ProductColor> listColor  = productColorService.getProductColorList(color);
-        for(ProductColor productColor : listColor){
-            Product product = productService.getProductById(productColor.getColorId());
-            InventoryInfo inventoryInfo = new InventoryInfo();
-            inventoryInfo.setInventoryProductName(product.getProductName());
-            inventoryInfo.setInventoryProductBar(productColor.getColorBar());
-            inventoryInfo.setInventoryRemainingNum(10000);
-            inventoryInfo.setInventoryState(1);
-            inventoryInfo.setInventoryProductColorId(productColor.getColorId());
-            inventoryInfo.setInventoryGoodProductNum(10000);
-            inventoryInfo.setInventoryDefectiveProductNum(0);
-            inventoryService.insert(inventoryInfo);
+    @RequestMapping(value = "/addProductInventory")
+    public ResponseJson addProductInventory(HttpServletRequest request,InventoryInfo inventoryInfo) {
+        ResponseJson msg = new ResponseJson();
+        if(inventoryInfo.getInventoryProductColorId() == null || inventoryInfo.getInventoryGoodProductNum() == null){
+            msg.setResultCode(500);
+            msg.setReturnCode(500);
+            return msg;
         }
-        return "true";
+        ProductColor color  = productColorService.getProductColorById(inventoryInfo.getInventoryProductColorId());
+        Product product = productService.getProductById(color.getColorId());
+        inventoryInfo.setInventoryProductName(product.getProductName());
+        inventoryInfo.setInventoryProductBar(color.getColorBar());
+        inventoryInfo.setInventoryRemainingNum(10000);
+        inventoryInfo.setInventoryState(1);
+        inventoryInfo.setInventoryDefectiveProductNum(0);
+        if(inventoryService.getByInventoryByBar(color.getColorBar(),1) !=null){
+            msg.setResultCode(500);
+            msg.setReturnCode(501);
+            return msg;
+        }
+        if(inventoryService.insert(inventoryInfo) > 0){
+            msg.setResultCode(200);
+            msg.setReturnCode(200);
+        }
+        return msg;
     }
 
 
-
 }

+ 20 - 1
watero-rst-web/src/main/webapp/WEB-INF/views/product/add_product.ftl

@@ -169,11 +169,12 @@
                                 <th style="text-align: center;" width="10"><span class="c-red">*</span>是否为水机</th>
                                 <th style="text-align: center;" width="10"><span class="c-red">*</span>状态</th>
                                 <th style="text-align: center;" width="20">图片</th>
+                                <th style="text-align: center;" width="20">库存</th>
                                 <th style="text-align: center;" width="5">操作</th>
                             </tr>
                         </thead>
                         <tbody id="add_color_id">
-                            <tr><td colspan="12" class="td-manage text-c" >暂时没有颜色,请添加!</td></tr>
+                            <tr><td colspan="13" class="td-manage text-c" >暂时没有颜色,请添加!</td></tr>
                         </tbody>
                     </table>
 
@@ -270,6 +271,24 @@
                 </div>
             </div>
 
+            <div id="addInventoryHtml" style="display: none">
+                <input type="hidden" id="inventoryProductColorId" class="inventoryProductColorId" value="">
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>库存数量:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text  str inventoryGoodProductNum" value="" placeholder="填写库存数量" id="inventoryGoodProductNum" name="inventoryGoodProductNum" myMinlength="1" myMaxlength="12" errormsg="库存数量必填!" >
+                    </div>
+                </div>
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"></label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="button" class="btn btn-primary add-color-button" onclick="addProductInventory()" value="添加" >
+                        <input style="margin-left: 10px;" type="button" class="btn btn-default cancel-color-button" onclick="cancel_inventory()" value="取消" >
+                    </div>
+                </div>
+            </div>
+
+
             <input type="hidden" id="colorListJson" name="colorListJson" value="" >
             <input type="hidden" id="productAreaRelaStr" name="productAreaRelaStr" value="" >
 

+ 18 - 0
watero-rst-web/src/main/webapp/WEB-INF/views/product/update_product.ftl

@@ -171,6 +171,7 @@
                             <th  width="10"><span class="c-red">*</span>是否为水机</th>
                             <th  width="10"><span class="c-red">*</span>状态</th>
                             <th  width="20">图片</th>
+                            <th  width="20">库存</th>
                             <th  width="5">操作</th>
                         </tr>
                         </thead>
@@ -201,6 +202,7 @@
                                             <img style="width: 40px;" src="<#if productColor.colorPicture?? && productColor.colorPicture?length gt 0 >${path}/${productColor.colorPicture}</#if>"  class="colorPictureMsg" >
                                             <input type="hidden"  class="colorPicture" value="${productColor.colorPicture}">
                                         </td>
+                                        <td width="10"><input type="hidden"  class="colorInventory" value="${productColor.inventoryGoodProductNum!''}"><span class="colorInventoryMsg">${productColor.inventoryGoodProductNum!''}</span></td>
                                         <td width="5">
                                             <a href="javascript:void(0)" class="del_product all_down" onclick="updTr($(this))" >修改</a>&nbsp;&nbsp;
                                             <a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a>
@@ -302,6 +304,22 @@
                     </div>
                 </div>
             </div>
+            <div id="addInventoryHtml" style="display: none">
+                <input type="hidden" id="inventoryProductColorId" class="inventoryProductColorId" value="">
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"><span class="c-red">*</span>库存数量:</label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="text" class="input-text  str inventoryGoodProductNum" value="" placeholder="填写库存数量" id="inventoryGoodProductNum" name="inventoryGoodProductNum" myMinlength="1" myMaxlength="12" errormsg="库存数量必填!" >
+                    </div>
+                </div>
+                <div class="row cl" id="" style="">
+                    <label class="form-label col-1 col-sm-1"></label>
+                    <div class="formControls col-2 col-sm-2">
+                        <input type="button" class="btn btn-primary add-color-button" onclick="addProductInventory()" value="添加" >
+                        <input style="margin-left: 10px;" type="button" class="btn btn-default cancel-color-button" onclick="cancel_inventory()" value="取消" >
+                    </div>
+                </div>
+            </div>
 
             <input type="hidden" id="colorListJson" name="colorListJson" value="" >
             <input type="hidden" id="productAreaRelaStr" name="productAreaRelaStr" value="" >

+ 49 - 6
watero-rst-web/src/main/webapp/common/js/product/product.js

@@ -5,6 +5,7 @@ var color_is_update = 1;    //1是添加  2是修改
  * 添加颜色
  */
 function add_color(isUpdate){
+    $("#addInventoryHtml").hide();
     var $node = $("#addColorHtml");
     var flag = verificationColor();
     if(!flag){
@@ -56,9 +57,14 @@ function add_color(isUpdate){
             + '<img style="width: 40px;" src="' + showImg + '"  class="colorPictureMsg" >'
             + '<input type="hidden"  class="colorPicture" value="'+ img +'">'
             + '</td>';
+        colorHtml += '<td width="40" >' +
+            '<input type="hidden"  class="colorInventory" value="0">'+
+            '<span class="colorInventoryMsg" >0</span>'+
+            '</td>';
         colorHtml += '<td width="40">' +
             '<a href="javascript:void(0)" class="del_product all_down" onclick="updTr($(this))" >修改</a>&nbsp;&nbsp;' +
-            '<a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a>' +
+            '<a href="javascript:void(0)" class="del_product all_down" onclick="delTr($(this))" >删除</a><br>' +
+            '<a href="javascript:void(0)" class="del_product all_down" onclick="to_inventory($(this))" >添加库存</a>' +
             '</td>';
         colorHtml += '</tr>';
         if(isHaveColorList == 2){
@@ -303,6 +309,7 @@ function getColorList(){
         color.colorPicture = cufte($(this).find(".colorPicture").val());
         color.colorIsMachine = cufte($(this).find('.colorIsMachine').val());
         color.colorStatus = cufte($(this).find('.colorStatus').val());
+        color.inventoryGoodProductNum = cufte($(this).find('.colorInventory').val());
         colorList.push(color);
     });
     return colorList;
@@ -401,15 +408,51 @@ function fileUpload(idValue) {
         dataType: 'json',   //json
         success: function (data) {
             if (data.returnCode == 200) {
-                var html = '<div><img style="width: 75px;" src="' + url_path +"/"+ data.returnMsg.imgUrl + '"  class="del_product all_down " >&nbsp;&nbsp;<a href="javascript:void(0)" onclick="fileOnclick(this)">重新上传</a></div>';
+                var html = '<div><img style="width: 75px;" src="' + url_path + "/" + data.returnMsg.imgUrl + '"  class="del_product all_down " >&nbsp;&nbsp;<a href="javascript:void(0)" onclick="fileOnclick(this)">重新上传</a></div>';
                 $("#" + idValue).parent().find(".download_file").html(html);
-                $("#"+idValue).parent().find(".colorPicture").val(data.returnMsg.imgUrl);
-                $("#upload_color_img").change(function() {
+                $("#" + idValue).parent().find(".colorPicture").val(data.returnMsg.imgUrl);
+                $("#upload_color_img").change(function () {
                     fileUpload("upload_color_img");
                 });
-            }else{
-                layer.msg('上传失败,请重试!',{icon: 5,time:2000});
+            } else {
+                layer.msg('上传失败,请重试!', {icon: 5, time: 2000});
             }
         }
     });
 }
+/**
+ * 取消添加库存
+ */
+function cancel_inventory() {
+    $("#addInventoryHtml").hide();
+}
+
+/**
+ * 添加库存
+ */
+function to_inventory($this) {
+    $this = $this.parents("tr");
+    var $addColor = $("#addInventoryHtml");
+    $addColor.find(".inventoryProductColorId").val($this.find(".colorId").val());
+    $("#addInventoryHtml").show();
+    $("#addColorHtml").hide();
+}
+function addProductInventory() {
+    var $addColor = $("#addInventoryHtml");
+    var colorId = $addColor.find(".inventoryProductColorId").val();
+    var inventoryGoodProductNum = $("#inventoryGoodProductNum").val();
+    $("#add_color_id").find("tr").each(function () {
+        if($(this).find(".colorId").val() == colorId){
+            $(this).find(".colorInventory").val(inventoryGoodProductNum);
+            $(this).find(".colorInventoryMsg").html(inventoryGoodProductNum);
+            $addColor.find(".inventoryProductColorId").val("");
+/*            layer.msg('产品添加完成后,请联系业务经理添加产品在各个客户的销售价格,并联系采购部门增加采购成本价格', {icon: 5, time: 5000});*/
+            layer.confirm('产品添加完成后,请联系业务经理添加产品在各个客户的销售价格,并联系采购部门增加采购成本价格', {
+                btn: ['确认'] //按钮
+            }, function(){
+                layer.closeAll();
+            });
+        }
+    })
+    $("#addInventoryHtml").hide();
+}