Browse Source

审核流打印加金额筛选

zxz 2 years ago
parent
commit
dc73d564fa

+ 23 - 22
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/GeneralAuditInfoServiceImpl.java

@@ -261,31 +261,32 @@ public class GeneralAuditInfoServiceImpl extends ServiceImpl<GeneralAuditInfoMap
         pageView.put("startDate", generalAuditInfo.getStartDate());
         pageView.put("endDate", generalAuditInfo.getEndDate());
         pageView.put("pageSize", generalAuditInfo.getPageSize());
+        pageView.put("amountMoney", generalAuditInfo.getAmountMoney());
         pageView.put("currentPage", generalAuditInfo.getCurrentPage());
         Integer dataCount = baseMapper.getPrintCountByCondition(pageView);
         List<GeneralAuditInfo> dataList = baseMapper.getPrintListByCondition(pageView);
-        if (!CollectionUtils.isEmpty(dataList)) {
-            for (GeneralAuditInfo generalAuditInfo1:dataList){
-                if ("费用审核".equals(generalAuditInfo1.getType())||"运费结算".equals(generalAuditInfo1.getType())){
-                    ExpenseInfo expenseInfo=expenseInfoService.selectById(generalAuditInfo1.getId());
-                    if (expenseInfo != null) {
-                        generalAuditInfo1.setPayerHeader(expenseInfo.getPayerHeader());
-                        generalAuditInfo1.setAmountMoney(expenseInfo.getAmountMoney());
-                        if ("库点费用".equals(expenseInfo.getPurpose())) {
-                            generalAuditInfo1.setWarehouseName(expenseInfo.getWarehouseName());
-                        }
-                    }
-                }
-                else if ("入库单请款".equals(generalAuditInfo1.getType())){
-                    List<WarehousingOrderRecord> warehousingOrderRecords=warehousingOrderRecordService.selectList(new EntityWrapper<WarehousingOrderRecord>()
-                    .eq("batch_id",generalAuditInfo1.getId()));
-                    if (!CollectionUtils.isEmpty(warehousingOrderRecords)) {
-                        double money = warehousingOrderRecords.stream().mapToDouble(WarehousingOrderRecord::getPaymentRequestAmount).sum();
-                        generalAuditInfo1.setAmountMoney(money);
-                    }
-                }
-            }
-        }
+//        if (!CollectionUtils.isEmpty(dataList)) {
+//            for (GeneralAuditInfo generalAuditInfo1:dataList){
+//                if ("费用审核".equals(generalAuditInfo1.getType())||"运费结算".equals(generalAuditInfo1.getType())){
+//                    ExpenseInfo expenseInfo=expenseInfoService.selectById(generalAuditInfo1.getId());
+//                    if (expenseInfo != null) {
+//                        generalAuditInfo1.setPayerHeader(expenseInfo.getPayerHeader());
+//                        generalAuditInfo1.setAmountMoney(expenseInfo.getAmountMoney());
+//                        if ("库点费用".equals(expenseInfo.getPurpose())) {
+//                            generalAuditInfo1.setWarehouseName(expenseInfo.getWarehouseName());
+//                        }
+//                    }
+//                }
+//                else if ("入库单请款".equals(generalAuditInfo1.getType())){
+//                    List<WarehousingOrderRecord> warehousingOrderRecords=warehousingOrderRecordService.selectList(new EntityWrapper<WarehousingOrderRecord>()
+//                    .eq("batch_id",generalAuditInfo1.getId()));
+//                    if (!CollectionUtils.isEmpty(warehousingOrderRecords)) {
+//                        double money = warehousingOrderRecords.stream().mapToDouble(WarehousingOrderRecord::getPaymentRequestAmount).sum();
+//                        generalAuditInfo1.setAmountMoney(money);
+//                    }
+//                }
+//            }
+//        }
         Page<GeneralAuditInfo> page = new Page<>();
         page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
         page.setTotal(dataCount == null ? 0 : dataCount);

+ 41 - 20
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/GeneralAuditInfoMapper.xml

@@ -129,15 +129,22 @@
           and create_date > #{year}
     </select>
     <select id="getPrintListByCondition" parameterType="Map" resultType="com.yh.saas.plugin.yiliangyiyun.entity.GeneralAuditInfo">
-        select
+       select * FROM (
+       select
         a.id,
         a.businessNo as businessNo,
         a.creater as creater,
         a.type as type,
         a.businessCode as businessCode,
         a.status,
-        a.createDate as createDate
+        case when a.type ='入库单请款' then IFNULL( sum( w.payment_request_amount ), 0 ) else e.amount_money end as
+        amountMoney,
+        a.createDate as createDate,
+        e.payer_header as payerHeader,
+        e.warehouse_name as warehouseName
         FROM v_audit_print a
+        left join expense_info e on e.id = a.id and e.delete_flag = '0'
+        left join warehousing_order_record w on w.batch_id = a.id and w.delete_flag = '0'
         where a.compId= #{compId}
         <if test="searchType != null and searchType != ''">
             AND a.type = #{searchType}
@@ -154,30 +161,44 @@
             AND (DATE_FORMAT(a.createDate,"%Y%m%d") &lt;=
             DATE_FORMAT(#{endDate},"%Y%m%d"))
         </if>
+        group by a.id
         ORDER BY a.createDate DESC
+        ) tt
+        <if test="amountMoney != null and amountMoney != ''">
+            where tt.amountMoney like CONCAT('%',#{amountMoney},'%')
+        </if>
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
         </if>
     </select>
     <select id="getPrintCountByCondition"  parameterType="Map" resultType="java.lang.Integer">
-        SELECT
-        COUNT(a.id)
-        FROM v_audit_print a
-        where a.compId= #{compId}
-        <if test="searchType != null and searchType != ''">
-            AND a.type = #{searchType}
-        </if>
-        <if test="searchKeyWord != null and searchKeyWord != ''">
-            AND (lower(a.businessNo) like lower(CONCAT('%',#{searchKeyWord},'%'))
-            OR lower(a.creater) like lower(CONCAT('%',#{searchKeyWord},'%')))
-        </if>
-        <if test="startDate != null">
-            AND (DATE_FORMAT(a.createDate,"%Y%m%d") &gt;=
-            DATE_FORMAT(#{startDate},"%Y%m%d"))
-        </if>
-        <if test="endDate != null">
-            AND (DATE_FORMAT(a.createDate,"%Y%m%d") &lt;=
-            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        SELECT COUNT(*) from(
+            SELECT
+            case when a.type ='入库单请款' then IFNULL( sum( w.payment_request_amount ), 0 ) else e.amount_money end as
+            amountMoney
+            FROM v_audit_print a
+            left join expense_info e on e.id = a.id and e.delete_flag = '0'
+            left join warehousing_order_record w on w.batch_id = a.id and w.delete_flag = '0'
+            where a.compId= #{compId}
+            <if test="searchType != null and searchType != ''">
+                AND a.type = #{searchType}
+            </if>
+            <if test="searchKeyWord != null and searchKeyWord != ''">
+                AND (lower(a.businessNo) like lower(CONCAT('%',#{searchKeyWord},'%'))
+                OR lower(a.creater) like lower(CONCAT('%',#{searchKeyWord},'%')))
+            </if>
+            <if test="startDate != null">
+                AND (DATE_FORMAT(a.createDate,"%Y%m%d") &gt;=
+                DATE_FORMAT(#{startDate},"%Y%m%d"))
+            </if>
+            <if test="endDate != null">
+                AND (DATE_FORMAT(a.createDate,"%Y%m%d") &lt;=
+                DATE_FORMAT(#{endDate},"%Y%m%d"))
+            </if>
+        group by a.id
+        ) tt
+        <if test="amountMoney != null and amountMoney != ''">
+            where tt.amountMoney like CONCAT('%',#{amountMoney},'%')
         </if>
     </select>
 </mapper>