1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564 |
- package com.yihu.wlyy.job;
- import com.yihu.wlyy.entity.organization.Hospital;
- import com.yihu.wlyy.entity.address.Town;
- import com.yihu.wlyy.entity.doctor.profile.Doctor;
- import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatientGroupInfo;
- import com.yihu.wlyy.entity.job.QuartzJobLog;
- import com.yihu.wlyy.entity.patient.SignFamily;
- import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
- import com.yihu.wlyy.repository.address.TownDao;
- import com.yihu.wlyy.repository.doctor.DoctorDao;
- import com.yihu.wlyy.repository.doctor.DoctorPatientGroupInfoDao;
- import com.yihu.wlyy.repository.job.QuartzJobLogDao;
- import com.yihu.wlyy.repository.organization.HospitalDao;
- import com.yihu.wlyy.repository.patient.SignFamilyDao;
- import com.yihu.wlyy.repository.statistics.WlyyQuotaResultDao;
- import com.yihu.wlyy.util.IdCardUtil;
- import com.yihu.wlyy.web.quota.WlyyJobConfigVO;
- import com.yihu.wlyy.web.quota.WlyyQuotaVO;
- import org.json.JSONArray;
- import org.json.JSONObject;
- import org.quartz.Job;
- import org.quartz.JobDataMap;
- 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.transaction.annotation.Transactional;
- import org.springframework.util.StringUtils;
- import org.springframework.web.context.support.SpringBeanAutowiringSupport;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * 签约的指标执行类
- */
- @Component
- public class SignJob implements Job {
- private WlyyQuotaVO wlyyQuota;//指标对象
- private WlyyJobConfigVO wlyyJobConfig;//配置对象
- @Autowired
- private WlyyQuotaResultDao wlyyQuotaResultDao;//指标结果Dao
- @Autowired
- private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
- @Autowired
- private SignFamilyDao signFamilyDao;
- @Autowired
- private DoctorDao doctorDao;
- @Autowired
- private HospitalDao hospitalDao;
- @Autowired
- private TownDao townDao;
- @Autowired
- private DoctorPatientGroupInfoDao doctorPatientGroupInfoDao;
- @Autowired
- private JdbcTemplate jdbcTemplate;
- @Autowired
- private StringRedisTemplate redisTemplate;
- String yesterday;
- String now;
- @Override
- public void execute(JobExecutionContext context)
- throws JobExecutionException {
- SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
- //初始化参数
- JobDataMap map = context.getJobDetail().getJobDataMap();
- wlyyQuota = (WlyyQuotaVO) map.get("quota");
- wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
- now = StringUtils.isEmpty(map.get("now")) ? SignJob.getDayString(0) : map.get("now").toString();
- yesterday = StringUtils.isEmpty(map.get("yesterday")) ? SignJob.getDayString(-1) : map.get("yesterday").toString();
- String level1 = wlyyQuota.getLevel1();//得到一级维度
- String level2 = wlyyQuota.getLevel2();//得到二级维度
- //如果一级维度为空 不进行统计
- if (!StringUtils.isEmpty(level1)) {
- if (StringUtils.isEmpty(level2)) {
- //線刪除今天的数据
- //2级维度是空按照一级的机构唯独计算指标
- computequota();
- } else {
- switch (level2) {
- case "1": {
- //線刪除今天的数据
- //患者性别
- computequotaByPatientSex();
- break;
- }
- case "2": {
- //患者分组
- computequotaByPatientGroup();
- break;
- }
- case "3": {
- //患者年龄
- computequotaByPatientAge();
- break;
- }
- }
- }
- }
- }
- /**
- * 机构维度下患者性别维度计算指标
- */
- @Transactional
- private void computequotaByPatientSex() {
- jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 6 + "'");
- try {
- //新建任务日志对象
- QuartzJobLog QuartzJobLog = new QuartzJobLog();
- QuartzJobLog.setJobStartTime(new Date());
- QuartzJobLog.setJobId(wlyyJobConfig.getId());
- QuartzJobLog.setJobName(wlyyJobConfig.getJobName());
- //查找出系统全部的机构
- List<Hospital> hospitals = hospitalDao.findHospitalzxFWZ();
- 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.findByJiatingSignYesterday(yesterday, now);
- //数组里面第一个是女 第二个是男 第三个是未知
- Map<String, Map<String, Long>> citySexMap = new HashMap<String, Map<String, Long>>();//key是市行政代码 目前只有厦门市
- citySexMap.put(Constant.city, new HashMap<String, Long>());
- Map<String, Map<String, Long>> townSexMap = new HashMap<String, Map<String, Long>>();//key是区行政代码
- Map<String, Map<String, Long>> orgSexMap = new HashMap<String, Map<String, Long>>();//key是机构代码
- //统计有签约的
- for (SignFamily signFamily : signFamilys) {
- String idcard = signFamily.getIdcard();//得到签约中患者的身份证号
- Hospital hospital = hospitalsMap.get(signFamily.getHospital());//得到患者签约的机构
- String town = hospital.getTown();//得到患者签约的机构的区号
- String hospitalCode = hospital.getCode();//得到患者签约的机构号
- String sex = IdCardUtil.getSexForIdcard(idcard);//根据身份证得到性别
- //统计市 目前只统计厦门市 所以先写死 后期再改造
- compute_level2_1(citySexMap,Constant.city, sex);
- //统计区
- compute_level2_1(townSexMap,town, sex);
- //统计机构
- //统计站
- String orgCode=hospital.getCode();
- if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
- //统计站
- String orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
- compute_level2_1(orgSexMap,orgCodeTemp, sex);
- } else {
- //统计社区
- compute_level2_1(orgSexMap,hospitalCode, sex);
- }
- }
- //保存统计数据
- //保存市统计数据
- for (Map.Entry<String, Map<String, Long>> entry : citySexMap.entrySet()) {
- for(int i=1;i<4;i++){
- String key=i+"";
- String city=Constant.city;
- String cityName=Constant.cityName;
- String town="";
- String townName="";
- String org="";
- String orgName="";
- String level="3";
- save_level2_1(entry.getValue(), key, city, cityName, town, townName, org, orgName, level);
- }
- }
- //保存区的统计数据
- for (Map.Entry<String, Town> townEntry : townsMap.entrySet()) {
- //判断该区是否有统计数据
- Map<String, Long> oneTownSexMap = townSexMap.get(townEntry.getKey());//得到当个区的统计数据
- Town townObj = townEntry.getValue();//得到区级信息
- for(int i=1;i<4;i++){
- String key=i+"";
- String city=Constant.city;
- String cityName=Constant.cityName;
- String town=townObj.getCode();
- String townName=townObj.getName();
- String org="";
- String orgName="";
- String level="3";
- save_level2_1(oneTownSexMap, key, city, cityName, town, townName, org, orgName, level);
- }
- }
- //统计机构
- for (Map.Entry<String, Hospital> hospitalEntry : hospitalsMap.entrySet()) {
- //判断该机构是否有统计数据
- Map<String, Long> oneorgSexMap = orgSexMap.get(hospitalEntry.getKey());//得到当个机构的统计数据
- Hospital hospital = hospitalEntry.getValue();//得到区级信息
- for(int i=1;i<4;i++){
- String key=i+"";
- String city=Constant.city;
- String cityName=Constant.cityName;
- String town=hospital.getTown();
- String townName=hospital.getTownName();
- String org=hospital.getCode();
- String orgName=hospital.getName();
- String level="2";
- save_level2_1(oneorgSexMap, key, city, cityName, town, townName, org, orgName, level);
- }
- }
- QuartzJobLog.setJobEndTime(new Date());
- QuartzJobLog.setJobContent("统计" + getYesterday() + " 的签约性别数据完成 ,得到签约数目:"+signFamilys.size());
- QuartzJobLog.setJobType("1");
- quartzJobLogDao.save(QuartzJobLog);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 机构维度下患者性别维度计算指标 公用保存方法
- * @param oneorgSexMap
- * @param key
- * @param city
- * @param cityName
- * @param town
- * @param townName
- * @param org
- * @param orgName
- * @param level
- */
- private void save_level2_1(Map<String, Long> oneorgSexMap, String key, String city, String cityName, String town, String townName, String org, String orgName, String level) {
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(city);
- wlyyQuotaResult.setCityName(cityName);
- wlyyQuotaResult.setTown(town);
- wlyyQuotaResult.setTownName(townName);
- wlyyQuotaResult.setOrgCode(org);
- wlyyQuotaResult.setOrgName(orgName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type(level);//机构级
- wlyyQuotaResult.setLevel2Type(key);
- wlyyQuotaResult.setLevel2TypeName(Constant.getLevelSexName(key));
- if (oneorgSexMap != null && oneorgSexMap.containsKey(key)) {
- wlyyQuotaResult.setResult(oneorgSexMap.get(key) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- private void compute_level2_1(Map<String, Map<String, Long>> citySexMap,String key, String sex) {
- if (citySexMap.containsKey(key)) {
- Map<String, Long> sexMap = citySexMap.get(key);
- sexMap.put(sex, (sexMap.get(sex) == null ? 0l : sexMap.get(sex)) + 1);
- citySexMap.put(key, sexMap);
- } else {
- Map<String, Long> sexMap = new HashMap<String, Long>();
- sexMap.put(sex, 1L);
- citySexMap.put(key, sexMap);
- }
- }
- /**
- * 机构维度患者分组维度计算指标
- */
- @Transactional
- private void computequotaByPatientGroup() {
- jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 7 + "'");
- try {
- //数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
- 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是机构代码
- //新建任务日志对象
- QuartzJobLog QuartzJobLog = new QuartzJobLog();
- QuartzJobLog.setJobStartTime(new Date());
- QuartzJobLog.setJobId(wlyyJobConfig.getId());
- QuartzJobLog.setJobName(wlyyJobConfig.getJobName());
- //查找出系统全部的机构
- List<Hospital> hospitals = hospitalDao.findHospital2();
- Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
- for (Hospital hospital : hospitals) {
- hospitalsMap.put(hospital.getCode(), hospital);
- Map<String, Long> one = new HashMap<String, Long>();
- one.put("1", 0L);
- one.put("2", 0L);
- one.put("3", 0L);
- one.put("4", 0L);
- one.put("5", 0L);
- one.put("100", 0L);
- orgGroupMap.put(hospital.getCode(), one);
- }
- //查找出厦门市全部的区
- List<Town> towns = townDao.findByCityCode(Constant.city);
- Map<String, Town> townsMap = new HashMap<String, Town>();
- for (Town town : towns) {
- townsMap.put(town.getCode(), town);
- Map<String, Long> one = new HashMap<String, Long>();
- one.put("1", 0L);
- one.put("2", 0L);
- one.put("3", 0L);
- one.put("4", 0L);
- one.put("5", 0L);
- one.put("100", 0L);
- townGroupMap.put(town.getCode(), one);
- }
- //找出今天的签约信息
- List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(yesterday, now);
- //统计有签约的
- for (SignFamily signFamily : signFamilys) {
- String patient = signFamily.getPatient();
- //设置查看病人所在分组
- List<DoctorPatientGroupInfo> dctorPatientGroupInfo = doctorPatientGroupInfoDao.findByMorenPatient(patient);
- String group ="";//得到该签约病人的所在分组 1 普通 2 慢病 3是 65岁以上人群 4是 高血压 5是糖尿病 100是高血压和糖尿病
- if (dctorPatientGroupInfo != null && dctorPatientGroupInfo.size() > 0) {
- group=dctorPatientGroupInfo.get(0).getGroup();
- } else {
- group="1";
- }
- Hospital hospital = hospitalsMap.get(signFamily.getHospital());//得到患者签约的机构
- if (hospital == null) {
- continue;
- }
- String 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);
- }
- //统计站
- String orgCode=hospital.getCode();
- if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
- //统计站
- String orgCodeTemp=orgCode.substring(0,orgCode.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);
- }
- }
- 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.get("signType").toString())) {
- 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 = "100";//有高血压又有糖尿病
- } else if(hasGXY){
- group = 4 + "";//4高血压,5糖尿病
- }else if(hasTNB){
- group = 5 + "";//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);
- }
- //统计机构
- //统计站
- if (!"00".equals(hospital.getCode().substring(8))) {
- String orgCodeTemp = hospital.getCode().substring(0, 8) + "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);
- }
- }
- }
- }
- //保存统计数据
- //保存市的统计数据
- for (Map.Entry<String, Map<String, Long>> entry : cityGroupMap.entrySet()) {
- //保存健康人群
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_1);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_1_name);
- if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_1)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_group_1) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存慢病人群
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_2);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_2_name);
- if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_2)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_group_2) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存65岁以上人群
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_3);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_3_name);
- if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_3)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_group_3) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存高血压
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_4);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_4_name);
- if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_4)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_group_4) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存糖尿病
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_5);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_5_name);
- if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_5)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_group_5) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存糖尿病和高血压
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_100);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_100_name);
- if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_100)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_group_100) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- //保存区级
- //保存区的统计数据
- for (Map.Entry<String, Town> townEntry : townsMap.entrySet()) {
- //判断该区是否有统计数据
- Map<String, Long> oneTownGroupMap = townGroupMap.get(townEntry.getKey());//得到当个区的统计数据
- Town town = townEntry.getValue();//得到区级信息
- //保存健康人群
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_1);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_1_name);
- if (oneTownGroupMap != null && oneTownGroupMap.containsKey(Constant.level_group_1)) {
- wlyyQuotaResult.setResult(oneTownGroupMap.get(Constant.level_group_1) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存慢病人群
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_2);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_2_name);
- if (oneTownGroupMap != null && oneTownGroupMap.containsKey(Constant.level_group_2)) {
- wlyyQuotaResult.setResult(oneTownGroupMap.get(Constant.level_group_2) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存65岁以上人群
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_3);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_3_name);
- if (oneTownGroupMap != null && oneTownGroupMap.containsKey(Constant.level_group_3)) {
- wlyyQuotaResult.setResult(oneTownGroupMap.get(Constant.level_group_3) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存高血压
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_4);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_4_name);
- if (oneTownGroupMap != null && oneTownGroupMap.containsKey(Constant.level_group_4)) {
- wlyyQuotaResult.setResult(oneTownGroupMap.get(Constant.level_group_4) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存糖尿病
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_5);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_5_name);
- if (oneTownGroupMap != null && oneTownGroupMap.containsKey(Constant.level_group_5)) {
- wlyyQuotaResult.setResult(oneTownGroupMap.get(Constant.level_group_5) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存糖尿病
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_100);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_100_name);
- if (oneTownGroupMap != null && oneTownGroupMap.containsKey(Constant.level_group_100)) {
- wlyyQuotaResult.setResult(oneTownGroupMap.get(Constant.level_group_100) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- //保存机构
- for (Map.Entry<String, Hospital> hospitalEntry : hospitalsMap.entrySet()) {
- //判断该机构是否有统计数据
- Map<String, Long> oneOrgGroupMap = orgGroupMap.get(hospitalEntry.getKey());//得到当个机构的统计数据
- Hospital hospital = hospitalEntry.getValue();//得到区级信息
- //保存健康人群
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_1);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_1_name);
- if (oneOrgGroupMap != null && oneOrgGroupMap.containsKey(Constant.level_group_1)) {
- wlyyQuotaResult.setResult(oneOrgGroupMap.get(Constant.level_group_1) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存慢病
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_2);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_2_name);
- if (oneOrgGroupMap != null && oneOrgGroupMap.containsKey(Constant.level_group_2)) {
- wlyyQuotaResult.setResult(oneOrgGroupMap.get(Constant.level_group_2) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存65岁以上人群
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_3);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_3_name);
- if (oneOrgGroupMap != null && oneOrgGroupMap.containsKey(Constant.level_group_3)) {
- wlyyQuotaResult.setResult(oneOrgGroupMap.get(Constant.level_group_3) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存高血压
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_4);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_4_name);
- if (oneOrgGroupMap != null && oneOrgGroupMap.containsKey(Constant.level_group_4)) {
- wlyyQuotaResult.setResult(oneOrgGroupMap.get(Constant.level_group_4) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存糖尿病
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_5);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_5_name);
- if (oneOrgGroupMap != null && oneOrgGroupMap.containsKey(Constant.level_group_5)) {
- wlyyQuotaResult.setResult(oneOrgGroupMap.get(Constant.level_group_5) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存糖尿病和高血压
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_group_100);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_group_100_name);
- if (oneOrgGroupMap != null && oneOrgGroupMap.containsKey(Constant.level_group_100)) {
- wlyyQuotaResult.setResult(oneOrgGroupMap.get(Constant.level_group_100) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- QuartzJobLog.setJobEndTime(new Date());
- QuartzJobLog.setJobContent("统计" + getYesterday() + " 的签约病人分组数据完成 ,得到签约数目:"+signFamilys.size());
- QuartzJobLog.setJobType("1");
- quartzJobLogDao.save(QuartzJobLog);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 机构维度患者年龄维度计算指标
- */
- @Transactional
- private void computequotaByPatientAge() {
- try {
- jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 8 + "'");
- //新建任务日志对象
- QuartzJobLog QuartzJobLog = new QuartzJobLog();
- QuartzJobLog.setJobStartTime(new Date());
- QuartzJobLog.setJobId(wlyyJobConfig.getId());
- QuartzJobLog.setJobName(wlyyJobConfig.getJobName());
- //查找出系统全部的机构
- 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.findByJiatingSignYesterday(yesterday, now);
- //数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
- Map<String, Map<String, Long>> cityAgeMap = new HashMap<String, Map<String, Long>>();//key是市行政代码 目前只有厦门市
- cityAgeMap.put(Constant.city, new HashMap<String, Long>());
- Map<String, Map<String, Long>> townAgeMap = new HashMap<String, Map<String, Long>>();//key是区行政代码
- Map<String, Map<String, Long>> orgAgeMap = new HashMap<String, Map<String, Long>>();//key是机构代码
- //统计有签约的
- for (SignFamily signFamily : signFamilys) {
- Hospital hospital = hospitalsMap.get(signFamily.getHospital());//得到患者签约的机构
- String town = hospital.getTown();
- int age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());//根据card解析年龄
- String ageCode = getAgeCode(age);//得到年龄的code
- //统计市
- if (cityAgeMap.containsKey(Constant.city)) {
- Map<String, Long> groupMapTemp = cityAgeMap.get(Constant.city);
- groupMapTemp.put(ageCode, (groupMapTemp.get(ageCode) == null ? 0l : groupMapTemp.get(ageCode)) + 1);
- cityAgeMap.put(Constant.city, groupMapTemp);
- } else {
- Map<String, Long> groupMapTemp = new HashMap<String, Long>();
- groupMapTemp.put(ageCode, 1L);
- cityAgeMap.put(Constant.city, groupMapTemp);
- }
- //统计区
- if (townAgeMap.containsKey(town)) {
- Map<String, Long> groupMapTemp = townAgeMap.get(town);
- groupMapTemp.put(ageCode, (groupMapTemp.get(ageCode) == null ? 0l : groupMapTemp.get(ageCode)) + 1);
- townAgeMap.put(town, groupMapTemp);
- } else {
- Map<String, Long> groupMapTemp = new HashMap<String, Long>();
- groupMapTemp.put(ageCode, 1L);
- townAgeMap.put(town, groupMapTemp);
- }
- //统计机构
- //统计站
- String orgCode=hospital.getCode();
- if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
- //统计站
- String orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
- //统计机构
- if (orgAgeMap.containsKey(orgCodeTemp)) {
- Map<String, Long> groupMapTemp = orgAgeMap.get(orgCodeTemp);
- groupMapTemp.put(ageCode, (groupMapTemp.get(ageCode) == null ? 0l : groupMapTemp.get(ageCode)) + 1);
- orgAgeMap.put(orgCodeTemp, groupMapTemp);
- } else {
- Map<String, Long> groupMapTemp = new HashMap<String, Long>();
- groupMapTemp.put(ageCode, 1L);
- orgAgeMap.put(orgCodeTemp, groupMapTemp);
- }
- } else {
- //统计机构
- if (orgAgeMap.containsKey(hospital.getCode())) {
- Map<String, Long> groupMapTemp = orgAgeMap.get(hospital.getCode());
- groupMapTemp.put(ageCode, (groupMapTemp.get(ageCode) == null ? 0l : groupMapTemp.get(ageCode)) + 1);
- orgAgeMap.put(hospital.getCode(), groupMapTemp);
- } else {
- Map<String, Long> groupMapTemp = new HashMap<String, Long>();
- groupMapTemp.put(ageCode, 1L);
- orgAgeMap.put(hospital.getCode(), groupMapTemp);
- }
- }
- }
- //保存统计数据
- // 保存市的统计数据
- for (Map.Entry<String, Map<String, Long>> entry : cityAgeMap.entrySet()) {
- Map<String, Long> oneAgeMap = entry.getValue();
- //保存0~6
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_1);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_1_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_1)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_age_1) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存7~18
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_2);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_2_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_2)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_age_2) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存18~30
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_3);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_3_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_3)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_age_3) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存30~50
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_4);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_4_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_4)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_age_4) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存50~65
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_5);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_5_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_5)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_age_5) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存18~30
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");//市级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_6);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_6_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_6)) {
- wlyyQuotaResult.setResult(entry.getValue().get(Constant.level_age_6) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- //保存区级
- for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
- //判断该区是否有统计数据
- Map<String, Long> oneAgeMap = townAgeMap.get(entry.getKey());//得到当个区的统计数据
- Town town = entry.getValue();//得到区级信息
- //保存0~6
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_1);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_1_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_1)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_1) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存7~18
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_2);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_2_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_2)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_2) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存18~30
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_3);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_3_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_3)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_3) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存30~50
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_4);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_4_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_4)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_4) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存50~65
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_5);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_5_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_5)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_5) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存18~30
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(entry.getKey());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(town.getCode());
- wlyyQuotaResult.setTownName(town.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("3");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_6);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_6_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_6)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_6) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- for (Map.Entry<String, Hospital> hospitalEntry : hospitalsMap.entrySet()) {
- //判断该机构是否有统计数据
- Map<String, Long> oneAgeMap = orgAgeMap.get(hospitalEntry.getKey());//得到当个机构的统计数据
- Hospital hospital = hospitalEntry.getValue();//得到区级信息
- //保存0~6
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(hospital.getCity());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//区级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_1);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_1_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_1)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_1) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存7~18
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(hospital.getCity());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_2);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_2_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_2)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_2) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存18~30
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(hospital.getCity());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_3);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_3_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_3)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_3) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存30~50
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(hospital.getCity());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_4);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_4_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_4)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_4) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存50~65
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(hospital.getCity());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_5);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_5_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_5)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_5) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- //保存18~30
- wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(hospital.getCity());
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setTown(hospital.getTown());
- wlyyQuotaResult.setTownName(hospital.getTownName());
- wlyyQuotaResult.setOrgCode(hospital.getCode());
- wlyyQuotaResult.setOrgName(hospital.getName());
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("2");//机构级
- wlyyQuotaResult.setLevel2Type(Constant.level_age_6);
- wlyyQuotaResult.setLevel2TypeName(Constant.level_age_6_name);
- if (oneAgeMap != null && oneAgeMap.containsKey(Constant.level_age_6)) {
- wlyyQuotaResult.setResult(oneAgeMap.get(Constant.level_age_6) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- QuartzJobLog.setJobEndTime(new Date());
- QuartzJobLog.setJobContent("统计" + getYesterday() + " 的签约患者年龄数据完成 ,得到签约数目:"+signFamilys.size());
- QuartzJobLog.setJobType("1");
- quartzJobLogDao.save(QuartzJobLog);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- /**
- * 机构维度计算指标
- */
- @Transactional
- private void computequota() {
- jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 1 + "'");
- //新建任务日志对象
- QuartzJobLog QuartzJobLog = new QuartzJobLog();
- QuartzJobLog.setJobStartTime(new Date());
- QuartzJobLog.setJobId(wlyyJobConfig.getId());
- QuartzJobLog.setJobName(wlyyJobConfig.getJobName());
- //查找出系统全部的全科医生
- List<Doctor> doctors = doctorDao.findAllQKDoctot();
- Map<String, Doctor> doctorsMap = new HashMap<String, Doctor>();
- for (Doctor doctor : doctors) {
- doctorsMap.put(doctor.getCode(), doctor);
- }
- //查找出系统全部的机构
- List<Hospital> hospitals = hospitalDao.findHospitalzxFWZ();
- 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);
- }
- //找出今天的签约信息 yesterday,now
- List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(yesterday, now);
- Map<String, Long> tjTownMap = new HashMap<String, Long>();//区级的统计map key 是区行政区划350200
- Map<String, Long> tjOrgMap = new HashMap<String, Long>();//机构的统计map key 是机构的code
- Map<String, Long> tjQkdoctorMap = new HashMap<String, Long>();//团队级的统计map 目前没有团队 先用全科医生统一 key doctorCode
- Long cityCount = 0L;
- //统计有签约的
- for (SignFamily signFamily : signFamilys) {
- String doctorCode = signFamily.getDoctor();//得到签约中全科医生的code
- //统计团队
- compute_level1(tjQkdoctorMap, doctorCode);
- //判断医生属于哪个机构
- Doctor doctor = doctorsMap.get(doctorCode);
- if (doctor == null) {
- continue;
- }
- String orgCode = doctor.getHospital();
- //统计机构
- //统计站
- if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
- //统计站
- String orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
- compute_level1(tjOrgMap, orgCodeTemp);
- } else {
- //统计社区
- compute_level1(tjOrgMap, orgCode);
- }
- Hospital hospital=hospitalsMap.get(doctor.getHospital());
- String townCode = hospital.getTown();
- //统计区
- compute_level1(tjTownMap, townCode);
- //统计市
- cityCount++;
- }
- //保存统计的结果
- //保存全科医生的签约统计
- for (Map.Entry<String, Doctor> entry : doctorsMap.entrySet()) {
- Doctor doctor = doctorsMap.get(entry.getKey());//得到全科医生
- Hospital hospital = hospitalsMap.get(doctor.getHospital());//得到全科医生的机构
- String city=Constant.city;
- String cityName=Constant.cityName;
- String town=hospital.getTown();
- String townName=hospital.getTownName();
- String org=doctor.getHospital();
- String orgName=doctor.getHosptialName();
- String doctorCode=doctor.getCode();
- String doctorName=doctor.getName();
- String doctorJob=doctor.getJob();
- String level="1";
- String key=doctor.getCode();
- save_level1(tjQkdoctorMap, key, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level);
- }
- //保存机构的签约统计
- for (Map.Entry<String, Hospital> entry : hospitalsMap.entrySet()) {
- Hospital hospital = hospitalsMap.get(entry.getKey());//得到全科医生
- String city=Constant.city;
- String cityName=Constant.cityName;
- String town=hospital.getTown();
- String townName=hospital.getTownName();
- String org=hospital.getCode();
- String orgName=hospital.getName();
- String doctorCode="";
- String doctorName="";
- String doctorJob="";
- String level="2";
- String key=hospital.getCode();
- save_level1(tjOrgMap, key, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level);
- }
- //保存区级的签约统计
- for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
- Town townObj = townsMap.get(entry.getKey());//得到全科医生
- String city=Constant.city;
- String cityName=Constant.cityName;
- String town=townObj.getCode();
- String townName=townObj.getName();
- String org="";
- String orgName="";
- String doctorCode="";
- String doctorName="";
- String doctorJob="";
- String level="3";
- String key=townObj.getCode();
- save_level1(tjTownMap, key, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level);
- }
- //保存市级的统计
- {
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setCity(Constant.city);
- wlyyQuotaResult.setCityName(Constant.cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setLevel1Type("4");
- //判断全科医生是否有签约量
- if (cityCount > 0) {
- wlyyQuotaResult.setResult(cityCount + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- QuartzJobLog.setJobEndTime(new Date());
- QuartzJobLog.setJobContent("统计" + getYesterday() + " 的签约数据完成 ,得到签约数目:"+signFamilys.size());
- QuartzJobLog.setJobType("1");
- quartzJobLogDao.save(QuartzJobLog);
- }
- /**
- * 统计签约的公用保存方案
- *
- */
- private void save_level1(Map<String, Long> countMap, String key, String city, String cityName, String town, String townName, String org, String orgName, String doctorCode, String doctorName, String doctorJob, String level) {
- WlyyQuotaResult wlyyQuotaResult = new WlyyQuotaResult();
- wlyyQuotaResult.setDel("1");
- wlyyQuotaResult.setOrgCode(org);
- wlyyQuotaResult.setOrgName(orgName);
- wlyyQuotaResult.setCity(city);
- wlyyQuotaResult.setCityName(cityName);
- wlyyQuotaResult.setQuatoCode(wlyyQuota.getId());
- wlyyQuotaResult.setQuatoName(wlyyQuota.getName());
- wlyyQuotaResult.setQuotaDate(getYesterday());
- wlyyQuotaResult.setCreateTime(new Date());
- wlyyQuotaResult.setQkdoctorJobName(doctorJob);
- wlyyQuotaResult.setQkdoctorName(doctorName);
- wlyyQuotaResult.setQkdoctorCode(doctorCode);
- wlyyQuotaResult.setTown(town);
- wlyyQuotaResult.setTownName(townName);
- wlyyQuotaResult.setLevel1Type(level);
- //判断全科医生是否有解约量
- if (countMap.containsKey(key)) {
- wlyyQuotaResult.setResult(countMap.get(key) + "");
- } else {
- wlyyQuotaResult.setResult("0");
- }
- wlyyQuotaResultDao.save(wlyyQuotaResult);
- }
- /**
- * 统计签约的公用统计方案
- * @param tjQkdoctorMap
- * @param doctorCode
- */
- private void compute_level1(Map<String, Long> tjQkdoctorMap, String doctorCode) {
- if (tjQkdoctorMap.containsKey(doctorCode)) {
- tjQkdoctorMap.put(doctorCode, tjQkdoctorMap.get(doctorCode) + 1);
- } else {
- tjQkdoctorMap.put(doctorCode, 1L);
- }
- }
- /*
- 得到昨天的日期字符串 yyyy-MM-dd
- */
- public String getYesterday() {
- return yesterday;
- }
- /**
- * 根据年龄得到对应的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;
- }
- }
- 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 static void main(String[] args) {
- getDayString(0);
- }
- }
|