Sfoglia il codice sorgente

审批系统开发

liujiankang 6 anni fa
parent
commit
431b399bc5

+ 9 - 0
watero-rst-core/src/main/java/com.iamberry.rst.core/approval/ApprovalInventoryRecords.java

@@ -9,6 +9,7 @@ public class ApprovalInventoryRecords implements Serializable {
     private static final long serialVersionUID = -2060549066223267336L;
     private Integer storageId;//
     private Integer approvalId;//审批订单id
+    private Integer itemId;//审批订单产品项id
     private Integer storageState;//入库状态
     private Integer productId;//产品id
     private String productName;//产品名称
@@ -106,4 +107,12 @@ public class ApprovalInventoryRecords implements Serializable {
     public void setOperatingTime(Integer operatingTime) {
         this.operatingTime = operatingTime;
     }
+
+    public Integer getItemId() {
+        return itemId;
+    }
+
+    public void setItemId(Integer itemId) {
+        this.itemId = itemId;
+    }
 }

+ 5 - 0
watero-rst-interface/src/main/java/com/iamberry/rst/faces/approval/ApprovalOrderService.java

@@ -91,4 +91,9 @@ public interface ApprovalOrderService {
      * @return
      */
     Integer insertInventoryRecords(ApprovalInventoryRecords approvalInventoryRecords);
+    /**
+     * 查询单个审批订单项
+     * @return
+     */
+    ApprovalProductionItem getProductionItem(Integer itemId);
 }

+ 5 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/approval/ApprovalOrderServiceImpl.java

@@ -204,4 +204,9 @@ public class ApprovalOrderServiceImpl implements ApprovalOrderService {
     public Integer insertInventoryRecords(ApprovalInventoryRecords approvalInventoryRecords) {
         return approvalOrderMapper.insertInventoryRecords(approvalInventoryRecords);
     }
+
+    @Override
+    public ApprovalProductionItem getProductionItem(Integer itemId) {
+        return approvalOrderMapper.getProductionItem(itemId);
+    }
 }

+ 5 - 0
watero-rst-service/src/main/java/com/iamberry/rst/service/approval/mapper/ApprovalOrderMapper.java

@@ -80,6 +80,11 @@ public interface ApprovalOrderMapper {
       * @return
       */
      Integer insertInventoryRecords(ApprovalInventoryRecords approvalInventoryRecords);
+     /**
+      * 查询单个审批订单项
+      * @return
+      */
+     ApprovalProductionItem getProductionItem(Integer itemId);
 
 
 

+ 28 - 10
watero-rst-service/src/main/java/com/iamberry/rst/service/approval/mapper/approvalOrderMapper.xml

@@ -333,7 +333,7 @@
   </select>
 
 
-  <!--查询提货产品项信息-->
+  <!--查询审批产品项信息-->
   <select id="listProductionItem" parameterType="Integer" resultType="ApprovalProductionItem">
     SELECT
     api.item_id itemId,
@@ -483,23 +483,18 @@
       <if test="itemShouldStorage != null" >
         item_should_storage = #{itemShouldStorage},
       </if>
-      <if test="itemActualStorage != null" >
-        item_actual_storage = #{itemActualStorage},
-      </if>
       <if test="itemLackNumber != null" >
         item_lack_number = #{itemLackNumber}
       </if>
     </set>
-    <where>
-      <if test="itemId != null and itemId != ''">
-        item_id = #{itemId}
-      </if>
-    </where>
+    WHERE
+    item_id = #{itemId}
   </update>
   <!-- 添加仓库入库记录-->
   <insert id="insertInventoryRecords" parameterType="ApprovalInventoryRecords">
     INSERT INTO tb_rst_approval_inventory_records(
     approval_id,
+    item_id,
     storage_state,
     product_id,
     product_name,
@@ -511,8 +506,31 @@
     operating_time
     )
     VALUES
-    (#{approvalId},#{storageState},#{productId}
+    (#{approvalId},#{itemId},#{storageState},#{productId}
     ,#{productName},#{colorName},#{shouldStorage}
     ,#{actualStorage},#{lackNumber},#{operatingAdminId},NOW())
   </insert>
+
+  <!--查询单个审批产品项信息-->
+  <select id="getProductionItem" parameterType="Integer" resultType="ApprovalProductionItem">
+    SELECT
+    api.item_id itemId,
+    api.production_id productionId,
+    api.product_id productId,
+    api.item_product_name itemProductName,
+    api.item_color_name itemColorName,
+    api.item_product_num itemProductNum,
+    api.item_brand_name itemBrandName,
+    api.item_product_model itemProductModel,
+    api.item_product_unit itemProductUnit,
+    api.item_product_box_number itemProductBoxNumber,
+    api.item_should_storage itemShouldStorage,
+    api.item_actual_storage itemActualStorage,
+    api.item_lack_number itemLackNumber,
+    api.item_create_time itemCreateTime,
+    api.item_update_time itemUpdateTime
+    from tb_rst_approval_production_item api
+    where
+    api.item_id = #{itemId}
+  </select>
 </mapper>

+ 57 - 0
watero-rst-web/src/main/java/com/iamberry/rst/controllers/approval/ApprovalController.java

@@ -335,4 +335,61 @@ public class ApprovalController {
         return rj;
     }
 
+    /**
+     * 添加入库信息
+     * @param request
+     * @param inventoryRecordss
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/addInventoryRecords")
+    public ResponseJson addInventoryRecords(HttpServletRequest request, String inventoryRecordss){
+        ResponseJson rj =new ResponseJson(200, "添加成功", 200);
+        if (inventoryRecordss == null || inventoryRecordss.equals("")) {
+            return  ResponseJson.getFAILURE();
+        }
+        //获取openid,根据openid查询当前登录人信息
+        String openId = WechatUtils.getUserBySession(request).getUserOpenid();
+        Admin admin = sysService.getByOpenid(openId);
+        if(admin == null){
+            return new ResponseJson(200, "未查询到登录人信息", 500);
+        }
+        JSONArray jsonRecordss = JSONArray.fromObject(inventoryRecordss);
+        for (int i = 0; i < jsonRecordss.size(); i++) {
+            JSONObject jsonRecords = jsonRecordss.getJSONObject(i);
+            //封装入库信息
+            ApprovalInventoryRecords records = new ApprovalInventoryRecords();
+            if(jsonRecords.get("shouldStorage") == null || jsonRecords.get("actualStorage") == null){
+                if(jsonRecords.getInt("shouldStorage") < jsonRecords.getInt("actualStorage")){
+                    return new ResponseJson(200, "实际入库数量不得大于应入库数量", 500);
+                }
+            }
+            records.setStorageState(jsonRecords.getInt("shouldStorage") > jsonRecords.getInt("actualStorage") ? 1 : 2);
+            records.setApprovalId(jsonRecords.getInt("approvalId"));
+            records.setProductName(jsonRecords.getString("productName"));
+            records.setColorName(jsonRecords.getString("colorName"));
+            records.setActualStorage(jsonRecords.getInt("actualStorage"));
+            records.setShouldStorage(jsonRecords.getInt("shouldStorage"));
+            records.setLackNumber(jsonRecords.getInt("lackNumber"));
+            records.setOperatingAdminId(admin.getAdminId());
+            if(approvalOrderService.insertInventoryRecords(records) < 1){
+                return new ResponseJson(200, "添加入库记录失败", 500);
+            }
+            //修改订单项信息
+            if(jsonRecords.get("itemId") == null || jsonRecords.get("itemId").equals("")){
+                return new ResponseJson(200, "产品项id不能为空", 500);
+            }
+
+            ApprovalProductionItem productionItem = approvalOrderService.getProductionItem(jsonRecords.getInt("itemId"));
+            if(productionItem.getItemActualStorage() < productionItem.getItemShouldStorage() + jsonRecords.getInt("shouldStorage")){
+                return new ResponseJson(200, "产品项id不能为空", 500);
+            }
+            productionItem.setItemShouldStorage(productionItem.getItemShouldStorage() + jsonRecords.getInt("shouldStorage"));
+            productionItem.setItemLackNumber(productionItem.getItemActualStorage() - (productionItem.getItemShouldStorage() + jsonRecords.getInt("shouldStorage")));
+            if(approvalOrderService.updateProductionItem(productionItem) < 1){
+                return new ResponseJson(200, "修改审批产品项失败", 500);
+            }
+        }
+        return rj;
+    }
 }