| 
					
				 | 
			
			
				@@ -253,6 +253,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<JcJyItemCharge> jcJyItemCharges = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //医生有可能同一个检验检查反复开,需要记录每种开了几次 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Integer> jyjcCount = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            countSameYjCode(jianYans, jyjcCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            countSameYjCode(jianChas, jyjcCount); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (jianYans.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 jcJyItemCharges = jcJyItemChargeService.queryJcItemChargeByCodeList(jianYans, ReqTypeEnum.JIAN_YAN.code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 itemNo = formatCxFeeItem(mzChargeDetail, mzChargeDetails, mzPatientMi, maxOrderNo, itemNo, mzYjReqMap, jianYans, tcNoMap, priceId, priceTime, receiptNo); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -267,7 +271,10 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (jcJyItemCharges != null && jcJyItemCharges.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 for (JcJyItemCharge jcJyItemCharge : jcJyItemCharges) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    itemNo = formatYjDetailChargeDetail(mzChargeDetail, mzChargeDetails, maxOrderNo, mzPatientMi, itemNo, mzYjReqMap, jcJyItemCharge, tcNoMap, priceId, priceTime, receiptNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Integer count = jyjcCount.get(jcJyItemCharge.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    for (int i = 0; i < count; i++) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        itemNo = formatYjDetailChargeDetail(mzChargeDetail, mzChargeDetails, maxOrderNo, mzPatientMi, itemNo, mzYjReqMap, jcJyItemCharge, tcNoMap, priceId, priceTime, receiptNo); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -279,6 +286,17 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return mzChargeDetails; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void countSameYjCode(List<String> jianChas, Map<String, Integer> jyjcCount) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (String str : jianChas) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer count = jyjcCount.get(str); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (count == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                count = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            count++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            jyjcCount.put(str, count); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 将未缴费的处方转成完整的收费明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -468,10 +486,21 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public List<Map<String, Object>> queryChargeListByPatient(YesNoEnum hisDate, String patientId, String name, String serialNo, Date beginDate, Date endDate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String, Object>> chargeListByPatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (YesNoEnum.YES.equals(hisDate)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return mzChargeDetailMapper.selectHisChargeListByPatient(patientId, name, serialNo, beginDate, endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            chargeListByPatient = mzChargeDetailMapper.selectHisChargeListByPatient(patientId, name, serialNo, beginDate, endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            chargeListByPatient = mzChargeDetailMapper.selectChargeListByPatient(patientId, name, serialNo, beginDate, endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Map<String, Object> map : chargeListByPatient) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String patientIdTemp = (String) map.get("patient_id"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Integer times = (Integer) map.get("times"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            List<MzReceiptSerial> lists = mzReceiptSerialMapper.selectSerialForJzTfThisTime(patientIdTemp, times); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (lists != null && lists.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                map.put("cheque_type", "本院记账已结算"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return mzChargeDetailMapper.selectChargeListByPatient(patientId, name, serialNo, beginDate, endDate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return chargeListByPatient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -755,7 +784,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<MzDepositFile> fullNewMzDepositFiles = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         int times = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (allRefund) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            getDeposFiles(opId, mzDepositFileVo, now, 0, 0, null, null, fullNewMzDepositFiles, allRefund,null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            getDeposFiles(opId, mzDepositFileVo, now, 0, 0, null, null, fullNewMzDepositFiles, allRefund, null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //新增收费方式记录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mzDepositFileMapper.batchInsertMzDepositFile(fullNewMzDepositFiles); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             times = 0; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -803,7 +832,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //退费后新的收款方式 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             List<MzDepositFile> newMzDepositFiles = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String payWay = Constants.CASH; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            payWay = getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, payWay, fullNewMzDepositFiles, allRefund,newMzDepositFiles); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            payWay = getDeposFiles(opId, mzDepositFileVo, now, times, serialNo, totalPayable, payWay, fullNewMzDepositFiles, allRefund, newMzDepositFiles); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //setMzReceiptSerial(opId, mzDepositFileVo.getPatientId(), times, windows, mzChargeDetails.get(0).getResponceType(), feeMap, now, serialNo, mzReceiptSerial, payWay, totalPayable, 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             MzPatientMi mzPatientMi = mzPatientMiService.queryByPatientId(mzDepositFileVo.getPatientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mzDepositFileVo.setMzDepositFiles(newMzDepositFiles); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -865,9 +894,9 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mz.setCharge18(BigDecimal.ZERO.subtract(mz.getCharge18())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mz.setCharge19(BigDecimal.ZERO.subtract(mz.getCharge19())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mz.setCharge20(BigDecimal.ZERO.subtract(mz.getCharge20())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(Constants.BYJZ.equals(mz.getChequeType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (Constants.BYJZ.equals(mz.getChequeType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 mz.setChequeType(Constants.BYJZ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 mz.setChequeType(Constants.CASH); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mz.setDcountNo(YesNoEnum.NO.code); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -927,7 +956,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param newMzDepositFiles 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private String getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, String payWay, List<MzDepositFile> fullNewMzDepositFiles, boolean allRefund,List<MzDepositFile> newMzDepositFiles) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String getDeposFiles(String opId, MzDepositFileVo mzDepositFileVo, Date now, int times, int serialNo, BigDecimal totalPayable, String payWay, List<MzDepositFile> fullNewMzDepositFiles, boolean allRefund, List<MzDepositFile> newMzDepositFiles) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<MzDepositFile> mzDepositFiles = mzDepositFileMapper.selectMzDepositFileByTimes(mzDepositFileVo.getPatientId(), mzDepositFileVo.getTimes(), mzDepositFileVo.getReceiptNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (mzDepositFiles != null || mzDepositFiles.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //本院记账总额 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1350,7 +1379,7 @@ public class MzChargeDetailServiceImpl implements MzChargeDetailService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //排除本院记账的金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         BigDecimal excludeByjzPay = BigDecimal.ZERO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (MzDepositFile m : mzDepositFileVo.getMzDepositFiles()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(m.getPatientId()==null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (m.getPatientId() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //此时是直接收费,需要设置相关参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 m.setPatientId(mzDepositFileVo.getPatientId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 m.setTimes(mzDepositFileVo.getTimes()); 
			 |