|  | @ -0,0 +1,1852 @@
 | 
	
		
			
				|  |  | package com.yihu.wlyy.statistics.job;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.dao.*;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.etl.model.ETLModel;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.etl.role.*;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.etl.storage.DBStorage;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.etl.storage.RedisStorage;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.consult.ConsultTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.doctor.DoctorPatientGroupInfo;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.hosptial.Hospital;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.patient.Patient;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.patient.PatientHealthGuidance;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.system.Town;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.model.team.AdminTeam;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.util.DateUtil;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.util.IdCardUtil;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
 | 
	
		
			
				|  |  | import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
 | 
	
		
			
				|  |  | import org.json.JSONArray;
 | 
	
		
			
				|  |  | import org.json.JSONObject;
 | 
	
		
			
				|  |  | import org.quartz.Job;
 | 
	
		
			
				|  |  | import org.quartz.JobExecutionContext;
 | 
	
		
			
				|  |  | import org.quartz.JobExecutionException;
 | 
	
		
			
				|  |  | import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | import org.springframework.data.redis.core.StringRedisTemplate;
 | 
	
		
			
				|  |  | import org.springframework.jdbc.core.JdbcTemplate;
 | 
	
		
			
				|  |  | import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  | import org.springframework.util.StringUtils;
 | 
	
		
			
				|  |  | import org.springframework.web.context.support.SpringBeanAutowiringSupport;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | import java.io.IOException;
 | 
	
		
			
				|  |  | import java.io.InputStream;
 | 
	
		
			
				|  |  | import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  | import java.util.*;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | /**
 | 
	
		
			
				|  |  |  * 实时统计今天的数据
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | @Component
 | 
	
		
			
				|  |  | public class CurrentDayAllQuotaJob implements Job {
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private SignFamilyDao signFamilyDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorDao doctorDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private HospitalDao hospitalDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private TownDao townDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private StringRedisTemplate redisTemplate;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private ConsultTeamDao consultTeamDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientHealthGuidanceDao patientHealthGuidanceDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientDao patientDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private DoctorAdminTeamDao doctorAdminTeamDao;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private Level1Role levelRole;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientAgeRole patientAgeRole;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientGroupRole patientGroupRole;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private PatientSexRole patientSexRole;
 | 
	
		
			
				|  |  |     @Autowired
 | 
	
		
			
				|  |  |     private RedisStorage redisStorage;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private org.apache.tomcat.jdbc.pool.DataSource fvdataSource = new org.apache.tomcat.jdbc.pool.DataSource();//随访数据源
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private JdbcTemplate jdbcTemplate = new JdbcTemplate();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private Properties systemProperties;
 | 
	
		
			
				|  |  |     List<Town> towns = null;//厦门市全部的区
 | 
	
		
			
				|  |  |     List<Hospital> hospitals = null;//系统全部的机构
 | 
	
		
			
				|  |  |     List<AdminTeam> adminTeams=null;//系统全部的团队
 | 
	
		
			
				|  |  |     Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
 | 
	
		
			
				|  |  |     Map<String, Town> townsMap = new HashMap<String, Town>();
 | 
	
		
			
				|  |  |     Map<String, AdminTeam> adminTeamMap = new HashMap<String, AdminTeam>();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private String now = getDayString(0);
 | 
	
		
			
				|  |  |     private String tomorrow = getDayString(1);
 | 
	
		
			
				|  |  |     private StringBuffer allContent=new StringBuffer();//日志内容
 | 
	
		
			
				|  |  |     @Override
 | 
	
		
			
				|  |  |     public void execute(JobExecutionContext context)
 | 
	
		
			
				|  |  |             throws JobExecutionException {
 | 
	
		
			
				|  |  |         try {
 | 
	
		
			
				|  |  |             SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
 | 
	
		
			
				|  |  |             getSystemProperties();
 | 
	
		
			
				|  |  |             fvdataSource.setDriverClassName(systemProperties.get("fv.jdbc.driver").toString());
 | 
	
		
			
				|  |  |             fvdataSource.setUrl(systemProperties.get("fv.jdbc.url").toString());
 | 
	
		
			
				|  |  |             fvdataSource.setUsername(systemProperties.get("fv.jdbc.username").toString());
 | 
	
		
			
				|  |  |             fvdataSource.setPassword(systemProperties.get("fv.jdbc.password").toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             jdbcTemplate.setDataSource(fvdataSource);//初始化随访的数据源
 | 
	
		
			
				|  |  |             towns = townDao.findByCityCode(Constant.city); //查找出厦门市全部的区
 | 
	
		
			
				|  |  |             hospitals = hospitalDao.findHospitalzxFWZ(); //查找出系统全部的机构
 | 
	
		
			
				|  |  |             adminTeams=doctorAdminTeamDao.findAllTeam();//查找出系统全部的全科医生
 | 
	
		
			
				|  |  |             for (Hospital hospital : hospitals) {
 | 
	
		
			
				|  |  |                 hospitalsMap.put(hospital.getCode(), hospital);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             for (Town town : towns) {
 | 
	
		
			
				|  |  |                 townsMap.put(town.getCode(), town);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             for (AdminTeam adminTeam : adminTeams) {
 | 
	
		
			
				|  |  |                 adminTeamMap.put(adminTeam.getId()+"", adminTeam);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //计算指标
 | 
	
		
			
				|  |  |             computequota();
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     //统计
 | 
	
		
			
				|  |  |     private void computequota() throws Exception {
 | 
	
		
			
				|  |  |         QuartzJobLog quartzJobLog =new QuartzJobLog();
 | 
	
		
			
				|  |  |         quartzJobLog.setJobStartTime(new Date());
 | 
	
		
			
				|  |  |         allContent=new StringBuffer();
 | 
	
		
			
				|  |  |         computequota_1(); //统计今天的签约
 | 
	
		
			
				|  |  |         computequota_2(); //统计今天的解约
 | 
	
		
			
				|  |  |         computequota_3(); //统计今天的健康咨询量
 | 
	
		
			
				|  |  |         computequota_4(); //统计今天的随访量
 | 
	
		
			
				|  |  |         computequota_5(); //统计今天的健康指导
 | 
	
		
			
				|  |  |         computequota_6(); //统计今天的签约患者性别
 | 
	
		
			
				|  |  |         computequota_7();//统计今天的签约患者分组
 | 
	
		
			
				|  |  |         computequota_8();//统计今天的签约患者年龄
 | 
	
		
			
				|  |  |         computequota_9();//统计今天的待签约
 | 
	
		
			
				|  |  |         computequota_10();//统计今天的改签
 | 
	
		
			
				|  |  |         computequota_12();//统计今天的签约下按年龄分组后再
 | 
	
		
			
				|  |  |         quartzJobLog.setJobContent(allContent.toString());
 | 
	
		
			
				|  |  |         quartzJobLog.setJobName("实时统计");
 | 
	
		
			
				|  |  |         quartzJobLog.setJobId("11");
 | 
	
		
			
				|  |  |         quartzJobLog.setJobType("1");
 | 
	
		
			
				|  |  |         quartzJobLog.setJobEndTime(new Date());
 | 
	
		
			
				|  |  |         quartzJobLogDao.save(quartzJobLog);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_12() throws Exception{
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String now = getDayString(0);
 | 
	
		
			
				|  |  |         String tomorrow = getDayString(1);
 | 
	
		
			
				|  |  |         //找出今天的签约信息 yesterday,now
 | 
	
		
			
				|  |  |         //查找出系统全部的机构
 | 
	
		
			
				|  |  |         List<Hospital> hospitals = hospitalDao.findHospital2();
 | 
	
		
			
				|  |  |         Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
 | 
	
		
			
				|  |  |         for (Hospital hospital : hospitals) {
 | 
	
		
			
				|  |  |             hospitalsMap.put(hospital.getCode(), hospital);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //查找出厦门市全部的区
 | 
	
		
			
				|  |  |         List<Town> towns = townDao.findByCityCode(Constant.city);
 | 
	
		
			
				|  |  |         Map<String, Town> townsMap = new HashMap<String, Town>();
 | 
	
		
			
				|  |  |         for (Town town : towns) {
 | 
	
		
			
				|  |  |             townsMap.put(town.getCode(), town);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //找出今天的签约信息
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterdayExpensesStatus(now, tomorrow);
 | 
	
		
			
				|  |  |         //数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
 | 
	
		
			
				|  |  |         Map<String, Map<String, Map>> cityAgeMap = new HashMap<String, Map<String, Map>>();//key是市行政代码 目前只有厦门市
 | 
	
		
			
				|  |  |         Map<String,Map> temp =new HashMap<String,Map>();
 | 
	
		
			
				|  |  |         cityAgeMap.put(Constant.city, temp);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Map<String, Map<String, Map>> townAgeMap = new HashMap<String, Map<String, Map>>();//key是区行政代码
 | 
	
		
			
				|  |  |         Map<String, Map<String, Map>> orgAgeMap = new HashMap<String, Map<String, Map>>();//key是机构代码
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有签约的
 | 
	
		
			
				|  |  |         for (SignFamily signFamily : signFamilys) {
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |              town = hospital.getTown();
 | 
	
		
			
				|  |  |             int age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());//根据card解析年龄
 | 
	
		
			
				|  |  |             String ageCode = getAgeCode(age);//得到年龄的code
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             boolean hasGXY = false;//有高血压
 | 
	
		
			
				|  |  |             boolean hasTNB = false;//有糖尿病
 | 
	
		
			
				|  |  |             //如果是慢病的 统计高血压的 糖尿病  1高血压,2糖尿病  糖尿病和高血压是3
 | 
	
		
			
				|  |  |             String diseaseType="";
 | 
	
		
			
				|  |  |             String jsonString = redisTemplate.opsForValue().get("disease:" + signFamily.getPatient());
 | 
	
		
			
				|  |  |             if (StringUtils.isEmpty(jsonString)) {
 | 
	
		
			
				|  |  |                 diseaseType="4";//健康人群
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //排除数据 只留下高血压和糖尿病
 | 
	
		
			
				|  |  |                 List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
 | 
	
		
			
				|  |  |                 JSONArray redisValues = new JSONArray(jsonString);
 | 
	
		
			
				|  |  |                 if(redisValues.length()>0){
 | 
	
		
			
				|  |  |                     for (Object obj : redisValues) {
 | 
	
		
			
				|  |  |                         JSONObject redisValue =  (JSONObject)(obj);
 | 
	
		
			
				|  |  |                         if(!redisValue.has("signType")){
 | 
	
		
			
				|  |  |                             continue;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         //排除掉三师签约
 | 
	
		
			
				|  |  |                         if ("1".equals(redisValue.getString("signType"))) {
 | 
	
		
			
				|  |  |                             continue;
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         String disease = redisValue.getString("disease");
 | 
	
		
			
				|  |  |                         if (("1").equals(disease)) {
 | 
	
		
			
				|  |  |                             jsonObjects.add(redisValue);
 | 
	
		
			
				|  |  |                             hasGXY = true;//设置有高血压
 | 
	
		
			
				|  |  |                             diseaseType="1";
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                         if (("2").equals(disease)) {
 | 
	
		
			
				|  |  |                             jsonObjects.add(redisValue);
 | 
	
		
			
				|  |  |                             hasTNB = true;//设置有糖尿病
 | 
	
		
			
				|  |  |                             diseaseType="2";
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if(hasGXY&&hasTNB){
 | 
	
		
			
				|  |  |                         diseaseType="3";
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     diseaseType="4";
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计市
 | 
	
		
			
				|  |  |             compute(cityAgeMap, Constant.city, ageCode, diseaseType);
 | 
	
		
			
				|  |  |             //统计区
 | 
	
		
			
				|  |  |             compute(townAgeMap, town, ageCode, diseaseType);
 | 
	
		
			
				|  |  |             //统计机构
 | 
	
		
			
				|  |  |             //统计站
 | 
	
		
			
				|  |  |              orgCode=hospital.getCode();
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //统计站
 | 
	
		
			
				|  |  |                  orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |                 //统计机构
 | 
	
		
			
				|  |  |                 compute(orgAgeMap, orgCodeTemp, ageCode, diseaseType);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 compute(orgAgeMap, hospital.getCode(), ageCode, diseaseType);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存市级数据
 | 
	
		
			
				|  |  |         for (Map.Entry<String, Map<String, Map>> entry : cityAgeMap.entrySet()) {
 | 
	
		
			
				|  |  |             Map<String, Map> oneAgeMap = entry.getValue();
 | 
	
		
			
				|  |  |             for(int i=1;i<7;i++){
 | 
	
		
			
				|  |  |                 for(int j=1;j<5;j++){
 | 
	
		
			
				|  |  |                     String key_2=i+"";
 | 
	
		
			
				|  |  |                     String key_3=j+"";
 | 
	
		
			
				|  |  |                     String name=Constant.cityName;
 | 
	
		
			
				|  |  |                     JSONObject jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |                     if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
 | 
	
		
			
				|  |  |                         Map<String,Long> key3Map=oneAgeMap.get(key_2);
 | 
	
		
			
				|  |  |                         if(key3Map!=null&&key3Map.containsKey(key_3)){
 | 
	
		
			
				|  |  |                             jsonObject.put("num",key3Map.get(key_3) + "");
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             jsonObject.put("num",0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         jsonObject.put("num",0);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     jsonObject.put("name",name);
 | 
	
		
			
				|  |  |                     jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |                     redisTemplate.opsForValue().set(new StringBuffer("quota:12:4:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存区级
 | 
	
		
			
				|  |  |         for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
 | 
	
		
			
				|  |  |             //判断该区是否有统计数据
 | 
	
		
			
				|  |  |             Map<String, Map> oneAgeMap = townAgeMap.get(entry.getKey());//得到当个区的统计数据
 | 
	
		
			
				|  |  |             Town townObj = entry.getValue();//得到区级信息
 | 
	
		
			
				|  |  |             for(int i=1;i<7;i++){
 | 
	
		
			
				|  |  |                 for(int j=1;j<5;j++){
 | 
	
		
			
				|  |  |                     String key_2=i+"";
 | 
	
		
			
				|  |  |                     String key_3=j+"";
 | 
	
		
			
				|  |  |                     String name=townObj.getName();
 | 
	
		
			
				|  |  |                     JSONObject jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |                     if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
 | 
	
		
			
				|  |  |                         Map<String,Long> key3Map=oneAgeMap.get(key_2);
 | 
	
		
			
				|  |  |                         if(key3Map!=null&&key3Map.containsKey(key_3)){
 | 
	
		
			
				|  |  |                             jsonObject.put("num",(key3Map.get(key_3) + ""));
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             jsonObject.put("num",0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         jsonObject.put("num",0);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     jsonObject.put("name",townObj.getName());
 | 
	
		
			
				|  |  |                     jsonObject.put("date", DateUtil.dateToStrLong(new Date()));//quota:12:2:6:1:350200
 | 
	
		
			
				|  |  |                     redisTemplate.opsForValue().set(new StringBuffer("quota:12:3:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存机构级
 | 
	
		
			
				|  |  |         for (Map.Entry<String, Hospital> entry : hospitalsMap.entrySet()) {
 | 
	
		
			
				|  |  |             //判断该机构是否有统计数据
 | 
	
		
			
				|  |  |             Map<String, Map> oneAgeMap = orgAgeMap.get(entry.getKey());//得到当个机构的统计数据
 | 
	
		
			
				|  |  |             Hospital hospital = entry.getValue();//得到机构信息
 | 
	
		
			
				|  |  |             for(int i=1;i<7;i++){
 | 
	
		
			
				|  |  |                 for(int j=1;j<5;j++){
 | 
	
		
			
				|  |  |                     String key_2=i+"";
 | 
	
		
			
				|  |  |                     String key_3=j+"";
 | 
	
		
			
				|  |  |                     String name=hospital.getName();
 | 
	
		
			
				|  |  |                     JSONObject jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |                     if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
 | 
	
		
			
				|  |  |                         Map<String,Long> key3Map=oneAgeMap.get(key_2);
 | 
	
		
			
				|  |  |                         if(key3Map!=null&&key3Map.containsKey(key_3)){
 | 
	
		
			
				|  |  |                             jsonObject.put("num",(key3Map.get(key_3) + ""));
 | 
	
		
			
				|  |  |                         }else{
 | 
	
		
			
				|  |  |                             jsonObject.put("num",0);
 | 
	
		
			
				|  |  |                         }
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         jsonObject.put("num",0);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     jsonObject.put("name",name);
 | 
	
		
			
				|  |  |                     jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |                     redisTemplate.opsForValue().set(new StringBuffer("quota:12:2:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         saveContent("12",signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("-----------12----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     private void compute(Map<String, Map<String, Map>> rootMap, String rootKey, String ageCode, String diseaseType) {
 | 
	
		
			
				|  |  |         if (rootMap.containsKey(rootKey)) {
 | 
	
		
			
				|  |  |             //得到市下面的所有的年龄map
 | 
	
		
			
				|  |  |             Map<String, Map> groupMapTemp = rootMap.get(rootKey);
 | 
	
		
			
				|  |  |             if(groupMapTemp.containsKey(ageCode)){
 | 
	
		
			
				|  |  |                 //得到这个年龄下的患者map
 | 
	
		
			
				|  |  |                 Map<String,Long> mape= groupMapTemp.get(ageCode);
 | 
	
		
			
				|  |  |                 if(mape.containsKey(diseaseType)){
 | 
	
		
			
				|  |  |                     mape.put(diseaseType,mape.get(diseaseType)+1L);
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     mape.put(diseaseType,1L);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //新增疾病的统计map
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp1 = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                 groupMapTemp1.put(diseaseType, 1L);
 | 
	
		
			
				|  |  |                 groupMapTemp.put(ageCode,groupMapTemp1);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             //没有就新建统计数据  新增疾病的统计map
 | 
	
		
			
				|  |  |             Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |             groupMapTemp.put(diseaseType, 1L);
 | 
	
		
			
				|  |  |             //把统计疾病的map放入对应的年龄组map中
 | 
	
		
			
				|  |  |             Map<String, Map> groupMapTemp2 = new HashMap<String, Map>();
 | 
	
		
			
				|  |  |             groupMapTemp2.put(ageCode,groupMapTemp);
 | 
	
		
			
				|  |  |             //把年龄组map放入市的map里面
 | 
	
		
			
				|  |  |             rootMap.put(rootKey, groupMapTemp2);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     private void computequota_1() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         //找出今天的签约信息 yesterday,now
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterdayExpensesStatus(now, tomorrow);
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(SignFamily signFamily:signFamilys){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,"1");
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         saveContent("1",signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("-----------1----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_2() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="2";
 | 
	
		
			
				|  |  |         //找出今天的解约信息
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterdayExpensesStatus(now,tomorrow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(SignFamily signFamily:signFamilys){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||(idCard.length()!=18&&idCard.length()!=15)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,quotaId);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("----------2-----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_3() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="3";
 | 
	
		
			
				|  |  |         //找出今天的咨询信息
 | 
	
		
			
				|  |  |         List<ConsultTeam> consultTeams = consultTeamDao.findByCzrqyYesterday(now,tomorrow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(ConsultTeam consultTeam:consultTeams){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             Long adminId=consultTeam.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("咨询Id:"+consultTeam.getId()+",咨询的团队(wlyy_consult_team)中的admin_team_code数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String teamCode = consultTeam.getAdminTeamId()+"";//行政的团队的id
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(teamCode);
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("咨询Id:"+consultTeam.getId()+",团队Id:"+adminTeam.getId()+",咨询的团队(wlyy_consult_team)中的团队不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCode = adminTeam.getOrgCode();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("咨询Id:"+consultTeam.getId()+",团队Id:"+adminTeam.getId()+",医生团队的机构为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             //统计机构
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //统计站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //统计社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计区 ---------------start--------------
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:"+hospital.getId()+",医生团队的机构不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town=hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:"+hospital.getId()+",机构表的区字段(town)为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj=townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:"+hospital.getId()+",机构表的区不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,quotaId);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         saveContent(quotaId,consultTeams.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("----------3-----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_4() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="4";
 | 
	
		
			
				|  |  |         //找出今天的随访信息
 | 
	
		
			
				|  |  |         List<Map<String,Object>> plans = getFvYesterday();
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(Map<String,Object> plan:plans){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             Object idCard=plan.get("id_card");//得到隨訪的身份證
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(idCard)){
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",随访(fv_plan)表id_card为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             SignFamily signFamily=signFamilyDao.findByIdcard(idCard.toString());
 | 
	
		
			
				|  |  |             if(signFamily==null){
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",签约code:"+signFamily.getCode()+",随访中的患者身份证在签约表中找不到数据");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminTeamId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminTeamId==null||adminTeamId<=0){
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",签约code:"+signFamily.getCode()+" 中的adminTeamId为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId());
 | 
	
		
			
				|  |  |             if(adminTeam==null){
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",签约code:"+signFamily.getCode()+",医生团队不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计机构------------------start ------------------
 | 
	
		
			
				|  |  |             //判断医生属于哪个机构
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             String orgCode=adminTeam.getOrgCode();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)){
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",团队Id:"+adminTeam.getId()+",随访的医生所属的团队(wlyy_admin_team)机构为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计机构
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //统计站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //统计社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital==null){
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",团队Id:"+adminTeam.getId()+",随访的医生所属的团队的机构不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",机构Id:"+hospital.getId()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("随访id:"+plan.get("id")+",机构Id:"+hospital.getId()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,quotaId);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         saveContent(quotaId,plans.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("-----------4----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_5() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="5";
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         List<PatientHealthGuidance> patientHealthGuidances = patientHealthGuidanceDao.findByCzrqyYesterday(now,tomorrow);
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(PatientHealthGuidance patientHealthGuidance:patientHealthGuidances){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String patient=patientHealthGuidance.getPatient();
 | 
	
		
			
				|  |  |             SignFamily signFamily= signFamilyDao.findByPatientAndType(patient,2);//只统计家庭签约
 | 
	
		
			
				|  |  |             if(signFamily == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",患者code:"+patient+",家庭签约不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String adminId=signFamily.getAdminTeamId()+"";//得到团队ID
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(adminId)){
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的团队AdminTeamCode为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam = adminTeamMap.get(adminId);
 | 
	
		
			
				|  |  |             if(adminTeam==null){
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的团队不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCode=signFamily.getHospital();//得到机构id
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)){
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的机构Hospital不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             //统计机构 -----------------start---------------------
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //统计站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //统计社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+orgCodeTemp+",健康咨询的医生所属的机构不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+hospital.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+hospital.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,quotaId);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         saveContent(quotaId,patientHealthGuidances.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("-----------5----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_6() throws Exception {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="6";
 | 
	
		
			
				|  |  |         //找出今天的签约信息
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterdayExpensesStatus(now, tomorrow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(SignFamily signFamily:signFamilys){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnData1s= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData= patientSexRole.elt(returnData1s);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel2(patientSexRoleData,quotaId,3,1);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("-----------6----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_7() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="7";
 | 
	
		
			
				|  |  |         String now = getDayString(0);
 | 
	
		
			
				|  |  |         String tomorrow = getDayString(1);
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterdayExpensesStatus(now, tomorrow);
 | 
	
		
			
				|  |  |         errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
 | 
	
		
			
				|  |  |         //查找出系统全部的患者
 | 
	
		
			
				|  |  |         List<Patient> patients = patientDao.findAllSignPatient();
 | 
	
		
			
				|  |  |         Map<String, Patient> patientsMap = new HashMap<String, Patient>();
 | 
	
		
			
				|  |  |         for (Patient patient : patients) {
 | 
	
		
			
				|  |  |             patientsMap.put(patient.getCode(), patient);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Map<String, Map<String, Long>> cityGroupMap = new HashMap<String, Map<String, Long>>();//key是市行政代码 目前只有厦门市
 | 
	
		
			
				|  |  |         cityGroupMap.put(Constant.city,new HashMap<String, Long>());
 | 
	
		
			
				|  |  |         Map<String, Map<String, Long>> townGroupMap = new HashMap<String, Map<String, Long>>();//key是区行政代码
 | 
	
		
			
				|  |  |         Map<String, Map<String, Long>> orgGroupMap = new HashMap<String, Map<String, Long>>();//key是机构代码
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //得到所有的签约病人的分组信息
 | 
	
		
			
				|  |  |         List<DoctorPatientGroupInfo> doctorPatientGroupInfos = doctorPatientGroupInfoDao.findAllPatient();
 | 
	
		
			
				|  |  |         Map<String, String> groupMap = new HashMap<String, String>();
 | 
	
		
			
				|  |  |         for (DoctorPatientGroupInfo doctorPatientGroupInfo : doctorPatientGroupInfos) {
 | 
	
		
			
				|  |  |             groupMap.put(doctorPatientGroupInfo.getPatient(), doctorPatientGroupInfo.getGroup());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有签约的
 | 
	
		
			
				|  |  |         for (SignFamily signFamily : signFamilys) {
 | 
	
		
			
				|  |  |             String patient=signFamily.getPatient();
 | 
	
		
			
				|  |  |             String group = groupMap.get(patient);//得到该签约病人的所在分组 1 普通 2 慢病 3是 65岁以上人群
 | 
	
		
			
				|  |  |             Hospital hospital = hospitalsMap.get(getOrg(signFamily.getHospital()));//得到患者签约的机构
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             town = hospital.getTown();
 | 
	
		
			
				|  |  |             //统计市  现在只有厦门市 默认先写死 后面再改
 | 
	
		
			
				|  |  |             if (cityGroupMap.containsKey(Constant.city)) {
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp = cityGroupMap.get(Constant.city);
 | 
	
		
			
				|  |  |                 groupMapTemp.put(group,(groupMapTemp.get(group)==null?0l:groupMapTemp.get(group))  + 1);
 | 
	
		
			
				|  |  |                 cityGroupMap.put(Constant.city, groupMapTemp);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                 groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                 cityGroupMap.put(Constant.city, groupMapTemp);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计区
 | 
	
		
			
				|  |  |             if (townGroupMap.containsKey(town)) {
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp = townGroupMap.get(town);
 | 
	
		
			
				|  |  |                 groupMapTemp.put(group, (groupMapTemp.get(group)==null?0l:groupMapTemp.get(group))+ 1);
 | 
	
		
			
				|  |  |                 townGroupMap.put(town, groupMapTemp);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                 groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                 townGroupMap.put(town, groupMapTemp);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计机构
 | 
	
		
			
				|  |  |             if (orgGroupMap.containsKey(hospital.getCode())) {
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp = orgGroupMap.get(hospital.getCode());
 | 
	
		
			
				|  |  |                 groupMapTemp.put(group, (groupMapTemp.get(group)==null?0l:groupMapTemp.get(group)) + 1);
 | 
	
		
			
				|  |  |                 orgGroupMap.put(hospital.getCode(), groupMapTemp);
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                 groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                 orgGroupMap.put(hospital.getCode(), groupMapTemp);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             boolean hasGXY = false;//有高血压
 | 
	
		
			
				|  |  |             boolean hasTNB = false;//有糖尿病
 | 
	
		
			
				|  |  |             if ("2".equals(group)) {
 | 
	
		
			
				|  |  |                 //如果是慢病的 统计高血压的 糖尿病  1高血压,2糖尿病
 | 
	
		
			
				|  |  |                 String jsonString = redisTemplate.opsForValue().get("disease:" + patient);
 | 
	
		
			
				|  |  |                 if (StringUtils.isEmpty(jsonString)) {
 | 
	
		
			
				|  |  |                     continue;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //排除数据 只留下高血压和糖尿病
 | 
	
		
			
				|  |  |                 List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
 | 
	
		
			
				|  |  |                 JSONArray redisValues = new JSONArray(jsonString);
 | 
	
		
			
				|  |  |                 for (Object obj : redisValues) {
 | 
	
		
			
				|  |  |                     JSONObject redisValue = (JSONObject)(obj);
 | 
	
		
			
				|  |  |                     if(!redisValue.has("signType")){
 | 
	
		
			
				|  |  |                         continue;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     //排除掉三师签约
 | 
	
		
			
				|  |  |                     if ("1".equals(redisValue.getString("signType"))) {
 | 
	
		
			
				|  |  |                         continue;
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     String disease = redisValue.getString("disease");
 | 
	
		
			
				|  |  |                     if ("1".equals(disease)) {
 | 
	
		
			
				|  |  |                         jsonObjects.add(redisValue);
 | 
	
		
			
				|  |  |                         hasGXY = true;//设置有高血压
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                     if ("2".equals(disease)) {
 | 
	
		
			
				|  |  |                         jsonObjects.add(redisValue);
 | 
	
		
			
				|  |  |                         hasTNB = true;//设置有糖尿病
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if(jsonObjects.size()==0){
 | 
	
		
			
				|  |  |                     continue;//如果没有高血压和糖尿病 不统计
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (hasGXY && hasTNB) {
 | 
	
		
			
				|  |  |                     group = "6";//有高血压又有糖尿病
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     group = Integer.valueOf(jsonObjects.get(0).get("disease").toString()) + 3 + "";//4高血压,5糖尿病
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (cityGroupMap.containsKey(Constant.city)) {
 | 
	
		
			
				|  |  |                     Map<String, Long> groupMapTemp = cityGroupMap.get(Constant.city);
 | 
	
		
			
				|  |  |                     groupMapTemp.put(group, (groupMapTemp.get(group) == null ? 0l : groupMapTemp.get(group)) + 1);
 | 
	
		
			
				|  |  |                     cityGroupMap.put(Constant.city, groupMapTemp);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                     groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                     cityGroupMap.put(Constant.city, groupMapTemp);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //统计区
 | 
	
		
			
				|  |  |                 if (townGroupMap.containsKey(town)) {
 | 
	
		
			
				|  |  |                     Map<String, Long> groupMapTemp = townGroupMap.get(town);
 | 
	
		
			
				|  |  |                     groupMapTemp.put(group, (groupMapTemp.get(group) == null ? 0l : groupMapTemp.get(group)) + 1);
 | 
	
		
			
				|  |  |                     townGroupMap.put(town, groupMapTemp);
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                     groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                     townGroupMap.put(town, groupMapTemp);
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 //统计机构
 | 
	
		
			
				|  |  |                 //统计站
 | 
	
		
			
				|  |  |                 String org=hospital.getCode();
 | 
	
		
			
				|  |  |                 if (!"00".equals(org.substring(org.length()-2,org.length()))) {
 | 
	
		
			
				|  |  |                     orgCodeTemp =org.substring(0,org.length()-2)+"00";
 | 
	
		
			
				|  |  |                     //统计机构
 | 
	
		
			
				|  |  |                     if (orgGroupMap.containsKey(orgCodeTemp)) {
 | 
	
		
			
				|  |  |                         Map<String, Long> groupMapTemp = orgGroupMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |                         groupMapTemp.put(group, (groupMapTemp.get(group) == null ? 0l : groupMapTemp.get(group)) + 1);
 | 
	
		
			
				|  |  |                         orgGroupMap.put(orgCodeTemp, groupMapTemp);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                         groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                         orgGroupMap.put(orgCodeTemp, groupMapTemp);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     //统计机构
 | 
	
		
			
				|  |  |                     if (orgGroupMap.containsKey(hospital.getCode())) {
 | 
	
		
			
				|  |  |                         Map<String, Long> groupMapTemp = orgGroupMap.get(hospital.getCode());
 | 
	
		
			
				|  |  |                         groupMapTemp.put(group, (groupMapTemp.get(group) == null ? 0l : groupMapTemp.get(group)) + 1);
 | 
	
		
			
				|  |  |                         orgGroupMap.put(hospital.getCode(), groupMapTemp);
 | 
	
		
			
				|  |  |                     } else {
 | 
	
		
			
				|  |  |                         Map<String, Long> groupMapTemp = new HashMap<String, Long>();
 | 
	
		
			
				|  |  |                         groupMapTemp.put(group, 1L);
 | 
	
		
			
				|  |  |                         orgGroupMap.put(hospital.getCode(), groupMapTemp);
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存统计数据
 | 
	
		
			
				|  |  |         //保存市的统计数据
 | 
	
		
			
				|  |  |         for (Map.Entry<String, Map<String, Long>> entry : cityGroupMap.entrySet()) {
 | 
	
		
			
				|  |  |             //保存健康人群
 | 
	
		
			
				|  |  |             JSONObject jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_1)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",entry.getValue().get(Constant.level_group_1));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",Constant.cityName);
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:1:"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存慢病人群
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_2)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",entry.getValue().get(Constant.level_group_2));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",Constant.cityName);
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:2:"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存65岁以上人群
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_3)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",entry.getValue().get(Constant.level_group_3));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",Constant.cityName);
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:3:"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存高血压
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_4)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",entry.getValue().get(Constant.level_group_4));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",Constant.cityName);
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:4:"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存糖尿病
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_5)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",entry.getValue().get(Constant.level_group_5));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",Constant.cityName);
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:5:"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存糖尿病和高血压
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_6)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",entry.getValue().get(Constant.level_group_6));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",Constant.cityName);
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:6:"+entry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //保存区级
 | 
	
		
			
				|  |  |         //保存区的统计数据
 | 
	
		
			
				|  |  |         for (Map.Entry<String, Town> townEntry : townsMap.entrySet()) {//保存健康人群
 | 
	
		
			
				|  |  |             JSONObject jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             Town town=townsMap.get(townEntry.getKey());
 | 
	
		
			
				|  |  |             Map<String, Long> oneTown= townGroupMap.get(townEntry.getKey());
 | 
	
		
			
				|  |  |             if (oneTown != null && oneTown.containsKey(Constant.level_group_1)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneTown.get(Constant.level_group_1));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",town.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:1:"+townEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存慢病人群
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneTown != null && oneTown.containsKey(Constant.level_group_2)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneTown.get(Constant.level_group_2));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",town.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:2:"+townEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存65岁以上人群
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneTown != null && oneTown.containsKey(Constant.level_group_3)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneTown.get(Constant.level_group_3));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",town.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:3:"+townEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存高血压
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneTown != null && oneTown.containsKey(Constant.level_group_4)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneTown.get(Constant.level_group_4));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",town.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:4:"+townEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存糖尿病
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneTown != null && oneTown.containsKey(Constant.level_group_5)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneTown.get(Constant.level_group_5));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",town.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:5:"+townEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存糖尿病和高血压
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneTown != null && oneTown.containsKey(Constant.level_group_6)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneTown.get(Constant.level_group_6));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",town.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:6:"+townEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //保存机构
 | 
	
		
			
				|  |  |         for (Map.Entry<String, Hospital> hospitalEntry : hospitalsMap.entrySet()) {
 | 
	
		
			
				|  |  |             //保存健康人群
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(hospitalEntry.getKey());
 | 
	
		
			
				|  |  |             if(hospital == null) continue;
 | 
	
		
			
				|  |  |             JSONObject jsonObject=new JSONObject();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             Map<String, Long> oneOrg= orgGroupMap.get(hospitalEntry.getKey());
 | 
	
		
			
				|  |  |             if (oneOrg != null && oneOrg.containsKey(Constant.level_group_1)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneOrg.get(Constant.level_group_1));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",hospital.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:1:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存慢病人群
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneOrg != null && oneOrg.containsKey(Constant.level_group_2)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneOrg.get(Constant.level_group_2));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",hospital.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:2:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |             //保存65岁以上人群
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneOrg != null && oneOrg.containsKey(Constant.level_group_3)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneOrg.get(Constant.level_group_3));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",hospital.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:3:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存高血压
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneOrg != null && oneOrg.containsKey(Constant.level_group_4)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneOrg.get(Constant.level_group_4));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",hospital.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:4:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存糖尿病
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneOrg != null && oneOrg.containsKey(Constant.level_group_5)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneOrg.get(Constant.level_group_5));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",hospital.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:5:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |             //保存糖尿病和高血压
 | 
	
		
			
				|  |  |             jsonObject=new JSONObject();
 | 
	
		
			
				|  |  |             if (oneOrg != null && oneOrg.containsKey(Constant.level_group_6)) {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",oneOrg.get(Constant.level_group_6));
 | 
	
		
			
				|  |  |             } else {
 | 
	
		
			
				|  |  |                 jsonObject.put("num",0);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             jsonObject.put("name",hospital.getName());
 | 
	
		
			
				|  |  |             jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
 | 
	
		
			
				|  |  |             redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:6:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("----------7-----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_8()throws Exception {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="8";
 | 
	
		
			
				|  |  |         //找出今天的签约信息
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterdayExpensesStatus(now, tomorrow);
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(SignFamily signFamily:signFamilys){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnData1s= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             List<Map<String, Map<String, List<ETLModel>>>> patientAgeRoleData= patientAgeRole.elt(returnData1s);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel2(patientAgeRoleData,quotaId,6,2);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("----------8-----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_9() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="9";
 | 
	
		
			
				|  |  |         //找出今天的待签约信息
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingWaitSignYesterdayExpensesStatus(now,tomorrow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(SignFamily signFamily:signFamilys){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||(idCard.length()!=18&&idCard.length()!=15)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,quotaId);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("----------9-----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     private void computequota_10() {
 | 
	
		
			
				|  |  |         StringBuffer errorContent=new StringBuffer();
 | 
	
		
			
				|  |  |         String quotaId="10";
 | 
	
		
			
				|  |  |         //查找出系统全部的全科医生
 | 
	
		
			
				|  |  |         List<AdminTeam> adminTeams=doctorAdminTeamDao.findAllTeam();
 | 
	
		
			
				|  |  |         Map<String, AdminTeam> adminTeamMap = new HashMap<String, AdminTeam>();
 | 
	
		
			
				|  |  |         for (AdminTeam adminTeam : adminTeams) {
 | 
	
		
			
				|  |  |             adminTeamMap.put(adminTeam.getId()+"", adminTeam);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //查找出系统全部的机构
 | 
	
		
			
				|  |  |         List<Hospital> hospitals = hospitalDao.findHospital2();
 | 
	
		
			
				|  |  |         Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
 | 
	
		
			
				|  |  |         for (Hospital hospital : hospitals) {
 | 
	
		
			
				|  |  |             hospitalsMap.put(hospital.getCode(), hospital);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //查找出厦门市全部的区
 | 
	
		
			
				|  |  |         List<Town> towns = townDao.findByCityCode(Constant.city);
 | 
	
		
			
				|  |  |         Map<String, Town> townsMap = new HashMap<String, Town>();
 | 
	
		
			
				|  |  |         for (Town town : towns) {
 | 
	
		
			
				|  |  |             townsMap.put(town.getCode(), town);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //找出今天的已改簽信息
 | 
	
		
			
				|  |  |         List<SignFamily> signFamilys = signFamilyDao.findByJiatingChaangeSignYesterdayExpensesStatus(now,tomorrow);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         Long cityCount = new Long(0L); //统计到市的数目
 | 
	
		
			
				|  |  |         Long townCount = new Long(0L); //统计到所有区的数目
 | 
	
		
			
				|  |  |         Long orgCount =new Long(0L);//统计到所有机构的数目
 | 
	
		
			
				|  |  |         Long adminCount = new Long(0L);//统计到所有团队的数目
 | 
	
		
			
				|  |  |         Long errorCount=new Long(0L);//脏数据
 | 
	
		
			
				|  |  |         Boolean isAll=true;//是否统计失败
 | 
	
		
			
				|  |  |         //统计有已改簽的
 | 
	
		
			
				|  |  |         List<ETLModel> etlModels=new ArrayList<ETLModel>();
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------start
 | 
	
		
			
				|  |  |         for(SignFamily signFamily:signFamilys){
 | 
	
		
			
				|  |  |             ETLModel etlModel=new ETLModel();
 | 
	
		
			
				|  |  |             String orgCode = signFamily.getHospital();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(orgCode)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String orgCodeTemp="";
 | 
	
		
			
				|  |  |             if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
 | 
	
		
			
				|  |  |                 //站
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
 | 
	
		
			
				|  |  |             }else{
 | 
	
		
			
				|  |  |                 //社区
 | 
	
		
			
				|  |  |                 orgCodeTemp=orgCode;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             //判断社区有没有值
 | 
	
		
			
				|  |  |             Hospital hospital=hospitalsMap.get(orgCodeTemp);
 | 
	
		
			
				|  |  |             if(hospital == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Long adminId=signFamily.getAdminTeamId();
 | 
	
		
			
				|  |  |             if(adminId == null||adminId<=0) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
 | 
	
		
			
				|  |  |             if(adminTeam == null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String idCard=signFamily.getIdcard();
 | 
	
		
			
				|  |  |             if(idCard == null||(idCard.length()!=18&&idCard.length()!=15)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             String town =hospital.getTown();
 | 
	
		
			
				|  |  |             if(StringUtils.isEmpty(town)) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             Town townObj =townsMap.get(town);
 | 
	
		
			
				|  |  |             if(townObj==null) {
 | 
	
		
			
				|  |  |                 errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
 | 
	
		
			
				|  |  |                 isAll=false;
 | 
	
		
			
				|  |  |                 errorCount++;
 | 
	
		
			
				|  |  |                 continue;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             etlModel.setAdminTeam(adminTeam.getId()+"");
 | 
	
		
			
				|  |  |             etlModel.setHospital(orgCodeTemp);
 | 
	
		
			
				|  |  |             etlModel.setTown(hospital.getTown());
 | 
	
		
			
				|  |  |             etlModel.setCity(Constant.city);
 | 
	
		
			
				|  |  |             etlModel.setIdcard(signFamily.getIdcard());
 | 
	
		
			
				|  |  |             etlModels.add(etlModel);
 | 
	
		
			
				|  |  |             //统计数目+1
 | 
	
		
			
				|  |  |             cityCount++;
 | 
	
		
			
				|  |  |             townCount++;
 | 
	
		
			
				|  |  |             orgCount++;
 | 
	
		
			
				|  |  |             adminCount++;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         //数据过滤清洗出脏数据  -----------end
 | 
	
		
			
				|  |  |         try{
 | 
	
		
			
				|  |  |             //统计数据
 | 
	
		
			
				|  |  |             List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels);
 | 
	
		
			
				|  |  |             //保存数据
 | 
	
		
			
				|  |  |             redisStorage.saveByLevel1(returnDatas,quotaId);
 | 
	
		
			
				|  |  |         }catch (Exception e){
 | 
	
		
			
				|  |  |             e.printStackTrace();
 | 
	
		
			
				|  |  |             errorContent.append("统计失败:"+e.getMessage());
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
 | 
	
		
			
				|  |  |         allContent.append(errorContent);
 | 
	
		
			
				|  |  |         allContent.append("-----------10----------");
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public Properties getSystemProperties() {
 | 
	
		
			
				|  |  |         if (systemProperties == null) {
 | 
	
		
			
				|  |  |             InputStream is = null;
 | 
	
		
			
				|  |  |             try {
 | 
	
		
			
				|  |  |                 is = this.getClass().getResourceAsStream("/application.properties");
 | 
	
		
			
				|  |  |                 systemProperties = new Properties();
 | 
	
		
			
				|  |  |                 systemProperties.load(is);
 | 
	
		
			
				|  |  |             } catch (IOException e1) {
 | 
	
		
			
				|  |  |                 e1.printStackTrace();
 | 
	
		
			
				|  |  |             } finally {
 | 
	
		
			
				|  |  |                 if (is != null) {
 | 
	
		
			
				|  |  |                     try {
 | 
	
		
			
				|  |  |                         is.close();
 | 
	
		
			
				|  |  |                     } catch (IOException e) {
 | 
	
		
			
				|  |  |                         e.printStackTrace();
 | 
	
		
			
				|  |  |                     }
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return systemProperties;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public static String getDayString(Integer size) {
 | 
	
		
			
				|  |  |         Date date = new Date();//取时间
 | 
	
		
			
				|  |  |         Calendar calendar = new GregorianCalendar();
 | 
	
		
			
				|  |  |         calendar.setTime(date);
 | 
	
		
			
				|  |  |         calendar.add(calendar.DATE, size);//把日期往后增加一天.整数往后推,负数往前移动
 | 
	
		
			
				|  |  |         date = calendar.getTime(); //这个时间就是日期往后推一天的结果
 | 
	
		
			
				|  |  |         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
 | 
	
		
			
				|  |  |         String dateString = formatter.format(date);
 | 
	
		
			
				|  |  |         return dateString;
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     public List<Map<String,Object>> getFvYesterday() {
 | 
	
		
			
				|  |  |         String now = getDayString(0);
 | 
	
		
			
				|  |  |         String tomorrow = getDayString(1);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql=" select * from fv_plan a where unix_timestamp(a.update_time)>=unix_timestamp('"+now+"') and unix_timestamp(a.update_time)< unix_timestamp('"+tomorrow+"')  ";
 | 
	
		
			
				|  |  |         return jdbcTemplate.queryForList(sql);
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |     /**
 | 
	
		
			
				|  |  |      * 根据年龄得到对应的code
 | 
	
		
			
				|  |  |      * @param age
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  |     public String getAgeCode(int age) {
 | 
	
		
			
				|  |  |         if (age < 7) {
 | 
	
		
			
				|  |  |             return Constant.level_age_1;
 | 
	
		
			
				|  |  |         } else if (age >= 7 && age < 18) {
 | 
	
		
			
				|  |  |             return Constant.level_age_2;
 | 
	
		
			
				|  |  |         } else if (age >= 18 && age < 30) {
 | 
	
		
			
				|  |  |             return Constant.level_age_3;
 | 
	
		
			
				|  |  |         } else if (age >= 30 && age < 50) {
 | 
	
		
			
				|  |  |             return Constant.level_age_4;
 | 
	
		
			
				|  |  |         } else if (age >= 50 && age < 65) {
 | 
	
		
			
				|  |  |             return Constant.level_age_5;
 | 
	
		
			
				|  |  |         } else {
 | 
	
		
			
				|  |  |             return Constant.level_age_6;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     private String getOrg(String org){
 | 
	
		
			
				|  |  |         //if(!"00".equals(org.substring(org.length()-2,org.length()))){
 | 
	
		
			
				|  |  |         if(org.length() == 10 && !org.endsWith("00")){
 | 
	
		
			
				|  |  |             return org.substring(0,org.length()-2)+"00";
 | 
	
		
			
				|  |  |         }else{
 | 
	
		
			
				|  |  |             return org;
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  |     private String saveContent(String id,Integer size, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent,Long errorCount) {
 | 
	
		
			
				|  |  |         StringBuffer string=new StringBuffer("统计 quotaid:"+id+" 的数据完成 ,数据库查询到改签数目:"+size);
 | 
	
		
			
				|  |  |         string.append(",过滤的脏数据数目:"+errorCount);
 | 
	
		
			
				|  |  |         string.append(",统计到市的数据总数:"+cityCount);
 | 
	
		
			
				|  |  |         string.append(",统计到区的数据总数:"+townCount);
 | 
	
		
			
				|  |  |         string.append(",统计到机构的数据总数:"+orgCount);
 | 
	
		
			
				|  |  |         string.append(",统计到团队的数据总数:"+qkCount);
 | 
	
		
			
				|  |  |         string.append(",是否统计成功:"+isAll);
 | 
	
		
			
				|  |  |         if(!isAll){
 | 
	
		
			
				|  |  |             string.append(",失败原因:"+errorContent);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         return string.toString();
 | 
	
		
			
				|  |  |     }
 | 
	
		
			
				|  |  | }
 |