trick9191 7 éve
szülő
commit
af0b37b66d
32 módosított fájl, 840 hozzáadás és 246 törlés
  1. 13 13
      common/common-entity/src/main/java/com/yihu/wlyy/entity/oldpeople/OldPeoplePhysicalExaminationEntity.java
  2. 8 6
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRemindRecordsEntity.java
  3. 25 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/Application.java
  4. 5 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java
  5. 6 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  6. 5 6
      patient-co/patient-co-statistics-es/src/main/resources/quartz.properties
  7. 9 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  8. 42 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/OldPeoplePhysicalExaminationSynJob.java
  9. 14 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/oldpeople/OldPeoplePhysicalExaminationDao.java
  10. 8 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/oldpeople/OldPeoplePhysicalExaminationService.java
  11. 79 4
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  12. 22 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java
  13. 34 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  14. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  15. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  16. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneDetailInfoDao.java
  17. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneInfoDao.java
  18. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildInfoDao.java
  19. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneDictDao.java
  20. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneHospitalDictDao.java
  21. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneMappingDao.java
  22. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneNeedleDao.java
  23. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyMemberDao.java
  24. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  25. 155 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/ChildImmuneService.java
  26. 1 69
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  27. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  28. 103 56
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  29. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  30. 35 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/ChildImmuneController.java
  31. 127 74
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  32. 2 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/StatisticsController.java

+ 13 - 13
common/common-entity/src/main/java/com/yihu/wlyy/entity/oldpeople/OldPeoplePhysicalExaminationEntity.java

@ -13,19 +13,19 @@ import java.sql.Timestamp;
@Entity
@Table(name = "wlyy_old_people_physical_examination",catalog = "")
public class OldPeoplePhysicalExaminationEntity extends IdEntity implements Serializable {
	private String code;
	private String medicalNo;
	private String patientName;
	private String patientCode;
	private String idCard;
	private String doctorCode;
	private String jwDoctorCode;
	private String orgCode;
	private String orgName;
	private Timestamp medicalTime;
	private Integer sex;
	private String homeAddres;
	private Timestamp createTime;
	private String code;            //业务CODE
	private String medicalNo;       //体检编码
	private String patientName;     //患者名称
	private String patientCode;     //患者CODE
	private String idCard;          //患者身份证号
	private String doctorCode;      //体检医生CODE
	private String jwDoctorCode;    //体检医生的基卫CODE
	private String orgCode;         //体检医院机构编码
	private String orgName;         //体检医院名称
	private Timestamp medicalTime;  //体检时间
	private Integer sex;            //居民性别,1男,2女
	private String homeAddres;      //具名地址
	private Timestamp createTime;   //创建时间
	
	private static final long serialVersionUID = 8358924836164389434L;
	

+ 8 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRemindRecordsEntity.java

@ -7,18 +7,20 @@ import java.io.Serializable;
import java.sql.Timestamp;
/**
 * 居民提醒记录表
 * 老年人体检提醒&免疫计划提醒
 * @author huangwenjie
 * @date 2017/10/18 17:15
 */
@Entity
@Table(name = "wlyy_people_remind_records", catalog = "")
@Table(name = "wlyy_people_remind_records")
public class PatientRemindRecordsEntity extends IdEntity implements Serializable {
	private String code;
	private Integer type;
	private String patientCode;
	private String relationCode;
	private Timestamp remindTime;
	private Timestamp createTime;
	private Integer type;           //1老年人体检提醒,2免疫计划提醒
	private String patientCode;     //居民CODE
	private String relationCode;    //关联的业务逻辑CODE
	private Timestamp remindTime;   //提醒时间
	private Timestamp createTime;   //创建时间
	
	private static final long serialVersionUID = 8358924836164389434L;
	

+ 25 - 0
patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/Application.java

@ -2,7 +2,10 @@ package com.yihu.wlyy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.FilterRegistrationBean;
import org.springframework.boot.context.web.ErrorPageFilter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
/**
@ -15,4 +18,26 @@ public class Application {
    public static void main(String[] args) {
        ctx = SpringApplication.run(Application.class, args);
    }
    /**
     * start 解决如下问题
     * Cannot forward to error page for
     * request [/strategy/list/] as the response has already been committed. As a
     * result, the response may have the wrong status code. If your application is
     * running on WebSphere Application Server you may be able to resolve this
     * problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
     */
    @Bean
    public ErrorPageFilter errorPageFilter() {
        return new ErrorPageFilter();
    }
    @Bean
    public FilterRegistrationBean disableSpringBootErrorFilter(ErrorPageFilter filter) {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(filter);
        filterRegistrationBean.setEnabled(false);
        return filterRegistrationBean;
    }
    //end
}

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

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

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

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

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

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

+ 9 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -160,6 +160,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            } else {
                logger.info("prenatal_inspector_job exist");
            }
    
            //老年人体检记录同步,每天凌晨1点执行一次
            if (!quartzHelper.isExistJob("old_people_tijian_syb_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("old_people_tijian_syb_job");
                quartzHelper.addJob(OldPeoplePhysicalExaminationSynJob.class, trigger, "old_people_tijian_syb_job", new HashMap<String, Object>());
                logger.info("old_people_tijian_syb_job  job success");
            } else {
                logger.info("old_people_tijian_syb_job  job exist");
            }
            // 启动redis 消息队列线程
            logger.info("redis message start");

+ 42 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/OldPeoplePhysicalExaminationSynJob.java

@ -0,0 +1,42 @@
package com.yihu.wlyy.job;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * 老年人体检记录同步JOB
 * @author huangwenjie
 * @date 2017/10/18 21:01
 */
public class OldPeoplePhysicalExaminationSynJob implements Job {
	
	private static final Logger logger = LoggerFactory.getLogger(OldPeoplePhysicalExaminationSynJob.class);
	
	@Autowired
	private JwPrescriptionService jwPrescriptionService;
	
	@Override
	public void execute(JobExecutionContext context) throws JobExecutionException {
		logger.info("START=====老年人体检记录同步JOB");
		try {
			
			//获取前一天的时间范围
			String startdate = DateUtil.getNextDay(DateUtil.getStringDateShort(),-1) + " 00:00:00";
			String enddate = DateUtil.getNextDay(DateUtil.getStringDateShort(),-1) + " 23:59:59";
			
			//根据起止时间查询家签慢病患者定标情况,并同步到本地数据库
			jwPrescriptionService.getOldPeoplePhysicalExaminationByTime(startdate,enddate);
			
			logger.info("END========老年人体检记录同步JOB");
		}catch (Exception e){
			e.printStackTrace();
			logger.info("END===ERROE===老年人体检记录同步JOB,message:"+e.getMessage());
		}
	}
}

+ 14 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/oldpeople/OldPeoplePhysicalExaminationDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.oldpeople;
import com.yihu.wlyy.entity.oldpeople.OldPeoplePhysicalExaminationEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 老年人体检记录
 * @author huangwenjie
 * @date 2017/10/18 21:33
 */
public interface OldPeoplePhysicalExaminationDao extends PagingAndSortingRepository<OldPeoplePhysicalExaminationEntity, Long>,JpaSpecificationExecutor<OldPeoplePhysicalExaminationEntity> {
}

+ 8 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/oldpeople/OldPeoplePhysicalExaminationService.java

@ -0,0 +1,8 @@
package com.yihu.wlyy.service.app.oldpeople;
/**
 * @author huangwenjie
 * @date 2017/10/18 21:32
 */
public class OldPeoplePhysicalExaminationService {
}

+ 79 - 4
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -3,9 +3,12 @@ package com.yihu.wlyy.service.third.jw;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.wlyy.entity.oldpeople.OldPeoplePhysicalExaminationEntity;
import com.yihu.wlyy.entity.patient.prescription.Prescription;
import com.yihu.wlyy.repository.oldpeople.OldPeoplePhysicalExaminationDao;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
@ -17,10 +20,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * 基位长处方接口
@ -41,6 +41,8 @@ public class JwPrescriptionService {
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PatientService patientService;
    @Autowired
    private OldPeoplePhysicalExaminationDao oldPeoplePhysicalExaminationDao;
    /**
     * 获取字典列表
@ -286,4 +288,77 @@ public class JwPrescriptionService {
            throw new Exception("获取慢病患者定标情况请求失败,无数据返回!");
        }
    }
    
    /**
     * 根据起止时间查询老年人体检记录,并同步到本地数据库
     * @param startdate
     * @param enddate
     * @return
     */
    public void getOldPeoplePhysicalExaminationByTime(String startdate, String enddate)throws Exception {
        
        logger.info("查询老年人体检记录,开始时间"+startdate+",结束时间:"+enddate);
        
        
        String url = jwUrl + "/third/sign/getSickMedicalSimpleListInfo";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("TIME_START", startdate));//开始时间
        params.add(new BasicNameValuePair("TIME_END", enddate));//结束时间
        String response = httpClientUtil.post(url, params, "UTF-8");
        
        //老年人体检记录列表
        List<OldPeoplePhysicalExaminationEntity> oldPeoplePhysicalExaminationEntities = new ArrayList<>();
        
        if(StringUtils.isNotBlank(response)){
            JSONObject reobj =  JSON.parseObject(response);
            Integer status = reobj.getInteger("status");
            String errmsg = reobj.getString("msg");
            if(200 == status){
                JSONObject jwData = reobj.getJSONObject("data");
                Integer jwCode = jwData.getInteger("CODE");
                if(1 == jwCode){
                    JSONArray dataArray = jwData.getJSONArray("DATA");
                    for (int i = 0; i < dataArray.size(); i++) {
    
                        OldPeoplePhysicalExaminationEntity oldPeoplePhysicalExaminationEntity = new OldPeoplePhysicalExaminationEntity();
    
                        JSONObject json = dataArray.getJSONObject(i);
                        String idcard = json.getString("IDENTITY_CARD_NO");//身份证号码
                        String medicalNo = json.getString("MEDICAL_NO");//体检编码
                        String patientName = json.getString("SICK_NAME");//姓名
                        String orgName = json.getString("ORG_NAME");//医院名称
                        String orgCode = json.getString("ORG_CODE");//医院机构编码
                        String jwDoctorCode = json.getString("MEDICAL_OPERATOR");//体检医生
                        String medicalTime = json.getString("MEDICAL_TIME");//体检时间
    
                        oldPeoplePhysicalExaminationEntity.setCode(UUID.randomUUID().toString());
                        oldPeoplePhysicalExaminationEntity.setIdCard(idcard);
                        oldPeoplePhysicalExaminationEntity.setMedicalNo(medicalNo);
                        oldPeoplePhysicalExaminationEntity.setPatientName(patientName);
                        oldPeoplePhysicalExaminationEntity.setOrgName(orgName);
                        oldPeoplePhysicalExaminationEntity.setOrgCode(orgCode);
                        oldPeoplePhysicalExaminationEntity.setJwDoctorCode(jwDoctorCode);
                        oldPeoplePhysicalExaminationEntity.setMedicalTime(DateUtil.fomrmatStringToTimeStamp(medicalTime));
                        oldPeoplePhysicalExaminationEntity.setCreateTime(DateUtil.getNowTimestamp());
                        oldPeoplePhysicalExaminationEntities.add(oldPeoplePhysicalExaminationEntity);
                    }
                    
                    if(!oldPeoplePhysicalExaminationEntities.isEmpty()){
                        logger.info("从基卫接口获取老年人体检记录数为"+oldPeoplePhysicalExaminationEntities.size());
                        oldPeoplePhysicalExaminationDao.save(oldPeoplePhysicalExaminationEntities);
                    }else{
                        logger.info("从基卫接口获取老年人体检记录数个数为"+oldPeoplePhysicalExaminationEntities.size());
                    }
                }else{
                    String jwMessage = jwData.getString("MESSAGE");
                    throw new Exception("从基卫接口获取老年人体检记,请求基卫接口失败:"+jwMessage);
                }
                
            }else{
                throw new Exception("从基卫接口获取老年人体检记请求失败,"+errmsg);
            }
        }else{
            throw new Exception("从基卫接口获取老年人体检记请求失败,无数据返回!");
        }
    }
}

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

@ -2,6 +2,7 @@ package com.yihu.wlyy.util;
import org.apache.commons.lang3.StringUtils;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
@ -844,4 +845,25 @@ public class DateUtil {
		cal.add(Calendar.DAY_OF_YEAR,day);
		return cal.getTime();
	}
	
	/**
	 * 转换日期字符串为Timestamp YYYY-MM-DD HH:MM:SS
	 * @return
	 */
	public static Timestamp fomrmatStringToTimeStamp(String dateStr){
		
		Timestamp ts = Timestamp.valueOf(dateStr);
		
		return ts;
	}
	
	/**
	 * 获取当前时间的Timestamp
	 * @return
	 */
	public static Timestamp getNowTimestamp(){
		Date date = new Date();
		Timestamp nousedate = new Timestamp(date.getTime());
		return nousedate;
	}
}

+ 34 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java

@ -572,4 +572,38 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /**
     *根据时间范围同步老年人体检记录
     *@author huangwenjie
     *@date 2017/10/18 21:40
     */
    @RequestMapping(value = "/executeOldPeoplePhysicalExaminationSynByTime", method = RequestMethod.POST)
    @ApiOperation("根据时间范围同步老年人体检记录")
    public String executeOldPeoplePhysicalExaminationSynByTime(
            @ApiParam(name="startdate", value="开始时间:yyyy-mm-dd")
            @RequestParam(value = "startdate",required = true) String startdate,
            @ApiParam(name="enddate", value="结束时间:yyyy-mm-dd")
            @RequestParam(value = "enddate",required = true) String enddate) {
        try {
            
            String start = "";
            String end = "";
            
            do{
                start = startdate + " 00:00:00";
                end = startdate + " 23:59:59";
                //根据时间范围同步老年人体检记录,并同步到本地数据库
                jwPrescriptionService.getOldPeoplePhysicalExaminationByTime(start,end);
                
                startdate = DateUtil.getNextDay(startdate,1);
                
            }while (!startdate.equals(enddate));
            
            return write(200, "执行成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

+ 2 - 0
patient-co/patient-co-wlyy-job/src/main/resources/system.properties

@ -110,6 +110,8 @@ sign_family_pay_result_migisterno_job=0 0/3 * * * ?
# 家庭签约支付回调失败,每3分钟一次去主动查询并保存
onepay_query_job=0 0/3 * * * ?
# 老年人体检记录同步,每天凌晨1点执行一次
old_people_tijian_syb_job=0 0 1 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html

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

@ -177,8 +177,8 @@ public class SwaggerConfig {
                        regex("/idc10/.*"),
                        regex("/im_new/.*"),
                        regex("/version/.*"),
                        regex("/express/.*")
                        regex("/express/.*"),
                        regex("/esstatistics/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -188,10 +188,6 @@ public class StatisticsESService {
     */
    public long getIntervalIncrement(String startDate, String endDate, String area, int level, String index) throws Exception {
        // 截止日期包含当天,则获取最新的更新时间
        if (endDate.compareTo(dateFormat.format(new Date())) >= 0) {
            endDate = elasticsearchUtil.getQuotaTime();
        }
        SaveModel saveModel = elasticsearchUtil.findOneDateQuotaLevel0(startDate,endDate,area,level,index,"1");
        return saveModel.getResult2();
    }
@ -269,10 +265,6 @@ public class StatisticsESService {
    public long getTotalAmount(String startDate, String endDate, String area, int level, String index, String level2_type)  throws Exception {
        SaveModel saveModel = null;
        // 截止日期包含当天,则获取最新的更新时间
        if (endDate.compareTo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())) >= 0) {
            endDate = elasticsearchUtil.getQuotaTime();
        }
        if(StringUtils.isNotEmpty(level2_type)){
            saveModel = elasticsearchUtil.findOneDateQuotaLevel1(startDate,endDate,area,level,index,"1",level2_type);
        }else{
@ -295,7 +287,7 @@ public class StatisticsESService {
        //如果year有值 就按照年度来查询 即2017年 就是大于2017-06-30
        if (!org.springframework.util.StringUtils.isEmpty(year)) {
            startDate = year + "-06-30' ";
            startDate = year + "-06-30";
        }
        String levelTemp = level+"";
        if(StringUtils.isNotEmpty(lowLevel)){
@ -1598,66 +1590,6 @@ public class StatisticsESService {
            return new JSONArray();
        }
    }
    /**
     * 获取三师转签或高危人群签约
     *
     * @param endDate
     * @param area
     * @param level
     * @param index
     * @return
     */
    public JSONObject getSszqAndGwrq(String endDate, String area, int level, String index) {
        JSONObject json = new JSONObject();
        // 查询语句
        String sql = " select " +
                "     ifnull(result,'0') amount" +
                " from  " +
                "     wlyy_quota_result " +
                " where " +
                "     quato_code = ? " +
                "   and level1_type = ? and del = '1'";
        if (level == 4) {
            // 市级别
            sql += " and city = ? ";
        } else if (level == 3) {
            // 区、城镇级别
            sql += " and town = ? ";
        } else if (level == 2) {
            // 机构级别
            sql += " and org_code = ? ";
        } else if (level == 1) {
            sql += " and qkdoctor_code = ?";
        }
        sql += "   order by quota_date DESC " +
                "   limit 0,1";
        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");
            if (total.equals("0")) {
                json.put("amount", 0L);
                json.put("num", 0L);
                json.put("rate", 0.0000D);
            } else {
                DecimalFormat df = new DecimalFormat("0.0000");
                String[] args = total.split("/");
                json.put("amount", Long.valueOf(args[0]));
                json.put("num", Long.valueOf(args[1]));
                json.put("rate", df.format(Long.valueOf(args[0]) * 1.0000 / Long.valueOf(args[1]) * 100));
            }
        } else {
            json.put("amount", 0L);
            json.put("num", 0L);
            json.put("rate", 0.0000D);
        }
        return json;
    }
    /**
     * 统计回复和未回复

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

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

+ 103 - 56
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -257,29 +258,33 @@ public class ElasticsearchUtil {
        }
        if (SaveModel.teamLevel.equals(low_level)) {
            sql.append("select team,teamName,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select team,teamName,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by team,teamName");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by hospital,hospitalName");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select town,townName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by town,townName");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select city,cityName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by city,cityName");
        }
        if (SaveModel.teamLevel.equals(level + "")) {
            sql.append(" and team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(level + "")) {
            sql.append(" and hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(level + "")) {
            sql.append(" and town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(level + "")) {
            sql.append(" and city='" + area + "'");
        if(StringUtils.isNotEmpty(area)){
            if (SaveModel.teamLevel.equals(level + "")) {
                sql.append(" team='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }
            sql.append(" and ");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
@ -293,11 +298,11 @@ public class ElasticsearchUtil {
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00') ");
            }
        }
        sql.append(groupBy);
@ -347,29 +352,33 @@ public class ElasticsearchUtil {
            low_level = lowLevel;
        }
        if (SaveModel.teamLevel.equals(low_level)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,sum(result1) result1, sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by team,teamName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select hospital,hospitalName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by hospital,hospitalName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select town,townName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by town,townName,slaveKey1,slaveKey1Name");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name");
        }
        if (SaveModel.teamLevel.equals(lowLevel)) {
            sql.append(" and team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(lowLevel)) {
            sql.append(" and hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(lowLevel)) {
            sql.append(" and town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
            sql.append(" and city='" + area + "'");
        if(StringUtils.isNotEmpty(area)){
            if (SaveModel.teamLevel.equals(level + "")) {
                sql.append(" team='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }
            sql.append(" and ");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
@ -385,11 +394,11 @@ public class ElasticsearchUtil {
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00') ");
            }
        }
        sql.append(groupBy);
@ -438,30 +447,32 @@ public class ElasticsearchUtil {
            low_level = lowLevel;
        }
        if (SaveModel.teamLevel.equals(low_level)) {
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,result1,result2 from wlyy_quota_test where 1=1 ");
            sql.append("select team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,result1,result2 from wlyy_quota_test where ");
            groupBy.append("  group by team,teamName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.OrgLevel.equals(low_level)) {
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select hospital,hospitalName,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by hospital,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,hospitalName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.townLevel.equals(low_level)) {
            sql.append("select town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by town,townName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        } else if (SaveModel.cityLevel.equals(low_level)) {
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where 1=1 ");
            sql.append("select city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name,sum(result1) result1,sum(result2) result2 from wlyy_quota_test where ");
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name,slaveKey2,slaveKey2Name");
        }
        if (SaveModel.teamLevel.equals(lowLevel)) {
            sql.append(" and team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(lowLevel)) {
            sql.append(" and hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(lowLevel)) {
            sql.append(" and town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
            sql.append(" and city='" + area + "'");
        if(StringUtils.isNotEmpty(area)){
            if (SaveModel.teamLevel.equals(level + "")) {
                sql.append(" team='" + area + "'");
            } else if (SaveModel.OrgLevel.equals(level + "")) {
                sql.append(" hospital='" + area + "'");
            } else if (SaveModel.townLevel.equals(level + "")) {
                sql.append(" town='" + area + "'");
            } else if (SaveModel.cityLevel.equals(level + "")) {
                sql.append(" city='" + area + "'");
            }
            sql.append(" and ");
        }
        sql.append(" and quotaCode='" + index + "'  ");
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
@ -481,11 +492,11 @@ public class ElasticsearchUtil {
        //根据时间维度分组
        if (StringUtils.isNotEmpty(interval)) {
            if (SaveModel.interval_month.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='month','time_zone'='+08:00') ");
            } else if (SaveModel.interval_week.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='week','time_zone'='+08:00') ");
            } else if (SaveModel.interval_day.equals(interval)) {
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d') ");
                groupBy.append(" ,date_histogram(field='quotaDate','interval'='1d','time_zone'='+08:00') ");
            }
        }
        sql.append(groupBy);
@ -497,12 +508,21 @@ public class ElasticsearchUtil {
     *
     * @param quotaDate
     */
    private String changeDate(String quotaDate) {
        return quotaDate + "T00:00:00+0800";
    private String changeDate(String quotaDate){
        try {
            quotaDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX").format(new SimpleDateFormat("yyyy-MM-dd").parse(quotaDate));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return quotaDate;
    }
    //获取最新更新的时间
    public String changeTime(String time) {
        time = time.replace(" ","T")+"+0800";
    public String changeTime(String time){
        try {
            time = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXX").format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return time;
    }
@ -732,7 +752,7 @@ public class ElasticsearchUtil {
     * @param level 等级 1 省 2 市 3 区县 4 机构 5团队
     * @param index  指标code
     * @param timelevel   1增量   2到达量(按照年度)
     * @param lowLevel  下一级区域等级   1 省 2 市 3 区县 4 机构 5团队
     * @param lowLevel  下一级区域等级   1 省 2 市 3 区县 4 机构 5团队.
     * @return
     * @throws Exception
     */
@ -816,4 +836,31 @@ public class ElasticsearchUtil {
        return list;
    }
    /**
     * 将参数转换成需要的SaveModel里的标识
     * @param level 等级  4 市  3区  2社区 1团队
     * @return
     * @author zhangdan
     * @time 2017-10-18
     */
    public int changeLevel(int level){
        int resultLevel =0;
        if (level==1){
            //团队转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.teamLevel);
        }else if(level==2){
            //社区转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.OrgLevel);
        }else if (level ==3){
            //区转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.townLevel);
        }else if (level==4){
            //市转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.cityLevel);
        }
        if(resultLevel==0){
            resultLevel = level;
        }
        return  resultLevel;
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java

@ -61,7 +61,7 @@ public class DoctorFollowUpController extends BaseController {
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/list_by_team", method = RequestMethod.GET)
    @RequestMapping(value = "/list_by_team", method = {RequestMethod.GET,RequestMethod.POST})
    @ResponseBody
    @ApiOperation(value = "查询居民随访列表")
    public String getListByPatientAndTeam(@RequestParam @ApiParam(value = "居民Code") String patient,

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

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

+ 127 - 74
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -4,6 +4,7 @@ import com.yihu.wlyy.service.app.statistics.StatisticsAllService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.app.statisticsES.StatisticsESService;
import com.yihu.wlyy.util.Constant;
import com.yihu.wlyy.util.ElasticsearchUtil;
import com.yihu.wlyy.util.ValueComparator;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.quota.vo.SaveModel;
@ -29,7 +30,7 @@ import java.util.TreeMap;
 * Created by chenweida on 2017/10/13.
 */
@Controller
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE,method = {RequestMethod.GET,RequestMethod.POST})
@RequestMapping(value = "/esstatistics", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET, RequestMethod.POST})
@Api(description = "ES统计查询")
public class EsStatisticsController extends BaseController {
@ -39,6 +40,8 @@ public class EsStatisticsController extends BaseController {
    StatisticsService statisticsService;
    @Autowired
    StatisticsAllService statisticsAllService;
    @Autowired
    ElasticsearchUtil elasticsearchUtil;
    /**
     * 获取统计时间
     *
@ -54,6 +57,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 指标按间隔统计  增量
     * 按年度统计是根据前端传的 startDate
@ -77,6 +81,8 @@ public class EsStatisticsController extends BaseController {
                                @RequestParam(required = false) String level2_type) {
        String tag = "";
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            if (index != null) {
@ -112,6 +118,8 @@ public class EsStatisticsController extends BaseController {
                                    @RequestParam(required = true) String index,
                                    @RequestParam(required = false) String year) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
@ -148,6 +156,8 @@ public class EsStatisticsController extends BaseController {
            @RequestParam(required = true) String index,
            @RequestParam(required = false) String level2_type) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
@ -187,6 +197,11 @@ public class EsStatisticsController extends BaseController {
                                        @RequestParam(required = false) String level2_type,
                                        @RequestParam(required = false) String year) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            if(StringUtils.isNotEmpty(lowLevel)){
                lowLevel = elasticsearchUtil.changeLevel(Integer.parseInt(lowLevel))+"";
            }
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
@ -222,6 +237,11 @@ public class EsStatisticsController extends BaseController {
                                            @RequestParam(required = false) String lowLevel,
                                            @RequestParam(required = false) String year) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            if(StringUtils.isNotEmpty(lowLevel)){
                lowLevel = elasticsearchUtil.changeLevel(Integer.parseInt(lowLevel))+"";
            }
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            JSONArray returnJa = new JSONArray();
@ -237,8 +257,8 @@ public class EsStatisticsController extends BaseController {
            JSONArray jsonArray2 = null;
            if (Constant.getNowYearByDate(endDate).equals(year)) {
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(endDate, endDate, area, level, indexes[1], sort, lowLevel);
            }else{
                String date=Integer.valueOf(year)+1+"-06-30";
            } else {
                String date = Integer.valueOf(year) + 1 + "-06-30";
                jsonArray2 = statisticsESService.getLowLevelIncrementDetail(date, date, area, level, indexes[1], sort, lowLevel);
            }
            jsonArrays.add(jsonArray2);
@ -274,13 +294,13 @@ public class EsStatisticsController extends BaseController {
                for (Map.Entry<String, JSONObject> one : index1.entrySet()) {
                    JSONObject map1 = one.getValue();
                    JSONObject map2 = index2.get(one.getKey());
                    String amount1="0";
                    if(map1!=null&&map1.has("amount")){
                        amount1=map1.get("amount").toString();
                    String amount1 = "0";
                    if (map1 != null && map1.has("amount")) {
                        amount1 = map1.get("amount").toString();
                    }
                    String amount2="0";
                    if(map2!=null&&map2.has("amount")){
                        amount2=map2.get("amount").toString();
                    String amount2 = "0";
                    if (map2 != null && map2.has("amount")) {
                        amount2 = map2.get("amount").toString();
                    }
                    String amount = amount1 + "," + amount2;
@ -321,6 +341,8 @@ public class EsStatisticsController extends BaseController {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) String index) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
@ -352,10 +374,12 @@ public class EsStatisticsController extends BaseController {
                                  @RequestParam(required = false) String year
    ) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            JSONObject result = new JSONObject();
            //year没传默认是今年
            if(org.springframework.util.StringUtils.isEmpty(year)){
                year= Constant.getNowYear();
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
@ -366,11 +390,11 @@ public class EsStatisticsController extends BaseController {
//                JSONObject signRate = statisticsAllService.getSignRate(endDate, area, level,year);
//                JSONObject signTaskRate = statisticsAllService.getSignTaskRate(endDate, area, level,year);
                long sign = statisticsESService.getIndexTotal(endDate, area, level, "13","2");
                long sign = statisticsESService.getIndexTotal(endDate, area, level, "13", "2");
                long weiJf = statisticsESService.getWeiJiaoFei(endDate, area, level);
                JSONObject jo = statisticsESService.getRenewPercent(level + "", area, Constant.getNowYear());
                JSONObject signRate = statisticsESService.getSignRate(endDate, area, level,year);
                JSONObject signTaskRate = statisticsESService.getSignTaskRate(endDate, area, level,year);
                JSONObject signRate = statisticsESService.getSignRate(endDate, area, level, year);
                JSONObject signTaskRate = statisticsESService.getSignTaskRate(endDate, area, level, year);
                result.put("sign", sign);
                result.put("expenses", weiJf);
@ -380,11 +404,11 @@ public class EsStatisticsController extends BaseController {
                result.put("renewRange", jo.get("renewRange"));//续签率  50.00%
            } else {
                //如果年度不是当前年度 就根据endDate 找到那个年度的最后一天的数据
                if(!Constant.getNowYear().equals(year)){
                    endDate=(Integer.valueOf(year)+1)+"-06-30";
                if (!Constant.getNowYear().equals(year)) {
                    endDate = (Integer.valueOf(year) + 1) + "-06-30";
                }
//                result = statisticsAllService.getGroupInfo(endDate, lowCode, area, level,year);
                result = statisticsESService.getGroupInfo(endDate, lowCode, area, level,year);
                result = statisticsESService.getGroupInfo(endDate, lowCode, area, level, year);
            }
            return write(200, "查询成功", "data", result);
@ -411,6 +435,9 @@ public class EsStatisticsController extends BaseController {
                                       int level,
                                       @RequestParam(required = false) String year) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            JSONArray result = statisticsESService.getSixFiveStatistics(endDate, area, level);
            return write(200, "查询成功", "data", result);
@ -445,16 +472,18 @@ public class EsStatisticsController extends BaseController {
                                     @RequestParam(required = false) String lowCode,
                                     @RequestParam(required = false) String year) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            if (index != null) {
                for (String idx : indexes) {
                    if(org.springframework.util.StringUtils.isEmpty(year)){
                        year=Constant.getNowYear();
                    if (org.springframework.util.StringUtils.isEmpty(year)) {
                        year = Constant.getNowYear();
                    }
//                    JSONObject json = statisticsAllService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode,year);
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode,year);
                    JSONObject json = statisticsESService.getDateTotal(startDate, endDate, interval, area, level, idx, lowCode, year);
                    result.put("index_" + idx, json);
                }
            }
@ -488,32 +517,39 @@ public class EsStatisticsController extends BaseController {
                                            @RequestParam(required = false) String lowLevel,
                                            @RequestParam(required = false) String lowCode) {
        try {
            int levelTemp = level;
            String lowLevelTemp = lowLevel;
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            if(StringUtils.isNotEmpty(lowLevel)){
                lowLevel = elasticsearchUtil.changeLevel(Integer.parseInt(lowLevel))+"";
            }
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            String year=Constant.getNowYearByDate(date);
            String year = Constant.getNowYearByDate(date);
            if (StringUtils.isNotEmpty(lowCode)) {
//                指定level下特定查询级别
                if (index.equals("17")) {
                    //sort=1&date=2017-07-13&level=4&index=17&area=350200&lowLevel=1&lowCode=3
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode,year));
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotalTeamLeader(date, area, level, index, sort, lowLevel, lowCode, year));
                } else {
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode,year));
                    result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotal(date, area, level, index, sort, lowLevel, lowCode, year));
                }
            } else {
//                未指定level下特定查询级别
                for (String idx : indexes) {
                    if (idx.equals("18") || index.equals("19")) {
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
                    } else if ( index.equals("21")) {
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, levelTemp, idx, sort, lowLevelTemp));
                    } else if (index.equals("21")) {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal2(date, area, level, idx, sort, lowLevel));
                    } else if (idx.equals("28")) {
                        //level=4&area=350200&sort=1&index=28&date=undefined&lowLevel=2
                        result.put("index_" + idx, statisticsESService.getAvgAllInfo(level, area, lowLevel));
                    } else if (idx.equals("13")) {
                        // sort=1&date=2017-07-13&level=4&index=13&area=350200&lowCode=
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel,year));
                        result.put("index_" + idx, statisticsESService.getLowLevelTotalTeamLeader(date, area, level, idx, sort, lowLevel, year));
                    } else {
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel,year));
                        result.put("index_" + idx, statisticsESService.getLowLevelTotal(date, area, level, idx, sort, lowLevel, year));
                    }
                }
            }
@ -541,8 +577,8 @@ public class EsStatisticsController extends BaseController {
        try {
            JSONObject result = new JSONObject();
            JSONObject sszq = statisticsESService.getSszqAndGwrq(endDate, area, level, "18");
            JSONObject gwrq = statisticsESService.getSszqAndGwrq(endDate, area, level, "19");
            JSONObject sszq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "18");
            JSONObject gwrq = statisticsAllService.getSszqAndGwrq(endDate, area, level, "19");
            result.put("sszq", sszq);
            result.put("gwrq", gwrq);
@ -571,11 +607,13 @@ public class EsStatisticsController extends BaseController {
                              @RequestParam(required = true) String index,
                              @RequestParam(required = false) String year) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            String[] indexes = index.split(",");
            JSONObject result = new JSONObject();
            for (String idx : indexes) {
                Long total = statisticsESService.getIndexTotal(endDate, area, level, idx,"2");
                Long total = statisticsESService.getIndexTotal(endDate, area, level, idx, "2");
                result.put("index_" + idx, total);
            }
@ -626,12 +664,16 @@ public class EsStatisticsController extends BaseController {
                                              @RequestParam(required = false) String lowlevel,
                                              @RequestParam(required = false) String year) {
        try {
//新         版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            if(StringUtils.isNotEmpty(lowlevel)){
                lowlevel = elasticsearchUtil.changeLevel(Integer.parseInt(lowlevel))+"";
            }
            JSONObject data = null;
            if (Constant.getNowYear().equals(year)) {
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel,null);
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel, null);
            } else if (org.springframework.util.StringUtils.isEmpty(year)) {
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel,null);
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel, null);
//                data = statisticsService.getConsultingStatisticsListAll(level, area, lowlevel, year);
            } else {
@ -647,6 +689,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 咨询统计
     * 咨询分析页面具体交互与业务分析内一致,即按市、区、社区、机构有不同展示,可一级级进入查看
@ -663,6 +706,8 @@ public class EsStatisticsController extends BaseController {
                                     @RequestParam(required = true) String area,
                                     @RequestParam(required = false) String year) {
        try {
            //版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            JSONObject data = null;
//            if (Constant.getNowYear().equals(year)) {
//                //查今年的查找redis即可
@ -675,7 +720,7 @@ public class EsStatisticsController extends BaseController {
//                //去数据库查找年份
//                data = statisticsService.getConsultingTitleWithYear(level, area, year);
//            }
            data = statisticsESService.getConsultingTitle(level, area,year);
            data = statisticsESService.getConsultingTitle(level, area, year);
            if (data != null) {
                return write(200, "查询成功", "data", data);
            } else {
@ -708,7 +753,9 @@ public class EsStatisticsController extends BaseController {
//            } else {
//                return write(200, "查询成功", "data", statisticsService.getCoutListByTimeYear(level, area, year));
//            }
            return write(200, "查询成功", "data", statisticsESService.getCoutListByTime(level,area,year));
            //版与旧版统计适配
            level = elasticsearchUtil.changeLevel(Integer.parseInt(level))+"";
            return write(200, "查询成功", "data", statisticsESService.getCoutListByTime(level, area, year));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
@ -732,6 +779,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取得分平均数
     *
@ -768,6 +816,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 统计当前团队,签约人数,服务次数,平均满意度
     *
@ -817,6 +866,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取咨询数和未回复数
     *
@ -838,6 +888,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取机构内服务排行
     *
@ -879,6 +930,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 判断团队是否是团队长
     *
@ -917,6 +969,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 计算团队医生月或周咨询未回复和总数折线图
     *
@ -941,6 +994,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队内这成员,未回复数,总数,结束咨询数
     *
@ -964,6 +1018,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取Doctor咨询结果
     *
@ -986,6 +1041,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队随访量折线统计图
     *
@ -1008,6 +1064,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamDoctorFollowupLine")
    @ResponseBody
    public String getTeamDoctorFollowupLine(@RequestParam(required = true) String type,
@ -1022,6 +1079,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 根据团队获取团队底下用户列表
     *
@ -1046,6 +1104,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生随访头信息
     *
@ -1068,6 +1127,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取待预约量团队统计则线图
     *
@ -1090,6 +1150,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生预约量团队统计则线图
     *
@ -1114,6 +1175,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队待预约量医生列表信息
     *
@ -1138,6 +1200,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生待预信息
     *
@ -1160,6 +1223,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康指导折线图
     *
@ -1182,6 +1246,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队医生则线图
     *
@ -1206,6 +1271,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队指导总数List
     *
@ -1230,6 +1296,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取医生健康指导头部信息
     *
@ -1252,6 +1319,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康教育折线统计
     *
@ -1274,6 +1342,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队健康
     *
@ -1297,6 +1366,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取团队成员健康教育列表
     *
@ -1321,6 +1391,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamDoctorEduTitle")
    @ResponseBody
    public String getTeamDoctorEduTitle(@RequestParam(required = true) String teamCode,
@ -1334,6 +1405,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getDotorInfo")
    @ResponseBody
    public String getDotorInfo(String code) {
@ -1344,6 +1416,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/getTeamRenewChangeLine")
    @ResponseBody
    public String getTeamRenewChangeLine(@RequestParam(required = true) String teamCode,
@ -1357,23 +1430,25 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    @RequestMapping("/cleanDoctorScore")
    @ResponseBody
    public String cleanDoctorScore(){
        try{
    public String cleanDoctorScore() {
        try {
            return write(200, "清洗完成", "data", statisticsAllService.cleanDoctorScore());
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取转签率和续签率
     * 前端:续签进展
     *
     * <p>
     * //@param index 42,43,44 (52,53,54 服务类型维度)
     * @param level 等级  4 市  3区  2社区 1团队
     * @param area  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code
     * @param area  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code.
     * @param year  年份 非比传
     * @param lowCode 服务类型维度code(老年人3,高血压4,糖尿病5)
     * @return
@ -1389,12 +1464,13 @@ public class EsStatisticsController extends BaseController {
        try {
            //return write(200, "查询成功", "data", statisticsService.getRenewPercentAndChangePercent(index,level, code, year,lowCode));
            return write(200,"查询成功!","data",statisticsESService.getRenewPercentAndChangePercent(changeLevel(level),area,year,lowCode));
            return write(200,"查询成功!","data",statisticsESService.getRenewPercentAndChangePercent(elasticsearchUtil.changeLevel(level),area,year,lowCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 获取转签人数,转签原因分析,转签分布
     * 前端:签约数据分析,团队转签详情
@ -1409,6 +1485,8 @@ public class EsStatisticsController extends BaseController {
            @RequestParam(required = true) String level,
            @RequestParam(required = true) String code) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(Integer.parseInt(level))+"";
            String switchIndex = "";
            String switchIndexReson = "";
            String signIn = "";
@ -1448,6 +1526,7 @@ public class EsStatisticsController extends BaseController {
            return error(-1, "查询失败");
        }
    }
    /**
     * 去年的签约量,续签量和续签率 列表
     *
@ -1483,7 +1562,7 @@ public class EsStatisticsController extends BaseController {
            }
            result.put("index_"+index, statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, level, index, sort, lowLevel, year,lowCode));
//            result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, changeLevel(level), index, sort, String.valueOf(changeLevel(Integer.valueOf(lowLevel))), year, lowCode));
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
@ -1494,42 +1573,16 @@ public class EsStatisticsController extends BaseController {
    @RequestMapping("/getLevelTotalSingle")
    @ResponseBody
    public String getLevelTotalSingle(@ApiParam(name="date", value="日期标识") @RequestParam(required = true)String date,
                                      @ApiParam(name="area", value="区域code") @RequestParam(required = true)String area,
                                      @ApiParam(name="level", value="级别") @RequestParam(required = true)int level){
        try{
            return write(200, "查询成功", "data", statisticsESService.getLowLevelTotalSingle2(date,area,level));
    public String getLevelTotalSingle(@ApiParam(name = "date", value = "日期标识") @RequestParam(required = true) String date,
                                      @ApiParam(name = "area", value = "区域code") @RequestParam(required = true) String area,
                                      @ApiParam(name = "level", value = "级别") @RequestParam(required = true) int level) {
        try {
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            return write(200, "查询成功", "data", statisticsESService.getLowLevelTotalSingle2(date, area, level));
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败");
        }
    }
    /**
     * 将参数转换成需要的SaveModel里的标识
     * @param level 等级  4 市  3区  2社区 1团队
     * @return
     * @author zhangdan
     * @time 2017-10-18
     */
    public int changeLevel(int level){
        int resultLevel =0;
        if (level==1){
            //团队转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.teamLevel);
        }else if(level==2){
            //社区转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.OrgLevel);
        }else if (level ==3){
            //区转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.townLevel);
        }else if (level==4){
            //市转成SaveModel里的标识
            resultLevel = Integer.valueOf(SaveModel.cityLevel);
        }
        if(resultLevel==0){
            resultLevel = level;
        }
        return  resultLevel;
    }
}

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

@ -1487,13 +1487,14 @@ public class StatisticsController extends BaseController {
     *
     * @param index 42,43,44 (52,53,54 服务类型维度)
     * @param level 等级  4 市  3区  2社区 1团队
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code
     * @param code  市 默认是厦门市 350200  区 就是区的code  社区就是社区的code 团队就是团队的code.
     * @param year  年份 非比传
     * @param lowCode 服务类型维度code(老年人3,高血压4,糖尿病5)
     * @return
     */
    @RequestMapping(value = "/getRenewPercentAndChangePercent", method = RequestMethod.GET)
    @ResponseBody
    @Deprecated
    public String getRenewPercentAndChangePercent(
            @RequestParam(required = true) String index,//续签index
            @RequestParam(required = true) String level,