Browse Source

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

huangwenjie 7 years ago
parent
commit
27f6612cd3
36 changed files with 1552 additions and 238 deletions
  1. 159 4
      common/common-entity/src/main/java/com/yihu/wlyy/entity/job/QuartzJobConfig.java
  2. 2 1
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/config/SwaggerConfig.java
  3. 1 1
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/ExtractDataController.java
  4. 5 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java
  5. 2 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/ServerTypeConvert.java
  6. 199 27
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/ExtractDataService.java
  7. 6 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  8. 22 22
      patient-co/patient-co-statistics-es/src/main/resources/application.yml
  9. 5 6
      patient-co/patient-co-statistics-es/src/main/resources/quartz.properties
  10. 7 14
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java
  11. 7 14
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  12. 14 8
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignJob.java
  13. 15 9
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignOrgJob.java
  14. 15 8
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignOrgOutJob.java
  15. 15 9
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTeamJob.java
  16. 14 8
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTeamOutJob.java
  17. 15 9
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownJob.java
  18. 14 8
      patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownOutJob.java
  19. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneDetailInfoDao.java
  20. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneInfoDao.java
  21. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildInfoDao.java
  22. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneDictDao.java
  23. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneHospitalDictDao.java
  24. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneMappingDao.java
  25. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneNeedleDao.java
  26. 5 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyMemberDao.java
  27. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  28. 155 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/ChildImmuneService.java
  29. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  30. 407 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  31. 87 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  32. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  33. 52 25
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  34. 35 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/ChildImmuneController.java
  35. 87 46
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  36. 67 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

+ 159 - 4
common/common-entity/src/main/java/com/yihu/wlyy/entity/job/QuartzJobConfig.java

@ -14,7 +14,7 @@ import org.hibernate.annotations.GenericGenerator;
@Table(name = "wlyy_job_config")
public class QuartzJobConfig implements java.io.Serializable {
    private String id;
    /*private String id;
    private String quotaId;//指标id
    private String jobName;//任务名称
    private String jobInfo;//任务描述
@ -24,12 +24,12 @@ public class QuartzJobConfig implements java.io.Serializable {
    private String status;//1 启动 0停止
    private String del;//是否删除 1正常 0删除
    /** minimal constructor */
    *//** minimal constructor *//*
    public QuartzJobConfig() {
    }
    /** full constructor */
    *//** full constructor *//*
    public QuartzJobConfig(String jobName, String jobInfo, String jobType,
                           String jobClass, String quartzCron, String status) {
        this.jobName = jobName;
@ -123,5 +123,160 @@ public class QuartzJobConfig implements java.io.Serializable {
    public void setDel(String del) {
        this.del = del;
    }
    }*/
    private String id;
	private String quotaId;//指标id
	private String jobName;//任务名称
	private String jobInfo;//任务描述
	private String jobType;//任务类型(0--单次执行  1--周期执行 2--监听任务)
	private String jobClass;//任务执行的class
	private String quartzCron;//quartz表达式
	private String status;//1 启动 0停止
	private String del;//是否删除 1正常 0删除
	private String sql;
	private String sqlCount;
	private String sqlDay;
	private String sqlYear;
	private String cacheKey;//缓存的key
	/** minimal constructor */
	public QuartzJobConfig() {
	}
	/** full constructor */
	public QuartzJobConfig(String jobName, String jobInfo, String jobType,
                           String jobClass, String quartzCron, String status) {
		this.jobName = jobName;
		this.jobInfo = jobInfo;
		this.jobType = jobType;
		this.jobClass = jobClass;
		this.quartzCron = quartzCron;
		this.status = status;
	}
	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "id", unique = true, nullable = false, length = 50)
	public String getId() {
		return this.id;
	}
	public void setId(String id) {
		this.id = id;
	}
	@Column(name = "job_name", length = 50)
	public String getJobName() {
		return this.jobName;
	}
	public void setJobName(String jobName) {
		this.jobName = jobName;
	}
	@Column(name = "job_info", length = 200)
	public String getJobInfo() {
		return this.jobInfo;
	}
	public void setJobInfo(String jobInfo) {
		this.jobInfo = jobInfo;
	}
	@Column(name = "job_type", length = 10)
	public String getJobType() {
		return this.jobType;
	}
	public void setJobType(String jobType) {
		this.jobType = jobType;
	}
	@Column(name = "job_class", length = 200)
	public String getJobClass() {
		return jobClass;
	}
	public void setJobClass(String jobClass) {
		this.jobClass = jobClass;
	}
	@Column(name = "quartz_cron", length = 200)
	public String getQuartzCron() {
		return this.quartzCron;
	}
	public void setQuartzCron(String quartzCron) {
		this.quartzCron = quartzCron;
	}
	@Column(name = "status", length = 1)
	public String getStatus() {
		return this.status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	@Column(name = "quota_id", length = 50)
	public String getQuotaId() {
		return quotaId;
	}
	public void setQuotaId(String quotaId) {
		this.quotaId = quotaId;
	}
	@Column(name = "del", length = 1)
	public String getDel() {
		return del;
	}
	public void setDel(String del) {
		this.del = del;
	}
	public String getSql() {
		return sql;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}
	public String getSqlCount() {
		return sqlCount;
	}
	public void setSqlCount(String sqlCount) {
		this.sqlCount = sqlCount;
	}
	public String getSqlDay() {
		return sqlDay;
	}
	public void setSqlDay(String sqlDay) {
		this.sqlDay = sqlDay;
	}
	public String getSqlYear() {
		return sqlYear;
	}
	public void setSqlYear(String sqlYear) {
		this.sqlYear = sqlYear;
	}
	public String getCacheKey() {
		return cacheKey;
	}
	public void setCacheKey(String cacheKey) {
		this.cacheKey = cacheKey;
	}
}

+ 2 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/config/SwaggerConfig.java

@ -42,7 +42,8 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
                .select()
                .paths(or(
                        regex("/job/.*"),
                        regex("/quotaQuery/.*")
                        regex("/quotaQuery/.*"),
                        regex("/extractDataToEs/.*")
                ))
                .build()
                .apiInfo(publicApiInfo());

+ 1 - 1
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/controller/ExtractDataController.java

@ -18,7 +18,7 @@ import java.util.List;
 */
@RestController
@RequestMapping("/extractData")
@RequestMapping("/extractDataToEs")
@Api(description = "抽取mysql数据到es")
public class ExtractDataController extends BaseController {
    @Autowired

+ 5 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.statistics.dao;
import com.yihu.wlyy.entity.job.QuartzJobConfig;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -24,4 +25,8 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")
    QuartzJobConfig findById(String id);
    @Modifying
    @Query(" update QuartzJobConfig a set a.status=?2 where a.id=?1 ")
    int updateStatus(String id, String status);
}

+ 2 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/etl/convert/wlyy/ServerTypeConvert.java

@ -32,6 +32,8 @@ public class ServerTypeConvert implements Convert {
            if (serverTypeList == null) {
                serverTypeList = new ArrayList<String>();
            }
            serverTypeList.add(one.getServerType());
            serverTypesMap.put(one.getSignCode(),serverTypeList);
        });
        oneList.stream().forEach(one -> {
            List<String> serverTypeList = serverTypesMap.get(one.getBusinessId());

+ 199 - 27
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/ExtractDataService.java

@ -2,12 +2,25 @@ package com.yihu.wlyy.statistics.service;
import com.yihu.wlyy.entity.statistics.WlyyQuotaResult;
import com.yihu.wlyy.statistics.dao.WlyyQuotaResultDao;
import com.yihu.wlyy.statistics.etl.save.es.ElasticFactory;
import com.yihu.wlyy.statistics.etl.save.es.ElastricSearchSave;
import com.yihu.wlyy.statistics.util.DateUtil;
import com.yihu.wlyy.statistics.vo.SaveModel;
import io.searchbox.client.JestClient;
import io.searchbox.core.*;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
@ -15,8 +28,12 @@ import java.util.List;
 */
@Service
public class ExtractDataService {
    @Autowired
    private ElasticFactory elasticFactory;
    @Value("${es.type}")
    private String esType;
    @Value("${es.index}")
    private String esIndex;
    @Autowired
    private WlyyQuotaResultDao wlyyQuotaResultDao;
    @Autowired
@ -24,10 +41,131 @@ public class ExtractDataService {
    public void extractOneDate(String date) {
        List<WlyyQuotaResult> quotaResults = wlyyQuotaResultDao.findByDate(date);
        save2es(quotaResults, date, null);
    }
    public void extractOneDateWithId(String date, String quotaId) {
        List<WlyyQuotaResult> quotaResults = wlyyQuotaResultDao.findByDateAndId(date, quotaId);
        save2es(quotaResults, date, quotaId);
    }
    public void extractDate2Date(String start, String end) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = sdf.parse(start);
        Date endDate = sdf.parse(end);
        if (startDate.after(endDate)) {
            throw new Exception("日期参数错误");
        }
        int day = daysBetween(startDate, endDate);
        for (int i = 0; i < day + 1; i++) {
            System.out.println(getYesterday(i, startDate));
            extractOneDate(getYesterday(i, startDate));
        }
    }
    public void extractDate2DateWithId(String start, String end, String quotaId) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date startDate = sdf.parse(start);
        Date endDate = sdf.parse(end);
        if (startDate.after(endDate)) {
            throw new Exception("日期参数错误");
        }
        int day = daysBetween(startDate, endDate);
        for (int i = 0; i < day + 1; i++) {
            extractOneDateWithId(getYesterday(i, startDate), quotaId);
        }
    }
    private String getYesterday(Integer day, Date startDate) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(startDate);
        cal.add(Calendar.DAY_OF_MONTH, day);
        String yesterday = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
        return yesterday;
    }
    private int daysBetween(Date smdate, Date bdate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        smdate = sdf.parse(sdf.format(smdate));
        bdate = sdf.parse(sdf.format(bdate));
        Calendar cal = Calendar.getInstance();
        cal.setTime(smdate);
        long time1 = cal.getTimeInMillis();
        cal.setTime(bdate);
        long time2 = cal.getTimeInMillis();
        long between_days = (time2 - time1) / (1000 * 3600 * 24);
        return Integer.parseInt(String.valueOf(between_days));
    }
    private void deleteData(Date quotaDate, String quotaCode) {
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("quotaCode", quotaCode))
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate))
            ).size(50000);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<SaveModel> saveModels = result.getSourceAsObjectList(SaveModel.class);
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (SaveModel obj : saveModels) {
                Delete index = new Delete.Builder(obj.getId()).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void deleteData(Date quotaDate) {
        try {
            JestClient jestClient = elasticFactory.getJestClient();
            //先根据条件查找出来
            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
            searchSourceBuilder.query(
                    new BoolQueryBuilder()
                            .must(QueryBuilders.matchQuery("quotaDate", quotaDate))
            ).size(100000);//一次取10000条
            Search search = new Search.Builder(searchSourceBuilder.toString()).addIndex(esIndex).addType(esType)
                    .build();
            SearchResult result = jestClient.execute(search);
            List<SaveModel> saveModels = result.getSourceAsObjectList(SaveModel.class);
            //根据id批量删除
            Bulk.Builder bulk = new Bulk.Builder().defaultIndex(esIndex).defaultType(esType);
            for (SaveModel obj : saveModels) {
                Delete index = new Delete.Builder(obj.getId()).build();
                bulk.addAction(index);
            }
            BulkResult br = jestClient.execute(bulk.build());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void save2es(List<WlyyQuotaResult> quotaResults, String quotaCode, String quotaDate) {
        List<SaveModel> saveModel = new ArrayList<>();
        if (quotaResults != null && quotaResults.size() > 0) {
            //查询ES是否有这天的数据有就删除
            if (StringUtils.isEmpty(quotaCode)) {
                deleteData(DateUtil.strToDate(quotaDate, "yyyy-MM-dd"));
            } else {
                deleteData(DateUtil.strToDate(quotaDate, "yyyy-MM-dd"), quotaCode);
            }
            //
            quotaResults.stream().forEach(one -> {
                SaveModel saveModelTemp = new SaveModel();
@ -50,37 +188,71 @@ public class ExtractDataService {
                saveModelTemp.setSlaveKey2Name(one.getLevel3TypeName());
                if (
                        "1".equals(one.getQuatoCode()) ||
                        "2".equals(one.getQuatoCode()) ||
                        "6".equals(one.getQuatoCode())||
                                "7".equals(one.getQuatoCode())||
                                "8".equals(one.getQuatoCode())||
                                "9".equals(one.getQuatoCode())
                   ){
                    saveModelTemp.setTimeLevel("2");
                                "2".equals(one.getQuatoCode()) ||
                                "6".equals(one.getQuatoCode()) ||
                                "7".equals(one.getQuatoCode()) ||
                                "8".equals(one.getQuatoCode()) ||
                                "9".equals(one.getQuatoCode()) ||
                                "10".equals(one.getQuatoCode()) ||
                                "12".equals(one.getQuatoCode()) ||
                                "13".equals(one.getQuatoCode()) ||
                                "14".equals(one.getQuatoCode()) ||
                                "15".equals(one.getQuatoCode()) ||
                                "16".equals(one.getQuatoCode()) ||
                                "17".equals(one.getQuatoCode()) ||
                                "20".equals(one.getQuatoCode()) ||
                                "21".equals(one.getQuatoCode()) ||
                                "26".equals(one.getQuatoCode()) ||
                                "29".equals(one.getQuatoCode()) ||
                                "30".equals(one.getQuatoCode()) ||
                                "31".equals(one.getQuatoCode()) ||
                                "32".equals(one.getQuatoCode()) ||
                                "33".equals(one.getQuatoCode()) ||
                                "34".equals(one.getQuatoCode()) ||
                                "35".equals(one.getQuatoCode()) ||
                                "36".equals(one.getQuatoCode()) ||
                                "37".equals(one.getQuatoCode()) ||
                                "38".equals(one.getQuatoCode()) ||
                                "39".equals(one.getQuatoCode()) ||
                                "40".equals(one.getQuatoCode()) ||
                                "41".equals(one.getQuatoCode()) ||
                                "42".equals(one.getQuatoCode()) ||
                                "43".equals(one.getQuatoCode()) ||
                                "44".equals(one.getQuatoCode()) ||
                                "45".equals(one.getQuatoCode()) ||
                                "46".equals(one.getQuatoCode()) ||
                                "47".equals(one.getQuatoCode()) ||
                                "48".equals(one.getQuatoCode()) ||
                                "49".equals(one.getQuatoCode()) ||
                                "50".equals(one.getQuatoCode()) ||
                                "51".equals(one.getQuatoCode()) ||
                                "52".equals(one.getQuatoCode()) ||
                                "53".equals(one.getQuatoCode()) ||
                                "54".equals(one.getQuatoCode()) ||
                                "55".equals(one.getQuatoCode()) ||
                                "56".equals(one.getQuatoCode()) ||
                                "57".equals(one.getQuatoCode())
                        ) {
                    saveModelTemp.setTimeLevel("2");//到达量
                }
                if (
                        "3".equals(one.getQuatoCode()) ||
                        "4".equals(one.getQuatoCode()) ||
                        "5".equals(one.getQuatoCode())
                        ){
                    saveModelTemp.setTimeLevel("2");
                                "4".equals(one.getQuatoCode()) ||
                                "5".equals(one.getQuatoCode()) ||
                                "22".equals(one.getQuatoCode()) ||
                                "23".equals(one.getQuatoCode()) ||
                                "24".equals(one.getQuatoCode()) ||
                                "25".equals(one.getQuatoCode()) ||
                                "27".equals(one.getQuatoCode())
                        ) {
                    saveModelTemp.setTimeLevel("1");//增量
                }
                saveModelTemp.setAreaLevel("5");
            });
        }
    }
    public void extractOneDateWithId(String date, String quotaId) {
        wlyyQuotaResultDao.findByDateAndId(date, quotaId);
    }
    public void extractDate2Date(String startDate, String endDate) {
    }
    public void extractDate2DateWithId(String startDate, String endDate, String quotaId) {
                saveModel.add(saveModelTemp);
            });
            elastricSearchSave.save(saveModel);
        }
    }
}

+ 6 - 4
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -27,7 +27,7 @@ import java.util.*;
 */
@Service
public class JobService {
    private Long sleepTime = 10000L;
    private Long sleepTime = 5000L;
    @Autowired
    private QuartzHelper quartzHelper;
@ -47,7 +47,7 @@ public class JobService {
        if (quartzJobConfig != null) {
            for (int j = 1; j <= 2; j++) {
                quartzHelper.removeJob(quartzJobConfig.getId() + "-" + j);
                quartzJobConfig.setStatus("0");
                wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(),"0") ;;
            }
        } else {
            throw new Exception("任务已经停止");
@ -72,7 +72,8 @@ public class JobService {
            for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
                for (int j = 1; j <= 2; j++) {
                    quartzHelper.removeJob(quartzJobConfig.getId() + "-" + j);
                    quartzJobConfig.setStatus("0");
                    wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(),"0") ;;
                }
            }
        } else {
@ -98,6 +99,7 @@ public class JobService {
     * @param quartzJobConfig
     * @throws Exception
     */
    @Transactional
    private void startOneJob(QuartzJobConfig quartzJobConfig) throws Exception {
        WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
@ -109,7 +111,7 @@ public class JobService {
            for (int j = 1; j <= 2; j++) {
                //往quartz框架添加任务
                quartzHelper.addJob(getRightClass(quartzJobConfig), quartzJobConfig.getQuartzCron(), quartzJobConfig.getId() + "-" + j, params);
                quartzJobConfig.setStatus("1");//设置任务状态是启动 }
               wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(),"1") ;//设置任务状态是启动 }
            }
        }
    }

+ 22 - 22
patient-co/patient-co-statistics-es/src/main/resources/application.yml

@ -108,30 +108,30 @@ spring:
  profiles: test
  datasource:
    primaryReadWrite:
      url: jdbc:mysql://172.19.103.85/data_for_stats?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
    primaryRead:
      url: jdbc:mysql://172.19.103.85/data_for_stats?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
    im: #im库
      url: jdbc:mysql://172.17.110.160/im_new?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: linzhou
      password: linzhou
#    primaryReadWrite:
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#      url: jdbc:mysql://172.19.103.85/data_for_stats?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: linzhou
#      password: linzhou
#    primaryRead:
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#      url: jdbc:mysql://172.19.103.85/data_for_stats?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: linzhou
#      password: linzhou
#    im: #im库
#      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: root
#      password: 123456
#      url: jdbc:mysql://172.17.110.160/im_new?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
#      username: linzhou
#      password: linzhou
    primaryReadWrite:
      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
    primaryRead:
      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
    im: #im库
      url: jdbc:mysql://172.19.103.77/wlyy_quota?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: root
      password: 123456
  redis:
    host: 172.19.103.88 # Redis server host.
@ -164,7 +164,7 @@ wlyy:
    databaseName: im_new
quartz:
  name: schedulerFactoryBean_test
  name: schedulerFactoryBean_cwd
---

+ 5 - 6
patient-co/patient-co-statistics-es/src/main/resources/quartz.properties

@ -2,7 +2,7 @@
# to create a Quartz Scheduler Instance, if a different
# properties file is not explicitly specified.
#
 
org.quartz.scheduler.instanceName: DefaultQuartzScheduler
org.quartz.scheduler.rmi.export: false
org.quartz.scheduler.rmi.proxy: false
@ -12,18 +12,17 @@ org.quartz.threadPool.class: org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount: 20
org.quartz.threadPool.threadPriority: 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread: true
 
org.quartz.jobStore.misfireThreshold: 18000000
 
org.quartz.jobStore.misfireThreshold: 60000
#============================================================================
# Configure JobStore
#============================================================================
 
# RAM
# org.quartz.jobStore.class: org.quartz.simpl.RAMJobStore
# Configure JobStore Cluster
org.quartz.jobStore.class:org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.useProperties=true
org.quartz.jobStore.driverDelegateClass:org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#datasource׺
org.quartz.jobStore.tablePrefix:QRTZ_

+ 7 - 14
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/etl/mycache/CachePool.java

@ -335,9 +335,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id ,fr.patient " +
                    "   from wlyy_sign_family_renew_log fr " +
                    "   join wlyy_patient p ON p.idcard = fr.idcard" +
                    "   where " +
                    "   fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(date)+"' " +
@ -367,9 +366,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    "  from wlyy_sign_family_renew_log fr " +
                    "  join wlyy_patient p ON p.idcard = fr.idcard" +
                    "  where " +
                    "  fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'   " +
@ -399,9 +397,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id ,p.`code` patient " +
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id ,fr.patient " +
                    "  from wlyy_sign_family_renew_log fr " +
                    "  join wlyy_patient p ON p.idcard = fr.idcard" +
                    "  where " +
                    "  fr.apply_date<'"+date+ Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'  " +
@ -431,9 +428,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id ,fr.patient " +
                    "   from wlyy_sign_family_renew_log fr " +
                    "   join wlyy_patient p ON p.idcard = fr.idcard" +
                    "   where " +
                    "   fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(date)+"' " +
@ -464,9 +460,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    "  from wlyy_sign_family_renew_log fr " +
                    "  join wlyy_patient p ON p.idcard = fr.idcard" +
                    "  where " +
                    "  fr.apply_date<'"+ date + Constant.quota_date_last+"'" +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'" +
@ -497,9 +492,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql="select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql="select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    "  from wlyy_sign_family_renew_log fr " +
                    "  join wlyy_patient p ON p.idcard = fr.idcard" +
                    "  where " +
                    "  fr.apply_date<'"+date+ Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'" +
@ -530,9 +524,8 @@ public class CachePool {
        if (model == null) {
            model = new RenewCacheModel();
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient  " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient  " +
                    "  from wlyy_sign_family_renew_log fr " +
                    "  join wlyy_patient p ON p.idcard = fr.idcard" +
                    "  where " +
                    "  fr.apply_date<'"+ date + Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(date)+"'" +

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

@ -147,9 +147,8 @@ public class CurrentDayAllQuotaJob implements Job {
     */
    public Map<String,Object> getCityRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard" +
                    " where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +
                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
@ -174,9 +173,8 @@ public class CurrentDayAllQuotaJob implements Job {
     */
    public Map<String,Object> getTowmRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard" +
                    " where  " +
                    " fr.apply_date<'"+ tomorrow+"' and " +
                    " fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and " +
@ -201,9 +199,8 @@ public class CurrentDayAllQuotaJob implements Job {
     */
    public Map<String,Object> getOrgRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard" +
                    " where " +
                    " fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "'and  fr.hospital=fr.old_hospital  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
@ -224,9 +221,8 @@ public class CurrentDayAllQuotaJob implements Job {
     */
    public Map<String,Object> getTeamRenewTotals(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard" +
                    " where   " +
                    " fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
@ -243,9 +239,8 @@ public class CurrentDayAllQuotaJob implements Job {
    public Map<String,Object> getTeamRenewOut(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard " +
                    " where    " +
                    " fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
@ -262,9 +257,8 @@ public class CurrentDayAllQuotaJob implements Job {
    public Map<String,Object> getOrgRenewOut(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient" +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard" +
                    " where   " +
                    " fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
@ -281,9 +275,8 @@ public class CurrentDayAllQuotaJob implements Job {
    public Map<String,Object> getTownRenewOut(){
        try{
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,p.`code` patient " +
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id ,fr.patient " +
                    " from wlyy_sign_family_renew_log fr " +
                    " join wlyy_patient p ON p.idcard = fr.idcard " +
                    " where " +
                    " fr.apply_date<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYearByDate(tomorrow) + "' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據

+ 14 - 8
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignJob.java

@ -6,6 +6,8 @@ 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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -50,6 +52,8 @@ public class RenewSignJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -87,15 +91,17 @@ public class RenewSignJob implements Job {
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id  from wlyy_sign_family_renew_log fr where " +
                    "   fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"' " +
                    "   and LENGTH(fr.hospital)=10 " +
                    "   and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
//            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id  from wlyy_sign_family_renew_log fr where " +
//                    "   fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
//                    "   and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"' " +
//                    "   and LENGTH(fr.hospital)=10 " +
//                    "   and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalCityMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

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

@ -5,6 +5,8 @@ import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -46,6 +48,8 @@ public class RenewSignOrgJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -82,16 +86,18 @@ public class RenewSignOrgJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "   fr.apply_date<'"+yesterday+Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'  " +
                    "  and fr.hospital=fr.old_hospital " +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
//            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where " +
//                    "   fr.apply_date<'"+yesterday+Constant.quota_date_last+"' " +
//                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'  " +
//                    "  and fr.hospital=fr.old_hospital " +
//                    "  and LENGTH(fr.hospital)=10 " +
//                    "  and LENGTH(fr.old_hospital)=10";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalOrgMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

+ 15 - 8
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignOrgOutJob.java

@ -5,6 +5,8 @@ import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -46,6 +48,8 @@ public class RenewSignOrgOutJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -82,16 +86,19 @@ public class RenewSignOrgOutJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql="select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+yesterday+Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'" +
                    "  and fr.hospital!=fr.old_hospital" +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10";
//            String sql="select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
//                    "  fr.apply_date<'"+yesterday+Constant.quota_date_last+"' " +
//                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'" +
//                    "  and fr.hospital!=fr.old_hospital" +
//                    "  and LENGTH(fr.hospital)=10 " +
//                    "  and LENGTH(fr.old_hospital)=10";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            RenewCacheModel cacheModel= cachePool.getArriveRenewSignOrgOutMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

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

@ -5,6 +5,8 @@ import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -46,6 +48,8 @@ public class RenewSignTeamJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -82,16 +86,18 @@ public class RenewSignTeamJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id  from wlyy_sign_family_renew_log fr where " +
                    "   fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"' " +
                    "   and fr.admin_team_id=fr.old_admin_team_id " +
                    "   and LENGTH(fr.hospital)=10 " +
                    "   and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
//            String sql=" select fr.sign_code code,fr.hospital ,fr.admin_team_id  from wlyy_sign_family_renew_log fr where " +
//                    "   fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
//                    "   and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"' " +
//                    "   and fr.admin_team_id=fr.old_admin_team_id " +
//                    "   and LENGTH(fr.hospital)=10 " +
//                    "   and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalTeamMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

+ 14 - 8
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTeamOutJob.java

@ -5,6 +5,8 @@ import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -46,6 +48,8 @@ public class RenewSignTeamOutJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -82,16 +86,18 @@ public class RenewSignTeamOutJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"'" +
                    "   and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'" +
                    "   and fr.admin_team_id!=fr.old_admin_team_id " +
                    "   and LENGTH(fr.hospital)=10 " +
                    "   and LENGTH(fr.old_hospital)=10 ";
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
//                    "  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"'" +
//                    "   and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'" +
//                    "   and fr.admin_team_id!=fr.old_admin_team_id " +
//                    "   and LENGTH(fr.hospital)=10 " +
//                    "   and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            RenewCacheModel cacheModel= cachePool.getArriveRenewSignTeamOutMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

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

@ -5,6 +5,8 @@ import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -46,6 +48,8 @@ public class RenewSignTownJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -82,16 +86,18 @@ public class RenewSignTownJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'   " +
                    "  and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) " +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
//                    "  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
//                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'   " +
//                    "  and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) " +
//                    "  and LENGTH(fr.hospital)=10 " +
//                    "  and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //从缓存取数据
            RenewCacheModel cacheModel=cachePool.getArriveRenewTotalTownMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

+ 14 - 8
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownOutJob.java

@ -5,6 +5,8 @@ import com.yihu.wlyy.statistics.etl.dataFilter.RenewSignDataFilter;
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.model.RenewCacheModel;
import com.yihu.wlyy.statistics.etl.mycache.CachePool;
import com.yihu.wlyy.statistics.etl.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
@ -46,6 +48,8 @@ public class RenewSignTownOutJob implements Job {
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    @Autowired
    private CachePool cachePool;
    String yesterday;
    String daybefore;
@ -82,16 +86,18 @@ public class RenewSignTownOutJob implements Job {
            quartzJobLog.setJobStartTime(new Date());
            quartzJobLog.setJobId(wlyyJobConfig.getId());
            quartzJobLog.setJobName(wlyyJobConfig.getJobName());
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
                    "  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'" +
                    "  and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  " +
                    "  and LENGTH(fr.hospital)=10 " +
                    "  and LENGTH(fr.old_hospital)=10 ";
//            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_id from wlyy_sign_family_renew_log fr where " +
//                    "  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"' " +
//                    "  and fr.sign_year ='"+Constant.getNowYearByDate(yesterday)+"'" +
//                    "  and LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6)  " +
//                    "  and LENGTH(fr.hospital)=10 " +
//                    "  and LENGTH(fr.old_hospital)=10 ";
//            //抽取數據
//            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            RenewCacheModel cacheModel= cachePool.getArriveRenewSignTownOutMapByDate(yesterday);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            FilterModel etlModels= signDataFilter.filter(cacheModel.getSignFamilies(),null,null,cacheModel.getSql(),yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneDetailInfoDao.java

@ -0,0 +1,11 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.prenatal.ChildImmuneDetailInfo;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ChildImmuneDetailInfoDao extends PagingAndSortingRepository<ChildImmuneDetailInfo, Long>, JpaSpecificationExecutor<ChildImmuneDetailInfo> {
//}

+ 11 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneInfoDao.java

@ -0,0 +1,11 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.prenatal.ChildImmuneInfo;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ChildImmuneInfoDao extends PagingAndSortingRepository<ChildImmuneInfo, Long>, JpaSpecificationExecutor<ChildImmuneInfo> {
//}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildInfoDao.java

@ -0,0 +1,19 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.entity.patient.prenatal.ChildInfo;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ChildInfoDao extends PagingAndSortingRepository<ChildInfo, Long>, JpaSpecificationExecutor<ChildInfo> {
//
//    @Query("select p from ChildInfo p where p.barcodeNo=?1")
//    ChildInfo findByBarcodeNo(String barcodeNo);
//
//    @Query("select p from ChildInfo p where p.code=?1")
//    ChildInfo findByCode(String code);
//}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneDictDao.java

@ -0,0 +1,19 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.Patient;
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneDict;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ImmuneDictDao extends PagingAndSortingRepository<ImmuneDict, Long>, JpaSpecificationExecutor<ImmuneDict> {
//
//    @Query("select p from ImmuneDict p where p.immuneType=?1 and p.effectiveSign=1 and p.del =1")
//    List<ImmuneDict> findByImmuneType(Integer immuneType);
//
//}

+ 19 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneHospitalDictDao.java

@ -0,0 +1,19 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.prenatal.ChildImmuneDetailInfo;
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneDict;
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneHospitalDict;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
//import java.util.List;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ImmuneHospitalDictDao extends PagingAndSortingRepository<ImmuneHospitalDict, Long>, JpaSpecificationExecutor<ChildImmuneDetailInfo> {
//
//    @Query("select p from ImmuneHospitalDict p where p.hospital=?1 and p.immuneType=2 and p.effectiveSign=1 and p.del =1")
//    List<ImmuneHospitalDict> findByHospital(String hospital);
//}

+ 12 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneMappingDao.java

@ -0,0 +1,12 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.prenatal.ChildImmuneDetailInfo;
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneMapping;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ImmuneMappingDao extends PagingAndSortingRepository<ImmuneMapping, Long>, JpaSpecificationExecutor<ChildImmuneDetailInfo> {
//}

+ 13 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneNeedleDao.java

@ -0,0 +1,13 @@
//package com.yihu.wlyy.repository.patient;
//
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneNeedle;
//import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
//import org.springframework.data.repository.PagingAndSortingRepository;
//
///**
// * Created by yeshijie on 2017/10/17.
// */
//public interface ImmuneNeedleDao extends PagingAndSortingRepository<ImmuneNeedle, Long>, JpaSpecificationExecutor<ImmuneNeedle> {
//
//
//}

+ 5 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyMemberDao.java

@ -1,7 +1,9 @@
package com.yihu.wlyy.repository.patient;
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
import com.yihu.wlyy.entity.patient.prenatal.ChildInfo;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -14,6 +16,9 @@ import java.util.List;
public interface PatientFamilyMemberDao extends PagingAndSortingRepository<PatientFamilyMember, Long>,
        JpaSpecificationExecutor<PatientFamilyMember> {
    @Query("select p from PatientFamilyMember p where p.familyMember=?1 and p.familyRelation=?2 ")
    PatientFamilyMember findByFamilyMember(String familyMember,Integer familyRelation);
    /**
     * 查询居民的某个成员
     *

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

@ -80,6 +80,7 @@ public class FamilyMemberService extends BaseService {
        relations.put(5, "儿子");
        relations.put(6, "女儿");
        relations.put(7, "未知");
        relations.put(8, "免疫关联");
    }
    /**

+ 155 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/ChildImmuneService.java

@ -0,0 +1,155 @@
//package com.yihu.wlyy.service.app.prenatalInspector;
//
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.yihu.wlyy.entity.patient.PatientFamilyMember;
//import com.yihu.wlyy.entity.patient.SignFamily;
//import com.yihu.wlyy.entity.patient.prenatal.ChildInfo;
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneDict;
//import com.yihu.wlyy.entity.patient.prenatal.ImmuneHospitalDict;
//import com.yihu.wlyy.repository.patient.*;
//import com.yihu.wlyy.service.BaseService;
//import com.yihu.wlyy.util.DateUtil;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Date;
//import java.util.List;
//
///**
// * Created by yeshijie on 2017/10/18.
// */
//@Component
//@Transactional(rollbackFor = Exception.class)
//public class ChildImmuneService extends BaseService{
//
//    @Autowired
//    private ChildInfoDao childInfoDao;
//    @Autowired
//    private PatientFamilyMemberDao memberDao;
//    @Autowired
//    private SignFamilyDao signFamilyDao;
//    @Autowired
//    private ImmuneDictDao immuneDictDao;
//    @Autowired
//    private ImmuneHospitalDictDao immuneHospitalDictDao;
//    @Autowired
//    private ImmuneMappingDao immuneMappingDao;
//    @Autowired
//    private ImmuneNeedleDao immuneNeedleDao;
//    @Autowired
//    private ChildImmuneDetailInfoDao childImmuneDetailInfoDao;
//    @Autowired
//    private ChildImmuneInfoDao childImmuneInfoDao;
//
//    /**
//     * 获取儿童信息
//     * @param barcodeNo
//     * @return
//     */
//    public JSONObject findChildInfo(String barcodeNo,String patient){
//        Integer status = 0;
//        ChildInfo childInfo = childInfoDao.findByBarcodeNo(barcodeNo);
//        if(childInfo==null){
//            //请求智业接口
//
//
//            childInfoDao.save(childInfo);
//        }
//
//        PatientFamilyMember familyMember = memberDao.findByFamilyMember(childInfo.getCode(),8);
//        if(familyMember!=null){
//            if(patient.equals(familyMember.getPatient())){
//                status = -2;
//            }else {
//                status = -1;
//            }
//        }
//
//        JSONObject re = new JSONObject();
//        re.put("name","张三");
//        re.put("age", DateUtil.getChildAge(DateUtil.strToDate("2017-01-01")));
//        re.put("birthday","2017-01-01");
//        re.put("sex","1");//0 未知的性别,1男,2女,9未说明的性别
//        re.put("barcodeNo","350400201609090099");
//        re.put("status",status);
//
//        return re;
//    }
//
//    /**
//     * 绑定儿童信息
//     * @param barcodeNo
//     * @param patient
//     * @return
//     */
//    public Integer bindChildInfo(String barcodeNo,String patient){
//        Integer re = 0;
//        ChildInfo childInfo = childInfoDao.findByBarcodeNo(barcodeNo);
//
//        PatientFamilyMember familyMember = memberDao.findByFamilyMember(childInfo.getCode(),8);
//        if(familyMember!=null){
//            if(patient.equals(familyMember.getPatient())){
//                return -2;
//            }else {
//                return -1;
//            }
//        }
//        familyMember = new PatientFamilyMember();
//        familyMember.setIsAuthorize(1);
//        familyMember.setPatient(patient);
//        familyMember.setCzrq(new Date());
//        familyMember.setFamilyMember(childInfo.getCode());
//        familyMember.setFamilyRelation(8);//免疫关联
//        memberDao.save(familyMember);
//        return re;
//    }
//
//    /**
//     * 获取免疫家人
//     * @param patient
//     * @return
//     */
//    public JSONArray getImmuneFamily(String patient){
//        JSONArray re = new JSONArray();
//        List<PatientFamilyMember> familyMemberList =  memberDao.findByPatientAndFamilyRelation(patient,8);
//        familyMemberList.forEach(one->{
//            JSONObject json = new JSONObject();
//            ChildInfo childInfo = childInfoDao.findByCode(one.getFamilyMember());
//            json.put("name",childInfo.getName());
//            json.put("age", DateUtil.getChildAge(childInfo.getBirthday()));
//            json.put("birthday",childInfo.getBirthday());
//            json.put("sex",childInfo.getSickSex());//0 未知的性别,1男,2女,9未说明的性别
//            json.put("barcodeNo",childInfo.getBarcodeNo());
//            json.put("photo",childInfo.getPhoto());
//            re.add(json);
//        });
//        return re;
//    }
//
//    /**
//     * 免疫计划表-居民端
//     * @param patient
//     */
//    public void getImmunePlan(String patient){
//
//        SignFamily signFamily = signFamilyDao.findByPatient(patient);
//        if(signFamily==null){
//            //未签约
//
//        }
//
//        //获取必打疫苗
//        List<ImmuneDict> oneImmuneList = immuneDictDao.findByImmuneType(1);
//
//
//        //获取非必打疫苗
//        List<ImmuneHospitalDict> twoImmuneList = immuneHospitalDictDao.findByHospital(signFamily.getHospital());
//
//
//
//    }
//
//
//}

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -2291,7 +2291,7 @@ public class SignWebService extends BaseService {
        log.setAdminTeamId(renew.getAdminTeamId());
        log.setDoctor(renew.getDoctor());
        log.setHospital(renew.getHospital());
        log.setPatient(renew.getPatient());
        //存储旧签约记录
        if (sign != null) {
            Integer id = (Integer) sign.get("admin_team_code");
@ -2326,7 +2326,7 @@ public class SignWebService extends BaseService {
        log.setAdminTeamId(renew.getAdminTeamId());
        log.setDoctor(renew.getDoctor());
        log.setHospital(renew.getHospital());
        log.setPatient(renew.getPatient());
        //存储旧签约记录
        if (sign != null) {
            Integer id = (Integer) sign.get("admin_team_code");

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

@ -21,6 +21,8 @@ import com.yihu.wlyy.util.MapListUtils;
import com.yihu.wlyy.util.SystemConf;
import io.swagger.models.auth.In;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.time.DateUtils;
import org.elasticsearch.common.inject.internal.Join;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
@ -34,6 +36,7 @@ import org.springframework.jdbc.support.nativejdbc.OracleJdbc4NativeJdbcExtracto
import org.springframework.stereotype.Service;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -4951,6 +4954,410 @@ public class StatisticsService extends BaseService {
    }
    public Map<String,Object> getPrescriptionCount(String level,String area,String disease){
        //总数
        String totalSql ="SELECT " +
                " count(1) total" +
                " FROM " +
                " wlyy_prescription p ";
        if(StringUtils.isNotBlank(disease)){
            totalSql += " JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            totalSql +=" WHERE 1=1 ";
        }
        //进行中
        String  processingSql="SELECT " +
                " count(1) processingCount " +
                " FROM " +
                " wlyy_prescription p ";
        if(StringUtils.isNotBlank(disease)){
            processingSql += " JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            processingSql +=" WHERE 1=1 ";
        }
        processingSql += " AND  p.`status` < " + PrescriptionLog.PrescriptionLogStatus.finish.getValue() +
                " AND p.`status`>= " + PrescriptionLog.PrescriptionLogStatus.revieweding.getValue() ;
        //已完成,已经取消,审核不通过,其他原因取消
        String stateSql = "SELECT " +
                " count(1) count" +
                " FROM " +
                " wlyy_prescription p ";
        if(StringUtils.isNotBlank(disease)){
            stateSql += " JOIN wlyy_prescription_diagnosis d ON  d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            stateSql +=" WHERE 1=1 ";
        }
        stateSql += " AND p.`status` = ? " ;
        //市区
        if("4".equals(level)){
            //市区无过滤
        //区级
        }else if("3".equals(level)){
            totalSql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
            processingSql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
            stateSql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
        //机构
        }else if("2".equals(level)){
            totalSql += " p.hospital = '"+area+"' ";
            processingSql += " p.hospital = '"+area+"' ";
            stateSql += " p.hospital = '"+area+"' ";
        }
        Map<String,Object> rs = new HashedMap();
        //总数
        List<Map<String,Object>> total = jdbcTemplate.queryForList(totalSql);
        if(total!=null&&total.size()>0){
            rs.put("total",total.get(0).get("total"));
        }else{
            rs.put("total",0);
        }
        //进行中
        List<Map<String,Object>> processingCount = jdbcTemplate.queryForList(processingSql);
        if(total!=null&&total.size()>0){
            rs.put("processingCount",processingCount.get(0).get("processingCount"));
        }else{
            rs.put("processingCount",0);
        }
        //已完成
        List<Map<String,Object>> finishCount = jdbcTemplate.queryForList(stateSql,new Object[]{PrescriptionLog.PrescriptionLogStatus.finish.getValue()});
        if(total!=null&&total.size()>0){
            rs.put("finishCount",finishCount.get(0).get("count"));
        }else{
            rs.put("finishCount",0);
        }
        //已取消
        List<Map<String,Object>> patientCancelCount = jdbcTemplate.queryForList(stateSql,new Object[]{PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue()});
        if(total!=null&&total.size()>0){
            rs.put("patientCancelCount",patientCancelCount.get(0).get("count"));
        }else{
            rs.put("patientCancelCount",0);
        }
        //审核不通过
        List<Map<String,Object>> noReviewedCount = jdbcTemplate.queryForList(stateSql,new Object[]{PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue()});
        if(total!=null&&total.size()>0){
            rs.put("noReviewedCount",noReviewedCount.get(0).get("count"));
        }else{
            rs.put("noReviewedCount",0);
        }
        //其他原因取消
        List<Map<String,Object>> payOuttimeCount = jdbcTemplate.queryForList(stateSql,new Object[]{PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue()});
        if(total!=null&&total.size()>0){
            rs.put("payOuttimeCount",payOuttimeCount.get(0).get("count"));
        }else{
            rs.put("payOuttimeCount",0);
        }
        return rs;
    }
    /**
     *
     * @param level 等级
     * @param area 等级编码
     * @param disease 疾病编码
     * @param type 类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
     * @return
     */
    public List<Map<String,Object>> getPrescriptionTotalHistogram(String level,String area,String disease,String type){
        List<Map<String,Object>> rs = new ArrayList<>();
        Calendar dd = Calendar.getInstance();//定义日期实例
        Date endDate = new Date();
        dd.setTime(endDate);
        for(int i=1;i<7;i++){
            Map<String,Object> mc = new HashedMap();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
            String date = sdf.format(dd.getTime());
            mc.put("month",date);
            mc.put("count",0);
            dd.add(Calendar.MONTH,-1);
            rs.add(mc);
        }
        String sql = "SELECT count(1) AS count,LEFT(p.create_time,7) AS month " +
                " FROM wlyy_prescription p ";
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            sql +=" WHERE 1=1 ";
        }
        //市区
        if("4".equals(level)){
            //市区无过滤
            //区级
        }else if("3".equals(level)){
            sql += " AND LEFT(p.hospital, 6) = '"+area+"' ";
            //机构
        }else if("2".equals(level)){
            sql += " p.hospital = '"+area+"' ";
        }
        //类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
        if("1".equals(type)){
            //无状态过滤
        }else if("2".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.finish.getValue()+"' ";
        }else if("3".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue()+"' ";
        }else if("4".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue()+"' ";
        }else if("5".equals(type)){
            sql +=" AND p.`status` <'"+PrescriptionLog.PrescriptionLogStatus.finish.getValue()+"' " +
                  " AND p.`status`>='"+PrescriptionLog.PrescriptionLogStatus.revieweding+"'";
        }else if("6".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue()+"'";
        }
        sql += " AND p.create_time >='"+DateUtil.dateToStr(dd.getTime(),"YYYY-MM-dd HH:mm:ss")+"' AND p.create_time <='"+ DateUtil.dateToStr(new Date(),"YYYY-MM-dd HH:mm:ss")+"'  GROUP BY LEFT(p.create_time,7) ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Iterator iterator = list.iterator();
        for(Map<String,Object> m:rs){
            while (iterator.hasNext()){
                Map<String,Object> ml = ( Map<String,Object>)iterator.next();
                String monthKey = (String)m.get("month");
                String monthKeyDb = (String)ml.get("month");
                if(monthKey.equals(monthKeyDb)){
                    m.put("count",ml.get("count"));
                    iterator.remove();
                }
            }
        }
        return rs;
    }
    /**
     *
     * @param level
     * @param lowlevel
     * @param area
     * @param disease
     * @param type
     * @return
     */
    public List<Map<String,Object>> getPrescriptionTotalLowLevel(String level,String lowlevel,String area,String disease,String type){
        List<Map<String,Object>> rs ;
        String sql =null;
        //市级维度
        if("4".equals(level)){
            //默认查找市级维度
            if("3".equals(lowlevel)){
                sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " dm_town t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        " count(1) count, " +
                        " LEFT (p.hospital, 6) code " +
                        " FROM " +
                        " wlyy_prescription p ";
                sql = setDiseaseTypeSql(disease,type,sql);
                sql +=  " GROUP BY " +
                        "  LEFT (p.hospital, 6) " +
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " ORDER BY num DESC";
            }else if("2".equals(lowlevel)){
                 sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        " count(1) count, " +
                        " p.hospital code " +
                        " FROM " +
                        " wlyy_prescription p ";
                 sql = setDiseaseTypeSql(disease,type,sql);
                 sql += " GROUP BY " +
                        "  p.hospital " +
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " ORDER BY num DESC";
            }else if("1".equals(lowlevel)){
                 sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        "  count(1) count, " +
                        "  p.admin_team_id code " +
                        "  FROM " +
                        "  wlyy_prescription p " ;
                sql = setDiseaseTypeSql(disease,type,sql);
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " ORDER BY num DESC ";
            }
        //区级维度
        }else if("3".equals(level)){
            if("2".equals(lowlevel)){
                 sql = "SELECT " +
                        " t.code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " dm_hospital t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        " count(1) count, " +
                        " p.hospital code " +
                        " FROM " +
                        " wlyy_prescription p ";
                sql = setDiseaseTypeSql(disease,type,sql);
                sql += " GROUP BY " +
                        "  p.hospital " +
                        " ) s ON s.code = t.code " +
                        " WHERE " +
                        " t.city='350200' " +
                        " AND LENGTH(t.code)=10 " +
                        " AND t.town ='"+area+"'" +
                        " ORDER BY num DESC";
            }else if("1".equals(lowlevel)){
                 sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        "  count(1) count, " +
                        "  p.admin_team_id code " +
                        "  FROM " +
                        "  wlyy_prescription p " ;
                sql = setDiseaseTypeSql(disease,type,sql);
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE LEFT(t.org_code,6) ='"+area+"' " +
                        " ORDER BY num DESC ";
            }
        //机构级维度
        }else if("2".equals(level)){
            if("1".equals(lowlevel)){
                 sql = " SELECT " +
                        " t.id code, " +
                        " t.name, " +
                        " ifnull(s.count,0) num  " +
                        " FROM " +
                        " wlyy_admin_team t " +
                        " LEFT JOIN ( " +
                        " SELECT " +
                        "  count(1) count, " +
                        "  p.admin_team_id code " +
                        "  FROM " +
                        "  wlyy_prescription p " ;
                sql = setDiseaseTypeSql(disease,type,sql);
                sql +=  "  GROUP BY " +
                        "  p.admin_team_id " +
                        " ) s ON s.code = t.id " +
                        " WHERE t.org_code ='"+area+"'" +
                        " ORDER BY num DESC ";
            }
        }
        rs = jdbcTemplate.queryForList(sql);
        return rs;
    }
    public String setDiseaseTypeSql(String disease,String type,String sql){
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = p.code WHERE d.health_problem ='"+disease+"' ";
        }else{
            sql +=" WHERE 1=1 ";
        }
        //类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消
        if("1".equals(type)){
            //无状态过滤
        }else if("2".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.finish.getValue()+"' ";
        }else if("3".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.patient_canel.getValue()+"' ";
        }else if("4".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.no_reviewed.getValue()+"' ";
        }else if("5".equals(type)){
            sql +=" AND p.`status` <'"+PrescriptionLog.PrescriptionLogStatus.finish.getValue()+"' " +
                    " AND p.`status`>='"+PrescriptionLog.PrescriptionLogStatus.revieweding+"'";
        }else if("6".equals(type)){
            sql +=" AND p.`status` ='"+PrescriptionLog.PrescriptionLogStatus.pay_outtime.getValue()+"'";
        }
        return sql;
    }
    public Map<String,Object> getPrescriptionCost(String level,String area,String disease){
        Map<String,Object> rs = new HashedMap();
        String sql = "SELECT " +
                " IFNULL(SUM(t.total_amount),0) sum" +
                " FROM " +
                " wlyy_prescription_pay t ";
        String avgSql = "SELECT" +
                " IFNULL(AVG(t.total_amount),0) avg" +
                " FROM" +
                " wlyy_prescription_pay t " ;
        if(StringUtils.isNotBlank(disease)){
            sql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = t.prescription_code ";
            avgSql += " JOIN wlyy_prescription_diagnosis d ON d.prescription_code = t.prescription_code ";
        }
        if("4".equals(level)){
            sql +=" WHERE 1=1  ";
            avgSql +=" WHERE 1=1  ";
        }else if("3".equals(level)){
            sql +=" JOIN wlyy_prescription p ON t.prescription_code = p.code WHERE LEFT(p.hospital,6) ='"+area+"' ";
            avgSql +=" JOIN wlyy_prescription p ON t.prescription_code = p.code WHERE LEFT(p.hospital,6) ='"+area+"' ";
        }else if("2".equals(level)){
            sql +=" JOIN wlyy_prescription p ON t.prescription_code = p.code WHERE p.hospital ='"+area+"' ";
            avgSql +=" JOIN wlyy_prescription p ON t.prescription_code = p.code WHERE p.hospital ='"+area+"' ";
        }
        if(StringUtils.isNotBlank(disease)){
            sql += " AND  d.health_problem ='"+disease+"'";
            avgSql += " AND  d.health_problem ='"+disease+"'";
        }
        sql +="AND t.trade_status = 1 ";
        avgSql +="AND t.trade_status = 1 ";
        List<Map<String,Object>> sum = jdbcTemplate.queryForList(sql);
        if(sum!=null&&sum.size()>0){
            BigDecimal s = (BigDecimal)sum.get(0).get("sum");
            rs.put("sum",s.divide(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP));
        }else{
            rs.put("sum",0);
        }
        List<Map<String,Object>> avg = jdbcTemplate.queryForList(avgSql);
        if(avg!=null&&avg.size()>0){
            BigDecimal a =  (BigDecimal)avg.get(0).get("avg");
            rs.put("avg",a.divide((new BigDecimal(100))).setScale(2,BigDecimal.ROUND_HALF_UP));
        }else{
            rs.put("avg",0);
        }
        return rs;
    }
}

+ 87 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java

@ -1924,9 +1924,94 @@ public class StatisticsESService {
        }
        return resultMaps;
    }
    public JSONObject getRenewPercentAndChangePercent(String renewIndex, String level, String code, String year, String lowCode) {
        return null;
    public JSONObject getRenewPercentAndChangePercent(Integer level, String area, String year, String lowCode) {
        JSONObject jo = new JSONObject();
        String switchIndex = "";//转签index
        String signIndex ="1";//签约index
        String renewIndex ="";//续签index
        String date = year + "-06-30";
        try{
            if (level == 5) {
                //团队的转签
                if(StringUtils.isNoneBlank(lowCode)){
                    //服务类型维度
                    switchIndex = "55";
                    renewIndex = "52";
                }else{
                    switchIndex = "35";
                    renewIndex = "42";
                }
            } else if (level == 4) {
                //社区的转签
                if(StringUtils.isNoneBlank(lowCode)){
                    //服务类型维度
                    switchIndex = "56";
                    renewIndex = "53";
                }else{
                    switchIndex = "35";
                    renewIndex = "43";
                }
            } else {
                //区和市的转签
                if(StringUtils.isNoneBlank(lowCode)){
                    //服务类型维度
                    switchIndex = "57";
                    renewIndex = "54";
                }else{
                    switchIndex = "35";
                    renewIndex = "44";
                }
            }
            String timeKey = elasticsearchUtil.getQuotaTime();
            SaveModel renewSaveModel = new SaveModel();
            SaveModel switchSaveModel = new SaveModel();
            SaveModel signSaveModel = new SaveModel();
            if (StringUtils.isNotBlank(lowCode)){
                //续签量
                renewSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level,renewIndex,"2",lowCode);
                //转签量
                switchSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey,area,level,switchIndex,"2",lowCode);
            }else{
                //续签量
                renewSaveModel=elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level,renewIndex,"2");
                //转签量
                switchSaveModel=elasticsearchUtil.findOneDateQuotaLevel0(timeKey,area,level,renewIndex,"2");
            }
            int renewNum = renewSaveModel.getResult2();
            int switchNum = switchSaveModel.getResult2();
            //根据年度获取去年的签约数 签约指标是1
            if(StringUtils.isNoneBlank(lowCode)){
                if("3".equals(lowCode)){
                    //老年人
                    lowCode = "3";
                }else if("4".equals(lowCode)){
                    //高血压
                    lowCode = "1";
                }else if("5".equals(lowCode)){
                    //糖尿病
                    lowCode = "2";
                }
                signIndex = "17";
                signSaveModel=elasticsearchUtil.findOneDateQuotaLevel1(date,area,level,signIndex,"2",lowCode);
            }else{
                signSaveModel=elasticsearchUtil.findOneDateQuotaLevel0(date,area,level,signIndex,"2");
            }
            //签约量
            int signNum = signSaveModel.getResult2();
            jo.put("yesterYearSign", signNum);//去年的签约量
            jo.put("thisYearRenew", renewNum);//今年的续签量
            jo.put("thisYearSwithch", switchNum);//今年的转签量
            jo.put("renewRange", getRange(renewNum, signNum, 2));//续签率  50.00%
            jo.put("switchRange", getRange(switchNum, renewNum, 2));//转签率
        }catch (Exception e){
            e.getMessage();
            jo.put("status","0");
            jo.put("error","查询失败"+e.getMessage());
            return jo;
        }
        return jo;
    }
    public JSONObject getRenewAnalysis(String switchIndex, String switchIndexReson, String signIn, String signOut, String level, String code) throws Exception{

+ 33 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java

@ -883,4 +883,37 @@ public class DateUtil {
		cal.set(Calendar.DATE, cal.get(Calendar.DATE) +(days));
		return  cal.getTime();
	}
	/**
	 * 获取儿童的年龄
	 * @param birthday
	 * @return
     */
	public static String getChildAge(Date date){
		Calendar now = Calendar.getInstance();
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		int year = now.get(Calendar.YEAR)-cal.get(Calendar.YEAR);
		int month = now.get(Calendar.MONTH)-cal.get(Calendar.MONTH);
		if(month<0){
			year--;
			month+=12;
		}
		int day = now.get(Calendar.DAY_OF_MONTH)-cal.get(Calendar.DAY_OF_MONTH);
		if(day<0){
			month--;
			Calendar temp = Calendar.getInstance();
			temp.setTime(date);
			temp.add(Calendar.MONTH,1);
			temp.set(Calendar.DAY_OF_MONTH,1);
			temp.add(Calendar.DAY_OF_MONTH,-1);
			day = temp.get(Calendar.DAY_OF_MONTH)+now.get(Calendar.DAY_OF_MONTH)-cal.get(Calendar.DAY_OF_MONTH);
		}
		String y = year>0? year+"岁":"";
		String m = month>0? month+"月":"";
		String d = day>0? day+"天":"";
		return y+m+d;
	}
}

+ 52 - 25
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -257,27 +257,27 @@ public class ElasticsearchUtil {
        }
        if (SaveModel.teamLevel.equals(low_level)) {
            sql.append("select team,teamName,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select team,teamName,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by team,teamName");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by town,townName");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by city,cityName");
        }
        if (SaveModel.teamLevel.equals(level + "")) {
            sql.append(" and team='" + area + "'");
            sql.append(" team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(level + "")) {
            sql.append(" and hospital='" + area + "'");
            sql.append(" hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(level + "")) {
            sql.append(" and town='" + area + "'");
            sql.append(" town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(level + "")) {
            sql.append(" and city='" + area + "'");
            sql.append(" city='" + area + "'");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
@ -347,27 +347,27 @@ public class ElasticsearchUtil {
            low_level = lowLevel;
        }
        if (SaveModel.teamLevel.equals(low_level)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by team,teamName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by hospital,hospitalName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by town,townName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name");
        }
        if (SaveModel.teamLevel.equals(lowLevel)) {
            sql.append(" and team='" + area + "'");
            sql.append(" team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(lowLevel)) {
            sql.append(" and hospital='" + area + "'");
            sql.append(" hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(lowLevel)) {
            sql.append(" and town='" + area + "'");
            sql.append(" town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
            sql.append(" and city='" + area + "'");
            sql.append(" city='" + area + "'");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
@ -438,28 +438,28 @@ public class ElasticsearchUtil {
            low_level = lowLevel;
        }
        if (SaveModel.teamLevel.equals(low_level)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,result1,result2 from wlyy_quota_test where 1=1 ");
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,result1,result2 from wlyy_quota_test where ");
            groupBy.append("  group by team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by hospital,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,hospitalName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        }
        if (SaveModel.teamLevel.equals(lowLevel)) {
            sql.append(" and team='" + area + "'");
            sql.append(" team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(lowLevel)) {
            sql.append(" and hospital='" + area + "'");
            sql.append(" hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(lowLevel)) {
            sql.append(" and town='" + area + "'");
            sql.append(" town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
            sql.append(" and city='" + area + "'");
            sql.append(" city='" + area + "'");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
@ -732,7 +732,7 @@ public class ElasticsearchUtil {
     * @param level 等级 1 省 2 市 3 区县 4 机构 5团队
     * @param index  指标code
     * @param timelevel   1增量   2到达量(按照年度)
     * @param lowLevel  下一级区域等级   1 省 2 市 3 区县 4 机构 5团队
     * @param lowLevel  下一级区域等级   1 省 2 市 3 区县 4 机构 5团队.
     * @return
     * @throws Exception
     */
@ -816,4 +816,31 @@ public class ElasticsearchUtil {
        return list;
    }
    /**
     * 将参数转换成需要的SaveModel里的标识
     * @param level 等级  4 市  3区  2社区 1团队
     * @return
     * @author zhangdan
     * @time 2017-10-18
     */
    public int changeLevel(int level){
        int resultLevel =0;
        if (level==1){
            //团队转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.teamLevel);
        }else if(level==2){
            //社区转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.OrgLevel);
        }else if (level ==3){
            //区转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.townLevel);
        }else if (level==4){
            //市转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.cityLevel);
        }
        if(resultLevel==0){
            resultLevel = level;
        }
        return  resultLevel;
    }
}

+ 35 - 10
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/ChildImmuneController.java

@ -1,10 +1,13 @@
//package com.yihu.wlyy.web.patient.prenatalInspector;
//
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.yihu.wlyy.service.app.prenatalInspector.ChildImmuneService;
//import com.yihu.wlyy.web.BaseController;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import io.swagger.annotations.ApiParam;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
@ -19,14 +22,19 @@
//@Api(description = "患者端-免疫")
//public class ChildImmuneController extends BaseController{
//
//    @Autowired
//    private ChildImmuneService childImmuneService;
//
//
//    @ApiOperation("获取儿童信息")
//    @RequestMapping(value = "findChildInfo", method = RequestMethod.GET)
//    public String findChildInfo(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
//                                                @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo){
//    public String findChildInfo(@ApiParam(name = "barcodeNo", value = "儿童条形码", defaultValue = "")
//                                @RequestParam(value = "barcodeNo", required = true) String barcodeNo){
//        try {
//            JSONObject jsonObject = null;
//            JSONObject jsonObject = childImmuneService.findChildInfo(barcodeNo,getUID());
//            if(jsonObject.size()==0){
//                return error(-1,"条码有误,请重新确认");
//            }
//            return write(200, "查询成功!", "data", jsonObject);
//        }catch (Exception e){
//            error(e);
@ -35,19 +43,36 @@
//    }
//
//    @ApiOperation("绑定儿童关联")
//    @RequestMapping(value = "findChildInfo", method = RequestMethod.GET)
//    public String bindChildInfo(@ApiParam(name = "pregnancyNo", value = "产检号", defaultValue = "")
//                                @RequestParam(value = "pregnancyNo", required = true) String pregnancyNo){
//    @RequestMapping(value = "bindChildInfo", method = RequestMethod.POST)
//    public String bindChildInfo(@ApiParam(name = "barcodeNo", value = "儿童条形码", defaultValue = "")
//                                @RequestParam(value = "barcodeNo", required = true) String barcodeNo){
//        try {
//            JSONObject jsonObject = null;
//
//            Integer status = childImmuneService.bindChildInfo(barcodeNo,getUID());
//            if(status==-1){
//                return error(-1,"绑定失败,儿童信息已被其他居民绑定");
//            }else if(status==-2){
//                return error(-1,"已绑定成功,请不要重复绑定");
//            }else {
//                return success("绑定成功!");
//            }
//
//        }catch (Exception e){
//            error(e);
//            return error(-1,"绑定失败");
//        }
//    }
//
//            return write(200, "查询成功!", "data", jsonObject);
//    @ApiOperation("获取免疫关联的家人")
//    @RequestMapping(value = "bindChildInfo", method = RequestMethod.GET)
//    public String getImmuneFamily(){
//        try {
//            JSONArray response = childImmuneService.getImmuneFamily(getUID());
//            return write(200, "查询成功!", "list", response);
//        }catch (Exception e){
//            error(e);
//            return error(-1,"查询失败");
//            return error(-1,"绑定失败");
//        }
//    }
//
//
//}

+ 87 - 46
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -4,8 +4,10 @@ import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.app.statisticsES.StatisticsESService;
import com.yihu.wlyy.util.Constant;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.ValueComparator;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.quota.vo.SaveModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
@ -28,7 +30,7 @@ import java.util.TreeMap;
 * Created by chenweida on 2017/10/13.
 */
@Controller
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@Api(description = "ES统计查询")
public class EsStatisticsController extends BaseController {
@ -38,6 +40,8 @@ public class EsStatisticsController extends BaseController {
    StatisticsService statisticsService;
    @Autowired
    StatisticsAllService statisticsAllService;
    @Autowired
    ElasticsearchUtil elasticsearchUtil;
    /**
     * 获取统计时间
     *
@ -53,6 +57,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 指标按间隔统计  增量
     * 按年度统计是根据前端传的 startDate
@ -236,8 +241,8 @@ public class EsStatisticsController extends BaseController {
            JSONArray jsonArray2 = null;
            if (Constant.getNowYearByDate(endDate).equals(year)) {
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            }else{
                String date=Integer.valueOf(year)+1+"-06-30";
            } else {
                String date = Integer.valueOf(year) + 1 + "-06-30";
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(date, date, area, level, indexes[1], sort, lowLevel);
            }
            jsonArrays.add(jsonArray2);
@ -273,13 +278,13 @@ public class EsStatisticsController extends BaseController {
                for (Map.Entry<String, JSONObject> one : index1.entrySet()) {
                    JSONObject map1 = one.getValue();
                    JSONObject map2 = index2.get(one.getKey());
                    String amount1="0";
                    if(map1!=null&&map1.has("amount")){
                        amount1=map1.get("amount").toString();
                    String amount1 = "0";
                    if (map1 != null && map1.has("amount")) {
                        amount1 = map1.get("amount").toString();
                    }
                    String amount2="0";
                    if(map2!=null&&map2.has("amount")){
                        amount2=map2.get("amount").toString();
                    String amount2 = "0";
                    if (map2 != null && map2.has("amount")) {
                        amount2 = map2.get("amount").toString();
                    }
                    String amount = amount1 + "," + amount2;
@ -353,8 +358,8 @@ public class EsStatisticsController extends BaseController {
        try {
            JSONObject result = new JSONObject();
            //year没传默认是今年
            if(org.springframework.util.StringUtils.isEmpty(year)){
                year= Constant.getNowYear();
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
@ -365,11 +370,11 @@ public class EsStatisticsController extends BaseController {
//                JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level,year);
//                JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level,year);
                long sign = statisticsESService.getIndexTotal(endDate, area, level, "13","2");
                long sign = statisticsESService.getIndexTotal(endDate, area, level, "13", "2");
                long weiJf = statisticsESService.getWeiJiaoFei(endDate, area, level);
                JSONObject jo = statisticsESService.getRenewPercent(level + "", area, Constant.getNowYear());
                JSONObject signRate = statisticsESService.getSignRate(endDate, area, level,year);
                JSONObject signTaskRate = statisticsESService.getSignTaskRate(endDate, area, level,year);
                JSONObject signRate = statisticsESService.getSignRate(endDate, area, level, year);
                JSONObject signTaskRate = statisticsESService.getSignTaskRate(endDate, area, level, year);
                result.put("sign", sign);
                result.put("expenses", weiJf);
@ -379,11 +384,11 @@ public class EsStatisticsController extends BaseController {
                result.put("renewRange", jo.get("renewRange"));//续签率  50.00%
            } else {
                //如果年度不是当前年度 就根据endDate 找到那个年度的最后一天的数据
                if(!Constant.getNowYear().equals(year)){
                    endDate=(Integer.valueOf(year)+1)+"-06-30";
                if (!Constant.getNowYear().equals(year)) {
                    endDate = (Integer.valueOf(year) + 1) + "-06-30";
                }
//                result = statisticsAllService.getGroupInfo(endDate, lowCode, area, level,year);
                result = statisticsESService.getGroupInfo(endDate, lowCode, area, level,year);
                result = statisticsESService.getGroupInfo(endDate, lowCode, area, level, year);
            }
            return write(200, "查询成功", "data", result);
@ -410,6 +415,8 @@ public class EsStatisticsController extends BaseController {
                                       int level,
                                       @RequestParam(required = false) String year) {
        try {
            level=changeLevel(level);
            JSONArray result = statisticsESService.getSixFiveStatistics(endDate, area, level);
            return write(200, "查询成功", "data", result);
@ -449,11 +456,11 @@ public class EsStatisticsController extends BaseController {
            if (index != null) {
                for (String idx : indexes) {
                    if(org.springframework.util.StringUtils.isEmpty(year)){
                        year=Constant.getNowYear();
                    if (org.springframework.util.StringUtils.isEmpty(year)) {
                        year = Constant.getNowYear();
                    }
//                    JSONObject json = statisticsAllService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode,year);
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode,year);
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode, year);
                    result.put("index_" + idx, json);
                }
            }
@ -488,31 +495,33 @@ public class EsStatisticsController extends BaseController {
                                            @RequestParam(required = false) String lowCode) {
        try {
            String[] indexes = index.split(",");
            level=elasticsearchUtil.changeLevel(level);
            lowLevel=changeLevel(Integer.valueOf(lowLevel))+"";
            JSONObject result = new JSONObject();
            String year=Constant.getNowYearByDate(date);
            String year = Constant.getNowYearByDate(date);
            if (StringUtils.isNotEmpty(lowCode)) {
//                指定level下特定查询级别
                if (index.equals("17")) {
                    //sort=1&date=2017-07-13&level=4&index=17&area=350200&lowLevel=1&lowCode=3
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode,year));
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode, year));
                } else {
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode,year));
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode, year));
                }
            } else {
//                未指定level下特定查询级别
                for (String idx : indexes) {
                    if (idx.equals("18") || index.equals("19")) {
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
                    } else if ( index.equals("21")) {
                    } else if (index.equals("21")) {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal2(date, area, level, idx, sort, lowLevel));
                    } else if (idx.equals("28")) {
                        //level=4&area=350200&sort=1&index=28&date=undefined&lowLevel=2
                        result.put("index_" + idx, statisticsESService.getAvgAllInfo(level, area, lowLevel));
                    } else if (idx.equals("13")) {
                        // sort=1&date=2017-07-13&level=4&index=13&area=350200&lowCode=
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel,year));
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel, year));
                    } else {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel,year));
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                    }
                }
            }
@ -574,7 +583,7 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                Long total = statisticsESService.getIndexTotal(endDate, area, level, idx,"2");
                Long total = statisticsESService.getIndexTotal(endDate, area, level, idx, "2");
                result.put("index_" + idx, total);
            }
@ -628,9 +637,9 @@ public class EsStatisticsController extends BaseController {
            JSONObject data = null;
            if (Constant.getNowYear().equals(year)) {
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel,null);
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel, null);
            } else if (org.springframework.util.StringUtils.isEmpty(year)) {
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel,null);
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel, null);
//                data = statisticsService.getConsultingStatisticsListAll(level, area, lowlevel, year);
            } else {
@ -646,6 +655,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 咨询统计
     * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
@ -674,7 +684,7 @@ public class EsStatisticsController extends BaseController {
//                //去数据库查找年份
//                data = statisticsService.getConsultingTitleWithYear(level, area, year);
//            }
            data = statisticsESService.getConsultingTitle(level, area,year);
            data = statisticsESService.getConsultingTitle(level, area, year);
            if (data != null) {
                return write(200, "查询成功", "data", data);
            } else {
@ -707,7 +717,7 @@ public class EsStatisticsController extends BaseController {
//            } else {
//                return write(200, "查询成功", "data", statisticsService.getCoutListByTimeYear(level, area, year));
//            }
            return write(200, "查询成功", "data", statisticsESService.getCoutListByTime(level,area,year));
            return write(200, "查询成功", "data", statisticsESService.getCoutListByTime(level, area, year));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
@ -731,6 +741,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取得分平均数
     *
@ -767,6 +778,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 统计当前团队,签约人数,服务次数,平均满意度
     *
@ -816,6 +828,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取咨询数和未回复数
     *
@ -837,6 +850,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取机构内服务排行
     *
@ -878,6 +892,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 判断团队是否是团队长
     *
@ -916,6 +931,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 计算团队医生月或周咨询未回复和总数折线图
     *
@ -940,6 +956,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队内这成员,未回复数,总数,结束咨询数
     *
@ -963,6 +980,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取Doctor咨询结果
     *
@ -985,6 +1003,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队随访量折线统计图
     *
@ -1007,6 +1026,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamDoctorFollowupLine")
    @ResponseBody
    public String getTeamDoctorFollowupLine(@RequestParam(required = true) String type,
@ -1021,6 +1041,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 根据团队获取团队底下用户列表
     *
@ -1045,6 +1066,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生随访头信息
     *
@ -1067,6 +1089,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取待预约量团队统计则线图
     *
@ -1089,6 +1112,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生预约量团队统计则线图
     *
@ -1113,6 +1137,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队待预约量医生列表信息
     *
@ -1137,6 +1162,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生待预信息
     *
@ -1159,6 +1185,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康指导折线图
     *
@ -1181,6 +1208,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生则线图
     *
@ -1205,6 +1233,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队指导总数List
     *
@ -1229,6 +1258,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生健康指导头部信息
     *
@ -1251,6 +1281,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康教育折线统计
     *
@ -1273,6 +1304,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康
     *
@ -1296,6 +1328,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队成员健康教育列表
     *
@ -1320,6 +1353,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamDoctorEduTitle")
    @ResponseBody
    public String getTeamDoctorEduTitle(@RequestParam(required = true) String teamCode,
@ -1333,6 +1367,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getDotorInfo")
    @ResponseBody
    public String getDotorInfo(String code) {
@ -1343,6 +1378,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamRenewChangeLine")
    @ResponseBody
    public String getTeamRenewChangeLine(@RequestParam(required = true) String teamCode,
@ -1356,23 +1392,25 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/cleanDoctorScore")
    @ResponseBody
    public String cleanDoctorScore(){
        try{
    public String cleanDoctorScore() {
        try {
            return write(200, "清洗完成", "data", statisticsAllService.cleanDoctorScore());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取转签率和续签率
     * 前端:续签进展
     *
     * @param index 42,43,44 (52,53,54 服务类型维度)
     * <p>
     * //@param index 42,43,44 (52,53,54 服务类型维度)
     * @param level 等级  4 市  3区  2社区 1团队
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code
     * @param area  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code.
     * @param year  年份 非比传
     * @param lowCode 服务类型维度code(老年人3,高血压4,糖尿病5)
     * @return
@ -1380,19 +1418,21 @@ public class EsStatisticsController extends BaseController {
    @RequestMapping(value = "/getRenewPercentAndChangePercent", method = RequestMethod.GET)
    @ResponseBody
    public String getRenewPercentAndChangePercent(
            @RequestParam(required = true) String index,//续签index
            @RequestParam(required = true) String level,
            @RequestParam(required = true) String code,
            //@RequestParam(required = true) String index,//续签index
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String area,
            @RequestParam(required = false) String year,
            @RequestParam(required = false) String lowCode) {
        try {
            return write(200, "查询成功", "data", statisticsESService.getRenewPercentAndChangePercent(index,level, code, year,lowCode));
            //return write(200, "查询成功", "data", statisticsService.getRenewPercentAndChangePercent(index,level, code, year,lowCode));
            return write(200,"查询成功!","data",statisticsESService.getRenewPercentAndChangePercent(elasticsearchUtil.changeLevel(level),area,year,lowCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取转签人数,转签原因分析,转签分布
     * 前端:签约数据分析,团队转签详情
@ -1446,6 +1486,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 去年的签约量,续签量和续签率 列表
     *
@ -1481,7 +1522,7 @@ public class EsStatisticsController extends BaseController {
            }
            result.put("index_"+index, statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, level, index, sort, lowLevel, year,lowCode));
            result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, changeLevel(level), index, sort, String.valueOf(changeLevel(Integer.valueOf(lowLevel))), year, lowCode));
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -1492,11 +1533,11 @@ public class EsStatisticsController extends BaseController {
    @RequestMapping("/getLevelTotalSingle")
    @ResponseBody
    public String getLevelTotalSingle(@ApiParam(name="date", value="日期标识") @RequestParam(required = true)String date,
                                      @ApiParam(name="area", value="区域code") @RequestParam(required = true)String area,
                                      @ApiParam(name="level", value="级别") @RequestParam(required = true)int level){
        try{
            return write(200, "查询成功", "data", statisticsESService.getLowLevelTotalSingle2(date,area,level));
    public String getLevelTotalSingle(@ApiParam(name = "date", value = "日期标识") @RequestParam(required = true) String date,
                                      @ApiParam(name = "area", value = "区域code") @RequestParam(required = true) String area,
                                      @ApiParam(name = "level", value = "级别") @RequestParam(required = true) int level) {
        try {
            return write(200, "查询成功", "data", statisticsESService.getLowLevelTotalSingle2(date, area, level));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");

+ 67 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ValueComparator;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -1486,13 +1487,14 @@ public class StatisticsController extends BaseController {
     *
     * @param index 42,43,44 (52,53,54 服务类型维度)
     * @param level 等级  4 市  3区  2社区 1团队
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code.
     * @param year  年份 非比传
     * @param lowCode 服务类型维度code(老年人3,高血压4,糖尿病5)
     * @return
     */
    @RequestMapping(value = "/getRenewPercentAndChangePercent", method = RequestMethod.GET)
    @ResponseBody
    @Deprecated
    public String getRenewPercentAndChangePercent(
            @RequestParam(required = true) String index,//续签index
            @RequestParam(required = true) String level,
@ -1662,4 +1664,68 @@ public class StatisticsController extends BaseController {
        }
    }
    //=================================长处方分析===============================================
    @RequestMapping("/getPrescriptionCount")
    @ResponseBody
    @ApiOperation("订单统计-顶部总数获取")
    public String getPrescriptionCount(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                       @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                       @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionCount(level,area,disease));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionTotalHistogram")
    @ResponseBody
    @ApiOperation("订单统计-中部树状图获取")
    public String getPrescriptionTotalHistogram(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                                @ApiParam(name="area", value="级别对应编码") @RequestParam(required = true)String area,
                                                @ApiParam(name="disease", value="疾病类型") @RequestParam(required = false)String disease,
                                                @ApiParam(name="type", value="类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消") @RequestParam(required = true)String type){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionTotalHistogram(level,area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionTotalLowLevel")
    @ResponseBody
    @ApiOperation("订单统计-下部列表接口")
    public String getPrescriptionTotalLowLevel(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                               @ApiParam(name="lowlevel", value="第二级别") @RequestParam(required = true)String lowlevel,
                                               @ApiParam(name="area", value="界别编码") @RequestParam(required = true)String area,
                                               @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease,
                                               @ApiParam(name="type", value="类型1.总量,2.已完成,3.居民取消,4.审核不通过,5.进行中,6.其他原因取消") @RequestParam(required = true)String type){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionTotalLowLevel(level,lowlevel,area,disease,type));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getPrescriptionCost")
    @ResponseBody
    @ApiOperation("费用统计-顶部部头部接口")
    public String getPrescriptionCost(@ApiParam(name="level", value="级别") @RequestParam(required = true)String level,
                                      @ApiParam(name="area", value="界别编码") @RequestParam(required = true)String area,
                                      @ApiParam(name="disease", value="疾病") @RequestParam(required = false)String disease){
        try{
            return write(200, "查询成功", "data", statisticsService.getPrescriptionCost(level,area,disease));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
}