Browse Source

物料库存数量金额表增加合计字段

chenw 7 years ago
parent
commit
4b25b13808

+ 2 - 0
applications/document/document-server/src/main/java/com/usoftchina/saas/document/mapper/ProductMapper.java

@@ -52,4 +52,6 @@ public interface ProductMapper extends CommonBaseMapper<Product> {
     Long selectIdByCode(@Param("code") String code, @Param("companyId") Long companyId);
 
     List<ProductReserveCostDTO> selectReserveCostByIgnoreWarehouse(@Param("con") String con, @Param("companyId") Long companyId);
+
+    String selectCalculateFields(@Param("fields") String fields, @Param("con") String con, @Param("companyId") Long companyId);
 }

+ 18 - 1
applications/document/document-server/src/main/java/com/usoftchina/saas/document/service/impl/ProductServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usoftchina.saas.document.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -502,7 +503,23 @@ public class ProductServiceImpl extends CommonBaseServiceImpl<ProductMapper, Pro
         //取分页信息
         PageInfo<ProductReserveCostDTO> pageInfo = new PageInfo<ProductReserveCostDTO>(reserveCostList);
         map.put("list", pageInfo);
-        map.put("calculate", null);
+        //替换listReqDTO中的数据
+        String calculateFields = listReqDTO.getCalculateFields().replaceAll("rc_amount", "pw_amount").replaceAll("pw_onhand", "rc_number");
+        listReqDTO.setCalculateFields(calculateFields);
+        //取对应计算数据
+        String calculateFieldsSql = listReqDTO.getCalculateFieldsSql();
+        Long companyId = BaseContextHolder.getCompanyId();
+        String condition = listReqDTO.getFinalCondition();
+        JSONArray arr = new JSONArray();
+        if (!StringUtils.isEmpty(calculateFieldsSql)) {
+            String res = getMapper().selectCalculateFields(calculateFieldsSql, condition, companyId);
+            res = res.replaceAll("pw_amount", "rc_amount").replace("pw_onhand", "rc_number");
+            try {
+                arr = JSONArray.parseArray(res);
+            } catch (Exception e) {
+            }
+        }
+        map.put("calculate", arr);
         return map;
     }
 

+ 13 - 0
applications/document/document-server/src/main/resources/mapper/ProductMapper.xml

@@ -491,6 +491,19 @@
         group by pr_code,pr_spec,pr_detail,pr_unit,pr_id
         ORDER BY PR_ID DESC
     </select>
+    <select id="selectCalculateFields" resultType="string">
+        select   ${fields}
+        from productWH tab left join Product on pw_prodcode=pr_code left join warehouse on pw_whid=wh_id
+        <where>
+            <if test="con != null">
+                ${con}
+            </if>
+            <if test="companyId!=null">
+                and tab.companyId=#{companyId} and Product.companyId=#{companyId} and warehouse.companyId=#{companyId}
+                and pw_onhand!=0
+            </if>
+        </where>
+    </select>
     <select id="getCountFromPurc" resultType="int">
         SELECT COUNT(*) FROM PURCHASEDETAIL
         WHERE PD_PRODID = #{id} AND COMPANYID=#{companyId}