Browse Source

优化总金额计算

hurugang 2 years ago
parent
commit
fec0f14d39

+ 1 - 1
src/main/java/cn/hnthyy/thmz/mapper/his/mz/MzDepositFileMapper.java

@@ -213,7 +213,7 @@ public interface MzDepositFileMapper {
     @Select({"<script>",
             "SELECT top ${pageSize} rtrim(patient_id) patient_id,times,receipt_no,rtrim(pay_mark) pay_mark,rtrim(cheque_type) cheque_type,rtrim(cheque_no) cheque_no,",
             "amount,charge_date,dcount_date,rtrim(dcount_no) dcount_no,rtrim(op_id) op_id,receipt_sn,serial_no,rtrim(responce_type) responce_type,yb_jlh,yb_ywh,dept_no,",
-            "psordnum,agtordnum,hisrefundnum,contract_id FROM (SELECT ROW_NUMBER() OVER (ORDER BY mz_deposit_file_page.${orderByCase} asc) ",
+            "psordnum,agtordnum,hisrefundnum,contract_id FROM (SELECT ROW_NUMBER() OVER (ORDER BY mz_deposit_file_page.${orderByCase} desc) ",
             "AS RowNumber,* from ${tableName} mz_deposit_file_page WITH(NOLOCK) where 1=1 ",
             "<when test='patientId!=null'>",
             " and patient_id =#{patientId}",

+ 10 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/mz/MzDepositFileServiceImpl.java

@@ -174,9 +174,18 @@ public class MzDepositFileServiceImpl implements MzDepositFileService {
 //                }
 //            }
             Map<String, String> employeeMap = new HashMap<>();
+            Map<String,Map<String, Object>> amountMap = new HashMap<>();
             for (MzDepositFile mf : list) {
                 String hisOrdNum = mf.getPatientId() + "_" + mf.getTimes() + "_" + mf.getReceiptNo();
                 if (set.contains(hisOrdNum)) {
+                    Map<String, Object> map = amountMap.get(hisOrdNum);
+                    BigDecimal amount= (BigDecimal)map.get("amount");
+                    if(amount==null){
+                        amount=BigDecimal.ZERO;
+                    }
+                    amount=amount.add(mf.getAmount());
+                    map.put("amount", amount);
+                    amountMap.put(hisOrdNum,map);
                     continue;
                 }
                 Map<String, Object> map = new HashMap<>();
@@ -199,6 +208,7 @@ public class MzDepositFileServiceImpl implements MzDepositFileService {
                 }
                 set.add(hisOrdNum);
                 resultList.add(map);
+                amountMap.put(hisOrdNum,map);
             }
         }
     }