Ver código fonte

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

demon 8 anos atrás
pai
commit
51f9f6b995
35 arquivos alterados com 1391 adições e 2174 exclusões
  1. 9 9
      patient-co-statistics/pom.xml
  2. 6 6
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/ServletInitializer.java
  3. 5 4
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/ConsultDataFilter.java
  4. 5 4
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/FollowUpDataFilter.java
  5. 5 4
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/HealthGuideDataFilter.java
  6. 96 31
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/SignDataFilter.java
  7. 8 3
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/extract/DBPageExtract.java
  8. 31 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/model/CacheModel.java
  9. 36 25
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java
  10. 236 5
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/RedisStorage.java
  11. 13 7
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/AllSignExpenseStatusJob.java
  12. 4 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/AllSignJob.java
  13. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/ChangeSignJob.java
  14. 25 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/Constant.java
  15. 188 1582
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  16. 9 3
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/HealthSignJob.java
  17. 10 4
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignAgeGroupDiseaseJob.java
  18. 40 39
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignExpenseStatusJob.java
  19. 21 11
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignJob.java
  20. 1 2
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/UnSignJob.java
  21. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/WaitSignJob.java
  22. 2 7
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/util/IdCardUtil.java
  23. 5 4
      patient-co-statistics/src/main/resources/application.yml
  24. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  25. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java
  26. 4 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  27. 403 211
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  28. 4 87
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  29. 104 51
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java
  30. 27 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java
  31. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java
  32. 1 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java
  33. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java
  34. 49 22
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java
  35. 37 37
      patient-co-wlyy/src/main/resources/application.properties

+ 9 - 9
patient-co-statistics/pom.xml

@ -8,8 +8,8 @@
    <modelVersion>4.0.0</modelVersion>
    <!--打成war包需要的配置-->
    <!--<packaging>war</packaging>-->
    <packaging>jar</packaging>
    <packaging>war</packaging>
    <!--<packaging>jar</packaging>-->
    <name>patient-co-statistics</name>
    <properties>
@ -371,7 +371,7 @@
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <version>${version.spring-boot}</version>
                <!--<scope>provided</scope>-->
                <scope>provided</scope>
            </dependency>
        <dependency>
            <groupId>org.json</groupId>
@ -394,12 +394,12 @@
    <build>
        <plugins>
            <!--打成war包需要的配置-->
            <!--<plugin>-->
                <!--<artifactId>maven-war-plugin</artifactId>-->
                <!--<configuration>-->
                    <!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
                <!--</configuration>-->
            <!--</plugin>-->
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>

+ 6 - 6
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/config/ServletInitializer.java

@ -7,9 +7,9 @@ import org.springframework.boot.context.web.SpringBootServletInitializer;
/**
 * Created by Administrator on 2016.10.14.
 */
//public class ServletInitializer extends SpringBootServletInitializer {
//    @Override
//    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
//        return application.sources(Application.class);
//    }
//}
public class ServletInitializer extends SpringBootServletInitializer {
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }
}

+ 5 - 4
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/ConsultDataFilter.java

@ -11,15 +11,13 @@ import com.yihu.wlyy.statistics.model.hosptial.Hospital;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Administrator on 2016.10.17.
@ -137,6 +135,9 @@ public class ConsultDataFilter {
    }
    private String saveContent(Integer size, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent,Long errorCount,String sql,String filterDate) {
        if(StringUtils.isEmpty(filterDate)){
            filterDate= DateUtil.dateToStrLong(new Date());
        }
        StringBuffer string=new StringBuffer("统计"+filterDate+" 的数据完成 ,数据库查询到数目:"+size);
        string.append(",sql语句:"+sql);
        string.append(",过滤的脏数据数目:"+errorCount);

+ 5 - 4
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/FollowUpDataFilter.java

@ -12,15 +12,13 @@ import com.yihu.wlyy.statistics.model.hosptial.Hospital;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Administrator on 2016.10.17.
@ -154,6 +152,9 @@ public class FollowUpDataFilter {
    }
    private String saveContent(Integer size, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent,Long errorCount,String sql,String filterDate) {
        if(StringUtils.isEmpty(filterDate)){
            filterDate= DateUtil.dateToStrLong(new Date());
        }
        StringBuffer string=new StringBuffer("统计"+filterDate+" 的数据完成 ,数据库查询到数目:"+size);
        string.append(",sql语句:"+sql);
        string.append(",过滤的脏数据数目:"+errorCount);

+ 5 - 4
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/HealthGuideDataFilter.java

@ -13,15 +13,13 @@ import com.yihu.wlyy.statistics.model.patient.PatientHealthGuidance;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Administrator on 2016.10.17.
@ -147,6 +145,9 @@ public class HealthGuideDataFilter {
        return FilterModel.getFiltrerMode(message,etlModels,isAll);
    }
    private String saveContent(Integer size, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent,Long errorCount,String sql,String filterDate) {
        if(StringUtils.isEmpty(filterDate)){
            filterDate= DateUtil.dateToStrLong(new Date());
        }
        StringBuffer string=new StringBuffer("统计"+filterDate+" 的数据完成 ,数据库查询到数目:"+size);
        string.append(",sql语句:"+sql);
        string.append(",过滤的脏数据数目:"+errorCount);

+ 96 - 31
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/dataFilter/SignDataFilter.java

@ -12,16 +12,14 @@ import com.yihu.wlyy.statistics.model.label.SignPatientLabelInfo;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.util.IdCardUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Administrator on 2016.10.16.
@ -36,9 +34,9 @@ public class SignDataFilter {
    public static String level2Group="3";//分组
    public static String level2Expenses="4";//费用
    public static String level2Health="5";//健康服务分布
    public static String level2Age2="6";//年龄
    public static String level3Disease="1";//疾病分组
   public static int size=0;
    private StringBuffer errorContent =new StringBuffer();//错误信息
    @Autowired
@ -49,10 +47,20 @@ public class SignDataFilter {
    private DoctorAdminTeamDao doctorAdminTeamDao;
    @Autowired
    private SignPatientLabelInfoDao signPatientLabelInfoDao;
    private int count=0;
    /**
     * 过滤数据
     * @param signFamilies 签约列表
     * @param filterDate 过滤的是哪天的数据 yyyy-MM-dd
     * @return
     */
    public FilterModel filter(List<SignFamily> signFamilies,String sql){
        return filterCommon(signFamilies,null,null,sql,null);
    }
    /**
     * 过滤数据
     * @param signFamilies 签约列表
     * @param filterDate 不传默认是但在的时间
     * @return
     */
    public FilterModel filter(List<SignFamily> signFamilies,String sql,String filterDate){
@ -117,8 +125,13 @@ public class SignDataFilter {
        Long adminCount = new Long(0L);//统计到所有团队的数目
        Long errorCount=new Long(0L);//脏数据
        Boolean isAll=true;//是否统计失败
        int a1=0;
        int a2=0;
        for (int i=0;i<signFamilies.size();i++){
            SignFamily signFamily=signFamilies.get(i);
            if("1".equals(signFamily.getExpensesStatus())){
                a1++;
            }
            String orgCode = signFamily.getHospital();
            if(StringUtils.isEmpty(orgCode)) {
                errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的hospital数据为空");
@ -148,42 +161,44 @@ public class SignDataFilter {
                errorCount++;
                continue;
            }
            Long adminId=signFamily.getAdminTeamCode();
            if(adminId == null||adminId<=0) {
                errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
            String town =hospital.getTown();
            if(StringUtils.isEmpty(town)) {
                errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
                isAll=false;
                errorCount++;
                continue;
            }
            AdminTeam adminTeam=adminTeamMap.get(signFamily.getAdminTeamCode()+"");
            if(adminTeam == null) {
                errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
            Town townObj =townsMap.get(town);
            if(townObj==null) {
                errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
                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数据异常");
           Long adminId=signFamily.getAdminTeamCode();
            if(adminId == null||adminId<=0) {
                errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据为空");
                isAll=false;
                errorCount++;
                continue;
            }
            String town =hospital.getTown();
            if(StringUtils.isEmpty(town)) {
                errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town为空");
            AdminTeam adminTeam=adminTeamMap.get(adminId+"");
            if(adminTeam == null) {
                errorContent.append("签约code:"+signFamily.getCode()+",签约表中(wlyy_sign_family)中的Admin_Team_Id数据不存在");
                isAll=false;
                errorCount++;
                continue;
            }
            Town townObj =townsMap.get(town);
            if(townObj==null) {
                errorContent.append("签约code:"+signFamily.getCode()+",机构表的中的town不存在");
            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("1".equals(signFamilies.get(i).getExpensesStatus())){
                a2++;
            }
            //设置二级维度的Key
            String returnLevel2Key=getLevel2Key(level2Key,signFamily);
            String returnLevel3Key=getLevel3Key(level3Key,signFamily);
@ -267,35 +282,49 @@ public class SignDataFilter {
                 //性别
                 case "1" :{
                     returnLevel2Key = getSex(signFamily);
                     break;
                     return returnLevel2Key;
                 }
                 //年龄
                 case "2" :{
                     returnLevel2Key = getAge(signFamily);
                     break;
                     return returnLevel2Key;
                 }
                 //分组
                 case "3" :{
                     //得到患者的分组标签
                     returnLevel2Key = getGroup(signFamily);
                     break;
                     return returnLevel2Key;
                 }
                 //费用
                 case "4" :{
                     returnLevel2Key = getExpenses(signFamily);
                     break;
                     return returnLevel2Key;
                 }
                 //健康服务分布
                 case "5" :{
                     returnLevel2Key = getHealth(signFamily);
                     break;
                     return returnLevel2Key;
                 }
                 //年龄
                 case "6" :{
                     returnLevel2Key = getAge2(signFamily);
                     return returnLevel2Key;
                 }
             }
        }
        return returnLevel2Key;
    }
    private String getAge2(SignFamily signFamily) {
        String returnLevel2Key;
        int age= IdCardUtil.getAgeForIdcard(signFamily.getIdcard());
        if(0==age){
            errorContent.append("签约code:"+signFamily.getCode()+",年龄是0");
        }
        returnLevel2Key=getAgeCode2(age);
        return returnLevel2Key;
    }
    private String getHealth(SignFamily signFamily) {
        String returnLevel2Key="0";//查找每个患者的健康分布标签
        List<SignPatientLabelInfo> signPatientLabelInfoList= signPatientLabelInfoDao.findByPatientAndLabelTypeAndStatus(signFamily.getPatient(),"2",1);
@ -306,7 +335,16 @@ public class SignDataFilter {
    }
    private String getExpenses(SignFamily signFamily) {
        String returnLevel2Key= StringUtils.isEmpty(signFamily.getExpensesStatus())?"0":signFamily.getExpensesStatus();
        if("1".equals(signFamily.getExpensesStatus())){
            count++;
        }
        String returnLevel2Key= signFamily.getExpensesStatus();
        if(returnLevel2Key==null){
            returnLevel2Key="0";
        }
        if("".equals(returnLevel2Key.trim())){
            returnLevel2Key="0";
        }
        return returnLevel2Key;
    }
@ -317,7 +355,14 @@ public class SignDataFilter {
        if(signPatientLabelInfoList!=null&&signPatientLabelInfoList.size()>0){
            returnLevel2KeyBuffer=new StringBuffer(signPatientLabelInfoList.get(0).getLabel());
        }
        //如果是慢病组  区分65岁以上还是以下   65岁以上的慢病患者是7  65岁上下是2
        if("2".equals(returnLevel2KeyBuffer.toString())){
             Integer age=IdCardUtil.getAgeForIdcard(signFamily.getIdcard());
            if(age>65){
                returnLevel2KeyBuffer=new StringBuffer("7");
            }
        }
        if("2".equals(returnLevel2KeyBuffer.toString())||"7".equals(returnLevel2KeyBuffer.toString())){
            String returnLevel2KeyTemp="0";
            boolean hasGXY=false;//有高血压
            boolean hasTNB=false;//糖尿病
@ -354,14 +399,20 @@ public class SignDataFilter {
    private String getSex(SignFamily signFamily) {
        String returnLevel2Key;
        returnLevel2Key= IdCardUtil.getSexForIdcard(signFamily.getIdcard());
        if("3".equals(returnLevel2Key)){
        try{
            returnLevel2Key= IdCardUtil.getSexForIdcard(signFamily.getIdcard());
        }catch (Exception e){
            //如果解析失败 默认是男 并且纪录解析失败的签约code
            errorContent.append("签约code:"+signFamily.getCode()+",IdCard解析错误,分到未知的组里");
            return Constant.level_sex_2;
        }
        return returnLevel2Key;
    }
    private String saveContent(Integer size, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent,Long errorCount,String sql,String filterDate) {
        if(StringUtils.isEmpty(filterDate)){
            filterDate= DateUtil.dateToStrLong(new Date());
        }
        StringBuffer string=new StringBuffer("统计"+filterDate+" 的数据完成 ,数据库查询到数目:"+size);
        string.append(",sql语句:"+sql);
        string.append(",过滤的脏数据数目:"+errorCount);
@ -396,4 +447,18 @@ public class SignDataFilter {
            return Constant.level_age_6;
        }
    }
    /**
     * 根据年龄得到对应的code
     *
     * @param age
     * @return
     */
    public String getAgeCode2(Integer age) {
        if (age <= 65) {
            return Constant.level_age2_1;
        } else {
            return Constant.level_age2_2;
        }
    }
}

+ 8 - 3
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/extract/DBPageExtract.java

@ -25,10 +25,14 @@ import java.util.concurrent.Future;
public class DBPageExtract<T> {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    private  List<T> returnList=new ArrayList<T>();
    public synchronized void addData( List<T> dataList) {
         returnList.addAll(dataList);
    }
     private  List<T> returnList=new ArrayList<T>();
    public List<T> extractByPage(Class<T> clazz, String sql,String countSql, int pageSize, Boolean isMultithreading) throws Exception{
    public List<T> extractByPage(Class<T> clazz, String sql, String countSql, int pageSize, Boolean isMultithreading) throws Exception{
        if(isMultithreading){
            if(StringUtils.isEmpty(countSql)){
                throw new Exception("countSql is null");
@ -79,6 +83,7 @@ public class DBPageExtract<T> {
            Integer dataCount=getCount(countSql);
            //根据count 计算出 总共要执行几次
            Integer forCount=getForCount(dataCount,pageSize);
            forCount++;
            //綫程返回值的值
            List<AsyncResult<Boolean>> asyncResultPool=new ArrayList<AsyncResult<Boolean>>();
            for(int page=0;page<forCount;page++){
@ -143,7 +148,7 @@ public class DBPageExtract<T> {
    private AsyncResult<Boolean> multiExtractData(String sql, int start, int pageSize, Class<T> clazz) {
        String finalSql=sql+" limit "+start+","+pageSize; //拼凑分页的语句
        List<T> listTemp= jdbcTemplate.query(finalSql,new BeanPropertyRowMapper(clazz));
        returnList.addAll(listTemp);
        addData(listTemp);
        return new AsyncResult<>(true);
    }

+ 31 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/model/CacheModel.java

@ -0,0 +1,31 @@
package com.yihu.wlyy.statistics.etl.model;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import java.util.List;
/**
 * Created by Administrator on 2016.10.19.
 * 缓存的model模型
 */
public class CacheModel {
    private List<SignFamily> signFamilies;//数据
    private String sql;//执行的sql语句
    public List<SignFamily> getSignFamilies() {
        return signFamilies;
    }
    public void setSignFamilies(List<SignFamily> signFamilies) {
        this.signFamilies = signFamilies;
    }
    public String getSql() {
        return sql;
    }
    public void setSql(String sql) {
        this.sql = sql;
    }
}

+ 36 - 25
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/DBStorage.java

@ -211,9 +211,10 @@ public class DBStorage   {
     * @param wlyyQuota
     * @param foreachNum2 标识二级维度循环的次数  例如 年龄就传6  性别就传3
     * @param foreachNum3 标识三级维度循环的次数  例如 年龄就传6  性别就传3
     * @param type 1 性别 2 年龄 3 用户分组 4.签约费用 5
     * @param type2 1性别 2年龄 3用户分组 4.签约费用 5健康服务 6年龄2
     * @param type3 1 疾病分组
     */
    public void saveByLevel3(List<Map<String, Map<String, Map<String, List<ETLModel>>>>> data, String day, WlyyQuotaVO wlyyQuota,Integer foreachNum2,Integer foreachNum3,Integer type) throws Exception{
    public void saveByLevel3(List<Map<String, Map<String, Map<String, List<ETLModel>>>>> data, String day, WlyyQuotaVO wlyyQuota,Integer foreachNum2,Integer foreachNum3,Integer type2,Integer type3) throws Exception{
        Integer start2=1;
        Integer start3=1;
        this.wlyyQuota=wlyyQuota;
@ -238,13 +239,13 @@ public class DBStorage   {
        Map<String, City> cityMap = new HashMap<String, City>();
        cityMap.put(Constant.city,city);
        //保存团队
        saveAdminTeamDataLevel3(data.get(0),day,adminTeamMap,foreachNum2,foreachNum3,type,start2,start3);
        saveAdminTeamDataLevel3(data.get(0),day,adminTeamMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存机构
        saveHospitalTeamDataLevel3(data.get(1),day,hospitalsMap,foreachNum2,foreachNum3,type,start2,start3);
        saveHospitalTeamDataLevel3(data.get(1),day,hospitalsMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存区
        saveTownTeamDataLevel3(data.get(2),day,townsMap,foreachNum2,foreachNum3,type,start2,start3);
        saveTownTeamDataLevel3(data.get(2),day,townsMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存市
        saveCityTeamDataLevel3(data.get(3),day,cityMap,foreachNum2,foreachNum3,type,start2,start3);
        saveCityTeamDataLevel3(data.get(3),day,cityMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
    }
    /**
@ -254,16 +255,17 @@ public class DBStorage   {
     * @param wlyyQuota
     * @param foreachNum2 标识二级维度循环的次数  例如 年龄就传6  性别就传3
     * @param foreachNum3 标识三级维度循环的次数  例如 年龄就传6  性别就传3
     * @param type 1 性别 2 年龄 3 用户分组 4.签约费用
     * @param type2 1 性别 2 年龄 3 用户分组 4.签约费用 5健康服务 6年龄2
     * @param type3 1 疾病类型
     * @param start2 耳機維度起始位置 默认是1
     * @param start3 耳機維度起始位置 默认是1
     */
    public void saveByLevel3(List<Map<String, Map<String, Map<String, List<ETLModel>>>>> data, String day, WlyyQuotaVO wlyyQuota,Integer foreachNum2,Integer foreachNum3,Integer type,Integer start2,Integer start3) throws Exception{
    public void saveByLevel3(List<Map<String, Map<String, Map<String, List<ETLModel>>>>> data, String day, WlyyQuotaVO wlyyQuota,Integer foreachNum2,Integer foreachNum3,Integer type2,Integer type3,Integer start2,Integer start3) throws Exception{
        if(start2==null){
            start2=1;
        }
        if(start3==null){
            start2=3;
            start2=1;
        }
        this.wlyyQuota=wlyyQuota;
        List<AdminTeam> adminTeams=doctorAdminTeamDao.findAllTeam();
@ -287,18 +289,18 @@ public class DBStorage   {
        Map<String, City> cityMap = new HashMap<String, City>();
        cityMap.put(Constant.city,city);
        //保存团队
        saveAdminTeamDataLevel3(data.get(0),day,adminTeamMap,foreachNum2,foreachNum3,type,start2,start3);
        saveAdminTeamDataLevel3(data.get(0),day,adminTeamMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存机构
        saveHospitalTeamDataLevel3(data.get(1),day,hospitalsMap,foreachNum2,foreachNum3,type,start2,start3);
        saveHospitalTeamDataLevel3(data.get(1),day,hospitalsMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存区
        saveTownTeamDataLevel3(data.get(2),day,townsMap,foreachNum2,foreachNum3,type,start2,start3);
        saveTownTeamDataLevel3(data.get(2),day,townsMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存市
        saveCityTeamDataLevel3(data.get(3),day,cityMap,foreachNum2,foreachNum3,type,start2,start3);
        saveCityTeamDataLevel3(data.get(3),day,cityMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
    }
    private void saveAdminTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, AdminTeam> adminTeamMap, Integer foreachNum2, Integer foreachNum3, Integer type, Integer start2, Integer start3)throws  Exception {
    private void saveAdminTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, AdminTeam> adminTeamMap, Integer foreachNum2, Integer foreachNum3, Integer type2,Integer type3, Integer start2, Integer start3)throws  Exception {
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,AdminTeam> oneAdminTeam:adminTeamMap.entrySet()){
@ -335,14 +337,15 @@ public class DBStorage   {
                     String level="1";
                     String level2=i+"";
                     String level3=j+"";
                     String level3Name=getLevel3Name(level3,type);
                     wlyyQuotaResults.add(save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,null,level3,level3Name,day));
                     String level2Name=getLevel2Name(level2,type2);
                     String level3Name=getLevel3Name(level3,type3);
                     wlyyQuotaResults.add(save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,level2Name,level3,level3Name,day));
                }
            }
        }
        saveAll(wlyyQuotaResults);
    }
    private void saveHospitalTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, Hospital> hospitalsMap, Integer foreachNum2, Integer foreachNum3, Integer type, Integer start2, Integer start3) throws  Exception{
    private void saveHospitalTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, Hospital> hospitalsMap, Integer foreachNum2, Integer foreachNum3, Integer type2,Integer type3, Integer start2, Integer start3) throws  Exception{
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,Hospital> oneHospital:hospitalsMap.entrySet()){
@ -376,14 +379,15 @@ public class DBStorage   {
                    String level="2";
                    String level2=i+"";
                    String level3=j+"";
                    String level3Name=getLevel3Name(level3,type);
                   wlyyQuotaResults.add( save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,null,level3,level3Name,day));
                    String level2Name=getLevel2Name(level2,type2);
                    String level3Name=getLevel3Name(level3,type3);
                   wlyyQuotaResults.add( save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,level2Name,level3,level3Name,day));
                }
            }
        }
        saveAll(wlyyQuotaResults);
    }
    private void saveTownTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, Town> townsMap, Integer foreachNum2, Integer foreachNum3, Integer type, Integer start2, Integer start3) throws  Exception{
    private void saveTownTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, Town> townsMap, Integer foreachNum2, Integer foreachNum3, Integer type2,Integer type3,  Integer start2, Integer start3) throws  Exception{
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,Town> oneTownTeam:townsMap.entrySet()){
@ -417,14 +421,15 @@ public class DBStorage   {
                    String level="3";
                    String level2=i+"";
                    String level3=j+"";
                    String level3Name=getLevel3Name(level3,type);
                   wlyyQuotaResults.add(save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,null,level3,level3Name,day));
                    String level2Name=getLevel2Name(level2,type2);
                    String level3Name=getLevel3Name(level3,type3);
                   wlyyQuotaResults.add(save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,level2Name,level3,level3Name,day));
                }
            }
        }
        saveAll((wlyyQuotaResults));
    }
    private void saveCityTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, City> cityMap, Integer foreachNum2, Integer foreachNum3, Integer type, Integer start2, Integer start3) throws  Exception{
    private void saveCityTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String day, Map<String, City> cityMap, Integer foreachNum2, Integer foreachNum3, Integer type2,Integer type3,  Integer start2, Integer start3) throws  Exception{
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,City> oneCityTeam:cityMap.entrySet()){
@ -456,8 +461,9 @@ public class DBStorage   {
                    String level="4";
                    String level2=i+"";
                    String level3=j+"";
                    String level3Name=getLevel3Name(level3,type);
                    wlyyQuotaResults.add(save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,null,level3,level3Name,day));
                    String level2Name=getLevel2Name(level2,type2);
                    String level3Name=getLevel3Name(level3,type3);
                    wlyyQuotaResults.add(save(num, city, cityName, town, townName, org, orgName, doctorCode, doctorName, doctorJob, level,level2,level2Name,level3,level3Name,day));
                }
            }
        }
@ -801,6 +807,11 @@ public class DBStorage   {
                //健康分布
                return Constant.getlevelHealthFbName(i);
            }
            case  6:{
                //年龄2
                return Constant.getLevelAge2(i);
            }
            default:{
                return "";
            }

+ 236 - 5
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/storage/RedisStorage.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.statistics.dao.TownDao;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.job.business.Constant;
import com.yihu.wlyy.statistics.model.hosptial.Hospital;
import com.yihu.wlyy.statistics.model.job.WlyyQuotaResult;
import com.yihu.wlyy.statistics.model.system.City;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
@ -17,10 +18,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Administrator on 2016.10.09.
@ -30,6 +28,10 @@ import java.util.Map;
@Scope("prototype")
@Transactional
public class RedisStorage {
    private Map<String, AdminTeam> adminTeamMap = new HashMap<String, AdminTeam>();
    private Map<String, Hospital> hospitalsMap = new HashMap<String, Hospital>();
    private Map<String, Town> townsMap = new HashMap<String, Town>();
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
@ -95,11 +97,240 @@ public class RedisStorage {
        Integer start=1;
        saveByLevel2Public(data, wlyyQuotaId, foreachNum, type, start);
    }
    /**
     * 保存二级维度的数据
     * @param data
     * @param wlyyQuotaId
     * @param foreachNum 标识二级维度循环的次数  例如 年龄就传6  性别就传3
     * @param type 1 性别 2 年龄 3 用户分组 4.签约费用 5 健康分布
     * @param start 循环开始
     */
    public void saveByLevel2(List<Map<String, Map<String, List<ETLModel>>>> data, String wlyyQuotaId,Integer foreachNum,Integer type,Integer start) throws Exception {
        saveByLevel2Public(data, wlyyQuotaId, foreachNum, type, start);
    }
    /**
     * 保存三级维度的数据
     * @param data
     * @param wlyyQuotaId
     * @param foreachNum2 标识二级维度循环的次数  例如 年龄就传6  性别就传3
     * @param foreachNum3 标识二级维度循环的次数  例如 年龄就传6  性别就传3
     * @param type2 1 性别 2 年龄 3 用户分组 4.签约费用 5 健康分布
     * @param type3 1 疾病
     * @param start2 循环开始
     * @param start3 循环开始
     */
    public void saveByLevel3(List<Map<String, Map<String, Map<String, List<ETLModel>>>>> data, String wlyyQuotaId,Integer foreachNum2,Integer foreachNum3,Integer type2,Integer type3,Integer start2,Integer start3) throws Exception {
        if(start2==null){
            start2=1;
        }
        if(start3==null){
            start2=1;
        }
        List<AdminTeam> adminTeams=doctorAdminTeamDao.findAllTeam();
        for (AdminTeam adminTeam : adminTeams) {
            adminTeamMap.put(adminTeam.getId()+"", adminTeam);
        }
        //查找出系统全部的机构
        List<Hospital> hospitals = hospitalDao.findHospitalzxFWZ();
        for (Hospital hospital : hospitals) {
            hospitalsMap.put(hospital.getCode(), hospital);
        }
        //查找出厦门市全部的区
        List<Town> towns = townDao.findByCityCode(Constant.city);
        for (Town town : towns) {
            townsMap.put(town.getCode(), town);
        }
        //全部的市
        City city=new City();
        city.setCode(Constant.city);
        city.setName(Constant.cityName);
        Map<String, City> cityMap = new HashMap<String, City>();
        cityMap.put(Constant.city,city);
        //保存团队
        saveAdminTeamDataLevel3(data.get(0),wlyyQuotaId,adminTeamMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存机构
        saveHospitalTeamDataLevel3(data.get(1),wlyyQuotaId,hospitalsMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存区
        saveTownTeamDataLevel3(data.get(2),wlyyQuotaId,townsMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
        //保存市
        saveCityTeamDataLevel3(data.get(3),wlyyQuotaId,cityMap,foreachNum2,foreachNum3,type2,type3,start2,start3);
    }
    private void saveAdminTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap, String wlyyQuotaId,Map<String, AdminTeam> adminTeamMap, Integer foreachNum2, Integer foreachNum3, Integer type2, Integer type3, Integer start2, Integer start3) {
        //遍历团队的Map
        for(Map.Entry<String,AdminTeam> oneAdminTeam:adminTeamMap.entrySet()){
            //得到每个团队的2级维度
            Map<String, Map<String, List<ETLModel>>> twoETLMap= etlModelMap.get(oneAdminTeam.getKey());
            for(int i=start2;i<=foreachNum2;i++){
                //得到每个团队的三级维度
                Map<String, List<ETLModel>> threeETLMap=null;
                if(twoETLMap!=null){
                    threeETLMap=twoETLMap.get(i+"");
                }
                for(int j=start3;j<=foreachNum3;j++){
                    String level1="1";
                    String level2=i+"";
                    String level3=j+"";
                    int num=0;
                    if(threeETLMap!=null){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    AdminTeam adminTeamObj = adminTeamMap.get(oneAdminTeam.getKey());//团队
                    if(adminTeamObj==null)continue;
                    JSONObject jo=new JSONObject();
                    jo.put("date", DateUtil.dateToStrLong(new Date()));
                    jo.put("num", num);
                    jo.put("teamName", adminTeamObj.getName());
                    jo.put("teamId", adminTeamObj.getId());
                    jo.put("name", getLevel3Name(level3,type3));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+level2+":"+level3+":"+adminTeamObj.getId()).toString(), jo.toString());
                }
            }
        }
    }
    private String getLevel3Name(String j, Integer type) {
        switch (type){
            case  1:{
                //疾病类型
                return Constant.getLevelDiseaseName(j);
            }
            default:{
                return "";
            }
        }
    }
    private void saveHospitalTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap,String wlyyQuotaId, Map<String, Hospital> hospitalMap, Integer foreachNum2, Integer foreachNum3, Integer type2, Integer type3, Integer start2, Integer start3) {
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,Hospital> oneHospital:hospitalMap.entrySet()){
            //得到每个团队的2级维度
            Map<String, Map<String, List<ETLModel>>> twoETLMap= etlModelMap.get(oneHospital.getKey());
            for(int i=start2;i<=foreachNum2;i++){
                //得到每个团队的三级维度
                Map<String, List<ETLModel>> threeETLMap= new HashMap<String, List<ETLModel>>();
                if(twoETLMap!=null){
                    threeETLMap=twoETLMap.get(i+"");
                }
                for(int j=start3;j<=foreachNum3;j++){
                    String level1="2";
                    String level2=i+"";
                    String level3=j+"";
                    int num=0;
                    if(threeETLMap!=null&&threeETLMap.size()>0){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    if(threeETLMap!=null){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    Hospital hospital = hospitalsMap.get(oneHospital.getKey());
                    if(hospital==null)continue;
                    JSONObject jo=new JSONObject();
                    jo.put("date", DateUtil.dateToStrLong(new Date()));
                    jo.put("num", num);
                    jo.put("orgName", hospital.getName());
                    jo.put("orgCode", hospital.getCode());
                    jo.put("name", getLevel3Name(level3,type3));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+level2+":"+level3+":"+hospital.getCode()).toString(), jo.toString());
                }
            }
        }
    }
    private void saveTownTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap,String wlyyQuotaId, Map<String, Town> townsMap, Integer foreachNum2, Integer foreachNum3, Integer type2, Integer type3, Integer start2, Integer start3) {
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,Town> oneTownTeam:townsMap.entrySet()){
            //得到每个团队的2级维度
            Map<String, Map<String, List<ETLModel>>> twoETLMap= etlModelMap.get(oneTownTeam.getKey());
            for(int i=start2;i<=foreachNum2;i++){
                //得到每个团队的三级维度
                Map<String, List<ETLModel>> threeETLMap= new HashMap<String, List<ETLModel>>();
                if(twoETLMap!=null){
                    threeETLMap=twoETLMap.get(i+"");
                }
                for(int j=start3;j<=foreachNum3;j++){
                    String level1="3";
                    String level2=i+"";
                    String level3=j+"";
                    int num=0;
                    if(threeETLMap!=null&&threeETLMap.size()>0){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    if(threeETLMap!=null){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    Town town=townsMap.get(oneTownTeam.getKey());
                    if(town==null)continue;
                    JSONObject jo=new JSONObject();
                    jo.put("date", DateUtil.dateToStrLong(new Date()));
                    jo.put("num", num);
                    jo.put("townName", town.getName());
                    jo.put("townCode", town.getCode());
                    jo.put("name", getLevel3Name(level3,type3));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+level2+":"+level3+":"+town.getCode()).toString(), jo.toString());
                }
            }
        }
    }
    private void saveCityTeamDataLevel3(Map<String, Map<String, Map<String, List<ETLModel>>>> etlModelMap,String wlyyQuotaId, Map<String, City> cityMap, Integer foreachNum2, Integer foreachNum3, Integer type2, Integer type3, Integer start2, Integer start3) {
        List<WlyyQuotaResult> wlyyQuotaResults=new ArrayList<WlyyQuotaResult>();
        //遍历团队的Map
        for(Map.Entry<String,City> oneCityTeam:cityMap.entrySet()){
            //得到每个团队的2级维度
            Map<String, Map<String, List<ETLModel>>> twoETLMap= etlModelMap.get(oneCityTeam.getKey());
            for(int i=start2;i<=foreachNum2;i++){
                //得到每个团队的三级维度
                Map<String, List<ETLModel>> threeETLMap= new HashMap<String, List<ETLModel>>();
                if(twoETLMap!=null){
                    threeETLMap=twoETLMap.get(i+"");
                }
                for(int j=start3;j<=foreachNum3;j++){
                    String level1="4";
                    String level2=i+"";
                    String level3=j+"";
                    int num=0;
                    if(threeETLMap!=null&&threeETLMap.size()>0){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    if(threeETLMap!=null){
                        List<ETLModel> etlModelList= threeETLMap.get(j+"");
                        if(etlModelList!=null&&etlModelList.size()>0){
                            num=etlModelList.size();
                        }
                    }
                    City cityObj=oneCityTeam.getValue();
                    JSONObject jo=new JSONObject();
                    jo.put("date", DateUtil.dateToStrLong(new Date()));
                    jo.put("num", num);
                    jo.put("cityName", cityObj.getName());
                    jo.put("cityCode", cityObj.getCode());
                    jo.put("name", getLevel3Name(level3,type3));
                    redisTemplate.opsForValue().set(new StringBuffer("quota:"+wlyyQuotaId+":"+level1+":"+level2+":"+level3+":"+cityObj.getCode()).toString(), jo.toString());
                }
            }
        }
    }
    private void saveByLevel2Public(List<Map<String, Map<String, List<ETLModel>>>> data, String wlyyQuotaId, Integer foreachNum, Integer type, Integer start) {
        List<AdminTeam> adminTeams=doctorAdminTeamDao.findAllTeam();
        Map<String, AdminTeam> adminTeamMap = new HashMap<String, AdminTeam>();

+ 13 - 7
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/AllSignExpenseStatusJob.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.etl.cache.CachePool;
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
@ -95,14 +96,19 @@ public class AllSignExpenseStatusJob implements Job{
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String dateTemp = date + Constant.quota_date_last;
            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< '"+dateTemp+"' ";
            String sqlCount=" select count(id) from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+dateTemp+"'";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
            //抽取第一种条件的语句
            String sql=" select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"' and expenses_status=1";
            String sqlCount=" select count(id) from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"'and expenses_status=1  ";
            //抽取數據 expensesStatus=1
            List<SignFamily> signFamilies_1= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
            //抽取第二种条件的语句
            sql=" select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"' and (expenses_status !=1 or expenses_status is null)";
            sqlCount=" select count(id) from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"'and (expenses_status !=1 or expenses_status is null)  ";
            List<SignFamily> signFamilies_2= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
            //抽取的语句
            sql="select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"'";
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies, SignDataFilter.level2Expenses,sql,date);
            FilterModel etlModels= signDataFilter.filter(signFamilies_1, SignDataFilter.level2Expenses,sql,date);
            //统计数据
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());

+ 4 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/AllSignJob.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.etl.cache.CachePool;
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
@ -50,6 +51,8 @@ public class AllSignJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private SignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String date; //起始时间
@ -89,7 +92,7 @@ public class AllSignJob implements Job {
            //抽取數據 分页抽取
            List<SignFamily> signFamilies= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies, SignDataFilter.level2Sex,sql,date);
            FilterModel etlModels= signDataFilter.filter(signFamilies,sql,date);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnData= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/ChangeSignJob.java

@ -87,7 +87,7 @@ public class ChangeSignJob implements Job {
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的已改簽信息
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and a.status =100 and  a.patient_apply_date>= '"+daybefore+ Constant.quota_date_last+"' and  a.patient_apply_date< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and a.status =100 and  a.patient_apply_date< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //清洗數據

+ 25 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/Constant.java

@ -30,6 +30,11 @@ public class Constant {
    public static String level_age_5_name="51~65";
    public static String level_age_6_name=">65";
    //二级维度的年龄
    public static String level_age2_1="1";
    public static String level_age2_2="2";
    public static String level_age2_1_name="<=65";
    public static String level_age2_2_name=">65";
    //二级维度的组
    public static String level_group_1="1";
@ -38,12 +43,15 @@ public class Constant {
    public static String level_group_4="4";
    public static String level_group_5="5";
    public static String level_group_6="6";
    public static String level_group_7="7";
    public static String level_group_1_name="普通人群";
    public static String level_group_2_name="慢病人群";
    public static String level_group_2_name="慢病65岁以下人群";
    public static String level_group_3_name="65岁以上人群";
    public static String level_group_4_name="高血压";
    public static String level_group_5_name="糖尿病";
    public static String level_group_6_name="糖尿病和高血压";
    public static String level_group_7_name="慢病65岁以上人群";
    //二级维度签约扣费
    public static String level_expense_0="0";
@ -96,6 +104,18 @@ public class Constant {
        return "";
    }
    public static String getLevelAge2(String key){
        switch (key){
            case "1":{
                return level_age2_1_name;
            }
            case "2":{
                return level_age2_2_name;
            }
        }
        return "";
    }
    public static String getLevelExpenseName(String key){
        switch (key){
            case "1":{
@ -144,6 +164,10 @@ public class Constant {
            case "6":{
                return level_group_6_name;
            }
            case "7":{
                return level_group_7_name;
            }
        }
        return "";
    }

+ 188 - 1582
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java

@ -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

+ 9 - 3
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/HealthSignJob.java

@ -1,8 +1,10 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.etl.cache.CachePool;
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.CacheModel;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
@ -55,6 +57,8 @@ public class HealthSignJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private SignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -93,11 +97,13 @@ public class HealthSignJob implements Job {
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的签约信息
            String sql=" select code,idcard,hospital,admin_team_code,patient from wlyy_sign_family a where  a.type =2 and  a.expenses_time>= '"+daybefore+ Constant.quota_date_last+"' and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //String sql=" select code,idcard,hospital,admin_team_code,patient from wlyy_sign_family a where  a.type =2 and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
           // List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //从缓存取数据
            CacheModel cacheModel=cachePool.getSignFamilysWithExpenseStatus1ByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies, SignDataFilter.level2Health,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(), SignDataFilter.level2Health,cacheModel.getSql(),yesterday);
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度

+ 10 - 4
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignAgeGroupDiseaseJob.java

@ -1,8 +1,10 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.etl.cache.CachePool;
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.CacheModel;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.role.*;
@ -60,6 +62,8 @@ public class SignAgeGroupDiseaseJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private SignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -97,11 +101,13 @@ public class SignAgeGroupDiseaseJob implements Job {
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的签约信息
            String sql=" select code,idcard,hospital,admin_team_code,patient from wlyy_sign_family a where  a.type =2 and  a.expenses_time>= '"+daybefore+ Constant.quota_date_last+"' and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            // String sql=" select code,idcard,hospital,admin_team_code,patient from wlyy_sign_family a where  a.type =2 and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //从缓存取数据
            CacheModel cacheModel=cachePool.getSignFamilysWithExpenseStatus1ByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Age,SignDataFilter.level3Disease,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),SignDataFilter.level2Age,SignDataFilter.level3Disease,cacheModel.getSql(),yesterday);
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
@ -109,7 +115,7 @@ public class SignAgeGroupDiseaseJob implements Job {
            //统计数据 三级维度
            List<Map<String, Map<String, Map<String, List<ETLModel>>>>> returnD=level3Role.elt(patientSexRoleData);
            //保存数据
            dbStorage.saveByLevel3(returnD,yesterday,wlyyQuota,6,4,1);
            dbStorage.saveByLevel3(returnD,yesterday,wlyyQuota,6,4,2,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(etlModels.getMessage());

+ 40 - 39
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignExpenseStatusJob.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.etl.cache.CachePool;
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
@ -10,39 +11,46 @@ import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.hosptial.Hospital;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.job.WlyyQuotaResult;
import com.yihu.wlyy.statistics.model.signfamily.SignFamily;
import com.yihu.wlyy.statistics.model.system.Town;
import com.yihu.wlyy.statistics.model.team.AdminTeam;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceContext;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Calendar;
/**
 * Created by Administrator on 2016.10.11.
 * 签约费用统计 增量
 * 签约费用统计 到达量
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class SignExpenseStatusJob implements Job{
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
@ -55,8 +63,7 @@ public class SignExpenseStatusJob implements Job{
    @Autowired
    private SignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    String date; //起始时间
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
@ -67,11 +74,11 @@ public class SignExpenseStatusJob implements Job{
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            date = StringUtils.isEmpty(map.get("yesterday")) ? SignJob.getDayString(-1) : map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            e.printStackTrace();
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
@ -81,53 +88,47 @@ public class SignExpenseStatusJob implements Job{
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
    private void computequota()throws Exception {
        try {
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + yesterday + "' and quato_code='" + 16 + "'");
            deleteData();
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的已改簽信息
            String sql=" select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date>= '"+daybefore+ Constant.quota_date_last+"' and  a.apply_date< '"+yesterday+ Constant.quota_date_last+"'  ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //抽取第一种条件的语句
            String sql=" select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"' and expenses_status=1";
            String sqlCount=" select count(id) from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"'and expenses_status=1  ";
            //抽取數據 expensesStatus=1
            List<SignFamily> signFamilies_1= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
            //抽取第二种条件的语句
            sql=" select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"' and (expenses_status !=1 or expenses_status is null)";
            sqlCount=" select count(id) from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"'and (expenses_status !=1 or expenses_status is null)  ";
            List<SignFamily> signFamilies_2= dbExtract.extractByPage(SignFamily.class,sql,sqlCount,true);
            //抽取的语句
            sql="select code,idcard,hospital,admin_team_code,expenses_status from wlyy_sign_family a where  a.type =2 and  a.apply_date< '"+date+ Constant.quota_date_last+"'";
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies, SignDataFilter.level2Expenses,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(signFamilies_1, SignDataFilter.level2Expenses,sql,date);
            //统计数据
            //统计数据 一级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> patientSexRoleData= level2Role.elt(returnDatas);
            //保存数据
            dbStorage.saveByLevel2(patientSexRoleData,yesterday,wlyyQuota,2,4,0);
            List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);
            //数据转换
            dbStorage.saveByLevel2(level2Data,date,wlyyQuota,2,4,0);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(etlModels.getMessage());
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog); }
        catch (Exception e) {
            dbStorage.saveLog(quartzJobLog);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private String saveContent(List<SignFamily> signFamilys, Long qkCount, Long orgCount, Long townCount, Long cityCount, boolean isAll, StringBuffer errorContent, Long errorCount,String sql) {
        StringBuffer string = new StringBuffer("统计" + yesterday + " 的簽約数据完成 ,数据库查询到簽約数据:" + signFamilys.size());
        string.append(",sql语句:"+sql);
        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();
    @Transactional
    private void deleteData() {
        jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='" + date + "' and quato_code='" + 16 + "'");
    }
    public String getYesterday() {

+ 21 - 11
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SignJob.java

@ -1,8 +1,10 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.*;
import com.yihu.wlyy.statistics.etl.cache.CachePool;
import com.yihu.wlyy.statistics.etl.dataFilter.SignDataFilter;
import com.yihu.wlyy.statistics.etl.extract.DBExtract;
import com.yihu.wlyy.statistics.etl.model.CacheModel;
import com.yihu.wlyy.statistics.etl.model.ETLModel;
import com.yihu.wlyy.statistics.etl.model.FilterModel;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
@ -49,6 +51,8 @@ public class SignJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private SignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -113,11 +117,13 @@ public class SignJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and  a.expenses_time>= '"+daybefore+ Constant.quota_date_last+"' and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
           // List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //从缓存取数据
            CacheModel cacheModel=cachePool.getSignFamilysWithExpenseStatus1ByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Sex,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),SignDataFilter.level2Sex,cacheModel.getSql(),yesterday);
            //统计数据 1级维度
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
@ -147,17 +153,19 @@ public class SignJob implements Job {
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的解约信息
            String sql=" select code,idcard,hospital,admin_team_code,patient from wlyy_sign_family a where  a.type =2 and  a.expenses_time>= '"+daybefore+ Constant.quota_date_last+"' and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //String sql=" select code,idcard,hospital,admin_team_code,patient from wlyy_sign_family a where  a.type =2 and   a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //从缓存取数据
            CacheModel cacheModel=cachePool.getSignFamilysWithExpenseStatus1ByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,SignDataFilter.level2Group,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),SignDataFilter.level2Group,cacheModel.getSql(),yesterday);
            //统计数据 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
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,6,3,1);
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,7,3,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
@ -183,7 +191,7 @@ public class SignJob implements Job {
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的签约信息
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and  a.expenses_time>= '"+daybefore+ Constant.quota_date_last+"' and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //清洗數據
@ -217,11 +225,13 @@ public class SignJob implements Job {
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的签约信息 yesterday,now
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and  a.expenses_time>= '"+daybefore+ Constant.quota_date_last+"' and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
           // String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and  a.expenses_time< '"+yesterday+ Constant.quota_date_last+"' and a.expenses_status=1 ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
           // List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //从缓存取数据
            CacheModel cacheModel=cachePool.getSignFamilysWithExpenseStatus1ByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

+ 1 - 2
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/UnSignJob.java

@ -86,9 +86,8 @@ public class UnSignJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的解约信息
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and a.status in(-3,-4) and  a.apply_unsign_date>= '"+daybefore+ Constant.quota_date_last+"' and  a.apply_unsign_date< '"+yesterday+ Constant.quota_date_last+"'";
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2 and a.status in(-3,-4) and a.apply_unsign_date< '"+yesterday+ Constant.quota_date_last+"'";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //清洗數據

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/WaitSignJob.java

@ -87,7 +87,7 @@ public class WaitSignJob implements Job {
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            //找出今天的待签约信息
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2  and a.status=0 and a.patient_apply_date>= '"+daybefore+ Constant.quota_date_last+"' and  a.patient_apply_date< '"+yesterday+ Constant.quota_date_last+"'  ";
            String sql=" select code,idcard,hospital,admin_team_code from wlyy_sign_family a where  a.type =2  and a.status=0 and  a.patient_apply_date< '"+yesterday+ Constant.quota_date_last+"'  ";
            //抽取數據
            List<SignFamily> signFamilies= dbExtract.extract(SignFamily.class,sql);
            //清洗數據

+ 2 - 7
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/util/IdCardUtil.java

@ -20,10 +20,8 @@ public class IdCardUtil {
     * @return
     * @throws Exception
     */
    public static String getSexForIdcard(String CardCode){
        String sex = Constant.level_sex_3;
        try {
    public static String getSexForIdcard(String CardCode) throws Exception{
        String sex = Constant.level_sex_2;
            if (CardCode.length() == 18) {
                if (Integer.parseInt(CardCode.substring(16).substring(0, 1)) % 2 == 0) {// 判断性别
                    // modifid by lyr 2016-09-29
@ -46,9 +44,6 @@ public class IdCardUtil {
                    sex = Constant.level_sex_2;
                }
            }
        }catch (Exception e){
            return  Constant.level_sex_3;
        }
        return sex;
    }

+ 5 - 4
patient-co-statistics/src/main/resources/application.yml

@ -1,9 +1,6 @@
server:
  port: 8080
logging:
  level:
    com:
      netflix: ERROR
spring:
  datasource:
@ -51,6 +48,10 @@ security:
    password: jkzlehr@402803a657d14f9f0157d1517f183d50
logging:
  level:
    root: INFO
---
spring:
  profiles: cwd

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java

@ -52,6 +52,6 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
	@Query(" select p from Patient p,SignFamily s where p.code=s.patient and s.status > 0 ")
	List<Patient> findAllSignPatient();
	@Query(" select p from Patient p where p.password is null and p.idcard is not null ")
	@Query(" select p from Patient p ")
	List<Patient> findAllIdCardPatientAndNoPassword();
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/account/DoctorInfoService.java

@ -742,7 +742,7 @@ public class DoctorInfoService extends BaseService {
        if(!newPassword1.equals(newPassword2)){
           throw new Exception("新密码不一致");
        }
        if(!newPassword1.equals(oldPassword)){
        if(newPassword1.equals(oldPassword)){
            throw new Exception("新旧密码一致");
        }
        Doctor doctor=doctorDao.findByCode(doctorCode);

+ 4 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java

@ -190,9 +190,10 @@ public class FamilyMemberService extends BaseService {
            result.put("isRegister", 0);
        } else {
            result.put("isRegister", 1);
            result.put("mobile", p.getMobile());
            result.put("name", p.getName());
            result.put("code", p.getCode());
            result.put("mobile", StringUtils.isEmpty(p.getMobile()) ? "" :p.getMobile());
            result.put("name", StringUtils.isEmpty(p.getName()) ? "" :p.getName());
            result.put("code", StringUtils.isEmpty(p.getCode()) ? "" :p.getCode());
            result.put("photo", StringUtils.isEmpty(p.getPhoto()) ? "" : p.getPhoto());
        }
        return result;

+ 403 - 211
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java

@ -133,7 +133,7 @@ public class StatisticsService extends BaseService {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num") && valJson.getInt("num") > 0) {
                if (valJson.has("num")) {
                    todayAmount = valJson.getInt("num");
                }
            }
@ -146,12 +146,76 @@ public class StatisticsService extends BaseService {
        }
    }
    /**
     * 获取一级指标达到量
     *
     * @param endDate 截止日期
     * @param area    区域
     * @param index   指标
     * @param level   级别
     * @return
     */
    public long getIndexTotal(String endDate,String area, int level , String index) {
        int todayAmount = 0;
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String dateCon = endDate;
        if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
            dateCon = dateFormat.format(calendar.getTime());
        }
        // 查询语句
        String sql = " select " +
                "     ifnull(result,'0') amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = ? " +
                "   and level1_type = ? and del = '1'" +
                "   and quota_date = ? ";
        if (level == 4) {
            // 市级别
            sql += " and city = ? ";
        } else if (level == 3) {
            // 区、城镇级别
            sql += " and town = ? ";
        } else if (level == 2) {
            // 机构级别
            sql += " and org_code = ? ";
        } else if (level == 1) {
            sql += " and qkdoctor_code = ?";
        }
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
                    todayAmount = valJson.getInt("num");
                }
            }
        }
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{index,level, dateCon, area});
        if (result != null && result.size() > 0) {
            return (result.get(0).get("amount") != null ? (Long.valueOf(result.get(0).get("amount").toString()) + todayAmount) : todayAmount);
        } else {
            return 0;
        }
    }
    /**
     * 获取缴费
     *
     * @param endDate 截止日期
     * @param area 区域
     * @param level 级别
     * @param area    区域
     * @param level   级别
     * @return
     */
    public long getWeiJiaoFei(String endDate, String area, int level) {
@ -171,7 +235,7 @@ public class StatisticsService extends BaseService {
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '14' " +
                "     quato_code = '16' " +
                "   and level1_type = ? and del = '1'" +
                "   and level2_type = '0' " +
                "   and quota_date = ? ";
@ -192,10 +256,10 @@ public class StatisticsService extends BaseService {
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            String val = redisTemplate.opsForValue().get("quota:14:" + level + ":" + area);
            String val = redisTemplate.opsForValue().get("quota:16:" + level + ":" + area);
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num") && valJson.getInt("num") > 0) {
                if (valJson.has("num")) {
                    todayAmount = valJson.getInt("num");
                }
            }
@ -220,7 +284,7 @@ public class StatisticsService extends BaseService {
     */
    public JSONObject getSignRate(String endDate, String area, int level) throws Exception {
        JSONObject json = new JSONObject();
        long signAmount = getTotalAmount(endDate, area, level, SIGN);
        long signAmount = getIndexTotal(endDate, area, level, "13");
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
        DecimalFormat df = new DecimalFormat("0.0000");
@ -247,7 +311,7 @@ public class StatisticsService extends BaseService {
     */
    public JSONObject getSignTaskRate(String endDate, String area, int level) throws Exception {
        JSONObject json = new JSONObject();
        long signAmount = getTotalAmount(endDate, area, level, SIGN);
        long signAmount = getIndexTotal(endDate, area, level, "13");
        PopulationBase peopleNum = peopleNumDao.findByCodeAndYear(area, Calendar.getInstance().get(Calendar.YEAR));
        DecimalFormat df = new DecimalFormat("0.0000");
@ -264,19 +328,6 @@ public class StatisticsService extends BaseService {
        return json;
    }
    /**
     * 查询截止某个日期累计建档率
     *
     * @param endDate 截止日期
     * @param area    区域或机构代码
     * @param level   级别
     * @return
     */
    public String getFilingRate(String endDate, String area, int level) {
        return "";
    }
    /**
     * 获取某个指标在某个期间的增长量
     *
@ -320,7 +371,7 @@ public class StatisticsService extends BaseService {
            String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num") && valJson.getInt("num") > 0) {
                if (valJson.has("num")) {
                    todayAmount = valJson.getInt("num");
                }
            }
@ -333,134 +384,6 @@ public class StatisticsService extends BaseService {
        }
    }
    /**
     * 查询截止某个日期某个区域后机构各下级累计签约情况
     *
     * @param endDate 截止日期
     * @param area    区域或机构代码
     * @param level   级别
     * @return
     */
    public JSONArray getLowLevelSignDetail(String endDate, String area, int level) {
        String areaField = "";
        String lowLevelField = "";
        String lowLevelName = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
            lowLevelField = "town";
            lowLevelName = "town_name";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
            lowLevelField = "org_code";
            lowLevelName = "org_name";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
            lowLevelField = "qkdoctor_code";
            lowLevelName = "qkdoctor_name";
        } else if (level == 1) {
        }
        // 查询语句
        String sql = " select " +
                "     ifnull(a." + lowLevelField + ",'') code " +
                "     ,ifnull(a." + lowLevelName + ",'') 'name' " +
                "     ,sum(a.result) amount ";
//        if(level > 3) {
//            sql += "     ,sum(a.result)*1.00/b.num*100 rate";
//        }
        sql += " from  " +
                "     wlyy_quota_result a";
//        if(level > 3) {
//            sql += "  inner join " +
//                    "     wlyy_people_num b" +
//                    "  on a." + lowLevelField + " = b.code ";
//        }
        sql += " where " +
                "     a.quato_code = '" + SIGN + "' " +
                "   and a.level1_type = ? and a.del = '1'" +
                "   and a.quota_date <= ? " +
                "   and a." + areaField + " = ? " +
                " group by a." + lowLevelField + ",a." + lowLevelName;
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{level - 1, endDate, area});
        if (resultList != null) {
            DecimalFormat df = new DecimalFormat("0.00");
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Math.round(Double.valueOf(map.get("amount").toString())) : 0);
//                if(level > 3){
//                    map.put("rate",df.format(map.get("rate") != null ? map.get("rate") : 0));
//                }
            }
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 查询截止某个日期某个区域后机构各下级累计建档情况
     *
     * @param endDate 截止日期
     * @param area    区域或机构代码
     * @param level   级别
     * @return
     */
    public JSONArray getLowLevelFilingDetail(String endDate, String area, int level) {
        String areaField = "";
        String lowLevelField = "";
        String lowLevelName = "";
        if (level == 4) {
            // 市级别
            areaField = "city";
            lowLevelField = "town";
            lowLevelName = "town_name";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
            lowLevelField = "org_code";
            lowLevelName = "org_name";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
            lowLevelField = "qkdoctor_code";
            lowLevelName = "qkdoctor_name";
        } else if (level == 1) {
        }
        // 查询语句
        String sql = " select " +
                "     ifnull(" + lowLevelField + ",'') code " +
                "     ,ifnull(" + lowLevelName + ",'') 'name' " +
                "     ,sum(result) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '' " +
                "   and level1_type = '1' and del = '1'" +
                "   and quota_date <= ? " +
                "   and " + areaField + " = ? " +
                " group by " + lowLevelField + "," + lowLevelName;
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{endDate, area});
        if (resultList != null) {
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") != null ? Math.round(Double.valueOf(map.get("amount").toString())) : 0);
            }
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
    /**
     * 查询截止某个日期某个区域后机构各下级指标累计情况
     *
@ -608,7 +531,7 @@ public class StatisticsService extends BaseService {
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                        if (valJson.has("num")) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
@ -801,7 +724,7 @@ public class StatisticsService extends BaseService {
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                        if (valJson.has("num")) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
@ -924,7 +847,7 @@ public class StatisticsService extends BaseService {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num") && valJson.getInt("num") > 0) {
                    if (valJson.has("num")) {
                        amount = (long) valJson.getInt("num");
                    }
                }
@ -1088,7 +1011,7 @@ public class StatisticsService extends BaseService {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num") && valJson.getInt("num") > 0) {
                    if (valJson.has("num")) {
                        amount = valJson.getInt("num");
                    }
                }
@ -1284,7 +1207,7 @@ public class StatisticsService extends BaseService {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num") && valJson.getInt("num") > 0) {
                    if (valJson.has("num")) {
                        amount = valJson.getInt("num");
                    }
                }
@ -1479,8 +1402,8 @@ public class StatisticsService extends BaseService {
                resultList.add(tnb);
                Map<String, Object> tnbGxy = new HashMap<>();
                tnbGxy.put("code", "100");
                tnbGxy.put("name", "高血压+糖尿病");
                tnbGxy.put("code", "6");
                tnbGxy.put("name", "高血压和糖尿病");
                tnbGxy.put("amount", Double.valueOf("0.0"));
                resultList.add(tnb);
            } else if (index.equals(AGE)) {
@ -1582,7 +1505,7 @@ public class StatisticsService extends BaseService {
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + code + ":" + area);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                        if (valJson.has("num")) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
@ -1639,14 +1562,21 @@ public class StatisticsService extends BaseService {
    /**
     * 统计65以上人群数据
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @return
     */
    public JSONArray getSixFiveStatistics(String startDate, String endDate, String area, int level) {
    public JSONArray getSixFiveStatistics(String endDate, String area, int level) {
        String areaField = "";
        SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
        String dateCon = endDate;
        if (endDate.compareTo(datef.format(new Date())) == 0) {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
            dateCon = datef.format(calendar.getTime());
        }
        if (level == 4) {
            // 市级别
@ -1666,7 +1596,7 @@ public class StatisticsService extends BaseService {
        String sql = " select " +
                "     ifnull(level3_type,'') code " +
                "     ,ifnull(level3_type_name,'') 'name' " +
                "     ,ifnull(sum(result),0.0) amount" +
                "     ,ifnull(result,0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -1675,21 +1605,13 @@ public class StatisticsService extends BaseService {
                "   and level1_type = ? and del = '1'";
        if (!org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
            sql += "   and quota_date >= ? ";
        }
        sql += "   and quota_date <= ? " +
        sql += "   and quota_date = ? " +
                "   and " + areaField + " = ? " +
                " group by level3_type,level3_type_name";
        List<Map<String, Object>> resultList = null;
        if (org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
            resultList = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
        } else {
            resultList = jdbcTemplate.queryForList(sql, new Object[]{level, startDate, endDate, area});
        }
        resultList = jdbcTemplate.queryForList(sql, new Object[]{level, dateCon, area});
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
@ -1724,12 +1646,12 @@ public class StatisticsService extends BaseService {
                map.put("amount", map.get("amount") == null ? 0 : Math.round(Double.valueOf(map.get("amount").toString())));
                // 当天数据统计
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) == 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:12:" + level + ":6:" + code + ":" + area);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                        if (valJson.has("num")) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
@ -1737,7 +1659,7 @@ public class StatisticsService extends BaseService {
            }
            // 65岁以上人群总数统计
            long sixFiveTotal = getSixFiveTotal(startDate, endDate, area, level);
            long sixFiveTotal = getSixFiveTotal(endDate, area, level);
            Map<String, Object> sixFive = new HashMap<>();
            sixFive.put("code", "0");
@ -1754,15 +1676,22 @@ public class StatisticsService extends BaseService {
    /**
     * 获取65岁以上人群总数
     *
     * @param startDate
     * @param endDate
     * @param area
     * @param level
     * @return
     */
    public long getSixFiveTotal(String startDate, String endDate, String area, int level) {
    public long getSixFiveTotal(String endDate, String area, int level) {
        String areaField = "";
        long total = 0;
        SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
        String dateCon = endDate;
        if (endDate.compareTo(datef.format(new Date())) == 0) {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
            dateCon = datef.format(calendar.getTime());
        }
        if (level == 4) {
            // 市级别
@ -1780,7 +1709,7 @@ public class StatisticsService extends BaseService {
        // 查询语句
        String sql = " select " +
                "     ifnull(sum(result),0.0) amount" +
                "     ifnull(result,0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
@ -1789,31 +1718,25 @@ public class StatisticsService extends BaseService {
                "   and level1_type = ? and del = '1'";
        if (!org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
            sql += "   and quota_date >= ? ";
        }
        sql += "   and quota_date <= ? " +
        sql += "   and quota_date = ? " +
                "   and " + areaField + " = ? ";
        Map<String, Object> result = null;
        if (org.apache.commons.lang3.StringUtils.isEmpty(startDate)) {
            result = jdbcTemplate.queryForMap(sql, new Object[]{level, endDate, area});
        } else {
            result = jdbcTemplate.queryForMap(sql, new Object[]{level, startDate, endDate, area});
        }
        result = jdbcTemplate.queryForMap(sql, new Object[]{level, dateCon, area});
        if (result != null && result.containsKey("amount")) {
            total += (result.get("amount") == null ? 0 : Math.round(Double.valueOf(result.get("amount").toString())));
        }
        String code = "6";
        String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + code + ":" + area);
        if (!StringUtils.isEmpty(val)) {
            JSONObject valJson = new JSONObject(val);
            if (valJson.has("num") && valJson.getInt("num") > 0) {
                total += valJson.getInt("num");
        if (endDate.compareTo(datef.format(new Date())) == 0) {
            String code = "6";
            String val = redisTemplate.opsForValue().get("quota:8:" + level + ":" + code + ":" + area);
            if (!StringUtils.isEmpty(val)) {
                JSONObject valJson = new JSONObject(val);
                if (valJson.has("num")) {
                    total += valJson.getInt("num");
                }
            }
        }
@ -1976,12 +1899,12 @@ public class StatisticsService extends BaseService {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                // 截止日期包含当天,则从redis查询当天统计数据
                if (date.compareTo(dateFormat.format(new Date())) >= 0) {
                if (date.compareTo(dateFormat.format(new Date())) == 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + low_level + ":" + code);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num") && valJson.getInt("num") > 0) {
                        if (valJson.has("num")) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
@ -2158,7 +2081,7 @@ public class StatisticsService extends BaseService {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num") && valJson.getInt("num") > 0) {
                    if (valJson.has("num")) {
                        amount = (long) valJson.getInt("num");
                    }
                }
@ -2170,10 +2093,10 @@ public class StatisticsService extends BaseService {
            countResult.put(startStr, range);
        }
        if(startDate.equals(df.format(new Date()))){
        if (startDate.equals(df.format(new Date()))) {
            Calendar preDate = Calendar.getInstance();
            preDate.setTime(df.parse(endDate));
            preDate.add(Calendar.DATE,-1);
            preDate.add(Calendar.DATE, -1);
            startDate = df.format(preDate.getTime());
        }
@ -2195,10 +2118,10 @@ public class StatisticsService extends BaseService {
        if (resultList != null) {
            String preStr = "";
            if (endDate.equals(df.format(new Date()))){
            if (endDate.equals(df.format(new Date()))) {
                Calendar preDate = Calendar.getInstance();
                preDate.setTime(df.parse(endDate));
                preDate.add(Calendar.DATE,-1);
                preDate.add(Calendar.DATE, -1);
                preStr = df.format(preDate.getTime());
            }
@ -2210,10 +2133,10 @@ public class StatisticsService extends BaseService {
                    long resultAmount = map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L;
                    range.put("amount", amount + resultAmount);
                }
                if(org.apache.commons.lang3.StringUtils.isNotEmpty(preStr) &&
                        preStr.equals(map.get("range").toString())){
                if (org.apache.commons.lang3.StringUtils.isNotEmpty(preStr) &&
                        preStr.equals(map.get("range").toString())) {
                    JSONObject range = (JSONObject) countResult.get(endDate);
                    if(range != null) {
                    if (range != null) {
                        long amount = range.getLong("amount");
                        long resultAmount = map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L;
                        range.put("amount", amount + resultAmount);
@ -2354,7 +2277,7 @@ public class StatisticsService extends BaseService {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num") && valJson.getInt("num") > 0) {
                    if (valJson.has("num")) {
                        amount = valJson.getInt("num");
                    }
                }
@ -2368,10 +2291,10 @@ public class StatisticsService extends BaseService {
            countResult.put(endStr, range);
        }
        if(startDate.equals(df.format(new Date()))){
        if (startDate.equals(df.format(new Date()))) {
            Calendar preDate = Calendar.getInstance();
            preDate.setTime(df.parse(endDate));
            preDate.add(Calendar.DATE,-1);
            preDate.add(Calendar.DATE, -1);
            startDate = df.format(preDate.getTime());
        }
@ -2396,7 +2319,7 @@ public class StatisticsService extends BaseService {
            if (endDate.equals(df.format(new Date()))) {
                Calendar preDate = Calendar.getInstance();
                preDate.setTime(df.parse(endDate));
                preDate.add(Calendar.DATE,-1);
                preDate.add(Calendar.DATE, -1);
                pre = df.format(preDate.getTime());
            }
@ -2551,7 +2474,7 @@ public class StatisticsService extends BaseService {
                String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + area);
                if (!StringUtils.isEmpty(val)) {
                    JSONObject valJson = new JSONObject(val);
                    if (valJson.has("num") && valJson.getInt("num") > 0) {
                    if (valJson.has("num")) {
                        amount = valJson.getInt("num");
                    }
                }
@ -2565,10 +2488,10 @@ public class StatisticsService extends BaseService {
            countResult.put(endStr, range);
        }
        if(startDate.equals(df.format(new Date()))){
        if (startDate.equals(df.format(new Date()))) {
            Calendar preDate = Calendar.getInstance();
            preDate.setTime(df.parse(endDate));
            preDate.add(Calendar.DATE,-1);
            preDate.add(Calendar.DATE, -1);
            startDate = df.format(preDate.getTime());
        }
@ -2593,7 +2516,7 @@ public class StatisticsService extends BaseService {
            if (endDate.equals(df.format(new Date()))) {
                Calendar preDate = Calendar.getInstance();
                preDate.setTime(df.parse(endDate));
                preDate.add(Calendar.DATE,-1);
                preDate.add(Calendar.DATE, -1);
                pre = df.format(preDate.getTime());
            }
            // 计算结果
@ -2639,4 +2562,273 @@ public class StatisticsService extends BaseService {
    }
    /**
     * 获取二级指标的到达量
     *
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     */
    public JSONArray getIndexLevelTwototal(String endDate, String area, int level, String index) {
        String areaField = "";
        SimpleDateFormat datef = new SimpleDateFormat("yyyy-MM-dd");
        String dateCon = endDate;
        if (endDate.compareTo(datef.format(new Date())) == 0) {
            Calendar calendar = Calendar.getInstance();
            calendar.add(Calendar.DATE, -1);
            dateCon = datef.format(calendar.getTime());
        }
        if (level == 4) {
            // 市级别
            areaField = "city";
        } else if (level == 3) {
            // 区、城镇级别
            areaField = "town";
        } else if (level == 2) {
            // 机构级别
            areaField = "org_code";
        } else if (level == 1) {
            // 团队
            areaField = "qkdoctor_code";
        }
        // 查询语句
        String sql = " select " +
                "     ifnull(level2_type,'') code " +
                "     ,ifnull(level2_type_name,'') 'name' " +
                "     ,ifnull(result,0.0) amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = '" + index + "' " +
                "   and level1_type = ? and del = '1'";
        sql += "   and quota_date = ? " +
                "   and " + areaField + " = ? " +
                " group by level2_type,level2_type_name";
        List<Map<String, Object>> resultList = null;
        resultList = jdbcTemplate.queryForList(sql, new Object[]{level, dateCon, area});
        if (resultList == null || resultList.size() < 1) {
            resultList = new ArrayList<>();
            if (index.equals(SEX)) {
                Map<String, Object> women = new HashMap<>();
                women.put("code", "1");
                women.put("name", "女");
                women.put("amount", Double.valueOf("0.0"));
                resultList.add(women);
                Map<String, Object> man = new HashMap<>();
                man.put("code", "2");
                man.put("name", "男");
                man.put("amount", Double.valueOf("0.0"));
                resultList.add(man);
                Map<String, Object> unknown = new HashMap<>();
                unknown.put("code", "3");
                unknown.put("name", "未知");
                unknown.put("amount", Double.valueOf("0.0"));
                resultList.add(unknown);
            } else if (index.equals(GROUP)) {
                Map<String, Object> nogroup = new HashMap<>();
                nogroup.put("code", "0");
                nogroup.put("name", "未分组");
                nogroup.put("amount", Double.valueOf("0.0"));
                resultList.add(nogroup);
                Map<String, Object> normal = new HashMap<>();
                normal.put("code", "1");
                normal.put("name", "普通人群");
                normal.put("amount", Double.valueOf("0.0"));
                resultList.add(normal);
                Map<String, Object> manbing = new HashMap<>();
                manbing.put("code", "2");
                manbing.put("name", "慢病人群");
                manbing.put("amount", Double.valueOf("0.0"));
                resultList.add(manbing);
                Map<String, Object> upsixfive = new HashMap<>();
                upsixfive.put("code", "3");
                upsixfive.put("name", "65岁以上人群");
                upsixfive.put("amount", Double.valueOf("0.0"));
                resultList.add(upsixfive);
                Map<String, Object> gxy = new HashMap<>();
                gxy.put("code", "4");
                gxy.put("name", "高血压");
                gxy.put("amount", Double.valueOf("0.0"));
                resultList.add(gxy);
                Map<String, Object> tnb = new HashMap<>();
                tnb.put("code", "5");
                tnb.put("name", "糖尿病");
                tnb.put("amount", Double.valueOf("0.0"));
                resultList.add(tnb);
                Map<String, Object> tnbGxy = new HashMap<>();
                tnbGxy.put("code", "6");
                tnbGxy.put("name", "高血压和糖尿病");
                tnbGxy.put("amount", Double.valueOf("0.0"));
                resultList.add(tnb);
//                Map<String, Object> mn65LowGxy = new HashMap<>();
//                mn65LowGxy.put("code", "7");
//                mn65LowGxy.put("name", "慢病人群65岁以上");
//                mn65LowGxy.put("amount", Double.valueOf("0.0"));
//                resultList.add(mn65LowGxy);
            } else if (index.equals(AGE)) {
                Map<String, Object> map1 = new HashMap<>();
                map1.put("code", "1");
                map1.put("name", "0~6");
                map1.put("amount", Double.valueOf("0.0"));
                resultList.add(map1);
                Map<String, Object> map2 = new HashMap<>();
                map2.put("code", "2");
                map2.put("name", "7~18");
                map2.put("amount", Double.valueOf("0.0"));
                resultList.add(map2);
                Map<String, Object> map3 = new HashMap<>();
                map3.put("code", "3");
                map3.put("name", "18~30");
                map3.put("amount", Double.valueOf("0.0"));
                resultList.add(map3);
                Map<String, Object> map4 = new HashMap<>();
                map4.put("code", "4");
                map4.put("name", "30~50");
                map4.put("amount", Double.valueOf("0.0"));
                resultList.add(map4);
                Map<String, Object> map5 = new HashMap<>();
                map5.put("code", "5");
                map5.put("name", "50~65");
                map5.put("amount", Double.valueOf("0.0"));
                resultList.add(map5);
                Map<String, Object> map6 = new HashMap<>();
                map6.put("code", "6");
                map6.put("name", "50~65");
                map6.put("amount", Double.valueOf("0.0"));
                resultList.add(map6);
            } else if (index.equals("16")) {
                Map<String, Object> map1 = new HashMap<>();
                map1.put("code", "0");
                map1.put("name", "未缴费人数");
                map1.put("amount", Double.valueOf("0.0"));
                resultList.add(map1);
                Map<String, Object> map2 = new HashMap<>();
                map2.put("code", "1");
                map2.put("name", "已缴费人数");
                map2.put("amount", Double.valueOf("0.0"));
                resultList.add(map2);
                Map<String, Object> map3 = new HashMap<>();
                map3.put("code", "2");
                map3.put("name", "已退费人数");
                map3.put("amount", Double.valueOf("0.0"));
                resultList.add(map3);
            } else if (index.equals("15")) {
                Map<String, Object> map1 = new HashMap<>();
                map1.put("code", "0");
                map1.put("name", "未标注");
                map1.put("amount", Double.valueOf("0.0"));
                resultList.add(map1);
                Map<String, Object> map2 = new HashMap<>();
                map2.put("code", "1");
                map2.put("name", "健康人群");
                map2.put("amount", Double.valueOf("0.0"));
                resultList.add(map2);
                Map<String, Object> map3 = new HashMap<>();
                map3.put("code", "2");
                map3.put("name", "患病人群");
                map3.put("amount", Double.valueOf("0.0"));
                resultList.add(map3);
                Map<String, Object> map4 = new HashMap<>();
                map4.put("code", "3");
                map4.put("name", "高危人群");
                map4.put("amount", Double.valueOf("0.0"));
                resultList.add(map4);
                Map<String, Object> map5 = new HashMap<>();
                map5.put("code", "4");
                map5.put("name", "恢复期人群");
                map5.put("amount", Double.valueOf("0.0"));
                resultList.add(map5);
            }
        }
        if (resultList != null) {
            long total = 0;
            for (Map<String, Object> map : resultList) {
                map.put("amount", map.get("amount") == null ? 0 : Math.round(Double.valueOf(map.get("amount").toString())));
                // 当天数据统计
                if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) == 0) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    String val = redisTemplate.opsForValue().get("quota:" + index + ":" + level + ":" + code + ":" + area);
                    if (!StringUtils.isEmpty(val)) {
                        JSONObject valJson = new JSONObject(val);
                        if (valJson.has("num")) {
                            map.put("amount", (long) map.get("amount") + valJson.getInt("num"));
                        }
                    }
                }
                if (index.equals(GROUP)) {
                    // 分组指标总数算法
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    if (code.equals("0") || code.equals("1") || code.equals("2") || code.equals("3")) {
                        total += (long) map.get("amount");
                    }
                } else if (index.equals("16")) {
                    String code = map.get("code") != null ? String.valueOf(map.get("code")) : "";
                    if (!code.equals("2")) {
                        total += (long) map.get("amount");
                    }
                } else {
                    total += (long) map.get("amount");
                }
            }
            if (!index.equals(AGE)) {
                DecimalFormat df = new DecimalFormat("0.0000");
                for (Map<String, Object> map : resultList) {
                    double rateG = (total > 0 ? ((long) map.get("amount")) * 1.0000 / total * 100 : 0);
                    map.put("rate", df.format(rateG));
                }
            }
            if (index.equals(SEX) && resultList.size() > 0) {
                int i = 0;
                boolean flag = false;
                for (; i < resultList.size(); i++) {
                    if (resultList.get(i).get("code") != null && String.valueOf(resultList.get(i).get("code")).equals("3")
                            && String.valueOf(resultList.get(i).get("amount")).equals("0")) {
                        flag = true;
                        break;
                    }
                }
                if (flag) {
                    resultList.remove(i);
                }
            }
            return new JSONArray(resultList);
        } else {
            return new JSONArray();
        }
    }
}

+ 4 - 87
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -215,90 +215,6 @@ public class LoginController extends BaseController {
        }
    }
    /**
     * 患者登录接口
     *
     * @param mobile  手机号
     * @param captcha 短信验证码
     * @param idcard  身份证号
     * @param password 密码
     * @return
     */
    @RequestMapping(value = "patient")
    @ResponseBody
    public String patient(
           @RequestParam(required = false) String mobile,
           @RequestParam(required = false) String captcha,
           @RequestParam(required = false) String idcard,
           @RequestParam(required = false) String password) {
        try {
            if (StringUtils.isEmpty(getIMEI())) {
                return error(-1, "获取手机IMEI码失败!");
            }
            //身份证登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
                password = RSAUtils.getInstance(doctorService).decryptString(password);
                Patient patient= patientService.findByMobile(mobile);
                if(patient==null){
                    return error(-1, "该身份证未注册!");
                }
                String loginPassword= MD5.GetMD5Code(password+patient.getSalt());
                if(loginPassword.equals(patient.getPassword())){
                    Token token = tokenService.newToken(patient.getCode(), getIMEI(), 1);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", patient.getId());
                    map.put("uid", patient.getCode());
                    map.put("name", URLEncoder.encode(patient.getName(), "UTF-8"));
                    map.put("token", token.getToken());
                    map.put("photo", patient.getPhoto());
                    return write(200, "登录成功", "data", map);
                }else{
                    return error(-1, "密码错误,登录失败");
                }
            }
            //短信登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
                // 对验证码进行校验
                int res = smsService.check(mobile, 4, captcha);
                switch (res) {
                    case -2:
                        return error(-1, "验证码已过期!");
                    case -1:
                        return error(-1, "请输入正确的验证码!");
                    case 0:
                        return error(-1, "验证码无效!");
                }
                // password = URLDecoder.decode(password, "UTF-8");
                // password = StringUtils.reverse(password);
                // idcard = RSAUtils.getInstance(doctorService).decryptString(idcard);
                // idcard = URLDecoder.decode(idcard, "UTF-8");
                // idcard = StringUtils.reverse(idcard);
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    return error(-1, "该手机号暂未注册帐号,请确认后重新输入!");
                } else if (patient.getStatus() == 0) {
                    return error(-1, "该手机号已被禁止使用!");
                } else if (patient.getStatus() == 2) {
                    return error(-1, "该帐号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”");
                } else {
                    // 用户校验通过,生成token
                    Token token = tokenService.newToken(patient.getCode(), getIMEI(), 1);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", patient.getId());
                    map.put("uid", patient.getCode());
                    map.put("name", URLEncoder.encode(patient.getName(), "UTF-8"));
                    map.put("token", token.getToken());
                    map.put("photo", patient.getPhoto());
                    return write(200, "登录成功", "data", map);
                }
            }
            return error(-1, "登录信息不完整,请重新输入!");
        } catch (Exception e) {
            error(e);
            return error(-1, "系统异常,登录失败");
        }
    }
    /**
     * 忘记密码
     *
@ -347,7 +263,6 @@ public class LoginController extends BaseController {
                if (doctor == null) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=MD5.GetMD5Code(password+doctor.getSalt());
                    doctor.setPassword(password);
@ -356,11 +271,13 @@ public class LoginController extends BaseController {
                }
            } else {
                // 患者端
                Patient patient = patientService.findByIdcard(idcard);
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    return error(-1, "操作失败:此用户未注册");
                } else {
                    patient.setPassword(newpwd);
                    String password = RSAUtils.getInstance(doctorService).decryptString(newpwd);
                    password=MD5.GetMD5Code(password+patient.getSalt());
                    patient.setPassword(password);
                    patientService.updatePatientPwd(patient);
                    return success("操作成功!");
                }

+ 104 - 51
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/WechatController.java

@ -1,6 +1,7 @@
package com.yihu.wlyy.web.common.account;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -10,6 +11,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SocialSecurityInfoDao;
import com.yihu.wlyy.service.app.family.FamilyService;
import com.yihu.wlyy.util.HttpUtil;
import com.yihu.wlyy.util.MD5;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
@ -18,6 +20,7 @@ import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.patient.Patient;
@ -205,7 +208,13 @@ public class WechatController extends WeixinBaseController {
     */
    @RequestMapping(value = "regist")
    @ResponseBody
    public String regist(String name, String idcard, String ssc, String mobile, String captcha, String openid) {
    public String regist(String name,
                         String idcard,
                         String ssc,
                         String mobile,
                         String captcha,
                         String openid,
                         String password) {
        try {
            if (StringUtils.isEmpty(name)) {
                return error(-1, "姓名不允许为空!");
@ -282,6 +291,12 @@ public class WechatController extends WeixinBaseController {
            patient.setName(name);
            patient.setIdcard(idcard);
            patient.setMobile(mobile);
            //增加密码
            String salt= UUID.randomUUID().toString().replace("-","");
            patient.setSalt(salt);
            password = RSAUtils.getInstance(patientService).decryptString(password);
            patient.setPassword(MD5.GetMD5Code(password+salt));
			patient.setSsc(ssc);
            patient.setOpenid(openid);
            JSONObject json = patientService.register(patient, openid, 3);
@ -301,66 +316,104 @@ public class WechatController extends WeixinBaseController {
    /**
     * 患者微信登录接口
     *
     * @param idcard   身份證号
     * @param captcha 短信号
     * @param mobile   电话号码
     * @param password 登录密码
     * @return
     */
    @RequestMapping(value = "login")
    @ResponseBody
    public String login(String mobile, String captcha, String openid) {
    public String login(
            @RequestParam(required = false) String mobile,
            @RequestParam(required = false) String captcha,
            @RequestParam(required = false) String password,
            String openid) {
        try {
            // 对验证码进行校验
            int res = smsService.check(mobile, 4, captcha);
            switch (res) {
                case -2:
                    return error(-1, "验证码已过期!");
                case -1:
                    return error(-1, "请输入正确的验证码!");
                case 0:
                    return error(-1, "验证码无效!");
            }
            Patient patient = patientService.findByMobile(mobile);
            if (patient == null) {
                return error(-1, "该手机号暂未注册帐号,请确认后重新输入!");
            } else if (patient.getStatus() == 0) {
                return error(-1, "该手机号已被禁止使用!");
            } else if (patient.getStatus() == 2) {
                return error(-1, "该帐号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”");
            } else if (StringUtils.isEmpty(openid)) {
                return error(-1, "无效的OpenID!");
            }
//			else if (StringUtils.isNotEmpty(patient.getOpenid()) && !StringUtils.equals(patient.getOpenid(), openid)) {
//				return error(-1, "该微信号已绑定其他手机号!");
//			}else if (StringUtils.isEmpty(patient.getOpenid())) {
//				// 未绑定openid,查询是否绑定其他帐号
//				if (patientService.countByOpenid(openid) > 0) {
//					return error(-1, "该微信号已绑定其他手机号!");
//				} else {
//					// 绑定用户手机号和openid
//					patient.setOpenid(openid);
//					patientService.updatePatient(patient);
//				}
//			}
            //账号登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(password)){
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    return error(-1, "该手机号暂未注册帐号,请确认后重新输入!");
                } else if (patient.getStatus() == 0) {
                    return error(-1, "该手机号已被禁止使用!");
                } else if (patient.getStatus() == 2) {
                    return error(-1, "该帐号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”");
                } else if (StringUtils.isEmpty(openid)) {
                    return error(-1, "无效的OpenID!");
                }
                //解密
                password = RSAUtils.getInstance(patientService).decryptString(password);
                //生成MD5
                String loginPassword= MD5.GetMD5Code(password+patient.getSalt());
                //判断d登录密码是否正确
                if(loginPassword.equals(patient.getPassword())){
                    // 绑定用户手机号和openid
                    if (!StringUtils.equals(patient.getOpenid(), openid)) {
                        patient.setOpenid(openid);
                        patientService.updatePatient(patient);
                    }
            // 绑定用户手机号和openid
            if (!StringUtils.equals(patient.getOpenid(), openid)) {
                patient.setOpenid(openid);
                patientService.updatePatient(patient);
                    // 用户校验通过,生成token
                    Token token = tokenService.newTxToken(patient.getCode(), openid);
                    Map<Object, Object> map = new HashMap<Object, Object>();
                    map.put("id", patient.getId());
                    map.put("uid", patient.getCode());
                    map.put("name", patient.getName());
                    map.put("token", token.getToken());
                    map.put("photo", patient.getPhoto());
                    if(StringUtils.isNoneEmpty(openid)){
                        //发送微信模板
                        familyService.sendWXMessage(patient);
                    }
                    return write(200, "登录成功", "data", map);
                }else{
                    return error(-1, "密码错误,登录失败");
                }
            }
            //短信登录
            if(StringUtils.isNoneEmpty(mobile)&&StringUtils.isNoneEmpty(captcha)){
                // 对验证码进行校验
                int res = smsService.check(mobile, 4, captcha);
                switch (res) {
                    case -2:
                        return error(-1, "验证码已过期!");
                    case -1:
                        return error(-1, "请输入正确的验证码!");
                    case 0:
                        return error(-1, "验证码无效!");
                }
                Patient patient = patientService.findByMobile(mobile);
                if (patient == null) {
                    return error(-1, "该手机号暂未注册帐号,请确认后重新输入!");
                } else if (patient.getStatus() == 0) {
                    return error(-1, "该手机号已被禁止使用!");
                } else if (patient.getStatus() == 2) {
                    return error(-1, "该帐号正在审核中,请确认审核通过后再登录,“如有疑问,拨打400-6677-400转2人工客服”");
                } else if (StringUtils.isEmpty(openid)) {
                    return error(-1, "无效的OpenID!");
                }
                // 绑定用户手机号和openid
                if (!StringUtils.equals(patient.getOpenid(), openid)) {
                    patient.setOpenid(openid);
                    patientService.updatePatient(patient);
                }
            // 用户校验通过,生成token
            Token token = tokenService.newTxToken(patient.getCode(), openid);
            Map<Object, Object> map = new HashMap<Object, Object>();
            map.put("id", patient.getId());
            map.put("uid", patient.getCode());
            map.put("name", patient.getName());
            map.put("token", token.getToken());
            map.put("photo", patient.getPhoto());
            if(StringUtils.isNoneEmpty(openid)){
                //发送微信模板
                familyService.sendWXMessage(patient);
                // 用户校验通过,生成token
                Token token = tokenService.newTxToken(patient.getCode(), openid);
                Map<Object, Object> map = new HashMap<Object, Object>();
                map.put("id", patient.getId());
                map.put("uid", patient.getCode());
                map.put("name", patient.getName());
                map.put("token", token.getToken());
                map.put("photo", patient.getPhoto());
                if(StringUtils.isNoneEmpty(openid)){
                    //发送微信模板
                    familyService.sendWXMessage(patient);
                }
                return write(200, "登录成功", "data", map);
            }
            return write(200, "登录成功", "data", map);
            return error(-1, "登录失败");
        } catch (Exception e) {
            error(e);
            return error(-1, "系统异常,登录失败");

+ 27 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandingService.java

@ -1,11 +1,14 @@
package com.yihu.wlyy.web.data;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.util.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.UUID;
@ -21,14 +24,34 @@ public class DataHandingService {
    private DoctorDao doctorDao;
    @Transactional
    public String producePatientAndDoctorPasswor() {
    public String producePatientAndDoctorPassword() {
        int patientCount=0;
        int doctorCount=0;
        List<Patient> patients= patientDao.findAllIdCardPatientAndNoPassword();
        for (Patient patient:patients){
            String idCard= patient.getIdcard();
            if(!StringUtils.isEmpty(patient.getPassword())){
                continue;
            }
            String phone= patient.getPhone();
            String password=phone.substring(5);
            String salt= UUID.randomUUID().toString().replace("-","");
            patient.setSalt(salt);
            patient.setPassword(MD5.GetMD5Code(password+salt));
            patientCount++;
        }
        List<Doctor> doctors= doctorDao.findAllDoctors();
        for (Doctor doctor:doctors){
            if(!StringUtils.isEmpty(doctor.getPassword())){
                continue;
            }
            String phone= doctor.getMobile();
            String password=phone.substring(5);
            String salt= UUID.randomUUID().toString().replace("-","");
            doctor.setSalt(salt);
            doctor.setPassword(MD5.GetMD5Code(password+salt));
            doctorCount++;
        }
        return null;
        return "更新患者:"+patientCount+",更新医生:"+doctorCount;
    }
}

+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/data/DataHandlingController.java

@ -62,11 +62,11 @@ public class DataHandlingController extends BaseController {
     * 生成医生和患者表中有身份的用户的密码
     * @return
     */
    @RequestMapping(value = "producePatientAndDoctorPasswor")
    @RequestMapping(value = "producePatientAndDoctorPassword")
    @ResponseBody
    public String producePatientAndDoctorPasswor() {
        try {
            return write(200, dataHandingService.producePatientAndDoctorPasswor());
            return write(200, dataHandingService.producePatientAndDoctorPassword());
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());

+ 1 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/health/DoctorHealthController.java

@ -89,6 +89,7 @@ public class DoctorHealthController extends BaseController {
				modelJson.put("value7", model.getValue7());
				modelJson.put("type", model.getType());
				modelJson.put("date", DateUtil.dateToStr(model.getRecordDate(), DateUtil.YYYY_MM_DD));
				modelJson.put("sortDate", DateUtil.dateToStrLong(model.getSortDate()));
				modelJson.put("czrq", DateUtil.dateToStr(model.getCzrq(), DateUtil.YYYY_MM_DD_HH_MM_SS));
				jsonArray.put(modelJson);
			}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/family/FamilyMemberController.java

@ -167,7 +167,7 @@ public class FamilyMemberController extends BaseController {
            JSONObject result = familyMemberService.isRegister(idcard);
            return write(-1, "查询成功", "data", result);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");

+ 49 - 22
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -32,12 +32,12 @@ public class StatisticsController extends BaseController {
     */
    @RequestMapping(value = "/time")
    @ResponseBody
    public String getStatisticsTime(){
        try{
            return write(200,"查询成功","data",statisticsService.getStatisticsTime());
        }catch (Exception e){
    public String getStatisticsTime() {
        try {
            return write(200, "查询成功", "data", statisticsService.getStatisticsTime());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
    }
@ -140,13 +140,13 @@ public class StatisticsController extends BaseController {
     */
    @RequestMapping("/lowlevel_increment")
    @ResponseBody
    public String getIndexLowLevelIncrement(String startDate, String endDate, String area, int level, String index, int sort,String lowLevel) {
    public String getIndexLowLevelIncrement(String startDate, String endDate, String area, int level, String index, int sort, String lowLevel) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getLowLevelIncrementDetail(startDate, endDate, area, level, idx, sort,lowLevel));
                result.put("index_" + idx, statisticsService.getLowLevelIncrementDetail(startDate, endDate, area, level, idx, sort, lowLevel));
            }
            return write(200, "查询成功", "data", result);
@ -201,7 +201,7 @@ public class StatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getLevelTwoIndexIncrement(startDate, endDate, area, level, idx));
                result.put("index_" + idx, statisticsService.getIndexLevelTwototal(endDate, area, level, idx));
            }
            return write(200, "查询成功", "data", result);
@ -226,15 +226,15 @@ public class StatisticsController extends BaseController {
        try {
            JSONObject result = new JSONObject();
            long sign = statisticsService.getTotalAmount(endDate, area, level, "1");
            long sign = statisticsService.getIndexTotal(endDate, area, level, "13");
            long weiJf = statisticsService.getWeiJiaoFei(endDate, area, level);
            JSONObject signRate = statisticsService.getSignRate(endDate,area,level);
            JSONObject signTaskRate = statisticsService.getSignTaskRate(endDate,area,level);
            JSONObject signRate = statisticsService.getSignRate(endDate, area, level);
            JSONObject signTaskRate = statisticsService.getSignTaskRate(endDate, area, level);
            result.put("sign",sign);
            result.put("expenses",weiJf);
            result.put("signRate",signRate);
            result.put("signTaskRate",signTaskRate);
            result.put("sign", sign);
            result.put("expenses", weiJf);
            result.put("signRate", signRate);
            result.put("signTaskRate", signTaskRate);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -254,14 +254,14 @@ public class StatisticsController extends BaseController {
     */
    @RequestMapping(value = "/sixfive_statistics")
    @ResponseBody
    public String getSixFiveStatistics(String startDate, String endDate, String area, int level){
        try{
            JSONArray result = statisticsService.getSixFiveStatistics(startDate,endDate,area,level);
    public String getSixFiveStatistics(String startDate, String endDate, String area, int level) {
        try {
            JSONArray result = statisticsService.getSixFiveStatistics(endDate, area, level);
            return write(200,"查询成功","data",result);
        }catch (Exception e){
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"查询失败");
            return error(-1, "查询失败");
        }
    }
@ -278,7 +278,7 @@ public class StatisticsController extends BaseController {
     */
    @RequestMapping(value = "/interval_total")
    @ResponseBody
    public String indexIntervalTotal(String startDate, String endDate, int interval, String area, int level, String index){
    public String indexIntervalTotal(String startDate, String endDate, int interval, String area, int level, String index) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
@ -322,4 +322,31 @@ public class StatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 二级指标到达量
     *
     * @param date
     * @param area
     * @param level
     * @param index
     * @return
     */
    @RequestMapping(value = "/leveltwo_all")
    @ResponseBody
    public String getIndexLevelTwoTotal(String date, String area, int level, String index) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsService.getIndexLevelTwototal(date, area, level, idx));
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 37 - 37
patient-co-wlyy/src/main/resources/application.properties

@ -42,51 +42,51 @@
#redis.testOnBorrow=true
#------------------------------------开发环境数据库配置------------------------------------#
##### mysql database setting
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#jdbc.username=root
#jdbc.password=123456
#
##### health index
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://172.19.103.77/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=root
#health.jdbc.password=123456
#
##### suifang
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.77/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=root
#fv.jdbc.password=123456
#
##### redis
#redis.host=172.19.103.47
#redis.port=6379
#---------------------------------测试环境数据库配置---------------------------------------#
##### mysql database setting
#### mysql database setting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
jdbc.username=luofaqiang
jdbc.password=luofaqiang
jdbc.url=jdbc:mysql://172.19.103.77/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
jdbc.username=root
jdbc.password=123456
##### health index
#### health index
health.jdbc.driver=com.mysql.jdbc.Driver
health.jdbc.url=jdbc:mysql://172.19.103.85/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
health.jdbc.username=luofaqiang
health.jdbc.password=luofaqiang
health.jdbc.url=jdbc:mysql://172.19.103.77/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
health.jdbc.username=root
health.jdbc.password=123456
##### suifang
#### suifang
fv.jdbc.driver=com.mysql.jdbc.Driver
fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
fv.jdbc.username=luofaqiang
fv.jdbc.password=luofaqiang
fv.jdbc.url=jdbc:mysql://172.19.103.77/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
fv.jdbc.username=root
fv.jdbc.password=123456
##### redis
redis.host=172.19.103.88
#### redis
redis.host=172.19.103.47
redis.port=6379
#---------------------------------测试环境数据库配置---------------------------------------#
###### mysql database setting
#jdbc.driver=com.mysql.jdbc.Driver
#jdbc.url=jdbc:mysql://172.19.103.85/wlyy?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#jdbc.username=luofaqiang
#jdbc.password=luofaqiang
#
###### health index
#health.jdbc.driver=com.mysql.jdbc.Driver
#health.jdbc.url=jdbc:mysql://172.19.103.85/device?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#health.jdbc.username=luofaqiang
#health.jdbc.password=luofaqiang
#
###### suifang
#fv.jdbc.driver=com.mysql.jdbc.Driver
#fv.jdbc.url=jdbc:mysql://172.19.103.85/fv?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#fv.jdbc.username=luofaqiang
#fv.jdbc.password=luofaqiang
#
###### redis
#redis.host=172.19.103.88
#redis.port=6379
#-----------------------------------通用配置--------------------------------------------#
##### redis
redis.maxIdle=300