|  | @@ -9,6 +9,7 @@ import cn.hnthyy.thmz.service.thmz.MzmxsrService;
 | 
	
		
			
				|  |  |  import cn.hnthyy.thmz.vo.ThmzmxsrParamsVo;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import java.math.BigDecimal;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  public class ProcessYpCountThread implements Runnable{
 | 
	
	
		
			
				|  | @@ -28,7 +29,7 @@ public class ProcessYpCountThread implements Runnable{
 | 
	
		
			
				|  |  |          calendar.set(Calendar.SECOND, 0);
 | 
	
		
			
				|  |  |          Date beginTime = calendar.getTime();
 | 
	
		
			
				|  |  |          Date now = DateUtil.getFirstSecond();
 | 
	
		
			
				|  |  | -        Date Today = DateUtil.pase("2020-06-22 00:00:00","yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  | +        Date Today = DateUtil.pase("2020-09-07 00:00:00","yyyy-MM-dd HH:mm:ss");
 | 
	
		
			
				|  |  |          if(year < 2020){
 | 
	
		
			
				|  |  |              calendar.add(Calendar.YEAR, 1);
 | 
	
		
			
				|  |  |              now=calendar.getTime();
 | 
	
	
		
			
				|  | @@ -40,6 +41,7 @@ public class ProcessYpCountThread implements Runnable{
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  process(beginTime, endTime);
 | 
	
		
			
				|  |  |              }catch (Exception e){
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  |                  log.error("当前日期没有抓取 beginTime="+beginTime+"----endTime="+endTime);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              log.info("=====>>>>>开始日期{},结束日期{}初始化统计完成", DateUtil.fomart(beginTime, "yyyy-MM-dd HH:mm:ss"), DateUtil.fomart(endTime, "yyyy-MM-dd HH:mm:ss"));
 | 
	
	
		
			
				|  | @@ -76,21 +78,36 @@ public class ProcessYpCountThread implements Runnable{
 | 
	
		
			
				|  |  |          thmzmxsrParamsVo.setHisData(YesNoEnum.YES);
 | 
	
		
			
				|  |  |          List<Mzmxsr> thmzmxsrsHis = chargeFeeVoService.queryThmzmxsr(thmzmxsrParamsVo);
 | 
	
		
			
				|  |  |          fomartThmzmxsr(thmzmxsrs, thmzmxsrsHis);
 | 
	
		
			
				|  |  | +        List<Map<String,Object>> list=chargeFeeVoService.querySumAmount(thmzmxsrParamsVo);
 | 
	
		
			
				|  |  | +        Map<String,BigDecimal> sumMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        if (list!=null && list.size()>0){
 | 
	
		
			
				|  |  | +            for (Map map :list){
 | 
	
		
			
				|  |  | +                String patientId = (String) map.get("patient_id");
 | 
	
		
			
				|  |  | +                Double totalChargeD = (Double) map.get("total_charge");
 | 
	
		
			
				|  |  | +                BigDecimal totalCharge =BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +                if(totalChargeD!=null){
 | 
	
		
			
				|  |  | +                    totalCharge=BigDecimal.valueOf(totalChargeD);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                sumMap.put(patientId,totalCharge);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          Date inputDate = new Date();
 | 
	
		
			
				|  |  |          //批量导入入库方式
 | 
	
		
			
				|  |  |          List<Mzmxsr> insertList = new ArrayList<>();
 | 
	
		
			
				|  |  |          thmzmxsrs.forEach(mzmxsr -> {
 | 
	
		
			
				|  |  |              mzmxsr.setInputDate(inputDate);
 | 
	
		
			
				|  |  | -            insertList.add(mzmxsr);
 | 
	
		
			
				|  |  | -            if (insertList.size() >= 50) {
 | 
	
		
			
				|  |  | -                try {
 | 
	
		
			
				|  |  | -                    mzmxsrService.batchSaveMzmxsr(insertList);
 | 
	
		
			
				|  |  | -                    insertList.clear();
 | 
	
		
			
				|  |  | -                } catch (Exception e) {
 | 
	
		
			
				|  |  | -                    log.error("统计门诊收入明细信息保存出错,参数列表长度{},错误信息:{}", thmzmxsrs.size(),e.getMessage());
 | 
	
		
			
				|  |  | +            BigDecimal totalCharge =sumMap.get(mzmxsr.getPatientId());
 | 
	
		
			
				|  |  | +            if(totalCharge!=null && totalCharge.compareTo(BigDecimal.ZERO)!=0){
 | 
	
		
			
				|  |  | +                insertList.add(mzmxsr);
 | 
	
		
			
				|  |  | +                if (insertList.size() >= 50) {
 | 
	
		
			
				|  |  | +                    try {
 | 
	
		
			
				|  |  | +                        mzmxsrService.batchSaveMzmxsr(insertList);
 | 
	
		
			
				|  |  | +                        insertList.clear();
 | 
	
		
			
				|  |  | +                    } catch (Exception e) {
 | 
	
		
			
				|  |  | +                        log.error("统计门诊收入明细信息保存出错,参数列表长度{},错误信息:{}", thmzmxsrs.size(),e.getMessage());
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          if (insertList.size() > 0) {
 | 
	
		
			
				|  |  |              try {
 |