|  | @@ -1,5 +1,6 @@
 | 
	
		
			
				|  |  |  package thyyxxk.webserver.service.casefrontsheet;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import lombok.extern.slf4j.Slf4j;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import thyyxxk.webserver.constants.frntsheet.DismissWay;
 | 
	
	
		
			
				|  | @@ -14,6 +15,7 @@ import thyyxxk.webserver.utils.StringUtil;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +@Slf4j
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class CaseFrontSheetExportService {
 | 
	
		
			
				|  |  |      private final FrontSheetExportDao dao;
 | 
	
	
		
			
				|  | @@ -29,54 +31,45 @@ public class CaseFrontSheetExportService {
 | 
	
		
			
				|  |  |          String begin = month + "-01 00:00:00.000";
 | 
	
		
			
				|  |  |          String end = DateUtil.getMonthEndtime(month);
 | 
	
		
			
				|  |  |          List<CaseFrontsheetMain> list = dao.fetchSheets(begin, end);
 | 
	
		
			
				|  |  | -        list.forEach(item -> {
 | 
	
		
			
				|  |  | -            String pmtd = item.getPayMethod();
 | 
	
		
			
				|  |  | -            if (StringUtil.invalidValue(pmtd)) {
 | 
	
		
			
				|  |  | -                item.setPayMethod("9");
 | 
	
		
			
				|  |  | +        for (CaseFrontsheetMain sheet : list) {
 | 
	
		
			
				|  |  | +            sheet.setSurgeryList(selectSurgeries(sheet.getBah(), sheet.getAdmissTimes()));
 | 
	
		
			
				|  |  | +            sheet.setZyDismissWay(DismissWay.getWjwCodeByHisCode(sheet.getZyDismissWay()));
 | 
	
		
			
				|  |  | +            sheet.setHbsAg(Hbsag.getWjwCodeByHisCode(sheet.getHbsAg()));
 | 
	
		
			
				|  |  | +            String ntvplc = sheet.getNativePlace().substring(0, 2);
 | 
	
		
			
				|  |  | +            sheet.setPayMethod(filterPayMethod(sheet.getPayMethod(), sheet.getSocialNo()));
 | 
	
		
			
				|  |  | +            sheet.setRh(filterRh(sheet.getRh()));
 | 
	
		
			
				|  |  | +            sheet.setNativePlace(Provinces.getWjwCodeByHisCode(ntvplc));
 | 
	
		
			
				|  |  | +            sheet.setCountry(redis.getCountryName(sheet.getCountry()));
 | 
	
		
			
				|  |  | +            sheet.setAdmissDeptCode(redis.getWjwDepartment(sheet.getAdmissDeptCode()));
 | 
	
		
			
				|  |  | +            sheet.setZkWardCode(redis.getWjwDepartment(sheet.getZkWardCode()));
 | 
	
		
			
				|  |  | +            sheet.setDismissDeptCode(redis.getWjwDepartment(sheet.getDismissDeptCode()));
 | 
	
		
			
				|  |  | +            sheet.setNation(redis.getWjwNation(sheet.getNation()));
 | 
	
		
			
				|  |  | +            sheet.setDisdiagList(dao.fetchDiags(sheet.getBah(), sheet.getAdmissTimes()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        list.removeIf(item -> item.getSurgeryList().isEmpty());
 | 
	
		
			
				|  |  | +        return list;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private List<CaseFrontsheetSurgery> selectSurgeries(String bah, int times) {
 | 
	
		
			
				|  |  | +        List<CaseFrontsheetSurgery> surgeries = dao.fetchSurgeries(bah, times);
 | 
	
		
			
				|  |  | +        surgeries.forEach(s -> {
 | 
	
		
			
				|  |  | +            int cut = 0;
 | 
	
		
			
				|  |  | +            if (StringUtil.notBlank(s.getCut())) {
 | 
	
		
			
				|  |  | +                cut = Integer.parseInt(s.getCut());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            int heal = 0;
 | 
	
		
			
				|  |  | +            if (StringUtil.notBlank(s.getHeal())) {
 | 
	
		
			
				|  |  | +                heal = Integer.parseInt(s.getHeal());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            if (cut == 0 || heal == 0) {
 | 
	
		
			
				|  |  | +                s.setWjwCutHeal(0);
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  | -                int mtd = Integer.parseInt(pmtd);
 | 
	
		
			
				|  |  | -                if (mtd < 4) {
 | 
	
		
			
				|  |  | -                    if (item.getSocialNo().startsWith("4301")) {
 | 
	
		
			
				|  |  | -                        pmtd = pmtd + ".1";
 | 
	
		
			
				|  |  | -                    } else {
 | 
	
		
			
				|  |  | -                        pmtd = pmtd + ".2";
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    item.setPayMethod(pmtd);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | +                int wjwCutHeal = (cut - 1) * cut + heal + negationCalculatingResidue(cut);
 | 
	
		
			
				|  |  | +                s.setWjwCutHeal(wjwCutHeal);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            item.setZyDismissWay(DismissWay.getWjwCodeByHisCode(item.getZyDismissWay()));
 | 
	
		
			
				|  |  | -            item.setHbsAg(Hbsag.getWjwCodeByHisCode(item.getHbsAg()));
 | 
	
		
			
				|  |  | -            String ntvplc = item.getNativePlace().substring(0, 2);
 | 
	
		
			
				|  |  | -            item.setPayMethod(filterPayMethod(item.getPayMethod(), item.getSocialNo()));
 | 
	
		
			
				|  |  | -            item.setRh(filterRh(item.getRh()));
 | 
	
		
			
				|  |  | -            item.setNativePlace(Provinces.getWjwCodeByHisCode(ntvplc));
 | 
	
		
			
				|  |  | -            item.setCountry(redis.getCountryName(item.getCountry()));
 | 
	
		
			
				|  |  | -            item.setAdmissDeptCode(redis.getWjwDepartment(item.getAdmissDeptCode()));
 | 
	
		
			
				|  |  | -            item.setZkWardCode(redis.getWjwDepartment(item.getZkWardCode()));
 | 
	
		
			
				|  |  | -            item.setDismissDeptCode(redis.getWjwDepartment(item.getDismissDeptCode()));
 | 
	
		
			
				|  |  | -            item.setNation(redis.getWjwNation(item.getNation()));
 | 
	
		
			
				|  |  | -            item.setDisdiagList(dao.fetchDiags(item.getBah(), item.getAdmissTimes()));
 | 
	
		
			
				|  |  | -            List<CaseFrontsheetSurgery> surgeries = dao.fetchSurgeries(item.getBah(), item.getAdmissTimes());
 | 
	
		
			
				|  |  | -            surgeries.forEach(s -> {
 | 
	
		
			
				|  |  | -                s.setAnaesthesia(redis.getWjwAnaesthesia(s.getAnaesthesia()));
 | 
	
		
			
				|  |  | -                int cut = 0;
 | 
	
		
			
				|  |  | -                if (StringUtil.notBlank(s.getCut())) {
 | 
	
		
			
				|  |  | -                    cut = Integer.parseInt(s.getCut());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                int heal = 0;
 | 
	
		
			
				|  |  | -                if (StringUtil.notBlank(s.getHeal())) {
 | 
	
		
			
				|  |  | -                    heal = Integer.parseInt(s.getHeal());
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (cut == 0 || heal == 0) {
 | 
	
		
			
				|  |  | -                    s.setWjwCutHeal(0);
 | 
	
		
			
				|  |  | -                } else {
 | 
	
		
			
				|  |  | -                    int wjwCutHeal = (cut - 1) * cut + heal + negationCalculatingResidue(cut);
 | 
	
		
			
				|  |  | -                    s.setWjwCutHeal(wjwCutHeal);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -            item.setSurgeryList(surgeries);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -        return list;
 | 
	
		
			
				|  |  | +        return surgeries;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private String filterPayMethod(String method, String idNumber) {
 |