Browse Source

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

trick9191 7 years ago
parent
commit
43319877cf
22 changed files with 355 additions and 101 deletions
  1. 3 6
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodPressure.java
  2. 3 5
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodSugger.java
  3. 3 5
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java
  4. 14 6
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/SignController.java
  5. 12 1
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/SignZYService.java
  6. 22 4
      patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftService.java
  7. 3 3
      patient-co/patient-co-statistics/src/main/resources/application.yml
  8. 12 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java
  9. 41 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PatientDiseaseConditionSynJob.java
  10. 5 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/repository/patient/PatientDao.java
  11. 40 3
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  12. 58 0
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  13. 59 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/quota/JobController.java
  14. 3 0
      patient-co/patient-co-wlyy-job/src/main/resources/system.properties
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctoreSchemeBloodPressureDao.java
  16. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/DoctrorSchemeBloodSuggerDao.java
  17. 3 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java
  18. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java
  19. 16 16
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  20. 51 43
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java
  21. 3 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  22. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java

+ 3 - 6
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodPressure.java

@ -32,7 +32,7 @@ public class DoctorSchemeBloodPressure extends IdEntity {
    private Timestamp createTime;      //创建时间
    private Short alertTag;            //是否提醒用户
    private String content;            //方案说明
    private Short del;          //0为正常,1为删除
    private Integer del;          //0为正常,1为删除
    @Basic
    @Column(name = "name")
@ -210,14 +210,11 @@ public class DoctorSchemeBloodPressure extends IdEntity {
        this.content = content;
    }
    @Basic
    @Column(name = "del")
    public Short getDel() {
    public Integer getDel() {
        return del;
    }
    public void setDel(Short del) {
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 3 - 5
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/scheme/DoctorSchemeBloodSugger.java

@ -36,7 +36,7 @@ public class DoctorSchemeBloodSugger extends IdEntity {
    private Timestamp createTime;
    private Short alertTag;                 //是否提醒用户
    private String content;                 //方案说明
    private Short del;          //0为正常,1为删除
    private Integer del;          //0为正常,1为删除
    @Basic
    @Column(name = "name")
@ -242,13 +242,11 @@ public class DoctorSchemeBloodSugger extends IdEntity {
        return alertTag;
    }
    @Basic
    @Column(name = "del")
    public Short getDel() {
    public Integer getDel() {
        return del;
    }
    public void setDel(Short del) {
    public void setDel(Integer del) {
        this.del = del;
    }

+ 3 - 5
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientSchemeList.java

@ -16,7 +16,7 @@ public class PatientSchemeList extends IdEntity {
    private String code;
    private String patientcode;
    private String schemecode;
    private Short type;//方案类型:1为血糖,2为血压
    private Integer type;//方案类型:1为血糖,2为血压
    private String doctorcode;
    private Timestamp createTime;
@ -51,13 +51,11 @@ public class PatientSchemeList extends IdEntity {
        this.schemecode = schemecode;
    }
    @Basic
    @Column(name = "type")
    public Short getType() {
    public Integer getType() {
        return type;
    }
    public void setType(Short type) {
    public void setType(Integer type) {
        this.type = type;
    }

+ 14 - 6
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/controller/SignController.java

@ -7,6 +7,7 @@ import com.zoe.phip.ssp.sdk.ApiException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@ -74,13 +75,20 @@ public class SignController {
	@RequestMapping(value = "getSickFamilyDoctorSpecialistControl",method = RequestMethod.POST)
	@ApiOperation("查询家签慢病患者定标情况接口")
	public Result getSickFamilyDoctorSpecialistControl(
			@ApiParam(name="TIME_START",value="修改的开始时间",defaultValue = "2016-9-1 00:00:00")
			@RequestParam(value="TIME_START",required = true) String TIME_START,
			@ApiParam(name="TIME_END",value="修改的开始时间",defaultValue = "2016-9-1 12:00:00")
			@RequestParam(value="TIME_END",required = true) String TIME_END){
			@ApiParam(name="TIME_START",value="修改的开始时间",defaultValue = "2017-6-6 00:00:00")
			@RequestParam(value="TIME_START",required = false) String TIME_START,
			@ApiParam(name="TIME_END",value="修改的开始时间",defaultValue = "2017-6-7 23:59:59")
			@RequestParam(value="TIME_END",required = false) String TIME_END,
			@ApiParam(name="IDENTITY_CARD_NO",value="身份证号",defaultValue = "360502194503120013")
			@RequestParam(value="IDENTITY_CARD_NO",required = false) String IDENTITY_CARD_NO){
		try {
			String response = signZYService.getSickFamilyDoctorSpecialistControl(TIME_START,TIME_END);
			return Result.success("查询签约成功!","");
			String response = "";
			if(StringUtils.isBlank(IDENTITY_CARD_NO)){
				response = signZYService.getSickFamilyDoctorSpecialistControl(TIME_START,TIME_END);
			}else{
				response = signZYService.getSickFamilyDoctorSpecialistControlByIdcard(IDENTITY_CARD_NO);
			}
			return Result.success("查询成功!",response);
		} catch (Exception ex) {
			ex.printStackTrace();
			if(ex instanceof ApiException)

+ 12 - 1
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/SignZYService.java

@ -139,7 +139,7 @@ public class SignZYService {
    }
    /**
     * 查询家签慢病患者定标情况接口
     * 根据时间范围查询家签慢病患者定标情况接口
     * @param time_start
     * @param time_end
     * @return
@ -149,4 +149,15 @@ public class SignZYService {
        String response = zysoftService.getSickFamilyDoctorSpecialistControl(time_start,time_end,hospitalMapping[0],hospitalMapping[1]);
        return response;
    }
    /**
     * 根据身份证号查询家签慢病患者定标情况接口
     * @param identity_card_no
     * @return
     */
    public String getSickFamilyDoctorSpecialistControlByIdcard(String identity_card_no) throws Exception {
        String[] hospitalMapping = getHospitalMapping(null); //获取机构映射
        String response = zysoftService.getSickFamilyDoctorSpecialistControlByIdcard(identity_card_no,hospitalMapping[0],hospitalMapping[1]);
        return response;
    }
}

+ 22 - 4
patient-co-service/wlyy_service/src/main/java/com/yihu/wlyy/service/service/ZysoftService.java

@ -120,8 +120,8 @@ public class ZysoftService {
        paramsList.put("msgHeader",msgHeader);
        paramsList.put("msgBody",msgBody);
        //System.out.print("msgHeader:"+msgHeader+"\r\n");
        //System.out.print("msgBody:"+msgBody+"\r\n");
        System.out.print("msgHeader:"+msgHeader+"\r\n");
        System.out.print("msgBody:"+msgBody+"\r\n");
        //新增日志
        String method = "POST";
@ -771,8 +771,26 @@ public class ZysoftService {
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("TEAM_CODE",time_start);
        params.put("TEAM_CODE",time_end);
        params.put("TIME_START",time_start);
        params.put("TIME_END",time_end);
        String response = postSecond("getSickFamilyDoctorSpecialistControl","查询家签慢病患者定标情况接口",params,header,false);
        return response;
    }
    /**
     * 根据身份证号查询家签慢病患者定标情况接口
     * @param identity_card_no
     * @return
     */
    public String getSickFamilyDoctorSpecialistControlByIdcard(String identity_card_no,String hospital,String licence) throws Exception{
        Map<String,String> header = new HashMap<>();
        header.put("ORGCODE",hospital);
        header.put("LICENCE",licence);
        Map<String,String> params = new HashMap<>();
        params.put("IDENTITY_CARD_NO",identity_card_no);
        String response = postSecond("getSickFamilyDoctorSpecialistControl","查询家签慢病患者定标情况接口",params,header,false);

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

@ -167,15 +167,15 @@ spring:
  datasource:
    primaryReadWrite:
      url: jdbc:mysql://10.59.22.7:3306/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      url: jdbc:mysql://10.95.22.7:3306/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123
    primaryRead:
      url: jdbc:mysql://10.59.22.7:3306/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      url: jdbc:mysql://10.95.22.7:3306/wlyy?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
      username: wlyy
      password: jkzlehr@123
    im: #im库:
      url: jdbc:mysql://10.59.22.7:3306/im?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      url: jdbc:mysql://10.95.22.7:3306/im?useUnicode=true&characterEncoding=utf-8&autoReconnect=true
      username: im
      password: im!)123

+ 12 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.event;
import com.yihu.wlyy.job.*;
import com.yihu.wlyy.job.consult.EvaluateScoreJob;
import com.yihu.wlyy.job.consult.FinishConsultJob;
import com.yihu.wlyy.redis.RedisThread;
import com.yihu.wlyy.util.SystemConf;
import org.slf4j.Logger;
@ -101,7 +102,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            //居民24小时未回复的咨询自动关闭 每小时59分开始执行一次
            if (!quartzHelper.isExistJob("finish_consult_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("finish_consult_job");
                quartzHelper.addJob(PrescriptionExecuteSickSettleJob.class, trigger, "finish_consult_job", new HashMap<String, Object>());
                quartzHelper.addJob(FinishConsultJob.class, trigger, "finish_consult_job", new HashMap<String, Object>());
                logger.info("finish_consult_job success");
            } else {
                logger.info("finish_consult_job exist");
@ -116,6 +117,16 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("doctor_feldsher_template_job reorder job job exist");
            }
            //慢病患者定标情况同步,每天凌晨2点执行一次
            if (!quartzHelper.isExistJob("patient_disease_contion_syn_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("patient_disease_contion_syn_job");
                quartzHelper.addJob(PatientDiseaseConditionSynJob.class, trigger, "patient_disease_contion_syn_job", new HashMap<String, Object>());
                logger.info("patient_disease_contion_syn_job  job success");
            } else {
                logger.info("patient_disease_contion_syn_job  job exist");
            }
            // 启动redis 消息队列线程
            logger.info("redis message start");

+ 41 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/PatientDiseaseConditionSynJob.java

@ -0,0 +1,41 @@
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/9/17 21:28
 */
public class PatientDiseaseConditionSynJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(PatientDiseaseConditionSynJob.class);
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("START=====开始更新慢病患者定标情况的JOB");
        try {
            String startdate = DateUtil.getStringDateShort() + " 00:00:00";
            String enddate = DateUtil.getStringDateShort() + " 23:59:59";
            //根据起止时间查询家签慢病患者定标情况,并同步到本地数据库
            jwPrescriptionService.getPatientDiseaseContentMapByTime(startdate,enddate);
            logger.info("END========开始更新慢病患者定标情况成功JOB");
        }catch (Exception e){
            e.printStackTrace();
            logger.info("END===ERROE===开始更新慢病患者定标情况JOB,message:"+e.getMessage());
        }
    }
}

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

@ -64,4 +64,9 @@ public interface PatientDao extends PagingAndSortingRepository<Patient, Long> {
    //获取所有的openid并排重
    @Query("select distinct p.openid from Patient p where p.openid is not null and p.openid <> '' ")
    List<String> findOpenids();
    //根据患者身份证号更新患者颜色定标情况
    @Modifying
    @Query("update Patient p set p.diseaseCondition = ?2 where p.idcard = ?1")
    void updatePatientDiseascontionByIdcard(String idcard, Integer diseaseCondition);
}

+ 40 - 3
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -24,7 +24,8 @@ import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,12 +33,14 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springside.modules.utils.Clock;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
@ -49,6 +52,8 @@ import java.util.*;
@Transactional(rollbackFor = Exception.class)
public class PatientService extends TokenService {
    private static final Logger logger = LoggerFactory.getLogger(PatientService.class);
    @Autowired
    private SignFamilyDao signFamilyDao;
    @Autowired
@ -64,6 +69,9 @@ public class PatientService extends TokenService {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private JpaTransactionManager transactionManager;
    private Clock clock = Clock.DEFAULT;
    //可续签月份
    private int[] canRenewMonth = {4, 5, 6, 7};
@ -982,4 +990,33 @@ public class PatientService extends TokenService {
    public void save(Patient patient) {
        patientDao.save(patient);
    }
    /**
     * 根据患者身份证号更新患者颜色定标情况
     * @param idcard_diseasecontion_map
     */
    @Transactional
    public void updatePatientDiseascontionByIdcard(HashMap<String, Integer> idcard_diseasecontion_map){
        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
        def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务
        TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
        try {
            for (String idcard : idcard_diseasecontion_map.keySet()) {
                patientDao.updatePatientDiseascontionByIdcard(idcard,idcard_diseasecontion_map.get(idcard));
            }
            //事务提交
            transactionManager.commit(status);
        } catch (Exception ex) {
            logger.info("更新患者颜色定标情况出错,从基卫获取的患者数据为:START");
            for (String idcard : idcard_diseasecontion_map.keySet()) {
                logger.info("idcard:"+idcard);
                logger.info("idcard:"+idcard_diseasecontion_map.get(idcard));
            }
            logger.info("更新患者颜色定标情况出错,从基卫获取的患者数据为:END");
            //报错事务回滚
            transactionManager.rollback(status);
        }
    }
}

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

@ -1,9 +1,11 @@
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.patient.prescription.Prescription;
import com.yihu.wlyy.repository.prescription.PrescriptionDao;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
@ -16,6 +18,7 @@ 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;
@ -36,6 +39,8 @@ public class JwPrescriptionService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PrescriptionDao prescriptionDao;
    @Autowired
    private PatientService patientService;
    /**
     * 获取字典列表
@ -228,4 +233,57 @@ public class JwPrescriptionService {
        return response;
    }
    /**
     * 根据起止时间查询家签慢病患者定标情况,并同步到本地数据库
     * @param startdate
     * @param enddate
     * @return
     */
    public void getPatientDiseaseContentMapByTime(String startdate, String enddate)throws Exception {
        logger.info("查询家签慢病患者定标情况,开始时间"+startdate+",结束时间:"+enddate);
        String url = jwUrl + "/third/sign/getSickFamilyDoctorSpecialistControl";
        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");
        HashMap<String, Integer> idcard_diseasecontion_map = new HashMap<>();
        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++) {
                        JSONObject json = dataArray.getJSONObject(i);
                        String idcard = json.getString("IDENTITY_CARD_NO");//身份证号码
                        Integer diseaseCondition = json.getInteger("SPECIALIST_CONTROL");//定标情况【 0 绿标 1 黄标 2 红标】
                        idcard_diseasecontion_map.put(idcard,diseaseCondition);
                    }
                    if(idcard_diseasecontion_map != null && !idcard_diseasecontion_map.keySet().isEmpty()){
                        logger.info("从基卫接口获取需要更新定标情况的慢病患者个数为"+idcard_diseasecontion_map.keySet().size());
                        patientService.updatePatientDiseascontionByIdcard(idcard_diseasecontion_map);
                    }else{
                        logger.info("从基卫接口获取需要更新定标情况的慢病患者个数为"+idcard_diseasecontion_map.keySet().size());
                    }
                }else{
                    String jwMessage = jwData.getString("MESSAGE");
                    throw new Exception("获取慢病患者定标情况,请求基卫接口失败:"+jwMessage);
                }
            }else{
                throw new Exception("获取慢病患者定标情况请求失败,"+errmsg);
            }
        }else{
            throw new Exception("获取慢病患者定标情况请求失败,无数据返回!");
        }
    }
}

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

@ -8,14 +8,18 @@ import com.yihu.wlyy.service.app.disease.PatientDiseaseService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.statistics.StatisticsService;
import com.yihu.wlyy.service.quota.JobService;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.util.DateUtil;
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.data.redis.core.StringRedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.text.SimpleDateFormat;
@ -40,15 +44,17 @@ public class JobController extends BaseController {
    private final QuartzHelper quartzHelper;
    private final DoctorWorkTimeService workTimeService;
    private final StatisticsService statisticsService;
    private final JwPrescriptionService jwPrescriptionService;
    @Autowired
    public JobController(StatisticsService statisticsService, JobService jobService, StringRedisTemplate redisTemplate, DoctorWorkTimeService workTimeService, PatientDiseaseService diseaseService, QuartzHelper quartzHelper) {
    public JobController(StatisticsService statisticsService, JobService jobService, StringRedisTemplate redisTemplate, DoctorWorkTimeService workTimeService, PatientDiseaseService diseaseService, QuartzHelper quartzHelper,JwPrescriptionService jwPrescriptionService) {
        this.statisticsService = statisticsService;
        this.jobService = jobService;
        this.redisTemplate = redisTemplate;
        this.workTimeService = workTimeService;
        this.diseaseService = diseaseService;
        this.quartzHelper = quartzHelper;
        this.jwPrescriptionService = jwPrescriptionService;
    }
    /**
@ -463,4 +469,56 @@ public class JobController extends BaseController {
            return error(-1, e.getMessage());
        }
    }
    /**
     *立即执行当天的慢病患者定标情况同步
     *@author huangwenjie
     *@date 2017/9/17 14:16
     */
    @RequestMapping(value = "/executePatientDiseaseConditionSynJob", method = RequestMethod.POST)
    @ApiOperation("立即执行当天的慢病患者定标情况同步")
    public String executePatientDiseaseConditionSynJob() {
        try {
            quartzHelper.startNow(PatientDiseaseConditionSynJob.class, "PATIENT-DISEASE-CONDITION-SYN", null);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
    /**
     *根据时间范围执行慢病患者定标情况同步
     *@author huangwenjie
     *@date 2017/9/17 14:16
     */
    @RequestMapping(value = "/executePatientDiseaseConditionSynJobByTime", method = RequestMethod.POST)
    @ApiOperation("根据时间范围执行慢病患者定标情况同步")
    public String executePatientDiseaseConditionSynJobByTime(
            @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.getPatientDiseaseContentMapByTime(start,end);
                startdate = DateUtil.getNextDay(startdate,1);
            }while (!startdate.equals(enddate));
            return write(200, "执行成功");
        } catch (Exception e) {
            error(e);
            return error(-1, e.getMessage());
        }
    }
}

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

@ -98,6 +98,9 @@ finish_consult_job=* 59 * * * ?
#提醒有监测方案的居民上传数据,每29分钟执行一次
doctor_feldsher_template_job=0 0/29 * * * ?
# 病患者定标情况同步JOB (每天2点一次)
patient_disease_contion_syn_job=0 0 2 * * ?
#统一支付平台支付成功后页面跳转地址
return_url={server}/wx/html/qygl/html/pay_result.html

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

@ -25,5 +25,5 @@ public interface DoctoreSchemeBloodPressureDao extends
    @Modifying
    @Query("update DoctorSchemeBloodPressure set del=?1 where doctorcode=?2 and code=?3")
    void updateDel(int i, String doctorcode, String schemecode);
    void updateDelStatus(int del, String doctorcode, String schemecode);
}

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

@ -30,5 +30,5 @@ public interface DoctrorSchemeBloodSuggerDao extends
    @Modifying
    @Query("update DoctorSchemeBloodSugger set del=?1 where doctorcode=?2 and code=?3")
    void updateDel(int i, String doctorcode, String schemecode);
    void updateDelStatus(int del, String doctorcode, String schemecode);
}

+ 3 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/scheme/PatientSchemeListDao.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.repository.patient.scheme;
import com.yihu.wlyy.entity.patient.PatientSchemeList;
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;
@ -14,6 +15,7 @@ public interface PatientSchemeListDao extends
        PagingAndSortingRepository<PatientSchemeList, Long>,
        JpaSpecificationExecutor<PatientSchemeList> {
    @Query("delete from PatientSchemeList where patientcode=?1 and type=?2 and schemecode=?3")
    @Modifying
    @Query("delete PatientSchemeList where patientcode=?1 and type=?2 and schemecode=?3")
    void delByPatientCodeAndSchemeCode(String patientcode, int i, String code);
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/health/PatientHealthGuidanceService.java

@ -248,7 +248,7 @@ public class PatientHealthGuidanceService extends BaseService {
	 */
	public JSONArray findByPatientAndGuidanceAndTeam(String patient,long teamCode,int page,int pageSize){
		Sort sort = new Sort(Sort.Direction.DESC,"createTime");
		PageRequest pageRequest = new PageRequest(0, pageSize, sort);
		PageRequest pageRequest = new PageRequest(page, pageSize, sort);
		Page<Object> result = patientHealthGuidanceDao.findByPatientAndTeamCode(patient,teamCode,pageRequest);
		JSONArray array = new JSONArray();
		if (result != null) {

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

@ -309,7 +309,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    "  ) " +
                    "  AND t1. STATUS > 0  AND t1.admin_team_code = ?";
            if(isSlowDisease){
                sql = sql + "  AND p.diease >0 " ;
                sql = sql + "  AND p.disease >0 " ;
            }
            if(StringUtils.isNotBlank(diseaseCondition)){
                sql = sql + " AND p.disease_condition ="+diseaseCondition;
@ -4090,16 +4090,16 @@ public class SignPatientLabelInfoService extends BaseService {
                " FROM " +
                "    wlyy_sign_family t1 " +
                " JOIN wlyy_sign_patient_label_info t2 ON t1.patient = t2.patient " +
                " JOIN wlyy_patiend t3 ON t1.patient = t3.code " +
                " JOIN wlyy_patient t3 ON t1.patient = t3.code " +
                (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                " WHERE " +
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND t2.status = 1) " +
                "    AND t2.status = 1 " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "")+
                (StringUtils.isNotEmpty(diseaseCondition) ? " AND t3.diseaseCondition = ? " : "");
                (StringUtils.isNotEmpty(diseaseCondition) ? " AND t3.disease_condition in (?) " : "");
        sql = sql + " AND t3.disease > 0 AND t3.status > 0 ";
        if (matcher.find()) {
@ -4141,17 +4141,17 @@ public class SignPatientLabelInfoService extends BaseService {
            signList = jdbcTemplate.queryForList(sql, args);
        }
        //查询患者设备绑定情况
        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
        List<Map<String,Object>> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql);
        if(!patientCodeDeviceTypes.isEmpty()){
            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
                String user = String.valueOf(patientCodeDeviceType.get("user"));
                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
                patientDeviceTypeMap.put(user,sum);
            }
        }
//        //查询患者设备绑定情况
//        String _pdsql = "select user,sum(category_code) deviceType FROM wlyy_patient_device GROUP BY user";
//        List<Map<String,Object>> patientCodeDeviceTypes =  jdbcTemplate.queryForList(_pdsql);
//
//        if(!patientCodeDeviceTypes.isEmpty()){
//            for (Map<String,Object> patientCodeDeviceType : patientCodeDeviceTypes) {
//                String user = String.valueOf(patientCodeDeviceType.get("user"));
//                String sum = String.valueOf(patientCodeDeviceType.get("deviceType"));
//                patientDeviceTypeMap.put(user,sum);
//            }
//        }
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
@ -4348,7 +4348,7 @@ public class SignPatientLabelInfoService extends BaseService {
                "  AND" +
                (isIdcard ? " t2.idcard like ? " : " t1.name like ? ");
        sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.diease >0 AND t2.status >0 ";
        sqlTemp = sqlTemp + " AND t2.disease_condition = "+diseaseCondition+" AND t2.disease >0 AND t2.status >0 ";
        String sql = sqlTemp + " order by t2.standard_status,t2.disease_condition,t2.disease,t2.openid desc  limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);

+ 51 - 43
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/scheme/DoctorSchemeService.java

@ -25,6 +25,7 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import java.util.*;
@ -249,7 +250,7 @@ public class DoctorSchemeService {
            doctorSchemeBloodSugger.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodSugger.setContent(content);
            doctorSchemeBloodSugger.setCreateTime(DateUtil.getNowTimestamp());
            doctorSchemeBloodSugger.setDel(new Short("0"));
            doctorSchemeBloodSugger.setDel(0);
            results.add(doctorSchemeBloodSugger);
        }
@ -308,7 +309,7 @@ public class DoctorSchemeService {
            doctorSchemeBloodPressure.setAlertTag(datalist.getJSONObject(i).getShort("alertTag"));
            doctorSchemeBloodPressure.setContent(content);
            doctorSchemeBloodPressure.setCreateTime(DateUtil.getNowTimestamp());
            doctorSchemeBloodPressure.setDel(new Short("0"));
            doctorSchemeBloodPressure.setDel(0);
            results.add(doctorSchemeBloodPressure);
        }
@ -326,20 +327,23 @@ public class DoctorSchemeService {
     * @param type
     * @throws Exception
     */
    @Transactional
    public void savePatientScheme(String doctorcode, String schemecode, String type,String patientcodes) throws Exception {
        List<String> patientcodeList = new ArrayList<>();
        JSONObject dataObj = JSON.parseObject(patientcodes);
        JSONArray codes = dataObj.getJSONArray("patientcodes");
        if (codes == null || codes.size() == 0) {
            throw new Exception("居民列表不能为空");
        }
        String[] codes = patientcodes.split(",");
        for (int i = 0; i < codes.size(); i++) {
            patientcodeList.add(codes.get(i).toString());
        if(patientcodes.contains(",")){
            for (String code : codes) {
                patientcodeList.add(code);
            }
        }else{
            patientcodeList.add(patientcodes);
        }
        if (!patientcodeList.isEmpty()) {
            //使用事务控制批量更新
@ -348,22 +352,21 @@ public class DoctorSchemeService {
            TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
            try {
                for (String patientcode : patientcodeList) {
                    PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                    patientSchemeListDao.delByPatientCodeAndSchemeCode(patientcode, Integer.parseInt(type), schemecode);
                    PatientSchemeList patientSchemeListObj = new PatientSchemeList();
                    patientSchemeListObj.setCode(UUID.randomUUID().toString());
                    patientSchemeListObj.setPatientcode(patientcode);
                    patientSchemeListObj.setSchemecode(schemecode);
                    patientSchemeListObj.setDoctorcode(doctorcode);
                    Short _type = new Short(type);
                    patientSchemeListObj.setType(_type);
                    patientSchemeListObj.setType(Integer.parseInt(type));
                    patientSchemeListObj.setCreateTime(DateUtil.getNowTimestamp());
                    patientSchemeListDao.save(patientSchemeListObj);
                }
                //事务提交
                transactionManager.commit(status);
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
                //报错事务回滚
                transactionManager.rollback(status);
            }
@ -380,11 +383,11 @@ public class DoctorSchemeService {
     * @param enddate
     * @return
     */
    public JSONArray getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate) throws Exception{
    public JSONObject getSlowDiseaseTeaminfos(String teamCode, int getcolor, int getstands, int gethealthindex, String startdate, String enddate) throws Exception{
        List<Patient> patients = patientDao.findAllSignPatientTeamcode(teamCode);
        JSONArray result = new JSONArray();
        JSONObject result = new JSONObject();
        JSONObject green = new JSONObject();//绿标
        JSONObject yellow = new JSONObject();//黄标
        JSONObject red = new JSONObject();//红标
@ -414,10 +417,10 @@ public class DoctorSchemeService {
        List<String> bloodsugar_patientcodes = new ArrayList<>();
        if(!patients.isEmpty()){
            for (Patient patient : red_patients) {
            for (Patient patient : patients) {
                //获取居民颜色标签
                if(1 == getcolor){
                if(1 == getcolor && patient.getDiseaseCondition() != null){
                    switch (patient.getDiseaseCondition()){
                        case 0:
                            green_patients.add(patient);
@ -434,15 +437,18 @@ public class DoctorSchemeService {
                }
                //获取预警居民CODES
                if(1 == getstands && 1 == patient.getStandardStatus()){
                if(1 == getstands && (patient.getStandardStatus() !=null && patient.getStandardStatus() ==1)){
                    if( 1 == patient.getDisease() || 3 == patient.getDisease()){
                        bloodpressure_patientcodes.add(patient.getCode());
                    }
                    if(patient.getDisease() != null){
                        if( 1 == patient.getDisease() || 3 == patient.getDisease()){
                            bloodpressure_patientcodes.add(patient.getCode());
                        }
                    if( 2 == patient.getDisease() || 3 == patient.getDisease()){
                        bloodsugar_patientcodes.add(patient.getCode());
                        if( 2 == patient.getDisease() || 3 == patient.getDisease()){
                            bloodsugar_patientcodes.add(patient.getCode());
                        }
                    }
                }
            }
        }
@ -450,19 +456,19 @@ public class DoctorSchemeService {
        if(1 == getcolor){
            green.put("greencount",green_patients.size());
            yellow.put("yellowcount",yellow_patients.size());
            red.put("redcount",red_patients.size());
            result.add(green);
            result.add(yellow);
            result.add(red);
            result.put("greencount",green_patients.size());
            result.put("yellowcount",yellow_patients.size());
            result.put("redcount",red_patients.size());
//            result.add(green);
//            result.add(yellow);
//            result.add(red);
        }
        if(1 == getstands){
            pressure_standard.put("pressure_standard",bloodpressure_patientcodes);
            sugar_standard.put("sugar_standard",bloodsugar_patientcodes);
            result.add(pressure_standard);
            result.add(sugar_standard);
            result.put("pressure_standard",bloodpressure_patientcodes);
            result.put("sugar_standard",bloodsugar_patientcodes);
//            result.add(pressure_standard);
//            result.add(sugar_standard);
        }
@ -498,15 +504,15 @@ public class DoctorSchemeService {
                }
            }
            pressure_count.put("pressure_count",pressure);
            pressure_unusual_ount.put("pressure_unusual_count",pressure_unusual);
            sugar_count.put("sugar_count",sugar);
            sugar_unusual_count.put("sugar_unusual_count",sugar_unusual);
            result.put("pressure_count",pressure);
            result.put("pressure_unusual_count",pressure_unusual);
            result.put("sugar_count",sugar);
            result.put("sugar_unusual_count",sugar_unusual);
            result.add(pressure_count);
            result.add(pressure_unusual_ount);
            result.add(sugar_count);
            result.add(sugar_unusual_count);
//            result.add(pressure_count);
//            result.add(pressure_unusual_ount);
//            result.add(sugar_count);
//            result.add(sugar_unusual_count);
        }
@ -519,14 +525,16 @@ public class DoctorSchemeService {
     * @param schemecode
     * @param type
     */
    @Transactional
    public void delDoctorScheme(String doctorcode, String schemecode, String type) throws Exception{
        if("1".equals(type)){
            doctroSchemeBloodSuggerDao.updateDel(1,doctorcode,schemecode);
            doctroSchemeBloodSuggerDao.updateDelStatus(1,doctorcode,schemecode);
        }
        if("2".equals(type)){
            doctoreSchemeBloodPressureDao.updateDel(1,doctorcode,schemecode);
            doctoreSchemeBloodPressureDao.updateDelStatus(1,doctorcode,schemecode);
        }
    }
}

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

@ -806,10 +806,11 @@ public class SignPatientLabelInfoController extends BaseController {
            page = page - 1;
            JSONArray result = labelInfoService.searchSlowDiseasePatientByNameOrLabel(getUID(), filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize,diseaseCondition);
            //JSONArray result = labelInfoService.searchPatientByNameOrLabel("test00000000005", filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize);
//            JSONArray result = labelInfoService.searchPatientByNameOrLabel("xy201703150222", filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize,diseaseCondition);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return error(-1, "查询失败");
        }
    }
@ -845,7 +846,7 @@ public class SignPatientLabelInfoController extends BaseController {
            @ApiParam(name="startdate", value="体征数据开始时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "startdate",required = false,defaultValue = "")  String startdate,
            @ApiParam(name="enddate", value="体征数据结束时间yyyy-mm-dd hh:mm:ss") @RequestParam(value = "enddate",required = false,defaultValue = "")  String enddate){
        try {
            com.alibaba.fastjson.JSONArray result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate);
            com.alibaba.fastjson.JSONObject result = doctorSchemeService.getSlowDiseaseTeaminfos(teamCode,getcolor,getstands,gethealthindex,startdate,enddate);
            return write(200, "查询成功", "data", result);
        }catch (Exception e){
            //日志文件中记录异常信息

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/scheme/DoctroSchemeController.java

@ -124,7 +124,7 @@ public class DoctroSchemeController extends BaseController {
            @ApiParam(name="doctorcode", value="医生CODE") @RequestParam(value = "doctorcode",required = true) String doctorcode,
            @ApiParam(name="schemecode", value="方案CODE") @RequestParam(value = "schemecode",required = true) String schemecode,
            @ApiParam(name="type", value="血糖1、血压2") @RequestParam(value = "type",required = true) String type,
            @ApiParam(name="patientcodes", value="JASON数据") @RequestParam(value = "patientcodes",required = true) String patientcodes){
            @ApiParam(name="patientcodes", value="用户CODE,多个用逗号拼接") @RequestParam(value = "patientcodes",required = true) String patientcodes){
        try {
            doctorSchemeService.savePatientScheme(doctorcode,schemecode,type,patientcodes);
            return write(200, "操作成功");