|
@ -10,6 +10,13 @@ import com.yihu.wlyy.entity.job.QuartzJobLog;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
|
import com.yihu.wlyy.entity.patient.PatientHealthGuidance;
|
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
|
import com.yihu.wlyy.job.elt.base.ETLModel;
|
|
|
import com.yihu.wlyy.job.elt.role.LevelRole;
|
|
|
import com.yihu.wlyy.job.elt.role.PatientAgeRole;
|
|
|
import com.yihu.wlyy.job.elt.role.PatientGroupRole;
|
|
|
import com.yihu.wlyy.job.elt.role.PatientSexRole;
|
|
|
import com.yihu.wlyy.job.elt.storage.DBStorage;
|
|
|
import com.yihu.wlyy.job.elt.storage.RedisStorage;
|
|
|
import com.yihu.wlyy.repository.address.TownDao;
|
|
|
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
|
|
|
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
|
|
@ -66,6 +73,17 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
|
|
|
@Autowired
|
|
|
private DoctorAdminTeamDao doctorAdminTeamDao;
|
|
|
@Autowired
|
|
|
private LevelRole 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();//随访数据源
|
|
|
|
|
@ -74,14 +92,14 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
private Properties systemProperties;
|
|
|
List<Town> towns = null;//厦门市全部的区
|
|
|
List<Hospital> hospitals = null;//系统全部的机构
|
|
|
List<Doctor> qkdoctors = null;//系统全部的全科医生
|
|
|
List<Doctor> jkglsdoctors = null;//系统全部的健康管理师
|
|
|
List<AdminTeam> adminTeams=null;//系统全部的团队
|
|
|
Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
|
|
|
Map<String, Doctor> jkglsdoctorsMap = new HashMap<String, Doctor>();
|
|
|
Map<String, Doctor> qkdoctorsMap = new HashMap<String, Doctor>();
|
|
|
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 {
|
|
@ -96,22 +114,13 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
jdbcTemplate.setDataSource(fvdataSource);//初始化随访的数据源
|
|
|
towns = townDao.findByCityCode(Constant.city); //查找出厦门市全部的区
|
|
|
hospitals = hospitalDao.findHospitalzxFWZ(); //查找出系统全部的机构
|
|
|
adminTeams=doctorAdminTeamDao.findAllTeam();//查找出系统全部的全科医生
|
|
|
for (Hospital hospital : hospitals) {
|
|
|
hospitalsMap.put(hospital.getCode(), hospital);
|
|
|
}
|
|
|
qkdoctors = doctorDao.findAllQKDoctot();//查找出系统全部的全科医生
|
|
|
for (Doctor doctor : qkdoctors) {
|
|
|
qkdoctorsMap.put(doctor.getCode(), doctor);
|
|
|
}
|
|
|
jkglsdoctors = doctorDao.findAllZKDoctot();//查找出系统全部的全科医生
|
|
|
for (Doctor doctor : jkglsdoctors) {
|
|
|
jkglsdoctorsMap.put(doctor.getCode(), doctor);
|
|
|
}
|
|
|
for (Town town : towns) {
|
|
|
townsMap.put(town.getCode(), town);
|
|
|
}
|
|
|
//查找出系统全部的全科医生
|
|
|
adminTeams=doctorAdminTeamDao.findAllTeam();
|
|
|
for (AdminTeam adminTeam : adminTeams) {
|
|
|
adminTeamMap.put(adminTeam.getId()+"", adminTeam);
|
|
|
}
|
|
@ -127,20 +136,19 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
private void computequota() throws Exception {
|
|
|
QuartzJobLog quartzJobLog =new QuartzJobLog();
|
|
|
quartzJobLog.setJobStartTime(new Date());
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
|
|
|
computequota_1(errorContent); //统计今天的签约
|
|
|
computequota_2(errorContent); //统计今天的解约
|
|
|
computequota_3(errorContent); //统计今天的健康咨询量
|
|
|
computequota_4(errorContent); //统计今天的随访量
|
|
|
computequota_5(errorContent); //统计今天的健康指导
|
|
|
computequota_6(errorContent); //统计今天的签约患者性别
|
|
|
computequota_7(errorContent);//统计今天的签约患者分组
|
|
|
computequota_8(errorContent);//统计今天的签约患者年龄
|
|
|
computequota_9(errorContent);//统计今天的待签约
|
|
|
computequota_10(errorContent);//统计今天的改签
|
|
|
computequota_12(errorContent);//统计今天的签约下按年龄分组后再
|
|
|
quartzJobLog.setJobContent(errorContent.toString());
|
|
|
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");
|
|
@ -148,8 +156,7 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
quartzJobLogDao.save(quartzJobLog);
|
|
|
}
|
|
|
|
|
|
private void computequota_12(StringBuffer errorContent) throws Exception{
|
|
|
errorContent.append("computequota_12---start,");
|
|
|
private void computequota_12() throws Exception{
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
//找出今天的签约信息 yesterday,now
|
|
@ -167,7 +174,6 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
}
|
|
|
//找出今天的签约信息
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(now, tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
|
|
|
//数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
|
|
|
Map<String, Map<String, Map>> cityAgeMap = new HashMap<String, Map<String, Map>>();//key是市行政代码 目前只有厦门市
|
|
|
Map<String,Map> temp =new HashMap<String,Map>();
|
|
@ -179,7 +185,6 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
for (SignFamily signFamily : signFamilys) {
|
|
|
Hospital hospital = hospitalsMap.get(getOrg(signFamily.getHospital()));//得到患者签约的机构
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据异常。");
|
|
|
continue;
|
|
|
}
|
|
|
String town = hospital.getTown();
|
|
@ -321,7 +326,6 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
errorContent.append("computequota_12---end!!");
|
|
|
}
|
|
|
private void compute(Map<String, Map<String, Map>> rootMap, String rootKey, String ageCode, String diseaseType) {
|
|
|
if (rootMap.containsKey(rootKey)) {
|
|
@ -352,556 +356,580 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
rootMap.put(rootKey, groupMapTemp2);
|
|
|
}
|
|
|
}
|
|
|
private void computequota_1(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_1---start,");
|
|
|
//签约需要的统计map
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjAdminTeamMap = new HashMap<String, JSONObject>();//团队级的统计map 目前没有团队 先用全科医生统一 key doctorCode
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, null,tjAdminTeamMap);
|
|
|
|
|
|
private void computequota_1() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
//找出今天的签约信息 yesterday,now
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(now, tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
|
|
|
//统计有签约的
|
|
|
for (SignFamily signFamily : signFamilys) {
|
|
|
String hospitalCode=getOrg(signFamily.getHospital());
|
|
|
Hospital hospital=hospitalsMap.get(hospitalCode);
|
|
|
AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
//统计机构
|
|
|
//判断是中心还是服务站 服务站的话添加到中心去
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据异常。");
|
|
|
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;
|
|
|
}
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的adminTeam数据异常。");
|
|
|
String orgCodeTemp=getOrg(orgCode);
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
JSONObject orgjo=tjOrgMap.get(getOrg(hospital.getCode()));
|
|
|
if(orgjo==null){
|
|
|
System.out.println(new JSONObject(hospital).toString());
|
|
|
Long adminId=signFamily.getAdminTeamId();
|
|
|
if(adminId == null||adminId<=0) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(hospital.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjAdminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//数据保存到redis
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:1:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:1:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:1:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjAdminTeamMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:1:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
errorContent.append("computequota_1---end!!!");
|
|
|
}
|
|
|
|
|
|
private void initMap(Map<String, JSONObject> tjCityMap, Map<String, JSONObject> tjTownMap, Map<String, JSONObject> tjOrgMap, Map<String, JSONObject> tjQkdoctorMap, Map<String, JSONObject> tjJKdoctorMap, Map<String, JSONObject> tjAdminTeamMap) {
|
|
|
JSONObject jo=new JSONObject();
|
|
|
jo.put("name", Constant.cityName);
|
|
|
jo.put("num",0);
|
|
|
tjCityMap.put(Constant.city,jo);
|
|
|
for(Town town:towns){
|
|
|
jo=new JSONObject();
|
|
|
jo.put("name",town.getName());
|
|
|
jo.put("num",0);
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
tjTownMap.put(town.getCode(),jo);
|
|
|
}
|
|
|
for(Hospital hospital:hospitals){
|
|
|
jo=new JSONObject();
|
|
|
jo.put("name",hospital.getName());
|
|
|
jo.put("num",0);
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
tjOrgMap.put(hospital.getCode(),jo);
|
|
|
}
|
|
|
if (tjQkdoctorMap!=null){
|
|
|
for(Doctor doctor:qkdoctors){
|
|
|
jo=new JSONObject();
|
|
|
jo.put("name",doctor.getName());
|
|
|
jo.put("num",0);
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
tjQkdoctorMap.put(doctor.getCode(),jo);
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
if(tjJKdoctorMap!=null){
|
|
|
for(Doctor doctor:jkglsdoctors){
|
|
|
jo=new JSONObject();
|
|
|
jo.put("name",doctor.getName());
|
|
|
jo.put("num",0);
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
tjJKdoctorMap.put(doctor.getCode(),jo);
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
if(tjAdminTeamMap!=null){
|
|
|
for(AdminTeam adminTeam:adminTeams){
|
|
|
jo=new JSONObject();
|
|
|
jo.put("name",adminTeam.getName());
|
|
|
jo.put("num",0);
|
|
|
jo.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
tjAdminTeamMap.put(adminTeam.getId()+"",jo);
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
saveContent("1",signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
private void computequota_2(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_2---start,");
|
|
|
//签约需要的统计map
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjAdminTeamMap = new HashMap<String, JSONObject>();//团队级的统计map 目前没有团队 先用全科医生统一 key doctorCode
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, null,tjAdminTeamMap);
|
|
|
|
|
|
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingUnSignYesterday(now, tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的解约数是:"+signFamilys.size()+",错误:");
|
|
|
//统计有签约的
|
|
|
for (SignFamily signFamily : signFamilys) {
|
|
|
String hospitalCode=getOrg(signFamily.getHospital());
|
|
|
Hospital hospital=hospitalsMap.get(hospitalCode);
|
|
|
AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
private void computequota_2() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="2";
|
|
|
//找出今天的解约信息
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingUnSignYesterday(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数据异常。");
|
|
|
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)中的adminTeam数据异常。");
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
//判断是中心还是服务站 服务站的话添加到中心去
|
|
|
JSONObject orgjo=tjOrgMap.get(getOrg(hospital.getCode()));
|
|
|
if(orgjo==null){
|
|
|
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;
|
|
|
}
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(hospital.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjAdminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
//数据保存到redis
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:2:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:2:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:2:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjAdminTeamMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:2:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
errorContent.append("computequota_2---end!!!");
|
|
|
saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
private void computequota_3(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_3---start,");
|
|
|
//签约需要的统计map
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjAdminTeamMap = new HashMap<String, JSONObject>();//全部的健康管理师
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, null,tjAdminTeamMap);
|
|
|
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
private void computequota_3() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="3";
|
|
|
//找出今天的咨询信息
|
|
|
List<ConsultTeam> consultTeams = consultTeamDao.findByCzrqyYesterday(now,tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的咨询数是:"+consultTeams.size()+",错误:");
|
|
|
//统计
|
|
|
for (ConsultTeam consultTeam : consultTeams) {
|
|
|
AdminTeam adminTeam=adminTeamMap.get(consultTeam.getAdminTeamId()+"");
|
|
|
|
|
|
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()+",咨询表中的团队数据有误。");
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",团队Id:"+adminTeam.getId()+",咨询的团队(wlyy_consult_team)中的团队不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
JSONObject orgjo=tjOrgMap.get(getOrg(adminTeam.getOrgCode()));
|
|
|
if(orgjo == null) {
|
|
|
errorContent.append("咨询id:"+consultTeam.getId()+",咨询表中的团队所属的机构数据有误。");
|
|
|
String orgCode = adminTeam.getOrgCode();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",团队Id:"+adminTeam.getId()+",医生团队的机构为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
Hospital hospital=hospitalsMap.get(getOrg(adminTeam.getOrgCode()));
|
|
|
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()+",咨询表中的团队所属的机构数据有误。");
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:"+hospital.getId()+",医生团队的机构不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(hospital.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjAdminTeamMap.get(consultTeam.getAdminTeamId()+"");
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
//数据保存到redis
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:3:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:3:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:3:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjAdminTeamMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:3:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
errorContent.append("computequota_3---end!!!");
|
|
|
saveContent(quotaId,consultTeams.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
private void computequota_4(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_4---start,");
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjJkdoctorMap = new HashMap<String, JSONObject>();//全部的健康管理师
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, tjJkdoctorMap,null);
|
|
|
private void computequota_4() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="4";
|
|
|
//找出今天的随访信息
|
|
|
List<Map<String,Object>> plans = getFvYesterday();
|
|
|
errorContent.append("截止时间:"+DateUtil.dateToStrLong(new Date())+",数据库查询的随访数是:"+plans.size()+",错误:");
|
|
|
//统计有随访的
|
|
|
for (Map<String,Object> plan : plans) {
|
|
|
String doctorCode = (String) plan.get("doctor_uid");//得到随访中健康医生的code
|
|
|
Doctor doctor=jkglsdoctorsMap.get(doctorCode);//得到健康管理师
|
|
|
if(doctor == null) {
|
|
|
errorContent.append("随访id:"+plan.get("id")+",随访医生字段doctor_uid数据有误。");
|
|
|
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;
|
|
|
}
|
|
|
//统计机构
|
|
|
JSONObject orgjo=tjOrgMap.get(getOrg(doctor.getHospital()));
|
|
|
if(orgjo==null){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",随访医生字段doctor_uid对应的doctor表中的hospital字段有误。");
|
|
|
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;
|
|
|
}
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(doctor.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjJkdoctorMap.get(doctor.getCode());
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("随访id:"+plan.get("id")+",机构Id:"+hospital.getId()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:4:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:4:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:4:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjJkdoctorMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:4:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
errorContent.append("computequota_4---end!!");
|
|
|
saveContent(quotaId,plans.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
private void computequota_5(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_5---start,");
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjAdminTeamMap = new HashMap<String, JSONObject>();//全部的健康管理师
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, null,tjAdminTeamMap);
|
|
|
//找出今天的健康指导信息
|
|
|
private void computequota_5() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="5";
|
|
|
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<PatientHealthGuidance> patientHealthGuidances = patientHealthGuidanceDao.findByCzrqyYesterday(now,tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的健康指導数是:"+patientHealthGuidances.size()+",错误:");
|
|
|
for (PatientHealthGuidance patientHealthGuidance: patientHealthGuidances) {
|
|
|
String doctorCode =patientHealthGuidance.getDoctor();
|
|
|
Doctor doctor=jkglsdoctorsMap.get(doctorCode);//得到健康管理师
|
|
|
SignFamily signFamily= signFamilyDao.findSignByPatient(patientHealthGuidance.getPatient(),2);//得到患者签约的行政团队
|
|
|
if(doctor==null){
|
|
|
doctor=qkdoctorsMap.get(doctorCode);//得到全科医生
|
|
|
if(doctor==null){
|
|
|
errorContent.append("健康指導id:"+patientHealthGuidance.getId()+",找不到对应的医生信息。");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
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()+",患者签约不存在或者已经过期。");
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",患者code:"+patient+",家庭签约不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
JSONObject orgjo=tjOrgMap.get(getOrg(doctor.getHospital()));
|
|
|
if(orgjo==null){
|
|
|
errorContent.append("健康指導id:"+patientHealthGuidance.getId()+",医生表中对应的hospital字段有误。");
|
|
|
String adminId=signFamily.getAdminTeamId()+"";//得到团队ID
|
|
|
if(StringUtils.isEmpty(adminId)){
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的团队AdminTeamCode为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(doctor.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
//统计机构
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjAdminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
}
|
|
|
}
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:5:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:5:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:5:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjAdminTeamMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:5:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
errorContent.append("computequota_5---end!!");
|
|
|
}
|
|
|
|
|
|
private void computequota_6(StringBuffer errorContent) throws Exception {
|
|
|
errorContent.append("computequota_6---start,");
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(now, tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
|
|
|
//统计有签约的
|
|
|
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(getOrg(signFamily.getHospital()));//得到患者签约的机构
|
|
|
//统计机构
|
|
|
//判断是中心还是服务站 服务站的话添加到中心去
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据异常。");
|
|
|
AdminTeam adminTeam = adminTeamMap.get(adminId);
|
|
|
if(adminTeam==null){
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的团队不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String town = hospital.getTown();//得到患者签约的机构的区号
|
|
|
String hospitalCode = hospital.getCode();//得到患者签约的机构号
|
|
|
String sex = IdCardUtil.getSexForIdcard(idcard);//根据身份证得到性别
|
|
|
//统计市 目前只统计厦门市 所以先写死 后期再改造
|
|
|
if (citySexMap.containsKey(Constant.city)) {
|
|
|
Map<String, Long> sexMap = citySexMap.get(Constant.city);
|
|
|
sexMap.put(sex, (sexMap.get(sex)==null?0l:sexMap.get(sex)) + 1);
|
|
|
citySexMap.put(Constant.city, sexMap);
|
|
|
} else {
|
|
|
Map<String, Long> sexMap = new HashMap<String, Long>();
|
|
|
sexMap.put(sex, 1L);
|
|
|
citySexMap.put(Constant.city, sexMap);
|
|
|
}
|
|
|
//统计区
|
|
|
if (townSexMap.containsKey(town)) {
|
|
|
Map<String, Long> sexMap = townSexMap.get(town);
|
|
|
sexMap.put(sex, (sexMap.get(sex)==null?0l:sexMap.get(sex)) + 1);
|
|
|
townSexMap.put(town, sexMap);
|
|
|
} else {
|
|
|
Map<String, Long> sexMap = new HashMap<String, Long>();
|
|
|
sexMap.put(sex, 1L);
|
|
|
townSexMap.put(town, sexMap);
|
|
|
String orgCode=signFamily.getHospital();//得到机构id
|
|
|
if(StringUtils.isEmpty(orgCode)){
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的机构Hospital不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
if (orgSexMap.containsKey(hospitalCode)) {
|
|
|
Map<String, Long> sexMap = orgSexMap.get(hospitalCode);
|
|
|
sexMap.put(sex, (sexMap.get(sex)==null?0l:sexMap.get(sex)) + 1);
|
|
|
orgSexMap.put(hospitalCode, sexMap);
|
|
|
} else {
|
|
|
Map<String, Long> sexMap = new HashMap<String, Long>();
|
|
|
sexMap.put(sex, 1L);
|
|
|
orgSexMap.put(hospitalCode, sexMap);
|
|
|
String orgCodeTemp="";
|
|
|
//统计机构 -----------------start---------------------
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//统计站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//统计社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
}
|
|
|
//保存统计数据
|
|
|
//保存市统计数据
|
|
|
for (Map.Entry<String, Map<String, Long>> entry : citySexMap.entrySet()) {
|
|
|
//保存女
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_sex_1)) {
|
|
|
jsonObject.put("num",entry.getValue().get(Constant.level_sex_1));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+orgCodeTemp+",健康咨询的医生所属的机构不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:4:1:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存男
|
|
|
jsonObject=new JSONObject();
|
|
|
if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_sex_2)) {
|
|
|
jsonObject.put("num",entry.getValue().get(Constant.level_sex_2));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+hospital.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:4:2:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存未知
|
|
|
jsonObject=new JSONObject();
|
|
|
if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_sex_3)) {
|
|
|
jsonObject.put("num",entry.getValue().get(Constant.level_sex_3));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+hospital.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:4:3:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
//保存区的统计数据
|
|
|
for (Map.Entry<String, Town> townEntry : townsMap.entrySet()) {
|
|
|
//判断该区是否有统计数据
|
|
|
Map<String, Long> oneTownSexMap = townSexMap.get(townEntry.getKey());//得到当个区的统计数据
|
|
|
Town town = townEntry.getValue();//得到区级信息
|
|
|
//保存女
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneTownSexMap != null && oneTownSexMap.containsKey(Constant.level_sex_1)) {
|
|
|
jsonObject.put("num",oneTownSexMap.get(Constant.level_sex_1));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
|
|
|
saveContent(quotaId,patientHealthGuidances.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
private void computequota_6() throws Exception {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="6";
|
|
|
//找出今天的签约信息
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(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;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:3:1:"+townEntry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存男
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneTownSexMap != null && oneTownSexMap.containsKey(Constant.level_sex_2)) {
|
|
|
jsonObject.put("num",oneTownSexMap.get(Constant.level_sex_2));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:3:2:"+townEntry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存未知
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneTownSexMap != null && oneTownSexMap.containsKey(Constant.level_sex_3)) {
|
|
|
jsonObject.put("num",oneTownSexMap.get(Constant.level_sex_3));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:3:3:"+townEntry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
//统计机构
|
|
|
for (Map.Entry<String, Hospital> hospitalEntry : hospitalsMap.entrySet()) {
|
|
|
//判断该区是否有统计数据
|
|
|
Map<String, Long> oneTownSexMap = orgSexMap.get(hospitalEntry.getKey());//得到当个区的统计数据
|
|
|
Hospital town = hospitalEntry.getValue();//得到区级信息
|
|
|
//保存女
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneTownSexMap != null && oneTownSexMap.containsKey(Constant.level_sex_1)) {
|
|
|
jsonObject.put("num",oneTownSexMap.get(Constant.level_sex_1));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
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;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:2:1:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存男
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneTownSexMap != null && oneTownSexMap.containsKey(Constant.level_sex_2)) {
|
|
|
jsonObject.put("num",oneTownSexMap.get(Constant.level_sex_2));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:2:2:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存未知
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneTownSexMap != null && oneTownSexMap.containsKey(Constant.level_sex_3)) {
|
|
|
jsonObject.put("num",oneTownSexMap.get(Constant.level_sex_3));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:6:2:3:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
errorContent.append("computequota_6---end!!");
|
|
|
saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
private void computequota_7(StringBuffer errorContent) {
|
|
|
|
|
|
private void computequota_7() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
errorContent.append("computequota_7---start,");
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
@ -999,7 +1027,7 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
continue;//如果没有高血压和糖尿病 不统计
|
|
|
}
|
|
|
if (hasGXY && hasTNB) {
|
|
|
group = "100";//有高血压又有糖尿病
|
|
|
group = "6";//有高血压又有糖尿病
|
|
|
} else {
|
|
|
group = Integer.valueOf(jsonObjects.get(0).get("disease").toString()) + 3 + "";//4高血压,5糖尿病
|
|
|
}
|
|
@ -1110,14 +1138,14 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
|
|
|
//保存糖尿病和高血压
|
|
|
jsonObject=new JSONObject();
|
|
|
if (entry.getValue() != null && entry.getValue().containsKey(Constant.level_group_100)) {
|
|
|
jsonObject.put("num",entry.getValue().get(Constant.level_group_100));
|
|
|
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:100:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:7:4:6:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
|
|
|
//保存区级
|
|
@ -1178,14 +1206,14 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
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_100)) {
|
|
|
jsonObject.put("num",oneTown.get(Constant.level_group_100));
|
|
|
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:100:"+townEntry.getKey()).toString(),jsonObject.toString());
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:7:3:6:"+townEntry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for (Map.Entry<String, Hospital> hospitalEntry : hospitalsMap.entrySet()) {
|
|
@ -1247,403 +1275,323 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
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_100)) {
|
|
|
jsonObject.put("num",oneOrg.get(Constant.level_group_100));
|
|
|
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:100:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:7:2:6:"+hospitalEntry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
|
|
|
errorContent.append("computequota_7---end!!");
|
|
|
}
|
|
|
|
|
|
private void computequota_8(StringBuffer errorContent)throws Exception {
|
|
|
errorContent.append("computequota_8---end,");
|
|
|
//查找出系统全部的机构
|
|
|
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);
|
|
|
}
|
|
|
private void computequota_8()throws Exception {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="8";
|
|
|
//找出今天的签约信息
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(now,tomorrow);
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
|
|
|
//数组里面第一个是健康人群 第二个是慢病人群 第三个是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(getOrg(signFamily.getHospital()));//得到患者签约的机构
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingSignYesterday(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数据异常。");
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
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);
|
|
|
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;
|
|
|
}
|
|
|
//统计区
|
|
|
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 town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
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);
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
// 保存市的统计数据
|
|
|
for (Map.Entry<String, Map<String, Long>> entry : cityAgeMap.entrySet()) {
|
|
|
Map<String,Long> oneAgeMap=entry.getValue();
|
|
|
//保存0~6
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_1)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_1));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:4:1:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存7~18
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_2)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_2));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:4:2:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存18~30
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_3)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_3));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:4:3:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存30~50
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_4)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_4));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:4:4:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存50~65
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_5)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_5));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
private void computequota_9() {
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
String quotaId="9";
|
|
|
//找出今天的待签约信息
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingWaitSignYesterday(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;
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:4:5:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存18~30
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_6)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_6));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
jsonObject.put("name",Constant.cityName);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:4:6:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
//保存区级
|
|
|
for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
|
|
|
//判断该区是否有统计数据
|
|
|
Map<String, Long> oneAgeMap = townAgeMap.get(entry.getKey());//得到当个区的统计数据
|
|
|
Town town = entry.getValue();//得到区级信息
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_1)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_1));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:3:1:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存7~18
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_2)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_2));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
Long adminId=signFamily.getAdminTeamId();
|
|
|
if(adminId == null||adminId<=0) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:3:2:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存18~30
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_3)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_3));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:3:3:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存30~50
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_4)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_4));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
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;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:3:4:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存50~65
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_5)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_5));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:3:5:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存18~30
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_6)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_6));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
jsonObject.put("name",town.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:3:6:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
for (Map.Entry<String, Hospital> entry : hospitalsMap.entrySet()) {
|
|
|
//判断该机构是否有统计数据
|
|
|
Map<String, Long> oneAgeMap = orgAgeMap.get(entry.getKey());//得到当个机构的统计数据
|
|
|
Hospital hospital = entry.getValue();//得到区级信息
|
|
|
//保存0~6
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_1)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_1));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",hospital.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:2:1:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存7~18
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_2)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_2));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",hospital.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:2:2:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存18~30
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_3)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_3));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",hospital.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:2:3:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存30~50
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_4)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_4));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",hospital.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:2:4:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存50~65
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_5)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_5));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
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.findByJiatingChaangeSignYesterday(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;
|
|
|
}
|
|
|
jsonObject.put("name",hospital.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:2:5:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
//保存18~30
|
|
|
jsonObject=new JSONObject();
|
|
|
if (oneAgeMap!=null&&oneAgeMap.containsKey(Constant.level_age_6)) {
|
|
|
jsonObject.put("num",oneAgeMap.get(Constant.level_age_6));
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
jsonObject.put("name",hospital.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:8:2:6:"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
errorContent.append("computequota_8---end!!");
|
|
|
}
|
|
|
|
|
|
private void computequota_9(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_9---start,");
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjAdminTeamMap = new HashMap<String, JSONObject>();//团队级的统计map 目前没有团队 先用全科医生统一 key doctorCode
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, null,tjAdminTeamMap);
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingWaitSignYesterday(now, tomorrow);
|
|
|
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
|
|
|
//统计有签约的
|
|
|
for (SignFamily signFamily : signFamilys) {
|
|
|
String hospitalCode=getOrg(signFamily.getHospital());
|
|
|
Hospital hospital=hospitalsMap.get(hospitalCode);
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据异常。");
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
//判断是中心还是服务站 服务站的话添加到中心去
|
|
|
JSONObject orgjo=tjOrgMap.get(getOrg(hospital.getCode()));
|
|
|
if(orgjo==null){
|
|
|
Long adminId=signFamily.getAdminTeamId();
|
|
|
if(adminId == null||adminId<=0) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(hospital.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjAdminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:9:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:9:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:9:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjAdminTeamMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:9:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
errorContent.append("computequota_9---end!!");
|
|
|
}
|
|
|
|
|
|
private void computequota_10(StringBuffer errorContent) {
|
|
|
errorContent.append("computequota_10---start,");
|
|
|
Map<String, JSONObject> tjCityMap = new HashMap<>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjTownMap = new HashMap<String, JSONObject>();//区级的统计map key 是区行政区划350200
|
|
|
Map<String, JSONObject> tjOrgMap = new HashMap<String, JSONObject>();//机构的统计map key 是机构的code
|
|
|
Map<String, JSONObject> tjAdminTeamMap = new HashMap<String, JSONObject>();//团队级的统计map 目前没有团队 先用全科医生统一 key doctorCode
|
|
|
|
|
|
initMap(tjCityMap, tjTownMap, tjOrgMap, null, null,tjAdminTeamMap);
|
|
|
String now = getDayString(0);
|
|
|
String tomorrow = getDayString(1);
|
|
|
List<SignFamily> signFamilys = signFamilyDao.findByJiatingChaangeSignYesterday(now, tomorrow);
|
|
|
|
|
|
errorContent.append("截止时间:"+now+"-"+DateUtil.dateToStrLong(new Date())+",数据库查询的签约数是:"+signFamilys.size()+",错误:");
|
|
|
//统计有签约的
|
|
|
for (SignFamily signFamily : signFamilys) {
|
|
|
String hospitalCode=getOrg(signFamily.getHospital());
|
|
|
Hospital hospital=hospitalsMap.get(hospitalCode);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据异常。");
|
|
|
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;
|
|
|
}
|
|
|
//统计机构
|
|
|
JSONObject orgjo=tjOrgMap.get(hospital.getCode());
|
|
|
if(orgjo==null){
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
orgjo.put("num",((int)orgjo.get("num"))+1);
|
|
|
//统计市
|
|
|
JSONObject cityjo=tjCityMap.get(Constant.city);
|
|
|
cityjo.put("num",((int)cityjo.get("num"))+1);
|
|
|
//统计区
|
|
|
JSONObject townjo=tjTownMap.get(hospital.getTown());
|
|
|
townjo.put("num",((int)townjo.get("num"))+1);
|
|
|
|
|
|
//统计全科医生
|
|
|
JSONObject qkjo=tjAdminTeamMap.get(signFamily.getAdminTeamId()+"");
|
|
|
if(qkjo!=null){
|
|
|
qkjo.put("num",((int)qkjo.get("num"))+1);
|
|
|
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){
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
//统计市
|
|
|
for(Map.Entry<String,JSONObject> entry:tjCityMap.entrySet()){
|
|
|
entry.getValue().put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:10:4:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存区
|
|
|
for(Map.Entry<String,JSONObject> entry:tjTownMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:10:3:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存机构
|
|
|
for(Map.Entry<String,JSONObject> entry:tjOrgMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:10:2:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
//保存全科医生
|
|
|
for(Map.Entry<String,JSONObject> entry:tjAdminTeamMap.entrySet()){
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:10:1:"+entry.getKey()).toString(), entry.getValue().toString());
|
|
|
}
|
|
|
errorContent.append("computequota_10---end!!");
|
|
|
saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount);
|
|
|
allContent.append(errorContent);
|
|
|
allContent.append("---------------------");
|
|
|
}
|
|
|
|
|
|
public Properties getSystemProperties() {
|
|
@ -1715,5 +1663,17 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
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();
|
|
|
}
|
|
|
}
|