|
@ -1,7 +1,13 @@
|
|
|
package com.yihu.wlyy.statistics.job.business;
|
|
|
|
|
|
import com.yihu.wlyy.statistics.dao.*;
|
|
|
import com.yihu.wlyy.statistics.etl.dataFilter.ConsultDataFilter;
|
|
|
import com.yihu.wlyy.statistics.etl.dataFilter.FollowUpDataFilter;
|
|
|
import com.yihu.wlyy.statistics.etl.dataFilter.HealthGuideDataFilter;
|
|
|
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
|
|
|
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
|
|
|
import com.yihu.wlyy.statistics.etl.model.ETLModel;
|
|
|
import com.yihu.wlyy.statistics.etl.model.FilterModel;
|
|
|
import com.yihu.wlyy.statistics.etl.role.*;
|
|
|
import com.yihu.wlyy.statistics.etl.storage.RedisStorage;
|
|
|
import com.yihu.wlyy.statistics.model.consult.ConsultTeam;
|
|
@ -57,11 +63,21 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
@Autowired
|
|
|
private Level2Role level2Role;
|
|
|
@Autowired
|
|
|
private RedisStorage redisStorage;
|
|
|
private Level3Role level3Role;
|
|
|
@Autowired
|
|
|
private SignPatientLabelInfoDao signPatientLabelInfoDao;
|
|
|
private RedisStorage redisStorage;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate ;
|
|
|
@Autowired
|
|
|
private DBExtract dbExtract;
|
|
|
@Autowired
|
|
|
private SignDataFilter signDataFilter;
|
|
|
@Autowired
|
|
|
private ConsultDataFilter consultDataFilter;
|
|
|
@Autowired
|
|
|
private HealthGuideDataFilter healthGuideDataFilter;
|
|
|
@Autowired
|
|
|
private FollowUpDataFilter followUpDataFilter;
|
|
|
|
|
|
private org.apache.tomcat.jdbc.pool.DataSource fvdataSource = new org.apache.tomcat.jdbc.pool.DataSource();//随访数据源
|
|
|
|
|
@ -78,7 +94,6 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
|
|
|
private String tomorrow = getDayString(1);
|
|
|
private StringBuffer allContent=new StringBuffer();//日志内容
|
|
|
private StringBuffer errorContent=new StringBuffer();//日常内容
|
|
|
|
|
|
@Value("${fv.jdbc.driver}")
|
|
|
String fv_jdbc_driver;
|
|
@ -151,663 +166,126 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
}
|
|
|
|
|
|
private void computequota_14() {
|
|
|
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="14";
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(signFamily.getAdminTeamCode()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setLevel2Key(signFamily.getExpensesStatus());
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and expenses_status=1 and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
String sqlCount=" select count(id) from wlyy_sign_family a where a.type =2 and expenses_status=1 and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
//抽取數據 expensesStatus=1
|
|
|
List<SignFamily> signFamilies_1= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
|
|
|
//抽取第二种条件的语句
|
|
|
sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and (expenses_status !=1 or expenses_status is null) and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
sqlCount=" select count(id) from wlyy_sign_family a where a.type =2 and (expenses_status !=1 or expenses_status is null) and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
List<SignFamily> signFamilies_2= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
|
|
|
//抽取的语句
|
|
|
sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies_1, SignDataFilter.level2Expenses,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnData1s= levelRole.elt(etlModels);
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> role2Data= level2Role.elt(returnData1s);
|
|
|
//统计数据 一级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel2(role2Data,quotaId,2,4,0);
|
|
|
redisStorage.saveByLevel2(level2Data,quotaId,2,4,0);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------14----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_13() {
|
|
|
errorContent=new StringBuffer();
|
|
|
//找出今天的签约信息 yesterday,now
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
String sqlCount=" select count(id) from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
|
|
|
try{
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
//抽取數據 分页抽取
|
|
|
List<SignFamily> signFamilies= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnData= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,"13");
|
|
|
redisStorage.saveByLevel1(returnData,"13");
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent("13",signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------13----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_16() {
|
|
|
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="16";
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.apply_date>= '"+now+"' and a.apply_date< '"+tomorrow+"' ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(signFamily.getAdminTeamCode()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setLevel2Key(signFamily.getExpensesStatus());
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies, SignDataFilter.level2Expenses,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnData1s= levelRole.elt(etlModels);
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> role2Data= level2Role.elt(returnData1s);
|
|
|
//统计数据 一级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> role2Data= level2Role.elt(returnDatas);
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel2(role2Data,quotaId,2,4,0);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------16----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_15() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="15";
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
//查找每个患者的健康分布标签
|
|
|
List<SignPatientLabelInfo> signPatientLabelInfoList= signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signFamily.getPatient(),"2",1);
|
|
|
String level2Key="0";
|
|
|
if(signPatientLabelInfoList!=null&&signPatientLabelInfoList.size()>0){
|
|
|
level2Key=signPatientLabelInfoList.get(0).getLabel();
|
|
|
}
|
|
|
etlModel.setLevel2Key(level2Key);//设置二级维度的Key
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setAdminTeam(signFamily.getAdminTeamCode()+"");
|
|
|
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>>>> roleData= level2Role.elt(returnData1s);
|
|
|
try{
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies, SignDataFilter.level2Health,sql,null);
|
|
|
//统计数据 一级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData= level2Role.elt(returnDatas);
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel2(roleData,quotaId,4,1,0);
|
|
|
redisStorage.saveByLevel2(patientSexRoleData,quotaId,4,5,0);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------15----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_12() throws Exception{
|
|
|
errorContent=new StringBuffer();
|
|
|
|
|
|
//找出今天的签约信息 yesterday,now
|
|
|
//查找出系统全部的机构
|
|
|
List<Hospital> hospitals = hospitalDao.findHospital2();
|
|
|
Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
|
|
|
for (Hospital hospital : hospitals) {
|
|
|
hospitalsMap.put(hospital.getCode(), hospital);
|
|
|
}
|
|
|
//查找出厦门市全部的区
|
|
|
List<Town> towns = townDao.findByCityCode(Constant.city);
|
|
|
Map<String, Town> townsMap = new HashMap<String, Town>();
|
|
|
for (Town town : towns) {
|
|
|
townsMap.put(town.getCode(), town);
|
|
|
}
|
|
|
String quotaId="12";
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
//数组里面第一个是健康人群 第二个是慢病人群 第三个是65岁以上人群
|
|
|
Map<String, Map<String, Map>> cityAgeMap = new HashMap<String, Map<String, Map>>();//key是市行政代码 目前只有厦门市
|
|
|
Map<String,Map> temp =new HashMap<String,Map>();
|
|
|
cityAgeMap.put(Constant.city, temp);
|
|
|
|
|
|
Map<String, Map<String, Map>> townAgeMap = new HashMap<String, Map<String, Map>>();//key是区行政代码
|
|
|
Map<String, Map<String, Map>> orgAgeMap = new HashMap<String, Map<String, Map>>();//key是机构代码
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有签约的
|
|
|
for (SignFamily signFamily : signFamilys) {
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
town = hospital.getTown();
|
|
|
int age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());//根据card解析年龄
|
|
|
String ageCode = getAgeCode(age);//得到年龄的code
|
|
|
|
|
|
boolean hasGXY = false;//有高血压
|
|
|
boolean hasTNB = false;//有糖尿病
|
|
|
//如果是慢病的 统计高血压的 糖尿病 1高血压,2糖尿病 糖尿病和高血压是3
|
|
|
String diseaseType="";
|
|
|
String jsonString = redisTemplate.opsForValue().get("disease:" + signFamily.getPatient());
|
|
|
if (StringUtils.isEmpty(jsonString)) {
|
|
|
diseaseType="4";//健康人群
|
|
|
}else{
|
|
|
//排除数据 只留下高血压和糖尿病
|
|
|
List<JSONObject> jsonObjects = new ArrayList<JSONObject>();
|
|
|
JSONArray redisValues = new JSONArray(jsonString);
|
|
|
if(redisValues.length()>0){
|
|
|
for (Object obj : redisValues) {
|
|
|
JSONObject redisValue = (JSONObject)(obj);
|
|
|
if(!redisValue.has("signType")){
|
|
|
continue;
|
|
|
}
|
|
|
//排除掉三师签约
|
|
|
if ("1".equals(redisValue.getString("signType"))) {
|
|
|
continue;
|
|
|
}
|
|
|
String disease = redisValue.getString("disease");
|
|
|
if (("1").equals(disease)) {
|
|
|
jsonObjects.add(redisValue);
|
|
|
hasGXY = true;//设置有高血压
|
|
|
diseaseType="1";
|
|
|
}
|
|
|
if (("2").equals(disease)) {
|
|
|
jsonObjects.add(redisValue);
|
|
|
hasTNB = true;//设置有糖尿病
|
|
|
diseaseType="2";
|
|
|
}
|
|
|
}
|
|
|
if(hasGXY&&hasTNB){
|
|
|
diseaseType="3";
|
|
|
}
|
|
|
}else{
|
|
|
diseaseType="4";
|
|
|
}
|
|
|
}
|
|
|
//统计市
|
|
|
compute(cityAgeMap, Constant.city, ageCode, diseaseType);
|
|
|
//统计区
|
|
|
compute(townAgeMap, town, ageCode, diseaseType);
|
|
|
//统计机构
|
|
|
//统计站
|
|
|
orgCode=hospital.getCode();
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//统计站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
//统计机构
|
|
|
compute(orgAgeMap, orgCodeTemp, ageCode, diseaseType);
|
|
|
} else {
|
|
|
compute(orgAgeMap, hospital.getCode(), ageCode, diseaseType);
|
|
|
}
|
|
|
try{
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Age,SignDataFilter.level3Disease,sql,null);
|
|
|
//统计数据 一级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData= level2Role.elt(returnDatas);
|
|
|
//统计数据 三级维度
|
|
|
List<Map<String, Map<String, Map<String, List<ETLModel>>>>> returnD=level3Role.elt(patientSexRoleData);
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel3(returnD,quotaId,6,4,2,1,1,1);
|
|
|
}catch (Exception e){
|
|
|
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//保存市级数据
|
|
|
for (Map.Entry<String, Map<String, Map>> entry : cityAgeMap.entrySet()) {
|
|
|
Map<String, Map> oneAgeMap = entry.getValue();
|
|
|
for(int i=1;i<7;i++){
|
|
|
for(int j=1;j<5;j++){
|
|
|
String key_2=i+"";
|
|
|
String key_3=j+"";
|
|
|
String name=Constant.cityName;
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
|
|
|
Map<String,Long> key3Map=oneAgeMap.get(key_2);
|
|
|
if(key3Map!=null&&key3Map.containsKey(key_3)){
|
|
|
jsonObject.put("num",key3Map.get(key_3) + "");
|
|
|
}else{
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",name);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:12:4:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//保存区级
|
|
|
for (Map.Entry<String, Town> entry : townsMap.entrySet()) {
|
|
|
//判断该区是否有统计数据
|
|
|
Map<String, Map> oneAgeMap = townAgeMap.get(entry.getKey());//得到当个区的统计数据
|
|
|
Town townObj = entry.getValue();//得到区级信息
|
|
|
for(int i=1;i<7;i++){
|
|
|
for(int j=1;j<5;j++){
|
|
|
String key_2=i+"";
|
|
|
String key_3=j+"";
|
|
|
String name=townObj.getName();
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
|
|
|
Map<String,Long> key3Map=oneAgeMap.get(key_2);
|
|
|
if(key3Map!=null&&key3Map.containsKey(key_3)){
|
|
|
jsonObject.put("num",(key3Map.get(key_3) + ""));
|
|
|
}else{
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",townObj.getName());
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));//quota:12:2:6:1:350200
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:12:3:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//保存机构级
|
|
|
for (Map.Entry<String, Hospital> entry : hospitalsMap.entrySet()) {
|
|
|
//判断该机构是否有统计数据
|
|
|
Map<String, Map> oneAgeMap = orgAgeMap.get(entry.getKey());//得到当个机构的统计数据
|
|
|
Hospital hospital = entry.getValue();//得到机构信息
|
|
|
for(int i=1;i<7;i++){
|
|
|
for(int j=1;j<5;j++){
|
|
|
String key_2=i+"";
|
|
|
String key_3=j+"";
|
|
|
String name=hospital.getName();
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
if (oneAgeMap != null && oneAgeMap.containsKey(key_2)) {
|
|
|
Map<String,Long> key3Map=oneAgeMap.get(key_2);
|
|
|
if(key3Map!=null&&key3Map.containsKey(key_3)){
|
|
|
jsonObject.put("num",(key3Map.get(key_3) + ""));
|
|
|
}else{
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
} else {
|
|
|
jsonObject.put("num",0);
|
|
|
}
|
|
|
jsonObject.put("name",name);
|
|
|
jsonObject.put("date", DateUtil.dateToStrLong(new Date()));
|
|
|
redisTemplate.opsForValue().set(new StringBuffer("quota:12:2:"+i+":"+j+":"+entry.getKey()).toString(),jsonObject.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
allContent.append( saveContent("12",signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------12----------");
|
|
|
}
|
|
|
private void compute(Map<String, Map<String, Map>> rootMap, String rootKey, String ageCode, String diseaseType) {
|
|
@ -840,1083 +318,217 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
}
|
|
|
}
|
|
|
private void computequota_1() {
|
|
|
errorContent=new StringBuffer();
|
|
|
//找出今天的签约信息 yesterday,now
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//找出今天的签约信息 yesterday,now
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,sql,"now");
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,"1");
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent("1",signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------1----------");
|
|
|
}
|
|
|
|
|
|
|
|
|
private void computequota_2() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="2";
|
|
|
//找出今天的解约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.apply_unsign_date>= '"+now+"' and a.apply_unsign_date< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||(idCard.length()!=18&&idCard.length()!=15)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//找出今天的解约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.apply_unsign_date>= '"+now+"' and a.apply_unsign_date< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,sql);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,quotaId);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("----------2-----------");
|
|
|
allContent.append("----------2-----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_3() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="3";
|
|
|
//找出今天的咨询信息
|
|
|
String sql=" select * from wlyy_consult_team a where a.type=2 and a.czrq>='"+now+"' and a.czrq< '"+tomorrow+"'";
|
|
|
List<ConsultTeam> consultTeams = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ConsultTeam .class));
|
|
|
|
|
|
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.getAdminTeamCode();
|
|
|
if(adminId == null||adminId<=0) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",咨询的团队(wlyy_consult_team)中的admin_team_code数据为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String teamCode = consultTeam.getAdminTeamCode()+"";//行政的团队的id
|
|
|
AdminTeam adminTeam=adminTeamMap.get(teamCode);
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",团队Id:"+adminTeam.getId()+",咨询的团队(wlyy_consult_team)中的团队不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCode = adminTeam.getOrgCode();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",团队Id:"+adminTeam.getId()+",医生团队的机构为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
//统计机构
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//统计站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//统计社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//统计区 ---------------start--------------
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:,医生团队的机构不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String town=hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:"+hospital.getId()+",机构表的区字段(town)为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj=townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("咨询Id:"+consultTeam.getId()+",机构Id:"+hospital.getId()+",机构表的区不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//找出今天的咨询信息
|
|
|
String sql=" select * from wlyy_consult_team a where a.type=2 and a.czrq>='"+now+"' and a.czrq< '"+tomorrow+"'";
|
|
|
//抽取數據
|
|
|
List<ConsultTeam> consultTeams= dbExtract.extract(ConsultTeam.class,sql);
|
|
|
//過濾數據
|
|
|
FilterModel etlModels= consultDataFilter.filter(consultTeams,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,quotaId);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,consultTeams.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("----------3-----------");
|
|
|
allContent.append("----------3-----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_4() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="4";
|
|
|
//找出今天的随访信息
|
|
|
List<Map<String,Object>> plans = getFvYesterday();
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(Map<String,Object> plan:plans){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
Object idCard=plan.get("id_card");//得到隨訪的身份證
|
|
|
if(StringUtils.isEmpty(idCard)){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",随访(fv_plan)表id_card为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
SignFamily signFamily=signFamilyDao.findByIdcard(idCard.toString());
|
|
|
if(signFamily==null){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",签约code:随访中的患者身份证在签约表中找不到数据");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminTeamId=signFamily.getAdminTeamCode();
|
|
|
if(adminTeamId==null||adminTeamId<=0){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",签约code:"+signFamily.getCode()+" 中的adminTeamId为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamCode());
|
|
|
if(adminTeam==null){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",签约code:"+signFamily.getCode()+",医生团队不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构------------------start ------------------
|
|
|
//判断医生属于哪个机构
|
|
|
String orgCodeTemp="";
|
|
|
String orgCode=adminTeam.getOrgCode();
|
|
|
if(StringUtils.isEmpty(orgCode)){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",团队Id:"+adminTeam.getId()+",随访的医生所属的团队(wlyy_admin_team)机构为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
//统计机构
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//统计站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//统计社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital==null){
|
|
|
errorContent.append("随访id:"+plan.get("id")+",团队Id:"+adminTeam.getId()+",随访的医生所属的团队的机构不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("随访id:"+plan.get("id")+",机构Id:"+hospital.getId()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("随访id:"+plan.get("id")+",机构Id:"+hospital.getId()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
//找出今天的随访信息
|
|
|
String sql=" select * from fv_plan a where unix_timestamp(a.update_time)>=unix_timestamp('"+now+"') and unix_timestamp(a.update_time)< unix_timestamp('"+tomorrow+"') ";
|
|
|
|
|
|
//找出今天的随访信息
|
|
|
List<Map<String, Object>> plans = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
FilterModel etlModels = followUpDataFilter.filter(plans, sql, null);
|
|
|
// 统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas = levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,quotaId);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,plans.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------4----------");
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}allContent.append("-----------4----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_5() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="5";
|
|
|
|
|
|
String sql="SELECT * FROM wlyy_patient_health_guidance a WHERE a.czrq>='"+now+"' and a.czrq< '"+tomorrow+"'";
|
|
|
List<PatientHealthGuidance> patientHealthGuidances = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientHealthGuidance .class));
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(PatientHealthGuidance patientHealthGuidance:patientHealthGuidances){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String patient=patientHealthGuidance.getPatient();
|
|
|
SignFamily signFamily= signFamilyDao.findByPatientAndType(patient,2);//只统计家庭签约
|
|
|
if(signFamily == null) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",患者code:"+patient+",家庭签约不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String adminId=signFamily.getAdminTeamCode()+"";//得到团队ID
|
|
|
if(StringUtils.isEmpty(adminId)){
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的团队AdminTeamCode为空");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
AdminTeam adminTeam = adminTeamMap.get(adminId);
|
|
|
if(adminTeam==null){
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的团队不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCode=signFamily.getHospital();//得到机构id
|
|
|
if(StringUtils.isEmpty(orgCode)){
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",签约code:"+signFamily.getCode()+",咨询的家庭签约的机构Hospital不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
//统计机构 -----------------start---------------------
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//统计站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//统计社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+orgCodeTemp+",健康咨询的医生所属的机构不存在");
|
|
|
isAll=false;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+hospital.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("健康咨询id:"+patientHealthGuidance.getId()+",机构code:"+hospital.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//抽取數據
|
|
|
List<PatientHealthGuidance> consultTeams= dbExtract.extract(PatientHealthGuidance.class,sql);
|
|
|
//過濾數據
|
|
|
FilterModel etlModels= healthGuideDataFilter.filter(consultTeams,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,quotaId);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,patientHealthGuidances.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------5----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_6() throws Exception {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="6";
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String sex= IdCardUtil.getSexForIdcard(signFamily.getIdcard());
|
|
|
if("3".equals(sex)){
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",IdCard解析错误,分到未知的组里");
|
|
|
}
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setAdminTeam(signFamily.getAdminTeamCode()+"");
|
|
|
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= level2Role.elt(returnData1s);
|
|
|
try{
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Sex,sql,null);
|
|
|
//统计数据 1级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);;
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel2(patientSexRoleData,quotaId,3,1);
|
|
|
redisStorage.saveByLevel2(level2Data,quotaId,3,1);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------6----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_7() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="7";
|
|
|
//查找出系统全部的全科医生
|
|
|
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);
|
|
|
}
|
|
|
//找出今天的解约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
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;//是否统计失败
|
|
|
StringBuffer errorContent=new StringBuffer();
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
//得到患者的分组标签
|
|
|
List<SignPatientLabelInfo> signPatientLabelInfoList= signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signFamily.getPatient(),"1",1);
|
|
|
String level2Key="1";
|
|
|
if(signPatientLabelInfoList!=null&&signPatientLabelInfoList.size()>0){
|
|
|
level2Key=signPatientLabelInfoList.get(0).getLabel();
|
|
|
}
|
|
|
etlModel.setLevel2Key(level2Key);//设置二级维度的Key
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
if("2".equals(level2Key)){
|
|
|
level2Key="0";
|
|
|
boolean hasGXY=false;//有高血压
|
|
|
boolean hasTNB=false;//糖尿病
|
|
|
//得到患者的疾病标签
|
|
|
signPatientLabelInfoList= signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signFamily.getPatient(),"3",1);
|
|
|
for (SignPatientLabelInfo signPatientLabelInfo:signPatientLabelInfoList){
|
|
|
if("1".equals(signPatientLabelInfo.getLabel())){
|
|
|
level2Key="4";
|
|
|
hasGXY=true;
|
|
|
}
|
|
|
if("2".equals(signPatientLabelInfo.getLabel())){
|
|
|
level2Key="5";
|
|
|
hasTNB=true;
|
|
|
}
|
|
|
}
|
|
|
if (hasTNB&&hasGXY){
|
|
|
level2Key="6";
|
|
|
}
|
|
|
etlModel=new ETLModel();
|
|
|
etlModel.setLevel2Key(level2Key);//设置二级维度的Key
|
|
|
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);
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Group,sql,null);
|
|
|
//统计数据 1级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);
|
|
|
//保存数据 1 表示:从1开始循环 6表示:循环6次 3表示 2级维度是 3
|
|
|
redisStorage.saveByLevel2(level2Data,quotaId,6,3);
|
|
|
redisStorage.saveByLevel2(level2Data,quotaId,7,3);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("----------7-----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_8()throws Exception {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="8";
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||((idCard.length()!=18&&idCard.length()!=15))) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
int age=IdCardUtil.getAgeForIdcard(signFamily.getIdcard());
|
|
|
etlModel.setLevel2Key(age+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setAdminTeam(signFamily.getAdminTeamCode()+"");
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
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= level2Role.elt(returnData1s);
|
|
|
//找出今天的签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where a.type =2 and a.expenses_time>= '"+now+"' and a.expenses_time< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Age,sql,null);
|
|
|
//统计数据 1级维度
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//统计数据 二级维度
|
|
|
List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);;
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel2(patientAgeRoleData,quotaId,6,2);
|
|
|
redisStorage.saveByLevel2(level2Data,quotaId,6,2);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("----------8-----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_9() {
|
|
|
errorContent=new StringBuffer();
|
|
|
String quotaId="9";
|
|
|
//找出今天的待签约信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.patient_apply_date>= '"+now+"' and a.patient_apply_date< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||(idCard.length()!=18&&idCard.length()!=15)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,quotaId);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("----------9-----------");
|
|
|
allContent.append("----------9-----------");
|
|
|
}
|
|
|
|
|
|
private void computequota_10() {
|
|
|
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);
|
|
|
}
|
|
|
//找出今天的已改簽信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.status =100 and a.patient_apply_date>= '"+now+"' and a.patient_apply_date< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
List<SignFamily> signFamilys = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SignFamily .class));
|
|
|
|
|
|
Long cityCount = new Long(0L); //统计到市的数目
|
|
|
Long townCount = new Long(0L); //统计到所有区的数目
|
|
|
Long orgCount =new Long(0L);//统计到所有机构的数目
|
|
|
Long adminCount = new Long(0L);//统计到所有团队的数目
|
|
|
Long errorCount=new Long(0L);//脏数据
|
|
|
Boolean isAll=true;//是否统计失败
|
|
|
//统计有已改簽的
|
|
|
List<ETLModel> etlModels=new ArrayList<ETLModel>();
|
|
|
//数据过滤清洗出脏数据 -----------start
|
|
|
for(SignFamily signFamily:signFamilys){
|
|
|
ETLModel etlModel=new ETLModel();
|
|
|
String orgCode = signFamily.getHospital();
|
|
|
if(StringUtils.isEmpty(orgCode)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String orgCodeTemp="";
|
|
|
if(!"00".equals(orgCode.substring(orgCode.length()-2,orgCode.length()))){
|
|
|
//站
|
|
|
orgCodeTemp=orgCode.substring(0,orgCode.length()-2)+"00";
|
|
|
}else{
|
|
|
//社区
|
|
|
orgCodeTemp=orgCode;
|
|
|
}
|
|
|
//判断社区有没有值
|
|
|
Hospital hospital=hospitalsMap.get(orgCodeTemp);
|
|
|
if(hospital == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Long adminId=signFamily.getAdminTeamCode();
|
|
|
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.getAdminTeamCode()+"");
|
|
|
if(adminTeam == null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String idCard=signFamily.getIdcard();
|
|
|
if(idCard == null||(idCard.length()!=18&&idCard.length()!=15)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的idCard数据异常");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
String town =hospital.getTown();
|
|
|
if(StringUtils.isEmpty(town)) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
Town townObj =townsMap.get(town);
|
|
|
if(townObj==null) {
|
|
|
errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
|
|
|
isAll=false;
|
|
|
errorCount++;
|
|
|
continue;
|
|
|
}
|
|
|
etlModel.setAdminTeam(adminTeam.getId()+"");
|
|
|
etlModel.setHospital(orgCodeTemp);
|
|
|
etlModel.setTown(hospital.getTown());
|
|
|
etlModel.setCity(Constant.city);
|
|
|
etlModel.setIdcard(signFamily.getIdcard());
|
|
|
etlModels.add(etlModel);
|
|
|
//统计数目+1
|
|
|
cityCount++;
|
|
|
townCount++;
|
|
|
orgCount++;
|
|
|
adminCount++;
|
|
|
}
|
|
|
//数据过滤清洗出脏数据 -----------end
|
|
|
try{
|
|
|
try{
|
|
|
//找出今天的已改簽信息
|
|
|
String sql=" select id,code,idcard,hospital,admin_team_code from wlyy_sign_family a where a.type =2 and a.status =100 and a.patient_apply_date>= '"+now+"' and a.patient_apply_date< '"+tomorrow+"' and a.expenses_status=1 ";
|
|
|
//抽取數據
|
|
|
List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
|
|
|
//清洗數據
|
|
|
FilterModel etlModels= signDataFilter.filter(signFamilies,sql,null);
|
|
|
//统计数据
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels);
|
|
|
List<Map<String, List<ETLModel>>> returnDatas= levelRole.elt(etlModels.getEtlModelList());
|
|
|
//保存数据
|
|
|
redisStorage.saveByLevel1(returnDatas,quotaId);
|
|
|
allContent.append(etlModels.getMessage());
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
errorContent.append("统计失败:"+e.getMessage());
|
|
|
allContent.append("统计失败:"+e.getMessage());
|
|
|
}
|
|
|
allContent.append(saveContent(quotaId,signFamilys.size(),adminCount,orgCount,townCount,cityCount,isAll,errorContent,errorCount));
|
|
|
allContent.append("-----------10----------");
|
|
|
}
|
|
|
|
|
@ -1933,12 +545,6 @@ public class CurrentDayAllQuotaJob implements Job {
|
|
|
return dateString;
|
|
|
}
|
|
|
|
|
|
public List<Map<String,Object>> getFvYesterday() {
|
|
|
|
|
|
String sql=" select * from fv_plan a where unix_timestamp(a.update_time)>=unix_timestamp('"+now+"') and unix_timestamp(a.update_time)< unix_timestamp('"+tomorrow+"') ";
|
|
|
return fv_jdbcTemplate.queryForList(sql);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据年龄得到对应的code
|
|
|
* @param age
|