Ver código fonte

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

yeshijie 8 anos atrás
pai
commit
73f0a4a5bd
24 arquivos alterados com 1233 adições e 169 exclusões
  1. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java
  2. 153 9
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/CurrentDayAllQuotaJob.java
  3. 104 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignOrgJob.java
  4. 111 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignOrgReasonJob.java
  5. 104 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTeamJob.java
  6. 111 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTeamReasonJob.java
  7. 1 1
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownInJob.java
  8. 104 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownJob.java
  9. 111 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownReasonJob.java
  10. 3 3
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SwitchSignJob.java
  11. 105 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SwitchTeamSignJob.java
  12. 105 0
      patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SwitchTownSignJob.java
  13. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  14. 3 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java
  15. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  16. 32 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  17. 13 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  18. 19 42
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java
  19. 48 43
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsService.java
  20. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  21. 2 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  22. 7 5
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java
  23. 23 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java
  24. 67 56
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

+ 1 - 1
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java

@ -18,7 +18,7 @@ public interface QuartzJobConfigDao extends PagingAndSortingRepository<QuartzJob
    @Query(" FROM QuartzJobConfig a WHERE a.status=?1 and a.del='1'")
    List<QuartzJobConfig> findByAll(String s);
    @Query(" FROM QuartzJobConfig a WHERE a.id in (1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17,20,21,22,23,24,25,26,27,29,30,31,32,32,33,34,35,36)  and a.del='1' ")
    @Query(" FROM QuartzJobConfig a WHERE  a.del='1' ")
    List<QuartzJobConfig> findByIds();
    @Query(" FROM QuartzJobConfig a WHERE a.id=?1 and a.del='1'")

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

@ -178,18 +178,25 @@ public class CurrentDayAllQuotaJob implements Job {
        computequota_27();//统计代预约量
        computequota_28();//统计平均值
        computequota_29(); //统计续签
        computequota_30(); //统计续签原因
        computequota_31(); //统计续签夸团队
        computequota_32(); //统计续签夸社区
        computequota_33(); //统计续签夸区
        computequota_34(); //续签团队签入
        computequota_35(); //统计团队签出
        computequota_36(sql, signFamilies, null); //签约服务类型
        computequota_37(); //统计转签
        computequota_37(); //统计团队转签
        computequota_38(); //续签机构签入
        computequota_39(); //统计机构签出
        computequota_40(); //续签区签入
        computequota_41(); //统计区签出
        computequota_42(); //统计团队续签
        computequota_43(); //统计社区续签
        computequota_44(); //统计区续签
        computequota_45(); //统计社区转签
        computequota_46(); //统计区转签
        computequota_30(); //统计团队续签原因
        computequota_47(); //统计社区续签原因
        computequota_48(); //统计区续签原因
        quartzJobLog.setJobContent(allContent.toString());
@ -216,7 +223,7 @@ public class CurrentDayAllQuotaJob implements Job {
    private void computequota_37() {
        String quotaId = "37";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where  fr.old_admin_team_id!=fr.admin_team_id and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where  fr.old_admin_team_id!=fr.admin_team_id  and fr.hospital=fr.old_hospital and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
@ -911,7 +918,6 @@ public class CurrentDayAllQuotaJob implements Job {
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            ;
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(level2Data, null, quotaId, 3, 1);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
@ -957,7 +963,6 @@ public class CurrentDayAllQuotaJob implements Job {
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            ;
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(level2Data, null, quotaId, 6, 2);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
@ -1155,7 +1160,7 @@ public class CurrentDayAllQuotaJob implements Job {
    private void computequota_30() {
        String quotaId = "30";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id,fr.renew_change_reason from wlyy_sign_family_renew_log fr where fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id,fr.renew_change_reason from wlyy_sign_family_renew_log fr where fr.old_admin_team_id=fr.admin_team_id  and fr.hospital=fr.old_hospital and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
@ -1174,6 +1179,50 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------30----------");
    }
    private void computequota_47() {
        String quotaId = "47";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id,fr.renew_change_reason from wlyy_sign_family_renew_log fr where  fr.hospital=fr.old_hospital and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"1", sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存redis
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(level2Data, null, quotaId, 6, 9, 1);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------47----------");
    }
    private void computequota_48() {
        String quotaId = "48";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id,fr.renew_change_reason from wlyy_sign_family_renew_log fr where LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)  and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies,"1", sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data = SpringUtil.getBean(Level2Role.class).elt(returnDatas);
            //保存redis
            SpringUtil.getBean(RedisStorage.class).saveByLevel2(level2Data, null, quotaId, 6, 9, 1);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------48----------");
    }
    private void computequota_31() {
        String quotaId = "31";
        try {
@ -1197,7 +1246,7 @@ public class CurrentDayAllQuotaJob implements Job {
    private void computequota_32() {
         String quotaId = "32";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'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)";
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where   fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "' 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)";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
@ -1357,13 +1406,108 @@ public class CurrentDayAllQuotaJob implements Job {
        allContent.append("-----------41----------");
    }
    private void computequota_42() {
        String quotaId = "42";
        try {
            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<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "' and fr.admin_team_id=fr.old_admin_team_id  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas, null, quotaId);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------42----------");
    }
    private void computequota_43() {
        String quotaId = "43";
        try {
            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<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'and  fr.hospital=fr.old_hospital  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas, null, quotaId);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------43----------");
    }
    private void computequota_44() {
        String quotaId = "44";
        try {
            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<'"+ tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "' and  LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)  and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas, null, quotaId);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------44----------");
    }
    private void computequota_45() {
        String quotaId = "45";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where  fr.hospital!=fr.old_hospital and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6)and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas, null, quotaId);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------45----------");
    }
    private void computequota_46() {
        String quotaId = "46";
        try {
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where  LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6) and fr.apply_date<'"+tomorrow+"' and  fr.sign_year= '" + Constant.getNowYear() + "'";
            //抽取數據
            List<SignFamilyRenew> signFamilies = SpringUtil.getBean(DBExtract.class).extract(SignFamilyRenew.class, sql);
            //清洗數據
            FilterModel etlModels = SpringUtil.getBean(RenewSignDataFilter.class).filter(signFamilies, sql, "now");
            //统计数据
            List<Map<String, List<ETLModel>>> returnDatas = SpringUtil.getBean(Level1Role.class).elt(etlModels.getEtlModelList());
            //保存数据
            SpringUtil.getBean(RedisStorage.class).saveByLevel1(returnDatas, null, quotaId);
            allContent.append(JsonUtil.objToStr(etlModels.getLogModel()));
        } catch (Exception e) {
            e.printStackTrace();
            allContent.append("统计失败:" + e.getMessage());
        }
        allContent.append("-----------46----------");
    }
    public List<Map<String, Object>> getCityHoss() {
        List<Map<String, Object>> map = jdbcTemplate.queryForList(getAvgSqlByCode("city_hos_SQL"));
        return map;
    }
    public List<Map<String, Object>> getTownHoss(String townCode) {
        List<Map<String, Object>> map = jdbcTemplate.queryForList(getAvgSqlByCode("town_hos_SQL"), new Object[]{townCode});
        List<Map<String, Object>> map = jdbcTemplate.queryForList(getAvgSqlByCode("town_hos_SQL"), townCode);
        return map;
    }
@ -1425,7 +1569,7 @@ public class CurrentDayAllQuotaJob implements Job {
        Date date = new Date();//取时间
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(date);
        calendar.add(calendar.DATE, size);//把日期往后增加一天.整数往后推,负数往前移动
        calendar.add(Calendar.DATE, size);//把日期往后增加一天.整数往后推,负数往前移动
        date = calendar.getTime(); //这个时间就是日期往后推一天的结果
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String dateString = formatter.format(date);

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

@ -0,0 +1,104 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签社区的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignOrgJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+34+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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.getNowYear()+"'   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";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据
            dbStorage.saveByLevel1(returnDatas,yesterday,wlyyQuota);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 111 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignOrgReasonJob.java

@ -0,0 +1,111 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签签约原因的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignOrgReasonJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+30+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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,fr.renew_change_reason from wlyy_sign_family_renew_log fr where  fr.hospital=fr.old_hospital and LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) and  fr.sign_year<'"+yesterday+Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"'";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,"1",null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);
            //数据转换
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,6,9,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

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

@ -0,0 +1,104 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签团队的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTeamJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+35+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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_code from wlyy_sign_family_renew_log fr where  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"' 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 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据
            dbStorage.saveByLevel1(returnDatas,yesterday,wlyyQuota);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 111 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTeamReasonJob.java

@ -0,0 +1,111 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签团队签约原因的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTeamReasonJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+30+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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,fr.renew_change_reason from wlyy_sign_family_renew_log fr where  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 fr.sign_year<'"+yesterday+Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"'";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,"1",null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);
            //数据转换
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,6,9,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

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

@ -82,7 +82,7 @@ public class RenewSignTownInJob 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_code from wlyy_sign_family_renew_log fr where  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"' and fr.admin_team_id!=fr.old_admin_team_id and fr.hospital!=fr.old_hospital  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 ";
            String sql=" select fr.sign_code code,fr.old_hospital hospital,fr.old_admin_team_id admin_team_code from wlyy_sign_family_renew_log fr where  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"' 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 ";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據

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

@ -0,0 +1,104 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签区的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTownJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+35+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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_code from wlyy_sign_family_renew_log fr where  fr.apply_date<'"+ yesterday + Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"'   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);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据
            dbStorage.saveByLevel1(returnDatas,yesterday,wlyyQuota);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 111 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/RenewSignTownReasonJob.java

@ -0,0 +1,111 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.role.Level2Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 续签区签约原因的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class RenewSignTownReasonJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private Level2Role level2Role;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+30+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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,fr.renew_change_reason from wlyy_sign_family_renew_log fr where LEFT(fr.hospital,6)=LEFT(fr.old_hospital,6) and fr.sign_year<'"+yesterday+Constant.quota_date_last+"'  and fr.sign_year ='"+Constant.getNowYear()+"'";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,"1",null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //统计数据 二级维度
            List<Map<String, Map<String, List<ETLModel>>>> level2Data= level2Role.elt(returnDatas);
            //数据转换
            dbStorage.saveByLevel2(level2Data,yesterday,wlyyQuota,6,9,1);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

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

@ -26,12 +26,12 @@ import java.util.List;
import java.util.Map;
/**
 * 转签的指标执行类
 * 团转签的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class SwitchSignJob implements Job {
public class SwitchOrgSignJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
@ -83,7 +83,7 @@ public class SwitchSignJob 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.`status`>0  and fr.old_admin_team_id!=fr.admin_team_id and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 and fr.apply_date<'"+yesterday+Constant.quota_date_last+"' and fr.apply_date >'"+Constant.getStartTime()+"'";
            String sql="select fr.sign_code code,fr.hospital,fr.admin_team_id from wlyy_sign_family_renew_log fr where 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 and fr.apply_date<'"+yesterday+Constant.quota_date_last+"' and fr.sign_year ='"+Constant.getNowYear()+"'";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據

+ 105 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SwitchTeamSignJob.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 团转签的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class SwitchTeamSignJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+45+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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.old_admin_team_id!=fr.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 and fr.apply_date<'"+yesterday+Constant.quota_date_last+"' and fr.sign_year ='"+Constant.getNowYear()+"'";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据
            dbStorage.saveByLevel1(returnDatas,yesterday,wlyyQuota);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 105 - 0
patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/job/business/SwitchTownSignJob.java

@ -0,0 +1,105 @@
package com.yihu.wlyy.statistics.job.business;
import com.yihu.wlyy.statistics.dao.QuartzJobLogDao;
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.role.Level1Role;
import com.yihu.wlyy.statistics.etl.storage.DBStorage;
import com.yihu.wlyy.statistics.model.job.QuartzJobLog;
import com.yihu.wlyy.statistics.model.signfamily.SignFamilyRenew;
import com.yihu.wlyy.statistics.util.JsonUtil;
import com.yihu.wlyy.statistics.vo.WlyyJobConfigVO;
import com.yihu.wlyy.statistics.vo.WlyyQuotaVO;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * 团转签的指标执行类
 */
@Component
@Scope("prototype")
@DisallowConcurrentExecution//防止到了执行时间点前一任务还在执行中,但是这时有空闲的线程,那么马上又会执行,这样一来就会存在同一job被并行执行
public class SwitchTownSignJob implements Job {
    private WlyyQuotaVO wlyyQuota;//指标对象
    private WlyyJobConfigVO wlyyJobConfig;//配置对象
    @Autowired
    private QuartzJobLogDao quartzJobLogDao;//执行日志Dao
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private Level1Role levelRole;
    @Autowired
    private DBStorage dbStorage;
    @Autowired
    private DBExtract dbExtract;
    @Autowired
    private RenewSignDataFilter signDataFilter;
    String yesterday;
    String daybefore;
    @Override
    public void execute(JobExecutionContext context)
            throws JobExecutionException {
        try{
            SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);
            //初始化参数
            JobDataMap map = context.getJobDetail().getJobDataMap();
            wlyyQuota = (WlyyQuotaVO) map.get("quota");
            wlyyJobConfig = (WlyyJobConfigVO) map.get("jobConfig");
            daybefore= StringUtils.isEmpty(map.get("daybefore"))?SignJob.getDayString(-2):map.get("daybefore").toString();
            yesterday= StringUtils.isEmpty(map.get("yesterday"))?SignJob.getDayString(-1):map.get("yesterday").toString();
            //计算指标
            computequota();
        }catch (Exception e){
            //如果出錯立即重新執行
            JobExecutionException e2 =new JobExecutionException(e);
            e2.setRefireImmediately(true);
        }
    }
    /**
     * 计算指标
     */
    @Transactional
    private void computequota() {
        try{
            jdbcTemplate.execute("delete from wlyy_quota_result where quota_date='"+yesterday+"' and quato_code='"+46+"'");
            //新建任务日志对象
            QuartzJobLog quartzJobLog = new QuartzJobLog();
            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  LEFT(fr.hospital,6)!=LEFT(fr.old_hospital,6) and LENGTH(fr.hospital)=10 and LENGTH(fr.old_hospital)=10 and fr.apply_date<'"+yesterday+Constant.quota_date_last+"' and fr.sign_year ='"+Constant.getNowYear()+"'";
            //抽取數據
            List<SignFamilyRenew> signFamilies= dbExtract.extract(SignFamilyRenew.class,sql);
            //清洗數據
            FilterModel etlModels= signDataFilter.filter(signFamilies,null,null,sql,yesterday);
            //统计数据
            List<Map<String, List<ETLModel>>>  returnDatas= levelRole.elt(etlModels.getEtlModelList());
            //保存数据
            dbStorage.saveByLevel1(returnDatas,yesterday,wlyyQuota);
            //保存日志
            quartzJobLog.setJobEndTime(new Date());
            quartzJobLog.setJobContent(JsonUtil.objToStr(etlModels.getLogModel()));
            quartzJobLog.setJobType(etlModels.getError()?"1":"0");
            quartzJobLogDao.save(quartzJobLog);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java

@ -40,6 +40,9 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 and a.signStatus='1'")
    Message findByPatient(String patient,String doctor);
    @Query(" from Message a where a.read = 1 and over ='1' and a.sender = ?1 and a.receiver=?2 ")
    Message findByPatientRenew(String patient,String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.sender=?2 and a.tzType=?3 order by a.createTime desc")
    List<Message> getHealthIndexMessageByPatient(String doctor,String patient,String type,Pageable pageRequest);

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyRenewDao.java

@ -56,4 +56,7 @@ public interface SignFamilyRenewDao extends PagingAndSortingRepository<SignFamil
    @Query("select a from SignFamilyRenew a where a.patient = ?1 and a.type = ?2 and a.status > 0")
    SignFamilyRenew findSignByPatient(String patient, int type);
    @Query("select a from SignFamilyRenew a where a.doctor = ?1 and a.patient = ?2 and a.type = 2 and a.status >= 0")
    SignFamilyRenew findByDoctorPatient(String doctor, String patient);
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -290,7 +290,7 @@ public class SignPatientLabelInfoService extends BaseService {
                args = new Object[]{doctor, doctor, teamCode};
            }else{
                sql = "SELECT " +
                        "    t1.* " +
                        "    t1.* "+
                        " FROM " +
                        "    wlyy_sign_family t1 " +
                        " WHERE (t1.doctor = ? or t1.doctor_health = ?) " +

+ 32 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -665,6 +665,38 @@ public class FamilyContractService extends BaseService {
        return 200;
    }
    /**
     * 取消续签
     * @param patient
     * @param doctor
     * @return
     * @throws Exception
     */
    public int unsignRenew(String patient, String doctor) throws Exception {
        if(DateUtil.getNowMonth()<7){
            SignFamilyRenew  sf = signFamilyRenewDao.findByDoctorPatient(doctor, patient);
            if (sf!=null&&sf.getStatus() != 0 && sf.getStatus() != 2) {
                return -2;
            }
            sf.setStatus(-1);
        }else{
            SignFamily  sf = signFamilyDao.findByDoctorPatient(doctor, patient);
            if (sf!=null&&sf.getStatus() != 0 && sf.getStatus() != 2) {
                return -2;
            }
            sf.setStatus(-1);
        }
        Message message = messageDao.findByPatientRenew(patient, doctor);
        //修改信息为无效
        if (message != null) {
            message.setRead(0);
            message.setOver("0");
        }
        return 200;
    }
    /**
     * 申请解约
     *

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

@ -489,7 +489,11 @@ public class SignWebService extends BaseService {
            jsonObject.put("createTime", signFamily.getCzrq());
            jsonObject.put("type", signFamily.getType());
            jsonObject.put("typeName", signFamily.getType() == 1 ? "三师签约" : "家庭签约");
            jsonObject.put("isRenew", "0");
            if(StringUtils.isNotBlank(signFamily.getRenewFlag())){
                jsonObject.put("isRenew", "1");
            }else{
                jsonObject.put("isRenew", "0");
            }
            String statusName = "";
            switch (jsonObject.getInt("status")) {
                case -4:
@ -683,7 +687,7 @@ public class SignWebService extends BaseService {
        //统计当年咨询数量
        String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //统计随访数量
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ? ";
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
@ -725,7 +729,7 @@ public class SignWebService extends BaseService {
        //获取咨询
        String consult_sql = "select w.consult,w.symptoms,w.czrq,w.status,1 as type from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //获取随访
        String followup_sql = "select w.id,w.followup_type,w.followup_class,w.followup_date as czrq,w.followup_manager_status,w.status,2 as type from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ? and w.followup_class is not null ";
        String followup_sql = "select w.id,w.followup_type,w.followup_class,w.followup_date as czrq,w.followup_manager_status,w.status,2 as type from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  ";
        //获取待预约
        String reservation_sql = "select w.code,w.id, w.doctor_name,w.doctor_code,w.doctor_job,w.doctor,w.dname,w.org_code,w.status,w.start_time as czrq,3 as type from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //获取健康教育
@ -1384,6 +1388,7 @@ public class SignWebService extends BaseService {
                data.put("doctor", dotorCode);
                data.put("toUser", patientCode);
                data.put("toName", renew.getName());
                data.put("isRenew","1");//表示为续签操作
                Patient patient = patientService.findByCode(renew.getPatient());
                if (patient != null && StringUtils.isNotBlank(patient.getOpenid())) {
@ -1719,7 +1724,7 @@ public class SignWebService extends BaseService {
        //统计当年咨询数量
        String consult_sql = "select count(1) as count from wlyy_consult_team  w where w.doctor = ? and w.patient =? and YEAR(w.czrq) = ? ";
        //统计随访数量
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ?  and w.followup_class is not null ";
        String followup_sql = "select count(1) as count from wlyy_followup  w where (w.doctor_code = ? or w.doctor_code =?) and w.patient_code =? and YEAR(w.create_time) = ? ";
        //统计待预约数量
        String reservation_sql = "select count(1) as count from wlyy_patient_reservation  w where (w.doctor = ? or w.doctor =?) and w.patient =? and YEAR(w.czrq) = ? ";
        //统计健康教育数量
@ -2025,7 +2030,8 @@ public class SignWebService extends BaseService {
        if(list!=null&&list.size()>0){
            sign = list.get(0);
        }
        Long id = (Long)sign.get("admin_team_code");
        Integer i = (Integer)sign.get("admin_team_code");
        Long id = i.longValue();
        if(id==null){
            renew.setRenewFlag("2");
        }else{
@ -2047,7 +2053,8 @@ public class SignWebService extends BaseService {
        if(list!=null&&list.size()>0){
            sign = list.get(0);
        }
        Long id = (Long)sign.get("admin_team_code");
        Integer i = (Integer)sign.get("admin_team_code");
        Long id = i.longValue();
        if(id==null){
            renew.setRenewFlag("2");
        }else{

+ 19 - 42
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java

@ -122,7 +122,7 @@ public class StatisticsAllService extends BaseService {
                sql += " and qkdoctor_code = ?";
            }
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{index, level, preDate, area});
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, index, level, preDate, area);
            if (result != null && result.size() > 0) {
                total = (result.get(0).get("amount") != null ? Long.valueOf(result.get(0).get("amount").toString()) : 0L);
@ -168,7 +168,7 @@ public class StatisticsAllService extends BaseService {
        sql += "   order by quota_date DESC " +
                "   limit 0,1";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{index, level, area});
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, index, level, area);
        if (result != null && result.size() > 0) {
            String total = (result.get(0).get("amount") != null ? result.get(0).get("amount").toString() : "0");
@ -253,7 +253,7 @@ public class StatisticsAllService extends BaseService {
                sql += " and qkdoctor_code = ?";
            }
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, preDate, area});
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, level, preDate, area);
            if (result != null && result.size() > 0) {
                total = (result.get(0).get("amount") != null ? Long.valueOf(result.get(0).get("amount").toString()) : 0L);
@ -384,7 +384,7 @@ public class StatisticsAllService extends BaseService {
                sql += " and qkdoctor_code = ? ";
            }
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{level, preDate, lowCode, area});
            List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, level, preDate, lowCode, area);
            if (result != null && result.size() > 0) {
                total = (result.get(0).get("amount") != null ? Long.valueOf(result.get(0).get("amount").toString()) : 0L);
@ -833,7 +833,7 @@ public class StatisticsAllService extends BaseService {
                "   and quota_date = ? " +
                "   and " + areaField + " = ? ";
        resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, date, area});
        resultList = jdbcTemplate.queryForList(sql, low_level, date, area);
        if (resultList == null || resultList.size() < 1) {
            resultList = getLowLevelMapKey(level, low_level, area);
@ -942,7 +942,7 @@ public class StatisticsAllService extends BaseService {
            sql += " order by amount asc ";
        }
        resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, date, area, lowCode});
        resultList = jdbcTemplate.queryForList(sql, low_level, date, area, lowCode);
        return resultList;
    }
@ -1009,7 +1009,7 @@ public class StatisticsAllService extends BaseService {
            sql += " order by amount asc ";
        }
        resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, date, area});
        resultList = jdbcTemplate.queryForList(sql, low_level, date, area);
        return resultList;
    }
@ -1431,7 +1431,7 @@ public class StatisticsAllService extends BaseService {
        List<Map<String, Object>> resultList = new ArrayList<>();
        resultList = jdbcTemplate.queryForList(sql, new Object[]{level, endDate, area});
        resultList = jdbcTemplate.queryForList(sql, level, endDate, area);
        if (resultList == null || resultList.size() < 1) {
            getLevelTwoMapKey(index);
@ -1725,7 +1725,7 @@ public class StatisticsAllService extends BaseService {
                    "   and " + areaField + " = ? " +
                    " group by level3_type,level3_type_name";
            resultList = jdbcTemplate.queryForList(sql, new Object[]{level, preDate, area});
            resultList = jdbcTemplate.queryForList(sql, level, preDate, area);
        }
        if (resultList == null || resultList.size() < 1) {
@ -1845,7 +1845,7 @@ public class StatisticsAllService extends BaseService {
            List<Map<String, Object>> result = null;
            result = jdbcTemplate.queryForList(sql, new Object[]{level, preDate, area});
            result = jdbcTemplate.queryForList(sql, level, preDate, area);
            if (result != null && result.size() > 0) {
                total = (result.get(0).get("amount") == null ? 0 : Math.round(Double.valueOf(result.get(0).get("amount").toString())));
@ -2063,7 +2063,7 @@ public class StatisticsAllService extends BaseService {
        if (resultList != null) {
            for (Map<String, Object> map : resultList) {
                if (countResult.containsKey(map.get("range").toString())) {
                    JSONObject range = (JSONObject) countResult.get(map.get("range").toString());
                    JSONObject range = countResult.get(map.get("range").toString());
                    long amount = range.getLong("amount");
                    long resultAmount = map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L;
                    range.put("amount", amount + resultAmount);
@ -2866,7 +2866,7 @@ public class StatisticsAllService extends BaseService {
        return filesize + "%";
    }
    public JSONArray getLevelTwoLowLevelTotalSignAndRenew(String date, String area, int level, String index, int sort, String lowLevel, String lowCode, String year) throws Exception {
    public JSONArray getLevelTwoLowLevelTotalSignAndRenew(String area, int level, String index, int sort, String lowLevel, String year) throws Exception {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String lastDate = year + "-06-30";
@ -2875,33 +2875,14 @@ public class StatisticsAllService extends BaseService {
        String low_level = String.valueOf(StringUtils.isEmpty(lowLevel) ? (level - 1) : lowLevel);
        List<Map<String, Object>> resultList = new ArrayList<>();//续签量
        //获取续签量
        JSONArray renewJA = getLevel2ListForRedis("29", level + "", lowLevel, area, timeKey);
        //获取续入量
        String indexTemp = "";
        if ("1".equals(lowLevel)) {
            indexTemp = "34";//团队的签入指标
        } else if ("2".equals(lowLevel)) {
            indexTemp = "38";//机构的签入指标
        } else {
            indexTemp = "40";//区的签入指标
        }
        JSONArray signInJA = getLevel2ListForRedis(indexTemp, level + "", lowLevel, area, timeKey);
        //签入的列表转map
        Map<String, Integer> signInMap = new HashMap<>();
        if (signInJA != null && signInJA.length() > 0) {
            for (int i = 0; i < signInJA.length(); i++) {
                JSONObject jo = signInJA.getJSONObject(i);
                signInMap.put(jo.getString("code"), jo.getInt("num"));
            }
        }
        JSONArray renewJA = getLevel2ListForRedis(index, level + "", lowLevel, area, timeKey);
        //续签的的列表转map
        Map<String, Integer> renewMap = new HashMap<>();
        if (renewJA != null && renewJA.length() > 0) {
            for (int i = 0; i < renewJA.length(); i++) {
                JSONObject jo = renewJA.getJSONObject(i);
                renewMap.put(jo.getString("code"),  jo.getInt("num"));
                renewMap.put(jo.getString("code"), jo.getInt("num"));
            }
        }
        //自建结果集
@ -2914,13 +2895,10 @@ public class StatisticsAllService extends BaseService {
                map.put("amount", map.get("amount") != null ? Long.valueOf(map.get("amount").toString()) : 0L);
                //获取去年签约的人数 默认是上个年度的最后一天
                WlyyQuotaResult redisNum = findOneQuotaResult(lastDate, Integer.valueOf(low_level), "1", map.get("code").toString());
                Integer signId = signInMap.get(map.get("code").toString()) == null ? 0 : signInMap.get(map.get("code").toString());
                if (redisNum == null) {
                    int signNum = 0;
                    int renewNum =renewMap.get(map.get("code").toString());
                    int signInNum=signInMap.get(map.get("code").toString());
                    int renewNum = renewMap.get(map.get("code").toString());
                    signNum = Integer.valueOf(0);
                    renewNum = renewNum-signInNum; //续签量等于 续签量-签入量
                    map.put("rate", getRange(renewNum, signNum, 2));
                    map.put("signNum", 0);
                    map.put("renewNum", renewNum);
@ -2928,11 +2906,8 @@ public class StatisticsAllService extends BaseService {
                    JSONObject peopleNum = new JSONObject(redisNum);
                    if (peopleNum != null) {
                        int signNum = 0;
                        int renewNum =renewMap.get(map.get("code").toString());
                        int signInNum=signInMap.get(map.get("code").toString());
                        int renewNum = renewMap.get(map.get("code").toString());
                        signNum = Integer.valueOf(redisNum.getResult());
                        renewNum = renewNum-signInNum; //续签量等于 续签量-签入量
                        map.put("rate", getRange(renewNum, signNum, 2));
                        map.put("signNum", signNum);
                        map.put("renewNum", renewNum);
@ -3010,7 +2985,9 @@ public class StatisticsAllService extends BaseService {
     */
    private JSONArray getLevel2ListForRedis(String index, String level, String level2, String code, String timeKey) {
        String key37 = "quota:" + index + ":" + level + ":" + code + ":" + level2 + ":" + timeKey;
        JSONArray switchJo = new JSONArray(redisTemplate.opsForValue().get(key37));
        String value = redisTemplate.opsForValue().get(key37);
        JSONArray switchJo = new JSONArray(value);
        return switchJo;
    }
}

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

@ -144,7 +144,7 @@ public class StatisticsService extends BaseService {
            sql += " and level2_type = '" + level2_type + "'";
        }
        Map<String, Object> result = jdbcTemplate.queryForMap(sql, new Object[]{level, endDate, area});
        Map<String, Object> result = jdbcTemplate.queryForMap(sql, level, endDate, area);
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
@ -206,7 +206,7 @@ public class StatisticsService extends BaseService {
            sql += " and qkdoctor_code = ?";
        }
        Map<String, Object> result = jdbcTemplate.queryForMap(sql, new Object[]{level, startDate, endDate, area});
        Map<String, Object> result = jdbcTemplate.queryForMap(sql, level, startDate, endDate, area);
        // 截止日期包含当天,则从redis查询当天统计数据
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
@ -310,7 +310,7 @@ public class StatisticsService extends BaseService {
            sql += " order by amount asc ";
        }
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, endDate, area});
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, low_level, endDate, area);
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
@ -525,7 +525,7 @@ public class StatisticsService extends BaseService {
            sql += " order by amount asc ";
        }
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, new Object[]{low_level, startDate, endDate, area});
        List<Map<String, Object>> resultList = jdbcTemplate.queryForList(sql, low_level, startDate, endDate, area);
        // 结果为空时,自建结果集
        if (resultList == null || resultList.size() < 1) {
@ -771,7 +771,7 @@ public class StatisticsService extends BaseService {
        if (resultList != null) {
            for (Map<String, Object> map : resultList) {
                if (countResult.containsKey(map.get("range").toString())) {
                    JSONObject range = (JSONObject) countResult.get(map.get("range").toString());
                    JSONObject range = countResult.get(map.get("range").toString());
                    long amount = range.getLong("amount");
                    long resultAmount = map.get("amount") != null ? Math.round(Double.valueOf(map.get("amount").toString())) : 0;
                    range.put("amount", amount + resultAmount);
@ -1647,7 +1647,7 @@ public class StatisticsService extends BaseService {
            sql += " AND d.hospital = ? ";
        }
        Map<String, Object> rs = jdbcTemplate.queryForMap(sql, new Object[]{area});
        Map<String, Object> rs = jdbcTemplate.queryForMap(sql, area);
        JSONObject json = new JSONObject();
@ -1681,7 +1681,7 @@ public class StatisticsService extends BaseService {
        sql += " GROUP BY mt order by mt DESC ";
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql, new Object[]{statDate, endDate, area});
        List<Map<String, Object>> rs = jdbcTemplate.queryForList(sql, statDate, endDate, area);
        Map<String, Object> map = new HashMap<>();
        if (rs != null && rs.size() > 0) {
            //降低循环层级
@ -2275,7 +2275,7 @@ public class StatisticsService extends BaseService {
//        startDate = startDate + " 00:00:00";
//        endDate = endDate + " 23:59:59";
        //随访数目
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' AND w.followup_class IS NOT NULL ";
        String followup_sql = "SELECT COUNT(1) AS followupCount from wlyy_followup w WHERE w.admin_team_code=" + id + " AND  w.create_time >='" + startDate + "' AND w.create_time<='" + endDate + "' ";
        //随访数目
        Map<String, Object> followupCout = jdbcTemplate.queryForMap(followup_sql);
        if (followupCout.get("followupCount") == null) {
@ -2866,14 +2866,14 @@ public class StatisticsService extends BaseService {
        List<Map<String, Object>> couTotal = jdbcTemplate.queryForList(couTotalSQL);
        if (couTotal != null && couTotal.size() > 0) {
            Map<String, Object> couTotalMap = couTotal.get(0);
            total = (Long) couTotalMap.get("total") == null ? 0L : (Long) couTotalMap.get("total");
            total = couTotalMap.get("total") == null ? 0L : (Long) couTotalMap.get("total");
        }
        rs.put("total", total);
        List<Map<String, Object>> reyTotal = jdbcTemplate.queryForList(reyTotalSql);
        if (reyTotal != null && reyTotal.size() > 0) {
            Map<String, Object> reyTotalMap = reyTotal.get(0);
            relyOnTime = (Long) reyTotalMap.get("total") == null ? 0L : (Long) reyTotalMap.get("total");
            relyOnTime = reyTotalMap.get("total") == null ? 0L : (Long) reyTotalMap.get("total");
        }
        if (total != 0L && relyOnTime != 0L) {
            double rr = (double) relyOnTime / total * 100;
@ -2887,7 +2887,7 @@ public class StatisticsService extends BaseService {
        List<Map<String, Object>> addTotal = jdbcTemplate.queryForList(addTotalSql);
        if (addTotal != null && addTotal.size() > 0) {
            Map<String, Object> addTotalMap = addTotal.get(0);
            addNumber = (Long) addTotalMap.get("total") == null ? 0L : (Long) addTotalMap.get("total");
            addNumber = addTotalMap.get("total") == null ? 0L : (Long) addTotalMap.get("total");
        }
        //本周或月增量
        rs.put("addNumber", addNumber);
@ -2895,7 +2895,7 @@ public class StatisticsService extends BaseService {
        List<Map<String, Object>> noRelyTotal = jdbcTemplate.queryForList(noRelySql);
        if (noRelyTotal != null && noRelyTotal.size() > 0) {
            Map<String, Object> noRelyTotalMap = noRelyTotal.get(0);
            noRelyNumber = (Long) noRelyTotalMap.get("total") == null ? 0L : (Long) noRelyTotalMap.get("total");
            noRelyNumber = noRelyTotalMap.get("total") == null ? 0L : (Long) noRelyTotalMap.get("total");
        }
        rs.put("noRelyNumber", noRelyNumber);
        return rs;
@ -2917,7 +2917,6 @@ public class StatisticsService extends BaseService {
                    " AND w.doctor_code ='" + doctor + "'" +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY dateNo";
            planSQL = "SELECT " +
@ -2930,7 +2929,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY dateNo";
        } else {
            //按月
@ -2945,7 +2943,6 @@ public class StatisticsService extends BaseService {
                    " AND w.doctor_code ='" + doctor + "'" +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
                    " ( " +
@ -2959,7 +2956,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSQL);
@ -2985,7 +2981,6 @@ public class StatisticsService extends BaseService {
                    " w.admin_team_code =" + teamCode +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY dateNo";
            planSQL = "SELECT " +
@ -2999,7 +2994,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
        } else {
            //按月
@ -3013,7 +3007,6 @@ public class StatisticsService extends BaseService {
                    " w.admin_team_code =" + teamCode +
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
            planSQL = "SELECT " +
                    " ( " +
@ -3026,7 +3019,6 @@ public class StatisticsService extends BaseService {
                    " AND w.create_time >= '" + startDate + "' " +
                    " AND w.create_time <= '" + endDate + "' " +
                    " AND w.status ='2'" +
                    " AND w.followup_class IS NOT NULL " +
                    " GROUP BY weekOfMonth";
        }
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSQL);
@ -3056,7 +3048,6 @@ public class StatisticsService extends BaseService {
                " WHERE " +
                " w.admin_team_code =" + teamCode +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
@ -3088,7 +3079,6 @@ public class StatisticsService extends BaseService {
                " w.admin_team_code =" + teamCode +
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
@ -3121,7 +3111,6 @@ public class StatisticsService extends BaseService {
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.status ='2'" +
                " AND w.followup_class IS NOT NULL " +
                " GROUP BY " +
                "  w.doctor_code " +
                " ) c ON c.doctor_code =m.doctor_code, " +
@ -3257,8 +3246,7 @@ public class StatisticsService extends BaseService {
                " WHERE " +
                " w.admin_team_code =" + teamCode +
                " AND w.doctor_code ='" + doctor + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL";
                " AND w.create_time <= '" + endDate + "' ";
        String addSql = "SELECT " +
                " COUNT(1) AS addCount " +
                " FROM " +
@ -3267,8 +3255,7 @@ public class StatisticsService extends BaseService {
                " w.admin_team_code =" + teamCode +
                " AND w.doctor_code ='" + doctor + "' " +
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.followup_class IS NOT NULL";
                " AND w.create_time <= '" + endDate + "' ";
        String planSql = "SELECT " +
                " COUNT(1) AS planCount " +
                " FROM " +
@ -3278,8 +3265,7 @@ public class StatisticsService extends BaseService {
                " AND w.doctor_code ='" + doctor + "' " +
                " AND w.create_time >= '" + startDate + "' " +
                " AND w.create_time <= '" + endDate + "' " +
                " AND w.status ='2'" +
                " AND w.followup_class IS NOT NULL";
                " AND w.status ='2'";
        JSONObject rs = new JSONObject();
        List<Map<String, Object>> totalList = jdbcTemplate.queryForList(totalSql);
@ -4027,12 +4013,30 @@ public class StatisticsService extends BaseService {
    }
    public JSONObject getRenewPercentAndChangePercent(String level, String code, String year) {
        String renewIndex="";
        String switchIndex="";
        if("2".equals(level)){
            //团队的续签量
            renewIndex="42";
            //团队的转签
            switchIndex="37";
        }else if("2".equals(level)){
            //社区的续签量
            renewIndex="43";
            //社区的转签
            switchIndex="45";
        }else{
            //区和市的续签量
            renewIndex="44";
            //区和市的转签
            switchIndex="46";
        }
        JSONObject jo = new JSONObject();
        //获取时间戳
        String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
        //从redis中获取最新的续签数据  续签指标是29
        int renewNum = getLevel1NumForRedis("29", level, code, timeKey);
        ;
        int renewNum = getLevel1NumForRedis(renewIndex, level, code, timeKey);
        //根据年度获取去年的签约数 签约指标是1
        String date = year + "-06-30";
        String index = "1";
@ -4042,7 +4046,7 @@ public class StatisticsService extends BaseService {
            signNum = Integer.valueOf(wlyyQuotaResult.getResult());
        }
        //从redis中获取最新的转签数据  指标是37
        int switchNum = getLevel1NumForRedis("37", level, code, timeKey);
        int switchNum = getLevel1NumForRedis(switchIndex, level, code, timeKey);
        jo.put("yesterYearSign", signNum);//去年的签约量
        jo.put("thisYearRenew", renewNum);//今年的续签量
        jo.put("thisYearSwithch", switchNum);//今年的转签量
@ -4053,18 +4057,19 @@ public class StatisticsService extends BaseService {
    }
    public JSONObject getRenewAnalysis(String level, String code) {
    public JSONObject getRenewAnalysis(String switchIndex,String switchIndexReson,String signIn,String signOut,String level, String code) {
        JSONObject jo = new JSONObject();
        String timeKey = redisTemplate.opsForValue().get("quota:timeKey");
        //获取签入人数
        int switchNum = getLevel1NumForRedis("37", level, code, timeKey);
        //获取转签人数
        int switchNum = getLevel1NumForRedis(switchIndex, level, code, timeKey);
        //获取转签分布
        JSONArray switchJO = getLevel2JsonObjectForRedis("30", level, code, timeKey);
        JSONArray switchJO = getLevel2JsonObjectForRedis(switchIndexReson, level, code, timeKey);
        //获取签入人数
        int inNum = getLevel1NumForRedis("34", level, code, timeKey);
        int inNum = getLevel1NumForRedis(signIn, level, code, timeKey);
        //获取签出人数
        int outNum = getLevel1NumForRedis("35", level, code, timeKey);
        int outNum = getLevel1NumForRedis(signOut, level, code, timeKey);
        int changeTeam = getLevel1NumForRedis("31", level, code, timeKey);//夸团队的数目
        int changeHospital = getLevel1NumForRedis("32", level, code, timeKey);//夸社区的数目
@ -4554,23 +4559,23 @@ public class StatisticsService extends BaseService {
                //市 区
                sql =" SELECT t.result As num,t.town_name AS name,t.town AS code,t.create_time AS date" +
                        " FROM wlyy_quota_result t " +
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='3'AND LEFT(t.create_time,10)='"+year+"-06-30'";
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='3'AND t.quota_date='"+year+"-06-30'";
            }else{
                //市 机构
                sql = "SELECT t.result As num,t.org_name AS name,t.org_code AS code,t.create_time AS date" +
                        " FROM wlyy_quota_result t " +
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND LEFT(t.create_time,10)='"+year+"-06-30'";
                        " WHERE t.city ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND t.quota_date='"+year+"-06-30'";
            }
        }else if (level ==3){
            //区 机构
            sql = "SELECT t.result As num,t.org_name AS name,t.org_code AS code,t.create_time AS date " +
                    "FROM wlyy_quota_result t " +
                    "WHERE t.town ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND LEFT(t.create_time,10)='"+year+"-06-30'";
                    "WHERE t.town ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='2' AND t.quota_date='"+year+"-06-30'";
        }else{
            //机构 团队
            sql ="SELECT t.result As num,t.qkdoctor_name AS name,t.qkdoctor_code AS code,t.create_time AS date " +
                    " FROM wlyy_quota_result t " +
                    " WHERE t.org_code ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='1' AND LEFT(t.create_time,10)='"+year+"-06-30'";
                    " WHERE t.org_code ='"+area+"' AND t.quato_code ='"+index+"' AND t.level1_type ='1' AND t.quota_date='"+year+"-06-30'";
        }
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list!=null&&list.size()>0){

Diferenças do arquivo suprimidas por serem muito extensas
+ 2 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java


+ 2 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -460,6 +460,8 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/patient_search_all", method = RequestMethod.GET)
    @ApiOperation("根据姓名搜索所有团队下居民(根据团队和当前医生)")
    public String searchPatients(@RequestParam(required = true) String filter,

+ 7 - 5
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -482,11 +482,13 @@ public class DoctorSignController extends WeixinBaseController {
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
//            int rs =signWebService.agreeRenew(getAccessToken(),"test00000000005",patient,state);
            }else{
                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
                //如果没有续签记录,走签约记录
                if(rs!=0){
                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
                }
//                rs =signWebService.agreeRenew(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
//                //如果没有续签记录,走签约记录
//                if(rs!=0){
//                    rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
//                }
                rs =signWebService.agreeRenewOverDue(getAccessToken(),getUID(),patient,state,mesId,year+"",signCode,health,disease,custom,sevId,healthDoctor,teamCode,expenses);
            }
            if(rs != 1){
                //设置代码为已读

+ 23 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/sign/FamilyContractController.java

@ -567,6 +567,29 @@ public class FamilyContractController extends BaseController {
        }
    }
    @RequestMapping(value = "unsignRenew")
    @ResponseBody
    public String unsignRenew(
            String doctor,
            @RequestParam(required = false) String patientCode
    ) {
        try {
            patientCode = StringUtils.isNoneBlank(patientCode) ? patientCode : getRepUID();
//            patientCode = StringUtils.isNoneBlank(patientCode) ? patientCode : getUID();
            int res = familyContractService.unsignRenew(patientCode, doctor);
            if (res == -1) {
                return error(-1, "取消签约失败!");
            } else if (res == 200) {
                return success("签约申请已取消!");
            } else {
                return error(-1, "签约状态已变化,无法申请取消签约!");
            }
        } catch (Exception e) {
            error(e);
            return error(-1, "取消签约失败!");
        }
    }
    /**
     * 申请解约
     *

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

@ -312,30 +312,26 @@ public class StatisticsController extends BaseController {
    /**
     * 指标期间      增长量
     *
     * @param startDate
     * 如果是查找去年的 前端根据endDate来查看 2016年度 就传 2017-6-30
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @param index 6 7 8 15 16
     * @return
     */
    @RequestMapping("/leveltwo_increment")
    @ResponseBody
    public String getIndexLevelTwoIncrement(@RequestParam(required = false) String startDate,
    public String getIndexLevelTwoIncrement(
                                            @RequestParam(required = true) String endDate,
                                            @RequestParam(required = true) String area,
                                            @RequestParam(required = true) int level,
                                            @RequestParam(required = true) String index,
                                            @RequestParam(required = false) String year) {
                                            @RequestParam(required = true) String index) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(endDate, area, level, idx));
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
@ -346,7 +342,8 @@ public class StatisticsController extends BaseController {
    /**
     * 获取签约率、签约完成率
     *t
     * t
     *
     * @param endDate 截止日期
     * @param area    区域
     * @param level   区域级别 4:城市 3:区 2:社区 1:团队
@ -552,37 +549,6 @@ public class StatisticsController extends BaseController {
        }
    }
    /**
     * 二级指标 到达量  废弃接口 前端没有调用
     *
     * @param date
     * @param area
     * @param level
     * @param index
     * @return
     */
    @RequestMapping(value = "/leveltwo_all")
    @ResponseBody
    @Deprecated
    public String getIndexLevelTwoTotal(@RequestParam(required = true) String date,
                                        @RequestParam(required = true) String area,
                                        @RequestParam(required = true) int level,
                                        @RequestParam(required = true) String index) {
        try {
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                result.put("index_" + idx, statisticsAllService.getIndexLevelTwototal(date, area, level, idx));
            }
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 指标截止日期  到达量
     *
@ -678,6 +644,7 @@ public class StatisticsController extends BaseController {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -716,6 +683,7 @@ public class StatisticsController extends BaseController {
                return error(-1, "查询失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
@ -1438,7 +1406,40 @@ public class StatisticsController extends BaseController {
            @RequestParam(required = true) String level,
            @RequestParam(required = true) String code) {
        try {
            return write(200, "查询成功", "data", statisticsService.getRenewAnalysis(level, code));
            String switchIndex = "";
            String switchIndexReson = "";
            String signIn = "";
            String signOut = "";
            if ("1".equals(level)) {
                //团队的转签人数
                switchIndex = "37";
                //团队的转签原因
                switchIndexReson = "30";
                //团队的签入
                signIn = "34";
                //团队的签出
                signOut = "35";
            } else if ("2".equals(level)) {
                //社区的续签量
                switchIndex = "45";
                //社区的转签原因
                switchIndexReson = "47";
                //社区的签入
                signIn = "38";
                //社区的签出
                signOut = "39";
            } else {
                //区和市的续签量
                switchIndex = "46";
                //区和市的转签原因
                switchIndexReson = "48";
                //区和市的签入
                signIn = "40";
                //区和市的签出
                signOut = "41";
            }
            return write(200, "查询成功", "data", statisticsService.getRenewAnalysis(switchIndex, switchIndexReson, signIn, signOut, level, code));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
@ -1462,34 +1463,44 @@ public class StatisticsController extends BaseController {
    /**
     * 去年的签约量,续签量和续签率 列表
     *
     * @param date
     * @param area
     * @param level   level1_type等级 1:团队 2社区机构 3区级 4市级
     * @param sort    0:升序 1:降序
     * @param level    level1_type等级 1:团队 2社区机构 3区级 4市级
     * @param sort     0:升序 1:降序
     * @param lowLevel 只有可能是 1,2,3,
     * @return
     */
    @RequestMapping("/lowlevel_all_sign_renew")
    @ResponseBody
    public String getIndexLowLevelTotalSignAndRenew(@RequestParam(required = true) String date,
                                                    @RequestParam(required = true) String area,
                                                    @RequestParam(required = true) int level,
                                                    @RequestParam(required = true) int sort,
                                                    @RequestParam(required = false) String lowLevel,
                                                    @RequestParam(required = false) String lowCode,
                                                    @RequestParam(required = false) String year) {
    public String getIndexLowLevelTotalSignAndRenew(
            @RequestParam(required = true) String area,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String year) {
        try {
            JSONObject result = new JSONObject();
            //如果年度是空,按当前时间计算是年度是属于那个年度
            if(org.springframework.util.StringUtils.isEmpty(year)){
                year=Constant.getNowYear();
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
            if(org.springframework.util.StringUtils.isEmpty(lowLevel)){
                lowLevel=level-1+"";
            if (org.springframework.util.StringUtils.isEmpty(lowLevel)) {
                lowLevel = level - 1 + "";
            }
            String index = "";
            if (1 == level) {
                //团队的续签量
                index = "42";
            } else if (2 == level) {
                //社区的续签量
                index = "43";
            } else {
                //区和市的续签量
                index = "44";
            }
            result.put("index_29" , statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(date, area, level, "29", sort, lowLevel, lowCode,year));
            result.put("index_29", statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, level, index, sort, lowLevel, year));
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {