zd_123 7 年 前
コミット
720c226b25
30 ファイル変更704 行追加174 行削除
  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. 5 0
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/dao/QuartzJobConfigDao.java
  4. 6 4
      patient-co/patient-co-statistics-es/src/main/java/com/yihu/wlyy/statistics/service/JobService.java
  5. 5 6
      patient-co/patient-co-statistics-es/src/main/resources/quartz.properties
  6. 9 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  7. 42 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/OldPeoplePhysicalExaminationSynJob.java
  8. 14 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/oldpeople/OldPeoplePhysicalExaminationDao.java
  9. 8 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/app/oldpeople/OldPeoplePhysicalExaminationService.java
  10. 79 4
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  11. 22 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/util/DateUtil.java
  12. 34 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  13. 2 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  14. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java
  15. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneDetailInfoDao.java
  16. 11 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildImmuneInfoDao.java
  17. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ChildInfoDao.java
  18. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneDictDao.java
  19. 19 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneHospitalDictDao.java
  20. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneMappingDao.java
  21. 13 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/ImmuneNeedleDao.java
  22. 4 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientFamilyMemberDao.java
  23. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/family/FamilyMemberService.java
  24. 155 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/prenatalInspector/ChildImmuneService.java
  25. 1 69
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  26. 33 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DateUtil.java
  27. 68 48
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/ElasticsearchUtil.java
  28. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/followup/DoctorFollowUpController.java
  29. 35 10
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/prenatalInspector/ChildImmuneController.java
  30. 53 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.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;
	

+ 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

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

+ 68 - 48
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;
@ -270,18 +271,22 @@ public class ElasticsearchUtil {
            groupBy.append("  group by city,cityName");
        }
        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 + "'");
        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(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" imeLevel='" + timeLevel + "'  ");
        sql.append(" areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + 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);
@ -360,18 +365,22 @@ public class ElasticsearchUtil {
            groupBy.append("  group by city,cityName,slaveKey1,slaveKey1Name");
        }
        if (SaveModel.teamLevel.equals(lowLevel)) {
            sql.append(" team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(lowLevel)) {
            sql.append(" hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(lowLevel)) {
            sql.append(" town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
            sql.append(" 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(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" imeLevel='" + timeLevel + "'  ");
        sql.append(" areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + 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);
@ -450,20 +459,22 @@ public class ElasticsearchUtil {
            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(StringUtils.isNotEmpty(area)){
        if (SaveModel.teamLevel.equals(lowLevel)) {
            sql.append(" team='" + area + "'");
        } else if (SaveModel.OrgLevel.equals(lowLevel)) {
            sql.append(" hospital='" + area + "'");
        } else if (SaveModel.townLevel.equals(lowLevel)) {
            sql.append(" town='" + area + "'");
        } else if (SaveModel.cityLevel.equals(lowLevel)) {
            sql.append(" city='" + 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(" and timeLevel='" + timeLevel + "'  ");
        sql.append(" and areaLevel='5'");
        sql.append(" quotaCode='" + index + "'  ");
        sql.append(" imeLevel='" + timeLevel + "'  ");
        sql.append(" areaLevel='5'");
        if (StringUtils.isNotEmpty(startDate)) {
            sql.append(" and quotaDate>='" + 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;
    }

+ 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,"绑定失败");
//        }
//    }
//
//
//}

+ 53 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -81,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) {
@ -116,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();
@ -152,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();
@ -191,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();
@ -226,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();
@ -325,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) {
@ -356,6 +374,8 @@ 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)) {
@ -416,7 +436,8 @@ public class EsStatisticsController extends BaseController {
                                       @RequestParam(required = false) String year) {
        try {
            level=elasticsearchUtil.changeLevel(level);
            //新版与旧版统计适配
            level = elasticsearchUtil.changeLevel(level);
            JSONArray result = statisticsESService.getSixFiveStatistics(endDate, area, level);
            return write(200, "查询成功", "data", result);
@ -451,6 +472,8 @@ 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();
@ -494,9 +517,14 @@ 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(",");
            level=elasticsearchUtil.changeLevel(level);
            lowLevel=elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))+"";
            JSONObject result = new JSONObject();
            String year = Constant.getNowYearByDate(date);
            if (StringUtils.isNotEmpty(lowCode)) {
@ -511,7 +539,7 @@ public class EsStatisticsController extends BaseController {
//                未指定level下特定查询级别
                for (String idx : indexes) {
                    if (idx.equals("18") || index.equals("19")) {
                        result.put("index_" + idx, statisticsAllService.getLowLevelTotalSpecial(date, area, level, idx, sort, lowLevel));
                        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")) {
@ -549,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);
@ -579,6 +607,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();
@ -634,7 +664,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))+"";
            }
            JSONObject data = null;
            if (Constant.getNowYear().equals(year)) {
                data = statisticsESService.getConsultingStatisticsList(level, area, lowlevel, null);
@ -672,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即可
@ -717,6 +753,8 @@ public class EsStatisticsController extends BaseController {
//            } else {
//                return write(200, "查询成功", "data", statisticsService.getCoutListByTimeYear(level, area, year));
//            }
            //版与旧版统计适配
            level = elasticsearchUtil.changeLevel(Integer.parseInt(level))+"";
            return write(200, "查询成功", "data", statisticsESService.getCoutListByTime(level, area, year));
        } catch (Exception e) {
            e.printStackTrace();
@ -1447,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 = "";
@ -1513,16 +1553,16 @@ public class EsStatisticsController extends BaseController {
            JSONObject result = new JSONObject();
            //如果年度是空,按当前时间计算是年度是属于那个年度
            if (StringUtils.isEmpty(year)) {
            if (org.springframework.util.StringUtils.isEmpty(year)) {
                year = Constant.getNowYear();
            }
            //lowLevel不传默认是 level-1
            if (StringUtils.isEmpty(lowLevel)) {
            if (org.springframework.util.StringUtils.isEmpty(lowLevel)) {
                lowLevel = level - 1 + "";
            }
            result.put("index_" + index, statisticsESService.getLevelTwoLowLevelTotalSignAndRenew(area, elasticsearchUtil.changeLevel(level), index, sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year, lowCode));
            //result.put("index_" + index, statisticsAllService.getLevelTwoLowLevelTotalSignAndRenew(area, elasticsearchUtil.changeLevel(level), index, sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(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) {
@ -1537,6 +1577,8 @@ public class EsStatisticsController extends BaseController {
                                      @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);