浏览代码

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

humingfen 7 年之前
父节点
当前提交
1d6c29dd0a
共有 18 个文件被更改,包括 971 次插入100 次删除
  1. 89 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRecordLog.java
  2. 2 2
      edu-article/JkEdu/src/Article.sql.xml
  3. 2 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java
  4. 4 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/message/MessageDao.java
  5. 14 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientRecordLogDao.java
  6. 12 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  7. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java
  8. 35 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statisticsES/StatisticsESService.java
  9. 515 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java
  10. 15 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  11. 141 51
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  12. 10 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  13. 44 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java
  14. 31 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java
  15. 0 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java
  16. 3 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java
  17. 3 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java
  18. 48 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdSpecialistController.java

+ 89 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientRecordLog.java

@ -0,0 +1,89 @@
package com.yihu.wlyy.entity.patient;/**
 * Created by nature of king on 2018/7/12.
 */
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * @author wangzhinan
 * @create 2018-07-12 14:36
 * @desc 居民取消关注日志
 **/
@Entity
@Table(name = "wlyy_patient_record_log")
public class PatientRecordLog extends IdEntity implements Serializable{
    @Column(name = "patient")
    private String patient;
    @Column(name = "patient_name")
    private String patientName;
    @Column(name = "idCard")
    private String idCard;
    @Column(name = "ssc")
    private String ssc;
    @Column(name = "open_id")
    private String openId;
    @Column(name = "czrq")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date czrq;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getIdCard() {
        return idCard;
    }
    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
    public String getOpenId() {
        return openId;
    }
    public void setOpenId(String openId) {
        this.openId = openId;
    }
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 2 - 2
edu-article/JkEdu/src/Article.sql.xml

@ -31,8 +31,8 @@ User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
		</Sql>-->
		</Sql>-->
		<Sql name='getCollectionArticleList'>
		<Sql name='getCollectionArticleList'>
			<![CDATA[
			<![CDATA[
select aa.* ,n.BrowseNumber,n.PointNumber,n.CollectionNumber,IFNULL(n.CommentNumber,0) as CommentNumber, IFNULL(n.PushNumber,0) as PushNumber,n.InsertTime as collectionInsertTime from (
select m.* from Org_Article m  INNER JOIN User_ArticleCollection n on  m.articleid=n.ArticleId and  1=1 and  m.ArticleState =1  @UserParam) as aa LEFT JOIN
select aa.* ,n.BrowseNumber,n.PointNumber,n.CollectionNumber,IFNULL(n.CommentNumber,0) as CommentNumber, IFNULL(n.PushNumber,0) as PushNumber from (
select m.*,n.InsertTime as collectionInsertTime from Org_Article m  INNER JOIN User_ArticleCollection n on  m.articleid=n.ArticleId and  1=1 and  m.ArticleState =1  @UserParam) as aa LEFT JOIN
User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
User_ArticleStatistics n on aa.ArticleId=n.ArticleId where 1=1 @Condition
			]]>
			]]>
		</Sql>
		</Sql>

+ 2 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SurveyScreenResultDao.java

@ -18,8 +18,8 @@ public interface SurveyScreenResultDao extends PagingAndSortingRepository<Survey
    @Query(nativeQuery = true, value = "SELECT * FROM `wlyy_survey_screen_result` WHERE template_code=?1 and patient_code = ?2 and source=1 ORDER BY czrq DESC LIMIT 1")
    @Query(nativeQuery = true, value = "SELECT * FROM `wlyy_survey_screen_result` WHERE template_code=?1 and patient_code = ?2 and source=1 ORDER BY czrq DESC LIMIT 1")
    List<SurveyScreenResult> findNewOneByTemplateCode(String templateCode,String patientCode);
    List<SurveyScreenResult> findNewOneByTemplateCode(String templateCode,String patientCode);
    @Query("select a from  SurveyScreenResult a where a.patientCode=?1 and a.templateCode=?2")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode);
    @Query("select a from  SurveyScreenResult a where a.patientCode=?1 and a.templateCode=?2 and a.source=?3")
    List<SurveyScreenResult> getByPatientCodeAndTemplateCode(String patientCode,String templateCode,int source);
    @Modifying
    @Modifying
    @Query("update SurveyScreenResult s set s.isAgain=0 where s.code=?1")
    @Query("update SurveyScreenResult s set s.isAgain=0 where s.code=?1")

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

@ -60,13 +60,13 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.sender=?2 and a.tzType=?3")
    @Query("update Message a set a.read = 0 where a.receiver = ?1 and a.sender=?2 and a.tzType=?3")
    int updateHealthIndexMessageByPatient(String doctor, String patient, String type);
    int updateHealthIndexMessageByPatient(String doctor, String patient, String type);
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,16,17) order by a.czrq desc")
    @Query("select a from Message a where a.read= 1 and a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,16,17,18) order by a.czrq desc")
    List<Message> getSystemMessageUnread(String doctor);
    List<Message> getSystemMessageUnread(String doctor);
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7) order by a.createTime desc")
    @Query("select a from Message a where a.receiver = ?1 and a.prescriptionStatus=?2 and a.type in (6,7) order by a.createTime desc")
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    List<Message> getSysTemMessageByPrescription(String doctor, String prescriptionStatus);
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,301) and (a.del = '1' or a.del is null) ")
    @Query("select a from Message a where a.receiver = ?1 and a.type not in (1,2,6,7,12,101,14,15,301,16,17,18) and (a.del = '1' or a.del is null) ")
    List<Message> getSystemMessage(String doctor, Pageable pageRequest);
    List<Message> getSystemMessage(String doctor, Pageable pageRequest);
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.prescriptionStatus='0' ")
    @Query("select a from Message a where a.receiver = ?1 and a.type=?2 and a.prescriptionStatus='0' ")
@ -130,10 +130,10 @@ public interface MessageDao extends PagingAndSortingRepository<Message, Long>, J
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 17 order by a.czrq desc")
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 17 order by a.czrq desc")
    List<Message> getFamilyTransfer(String receiver);
    List<Message> getFamilyTransfer(String receiver);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 18 order by a.czrq desc")
    @Query("select a from Message a where a.read = 1 and a.receiver = ?1 and a.state = 1 and a.type = 18 order by a.czrq desc")
    List<Message> getFamilySign(String receiver);
    List<Message> getFamilySign(String receiver);
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 18")
    @Query("select a from Message a where a.receiver = ?1 and a.state = 1 and a.type = 18 and a.read = 1")
    List<Message> selectFamilySign(String receiver,Pageable pageableRequest);
    List<Message> selectFamilySign(String receiver,Pageable pageableRequest);
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = 17 order by a.czrq desc")
    @Query("select a from Message a where a.read= ?2 and a.receiver = ?1 and a.state = 1 and a.over = ?3 and a.type = 17 order by a.czrq desc")

+ 14 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/PatientRecordLogDao.java

@ -0,0 +1,14 @@
package com.yihu.wlyy.repository.patient;/**
 * Created by nature of king on 2018/7/12.
 */
import com.yihu.wlyy.entity.patient.PatientRecordLog;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * @author wangzhinan
 * @create 2018-07-12 15:02
 * @desc 取消关注记录
 **/
public interface PatientRecordLogDao extends PagingAndSortingRepository<PatientRecordLog, Long> {
}

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

@ -1120,6 +1120,18 @@ public class SignPatientLabelInfoService extends BaseService {
                } else {
                } else {
                    json.put("wechatFocusRemind", 1);
                    json.put("wechatFocusRemind", 1);
                }
                }
                //病情类型:0健康,1高血压,2糖尿病,3高血压+糖尿病
                json.put("disease", p.getDisease());
                // 病情:0绿标,1黄标,2红标,
                json.put("diseaseCondition", p.getDiseaseCondition());
                //预警状态
                json.put("standardStatus", p.getStandardStatus());
                String deviceSql = "select group_concat(category_code) deviceType FROM wlyy_patient_device where user ='"+p.getCode()+"'";
                List<Map<String,Object>> deviceMapList = jdbcTemplate.queryForList(deviceSql);
                if (deviceMapList!=null && deviceMapList.size()>0){
                    //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
                    json.put("deviceType",deviceMapList.get(0).get("deviceType")==null?"":deviceMapList.get(0).get("deviceType"));
                }
                // 患者标签
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                json.put("labels", labels == null ? "" : labels);

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/message/MessageService.java

@ -234,7 +234,7 @@ public class MessageService extends BaseService {
            JSONObject  familyJson = new JSONObject();
            JSONObject  familyJson = new JSONObject();
            familyJson.put("title", familyList.get(0).getTitle());
            familyJson.put("title", familyList.get(0).getTitle());
            familyJson.put("type", familyList.get(0).getType());
            familyJson.put("type", familyList.get(0).getType());
            familyJson.put("msg", familyList.get(0).getContent());
            familyJson.put("msg", "您有"+familyList.size()+"个居民申请共管服务!");
            familyJson.put("msgTime", DateUtil.dateToStrLong(familyList.get(0).getCreateTime()));
            familyJson.put("msgTime", DateUtil.dateToStrLong(familyList.get(0).getCreateTime()));
            familyJson.put("relationCode",familyList.get(0).getRelationCode());
            familyJson.put("relationCode",familyList.get(0).getRelationCode());
            familyJson.put("reason",familyList.get(0).getReason());
            familyJson.put("reason",familyList.get(0).getReason());
@ -827,7 +827,7 @@ public class MessageService extends BaseService {
            JSONObject specialistObject = new JSONObject();
            JSONObject specialistObject = new JSONObject();
            specialistObject.put("title", specialist.get(0).getTitle());
            specialistObject.put("title", specialist.get(0).getTitle());
            specialistObject.put("type", specialist.get(0).getType());
            specialistObject.put("type", specialist.get(0).getType());
            specialistObject.put("msg", specialist.get(0).getContent());
            specialistObject.put("msg", "您有"+specialist.size()+"个居民申请共管服务");
            specialistObject.put("msgTime", DateUtil.dateToStrLong(specialist.get(0).getCreateTime()));
            specialistObject.put("msgTime", DateUtil.dateToStrLong(specialist.get(0).getCreateTime()));
            specialistObject.put("relationCode",specialist.get(0).getRelationCode());
            specialistObject.put("relationCode",specialist.get(0).getRelationCode());
            specialistJson.put("specialist",specialistObject);
            specialistJson.put("specialist",specialistObject);
@ -842,7 +842,7 @@ public class MessageService extends BaseService {
            JSONObject familyObject = new JSONObject();
            JSONObject familyObject = new JSONObject();
            familyObject.put("title", familyList.get(0).getTitle());
            familyObject.put("title", familyList.get(0).getTitle());
            familyObject.put("type", familyList.get(0).getType());
            familyObject.put("type", familyList.get(0).getType());
            familyObject.put("msg", familyList.get(0).getContent());
            familyObject.put("msg", "您有"+familyList.size()+"个居民筛查转诊通知");
            familyObject.put("msgTime", DateUtil.dateToStrLong(familyList.get(0).getCreateTime()));
            familyObject.put("msgTime", DateUtil.dateToStrLong(familyList.get(0).getCreateTime()));
            familyObject.put("relationCode",familyList.get(0).getRelationCode());
            familyObject.put("relationCode",familyList.get(0).getRelationCode());
            familyJson.put("familyList",familyObject);
            familyJson.put("familyList",familyObject);

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

@ -792,6 +792,15 @@ public class StatisticsESService {
        String filesize = df.format(size);
        String filesize = df.format(size);
        return filesize + "%";
        return filesize + "%";
    }
    }
    public int getRangeNum(int first, int second, int i) {
        if (second == 0 && first > 0) {
            return 100;
        } else if (second == 0 && first == 0) {
            return 0;
        }
        float size = (float) (first * 100) / second;
        return (int)(size*100);
    }
    public Double getRange2(int first, int second, int i) {
    public Double getRange2(int first, int second, int i) {
        if (second == 0 && first > 0) {
        if (second == 0 && first > 0) {
@ -5397,12 +5406,13 @@ public class StatisticsESService {
        return saveModel.getResult2().longValue();
        return saveModel.getResult2().longValue();
    }
    }
    public Map<String, Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year, String deviceType) throws Exception {
    public Map<String, Object> getLevelDeviceAndBinding(String area, int level, int sort, String lowLevel, String year, String deviceType,int sortType) throws Exception {
        String index_85 = "85";//设备发放量统计指标
        String index_85 = "85";//设备发放量统计指标
        String index_86 = "86";//设备绑定量统计指标
        String index_86 = "86";//设备绑定量统计指标
        String index_87 = "87";//设备使用量统计指标
        String index_87 = "87";//设备使用量统计指标
        String index_88 = "88";//设备异常数据24H统计指标
        String index_88 = "88";//设备异常数据24H统计指标
        String index_96 = "96";//设备本周使用量
        String index_96 = "96";//设备本周使用量
        String index_97 = "97";//设备本周使用量
        //String lastDate = year + "-06-30";
        //String lastDate = year + "-06-30";
        //String timeKey = elasticsearchUtil.getQuotaTime();
        //String timeKey = elasticsearchUtil.getQuotaTime();
        String timeKey = DateUtil.getStringDateShort();//当前时间
        String timeKey = DateUtil.getStringDateShort();//当前时间
@ -5419,6 +5429,7 @@ public class StatisticsESService {
//        List<SaveModel> endUseSaveModel = null;
//        List<SaveModel> endUseSaveModel = null;
        SaveModel useSaveModel = null;
        SaveModel useSaveModel = null;
        SaveModel anomalySaveModel = null;
        SaveModel anomalySaveModel = null;
        SaveModel anomalyCountSaveModel = null;
        String allCountSql = "";
        String allCountSql = "";
        String anomalyCountSql = "";
        String anomalyCountSql = "";
        String useCountSql = "";
        String useCountSql = "";
@ -5443,7 +5454,8 @@ public class StatisticsESService {
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "hemopiezometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "hemopiezometer");
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "hemopiezometer");
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_97, SaveModel.timeLevel_DDL, "hemopiezometer");
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =1 and i.status=1 and i.del=1 " + areaCondition;
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "hemopiezometer", "", low_level);
                break;
                break;
@ -5457,7 +5469,8 @@ public class StatisticsESService {
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, "glucometer", null, null);
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "glucometer");
                anomalySaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_88, SaveModel.timeLevel_DDL, "glucometer");
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel1(timeKey, area, level, index_97, SaveModel.timeLevel_DDL, "glucometer");
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where i.type =2 and i.status=1 and i.del=1 " + areaCondition;
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                allAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                bindingAmountList = elasticsearchUtil.findDateQuotaLevel1(timeKey, timeKey, area, level, index_86, SaveModel.timeLevel_DDL, "glucometer", "", low_level);
                break;
                break;
@ -5469,7 +5482,8 @@ public class StatisticsESService {
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 " + areaCondition;
                allCountSql = "SELECT COUNT(*) FROM device.wlyy_devices d where 1=1 " + areaCondition;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1  and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
//                useCountSql = "SELECT COUNT(DISTINCT p.device_sn)  FROM device.wlyy_patient_health_index p LEFT JOIN device.wlyy_devices d on d.device_code=p.device_sn WHERE p.type IN (1, 2) and p.del=1  and p.czrq>= '"+mondayTime+"' AND p.czrq < '"+currentTime+"' "+areaCondition ;
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
                useSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(DateUtil.getSundayOfThisDate(new Date()), area, level, index_96, SaveModel.timeLevel_ZL);
                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
                anomalyCountSaveModel = elasticsearchUtil.findOneDateQuotaLevel0(timeKey, area, level, index_97, SaveModel.timeLevel_DDL);
//                anomalyCountSql = " SELECT COUNT(i.id) FROM device.wlyy_patient_health_index i left join device.wlyy_devices d on i.device_sn=d.device_code where  i.status=1 and i.del=1 " + areaCondition;
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
//                startUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(mondayTime, mondayTime, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
//                endUseSaveModel = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_87, SaveModel.timeLevel_DDL, null, null);
                allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
                allAmountList = elasticsearchUtil.findDateQuotaLevel0(timeKey, timeKey, area, level, index_85, SaveModel.timeLevel_DDL, "", low_level);
@ -5503,7 +5517,8 @@ public class StatisticsESService {
        } else {
        } else {
            resultMap.put("totalUseRange", 0.0 + "%");//本周使用率
            resultMap.put("totalUseRange", 0.0 + "%");//本周使用率
        }
        }
        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql, Integer.class);
//        Integer totalAnomaly = jdbcTemplate.queryForObject(anomalyCountSql, Integer.class);
        Integer totalAnomaly = anomalyCountSaveModel!=null?anomalyCountSaveModel.getResult1().intValue():0;
        resultMap.put("totalAnomaly", totalAnomaly);//异常数据量
        resultMap.put("totalAnomaly", totalAnomaly);//异常数据量
        resultMap.put("totalIntervene", anomalySaveModel.getResult1());//干预指导数
        resultMap.put("totalIntervene", anomalySaveModel.getResult1());//干预指导数
        if (totalAnomaly > 0) {
        if (totalAnomaly > 0) {
@ -5547,10 +5562,21 @@ public class StatisticsESService {
            }
            }
            //对结果进行排序
            //对结果进行排序
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
            Collections.sort(resultList, new Comparator<Map<String, Object>>() {
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = (int) o1.get("allNum");
                    int map2value = (int) o2.get("allNum");
                public int compare(Map<String, Object> o1, Map<String, Object> o2) {
                    int map1value = 0;
                    int map2value = 0;
                    if(sortType==1){
                        map1value = (int) o1.get("allNum");
                        map2value = (int) o2.get("allNum");
                    }else if(sortType==2){
                        map1value = (int) o1.get("bindingNum");
                        map2value = (int) o2.get("bindingNum");
                    }else {
                        map1value = (int) o1.get("rateNum");
                        map2value = (int) o2.get("rateNum");
                    }
                    if (map1value - map2value > 0) {
                    if (map1value - map2value > 0) {
                        return sort == 1 ? -1 : 1;
                        return sort == 1 ? -1 : 1;
                    } else if (map1value - map2value < 0) {
                    } else if (map1value - map2value < 0) {
@ -5673,6 +5699,7 @@ public class StatisticsESService {
        reMap.put("allNum", allAmount);
        reMap.put("allNum", allAmount);
        reMap.put("bindingNum", bindingAmount);
        reMap.put("bindingNum", bindingAmount);
        reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        reMap.put("rate", getRange(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        reMap.put("rateNum", getRangeNum(bindingAmount, allAmount, 2));//续签率是 续签量/去年的签约数
        return reMap;
        return reMap;
    }
    }

+ 515 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/survey/SurveyScreenResultService.java

@ -4,15 +4,22 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.entity.doctor.survey.*;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.dict.SystemDictDao;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.doctor.*;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.service.survey.ManagerQuestionnaireService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -22,6 +29,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
/**
/**
@ -56,6 +64,40 @@ public class SurveyScreenResultService extends BaseService {
    private SignFamilyDao signFamilyDao;
    private SignFamilyDao signFamilyDao;
    @Autowired
    @Autowired
    private ManagerQuestionnaireService managerQuestionnaireService;
    private ManagerQuestionnaireService managerQuestionnaireService;
    @Autowired
    private SurveyDao surveyDao;
    @Autowired
    private SurveyQuestionsDao surveyQuestionsDao;
    @Autowired
    private SurveyLabelInfoDao surveyLabelInfoDao;
    @Autowired
    private SurveyQuestionsOptionsDao surveyQuestionsOptionsDao;
    @Autowired
    private SurveyUserDao surveyUserDao;
    @Autowired
    private SurveyFilterDao surveyFilterDao;
    @Autowired
    private SurveyQuestionnaireOptionsDao surveyQuestionnaireOptionsDao;
    @Autowired
    private SurveyQuestionnaireDao surveyQuestionnaireDao;
    @Autowired
    private SurveyTemplateOptionsDao surveyTemplateOptionsDao;
    @Autowired
    private SurveyAnswersDao surveyAnswersDao;
    @Autowired
    private SystemDictDao systemDictDao;
    @Autowired
    private SurveyDimensionDao surveyDimensionDao;
    @Autowired
    private SurveyDimensionDetailDao surveyDimensionDetailDao;
    @Autowired
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Autowired
    WeiXinOpenIdUtils weiXinOpenIdUtils;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    private Logger logger = LoggerFactory.getLogger(this.getClass());
@ -254,12 +296,13 @@ public class SurveyScreenResultService extends BaseService {
        infoMap.put("sex",IdCardUtil.getSexForIdcard_new(idcard));
        infoMap.put("sex",IdCardUtil.getSexForIdcard_new(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(idcard));
        infoMap.put("age",IdCardUtil.getAgeForIdcard(idcard));
        String templateCode = String.valueOf(infoMap.get("template_code"));
        String templateCode = String.valueOf(infoMap.get("template_code"));
        //String doctorCode = String.valueOf(infoMap.get("doctor"));
        String doctorCode = String.valueOf(infoMap.get("doctor"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
        String patientCode = String.valueOf(infoMap.get("patient_code"));
       /* Doctor doctor = doctorDao.findByCode(doctorCode);
        Doctor doctor = doctorDao.findByCode(doctorCode);
        if (doctor!=null){
        if (doctor!=null){
            infoMap.put("level",doctor.getLevel());
            infoMap.put("doctorName",doctor.getName());
            infoMap.put("doctorName",doctor.getName());
        }*/
        }
        json.put("info",infoMap);
        json.put("info",infoMap);
        /*String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+patientCode+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
        /*String healthSql ="SELECT value1,value2 FROM device.wlyy_patient_health_index WHERE user='"+patientCode+"' AND type=3 ORDER BY record_date DESC LIMIT 1";
        List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);
        List<Map<String,Object>> healthMapList = jdbcTemplate.queryForList(healthSql);
@ -344,7 +387,7 @@ public class SurveyScreenResultService extends BaseService {
        for (SurveyTemplates surveyTemplates : templates){
        for (SurveyTemplates surveyTemplates : templates){
            Map<String,Object> sMap = new HashedMap();
            Map<String,Object> sMap = new HashedMap();
            sMap.put("surveyTemplate",surveyTemplates);
            sMap.put("surveyTemplate",surveyTemplates);
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode()).size();
            int count =  surveyScreenResultDao.getByPatientCodeAndTemplateCode(patientCode,surveyTemplates.getCode(),2).size();
            sMap.put("myRecordCount",count);
            sMap.put("myRecordCount",count);
            mapList.add(sMap);
            mapList.add(sMap);
        }
        }
@ -353,14 +396,14 @@ public class SurveyScreenResultService extends BaseService {
    }
    }
    public List<SurveyScreenResult> patientGetResult(String patientCode){
    public List<SurveyScreenResult> patientGetResult(String patientCode){
        Map<String,Object> map = new HashedMap();
        Map<String,Object> map = new HashedMap();
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE patient_code='"+patientCode+"' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        String sql = "SELECT a.* FROM (SELECT * FROM wlyy_survey_screen_result WHERE source=2 and patient_code='"+patientCode+"' ORDER BY czrq DESC) a  GROUP BY a.template_code";
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        List<SurveyScreenResult> surveyScreenResultList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(SurveyScreenResult.class));
        return surveyScreenResultList;
        return surveyScreenResultList;
    }
    }
    public List<Map<String,Object>> getResultByTemplateCode(int pageNo,int pageSize,String templateCode,String patientCode){
    public List<Map<String,Object>> getResultByTemplateCode(int pageNo,int pageSize,String templateCode,String patientCode){
        int start = (pageNo-1)*pageSize;
        int start = (pageNo-1)*pageSize;
        String sql ="SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' limit ?,?";
        String sql ="SELECT st.*,ssr.code screenCode,ssr.screen_result,ssr.screen_result_score,ssr.czrq as screenCzrq,ssr.is_again FROM wlyy_survey_templates st LEFT JOIN wlyy_survey_screen_result ssr ON st.code = ssr.template_code WHERE ssr.source=2 and st.`code`='"+templateCode+"' AND ssr.patient_code='"+patientCode+"' order by ssr.czrq limit ?,?";
        return jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
        return jdbcTemplate.queryForList(sql,new Object[]{start,pageSize});
    }
    }
@ -505,4 +548,470 @@ public class SurveyScreenResultService extends BaseService {
        List<String> patients = jdbcTemplate.queryForList(sql, String.class);
        List<String> patients = jdbcTemplate.queryForList(sql, String.class);
        return patients;
        return patients;
    }
    }
    public String createSurvey(String doctor, JSONObject jsonStr, String accessToken) throws Exception {
//        问卷信息
        String surveyCode = getCode();
        String surveyName = jsonStr.getString("surveyName");
        String surveyComment = jsonStr.getString("comment");
        String templateCode = null;
        String send = jsonStr.get("send").toString();
        String templateLabel = jsonStr.getString("label");
        int status = 1;
//        自主创建
        int useType = 1;
        if (!StringUtils.isEmpty(jsonStr.getString("templateCode"))) {
//          模板创建
            useType = 0;
            templateCode = jsonStr.getString("templateCode");
        }
//      获取调查对象
        JSONObject surveyTarget = jsonStr.getJSONObject("surveyTarget");
        //            0不限 1男 2女
//        int sex = Integer.parseInt(surveyTarget.get("sex").toString());
        JSONArray sex = surveyTarget.getJSONArray("sex");
        JSONArray disease = surveyTarget.getJSONArray("disease");
        JSONArray service = surveyTarget.getJSONArray("service");
        JSONArray healthCondition = surveyTarget.getJSONArray("healthCondition");
        int sexList = 0;
        for (Object se : sex) {
            JSONObject sexJson = new JSONObject(se.toString());
            int label = sexJson.getInt("label");
            sexList = label;
            if (label != 0) {
                String dimensionCode = surveyDimensionDao.findByName("性别");
                String dimensionDetailCode = getCode();
//            SurveyDimensionDetail surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, sex == 1 ? "男" : "女", sex, "性别", 1, surveyCode);
//            modify by wjj 2017.7.24 居民标签更改
                SurveyDimensionDetail surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, sexJson.getString("labelName"), label, "性别", 1, surveyCode);
                surveyDimensionDetailDao.save(surveyDimensionDetail);
//          保存到筛选表
                SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
        List servList = new ArrayList();
        for (Object serv : service) {
            JSONObject servJson = new JSONObject(serv.toString());
            int label = servJson.getInt("label");
            servList.add(label);
            if (label == 0) {
                break;
            } else {
//                       ===================================
                String dimensionCode = surveyDimensionDao.findByName("服务类型");
                String dimensionDetailCode = getCode();
                SurveyDimensionDetail surveyDimensionDetail = null;
                surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, servJson.getString("labelName"), label, "服务类型", 3, surveyCode);
               /* switch (Integer.parseInt(serv.toString())) {
//                1.普通人群 2.慢病人群 3.65岁以上人群
                    case 1:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "普通人群", 1, "服务类型", 3, surveyCode);
                        break;
                    case 2:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "慢病人群", 2, "服务类型", 3, surveyCode);
                        break;
                    case 3:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "65岁以上人群", 3, "服务类型", 3, surveyCode);
                        break;
                }
*/
                surveyDimensionDetailDao.save(surveyDimensionDetail);
                SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
        List healthList = new ArrayList();
        for (Object health : healthCondition) {
            JSONObject healthJson = new JSONObject(health.toString());
            int label = healthJson.getInt("label");
            healthList.add(label);
            if (label == 0) {
                break;
            } else {
                String dimensionCode = surveyDimensionDao.findByName("健康状况");
                String dimensionDetailCode = getCode();
                String surveyFilterCode = getCode();
                SurveyDimensionDetail surveyDimensionDetail = null;
                surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, healthJson.getString("labelName"), label, "健康状况", 4, surveyCode);
                /*switch (Integer.parseInt(health.toString())) {
//                1.健康人群 2.患病人群 3.高危人群 4.恢复期人群
                    case 1:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "健康人群", 1, "健康状况", 4, surveyCode);
                        break;
                    case 2:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "患病人群", 2, "健康状况", 4, surveyCode);
                        break;
                    case 3:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "高危人群", 3, "健康状况", 4, surveyCode);
                        break;
                    case 4:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "恢复期人群", 4, "健康状况", 4, surveyCode);
                        break;
                }*/
                surveyDimensionDetailDao.save(surveyDimensionDetail);
                SurveyFilter surveyFilter = new SurveyFilter(surveyFilterCode, surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
        List diseaList = new ArrayList();
        for (Object disea : disease) {
            JSONObject diseaJson = new JSONObject(disea.toString());
            int label = diseaJson.getInt("label");
            diseaList.add(label);
            if (label == 0) {
//                dise += ",";
                break;
            } else {
                String dimensionCode = surveyDimensionDao.findByName("疾病类型");
                String dimensionDetailCode = getCode();
                SurveyDimensionDetail surveyDimensionDetail = null;
                surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, diseaJson.getString("labelName"), label, "疾病类型", 2, surveyCode);
                /*switch (Integer.parseInt(disea.toString())) {
//                  1.高血压 2糖尿病 3.高血压+糖尿病
                    case 1:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "高血压", 1, "疾病类型", 2, surveyCode);
                        break;
                    case 2:
                        surveyDimensionDetail = new SurveyDimensionDetail(dimensionDetailCode, dimensionCode, "糖尿病", 2, "疾病类型", 2, surveyCode);
                        break;
                }*/
                surveyDimensionDetailDao.save(surveyDimensionDetail);
                SurveyFilter surveyFilter = new SurveyFilter(getCode(), surveyCode, dimensionDetailCode);
                surveyFilterDao.save(surveyFilter);
            }
        }
//        List<String> codes = getCount(surveyTarget.toString());
        JSONObject countJson = new JSONObject();
        countJson.put("sex", sexList);
        countJson.put("disease", diseaList);
        countJson.put("healthCondition", healthList);
        countJson.put("service", servList);
        List<String> codes = getCountByDoctor(countJson.toString(),doctor);
        int amount = codes.size();
        for (String code : codes) {
//            String code = patient.get("patient").toString();
            SurveyUser user = new SurveyUser(surveyCode, code, 0, 1, new Date(), new Date());
            surveyUserDao.save(user);
        }
        //            发送居民模板 send=1发送
        if ("1".equals(send)) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//            String str = "{\"remark\":\"我们将按调查最终结果,优化健康服务。\",\"keyword1\":\"调查问卷\"}";
//            JSONObject json = new JSONObject(str);
            JSONObject json = new JSONObject();
 /*           for (String code : codes) {
//            codes.stream().forEach(c -> {
//                Patient p = patientDao.findByCode(c);
                Patient p = patientDao.findByCode(code);
                String name = p.getName();
                String openId = p.getOpenid();
                json.put("keyword2", sdf.format(new Date()));
//                json.put("toUser", c);
                json.put("toUser", code);
                json.put("survey_id", surveyCode);
                json.put("first", name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。");
                logger.error("patient =======>" + code);
                logger.error("name =======>" + name);
                logger.error("openId =======>" + openId);
                //判断是否有openId,有发送没有则查找家人发送
                if (StringUtils.isNotBlank(p.getOpenid())) {
                    // 添加到发送队列
                    logger.error("json =======>" + json);
                    PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
                } else {
                    JSONObject j = weiXinOpenIdUtils.getFamilyOpenId(p.getOpenid());
                    Patient member = (Patient) j.get("member");
                    if (StringUtils.isNotBlank(member.getOpenid())) {
                        String first = (String) json.get("first");
                        json.remove("first");
                        try {
                            json.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), member.getName()) + first);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        logger.error("没有opIn  json =======>" + json);
                        PushMsgTask.getInstance().putWxMsg(accessToken, 11, member.getOpenid(), member.getName(), json);
                    }
                }
//            });
            }*/
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","scwj");
            String remark = templateConfig.getRemark();
            String keyword1 = templateConfig.getKeyword1();
            String wxTemplateCode = templateCode;
            new Thread() {
                public void run() {
                    for (String c : codes) {
                        Patient p = null;
                        String name = null;
                        String openId = null;
                        String first = null;
                        try {
                            p = patientDao.findByCode(c);
                            name = p.getName();
                            openId = p.getOpenid();
                            json.put("keyword2", sdf.format(new Date()));
                            json.put("survey", wxTemplateCode);
//                        String first = name + ",您好!为了给您提供更好的家庭医生健康服务,现有一份问卷需要您填写。";
                            first = templateConfig.getFirst();
                            first = first.replace("key1",(name==null?"":name));
                            json.put("first", first);
                            json.put("remark", remark);
                            json.put("keyword1", keyword1);
                        } catch (JSONException e) {
                            continue;
                        }
                        //判断是否判定openId,有没有发则查找家人发送
                        if (StringUtils.isNotBlank(p.getOpenid())) {
                            // 添加到发送队列
                            logger.error("json =======>" + json);
//                            PushMsgTask.getInstance().putWxMsg(accessToken, 11, openId, name, json);
                            pushMsgTask.sendWeixinMessage(accessToken, 11, openId, name, json);
                        }else {
                            //发送代理人
                            JSONArray jsonArray = weiXinOpenIdUtils.getAgentOpenId(p.getCode(), p.getOpenid());
                            if (jsonArray != null && jsonArray.length() > 0) {
                                for (int i = 0; i < jsonArray.length(); i++) {
                                    JSONObject j = jsonArray.getJSONObject(i);
                                    Patient member = (Patient) j.get("member");
                                    if (StringUtils.isNotBlank(member.getOpenid())) {
                                        json.remove("toUser");
                                        json.put("toUser", member.getCode());
                                        json.remove("first");
                                        try {
                                            json.put("first", weiXinOpenIdUtils.getTitleMes(p, j.getInt("relation"), p.getName()) + first);
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                        pushMsgTask.sendWeixinMessage(weiXinAccessTokenUtils.getAccessToken(), 11, member.getOpenid(), p.getName(), json);
                                    }
                                }
                            }
                        }
                    }
                }
            }.start();
        }
//       =====================================================
//     获取标签数组
        JSONArray lables = jsonStr.getJSONArray("label");
//        标签保存到wlyy_survey_label_info
        for (Object label : lables) {
            SurveyLabelInfo surveyLabelInfo = new SurveyLabelInfo();
            surveyLabelInfo.setCode(getCode());
            surveyLabelInfo.setRelationCode(surveyCode);
            surveyLabelInfo.setUseType(useType);
            surveyLabelInfo.setLabel(Integer.parseInt(label.toString()));
            SurveyLabelInfo ss = surveyLabelInfoDao.save(surveyLabelInfo);
        }
//        获取问题数组
        JSONArray questions = jsonStr.getJSONArray("questions");
        for (Object question : questions) {
            JSONObject tempQestion = new JSONObject(question.toString());
//            不分题型都有的属性
            String questionnaireCode = tempQestion.get("qstCode").toString();
            String title = tempQestion.get("title").toString();
            String comment = tempQestion.get("comment").toString();
            int type = Integer.parseInt(tempQestion.get("type").toString());
            int isRequired = Integer.parseInt(tempQestion.get("isRequired").toString());
            int sort = Integer.parseInt(tempQestion.get("sort").toString());
            int del = 1;
            String qstNextQuestion = null;
//            前提一定要有nextQuestion字段传入,没有为""
            if (!StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                qstNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempQestion.get("nextQuestion"));
                qstNextQuestion = (qstNextQuestion == null ? "0" : qstNextQuestion);
            }
            switch (type) {
                case 0:
//                    单选
                    SurveyQuestionnaire surveyQuestionnaire = new SurveyQuestionnaire();
                    surveyQuestionnaire.setCode(questionnaireCode);
                    surveyQuestionnaire.setTitle(title);
                    surveyQuestionnaire.setQuestionComment(comment);
                    surveyQuestionnaire.setQuestionType(type);
                    surveyQuestionnaire.setSurveyCode(surveyCode);
                    surveyQuestionnaire.setIsRequired(isRequired);
                    surveyQuestionnaire.setDel(del);
                    surveyQuestionnaire.setSort(sort);
                    surveyQuestionnaire.setCreateTime(new Date());
                    surveyQuestionnaire.setUpdateTime(new Date());
                    //                   单选没有最大最小选项数及题目逻辑跳转
                    surveyQuestionnaire.setMinNum(null);
                    surveyQuestionnaire.setMaxNum(null);
                    surveyQuestionnaire.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaireDao.save(surveyQuestionnaire);
                    //                        =======================选项保存=========================
                    //                选择题
                    JSONArray options = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options) {
//                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        String optionCode = tempOption.get("optCode").toString();
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                            optionNextQuestion = (optionNextQuestion == null ? "0" : optionNextQuestion);
                        }
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions(optionCode, haveComment, questionnaireCode, optionComment,
                                surveyCode, optionNextQuestion, required, optionSort, optionDel);
                       /* surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);*/
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                单选题保存到统计表
                        String statisticsCode = getCode();
                        String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                        String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                        surveyStatisticsDao.save(statistics);
                    }
                    break;
                case 1:
//            多选特有属性
                    Integer maxOptions = null;
                    Integer minOptions = null;
                    if (!StringUtils.isEmpty(tempQestion.get("minOptions").toString())) {
                        minOptions = Integer.parseInt(tempQestion.get("minOptions").toString());
                    }
                    if (!StringUtils.isEmpty(tempQestion.get("maxOptions").toString())) {
                        maxOptions = Integer.parseInt(tempQestion.get("maxOptions").toString());
                    }
                    SurveyQuestionnaire surveyQuestionnaire1 = new SurveyQuestionnaire();
                    surveyQuestionnaire1.setCode(questionnaireCode);
                    surveyQuestionnaire1.setTitle(title);
                    surveyQuestionnaire1.setQuestionComment(comment);
                    surveyQuestionnaire1.setQuestionType(type);
                    surveyQuestionnaire1.setSurveyCode(surveyCode);
                    surveyQuestionnaire1.setIsRequired(isRequired);
                    surveyQuestionnaire1.setMinNum(minOptions);
                    surveyQuestionnaire1.setMaxNum(maxOptions);
                    surveyQuestionnaire1.setSort(sort);
                    surveyQuestionnaire1.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire1.setDel(del);
                    surveyQuestionnaire1.setCreateTime(new Date());
                    surveyQuestionnaire1.setUpdateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire1);
//                        =======================选项保存=========================
                    //                选择题
                    JSONArray options1 = new JSONArray(tempQestion.get("options").toString());
                    for (Object option : options1) {
//                        String optionCode = getCode();
                        JSONObject tempOption = new JSONObject(option.toString());
                        String optionCode = tempOption.get("optCode").toString();
                        int haveComment = Integer.parseInt(tempOption.get("haveComment").toString());
                        String optionComment = tempOption.get("content").toString();
                        int required = Integer.parseInt(tempOption.get("isRequired").toString());
                        int optionSort = Integer.parseInt(tempOption.get("sort").toString());
                        int optionDel = 1;
                        String optionNextQuestion = null;
                        if (!StringUtils.isEmpty(tempOption.get("nextQuestion").toString())) {
//                            optionNextQuestion = tempOption.get("nextQuestion").toString();
                            optionNextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode, tempOption.get("nextQuestion"));
                            optionNextQuestion = (optionNextQuestion == null ? "0" : optionNextQuestion);
                        }
//                        自主创建,插入表
                        SurveyQuestionnaireOptions surveyQuestionnaireOptions = new SurveyQuestionnaireOptions();
                        surveyQuestionnaireOptions.setCode(optionCode);
                        surveyQuestionnaireOptions.setHaveComment(haveComment);
                        surveyQuestionnaireOptions.setQuestionnaireCode(questionnaireCode);
                        surveyQuestionnaireOptions.setContent(optionComment);
                        surveyQuestionnaireOptions.setSurveyCode(surveyCode);
                        surveyQuestionnaireOptions.setQuestionCodeNext(optionNextQuestion);
                        surveyQuestionnaireOptions.setIsRequired(required);
                        surveyQuestionnaireOptions.setSort(optionSort);
                        surveyQuestionnaireOptions.setDel(optionDel);
                        surveyQuestionnaireOptionsDao.save(surveyQuestionnaireOptions);
                        //                多选题保存到统计表
                        String statisticsCode = getCode();
                        String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                        String optcontent = surveyQuestionnaireOptionsDao.findByRelationCode(surveyCode, questionnaireCode, optionCode).getContent();
                        SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, optionCode, 0, optcontent, haveComment, type, sort, optionSort);
                        surveyStatisticsDao.save(statistics);
                    }
//                        ===============================================================
                    break;
                case 2:
//            问答特有属性
                    /*String nextQuestion = null;
                    if (StringUtils.isEmpty(tempQestion.get("nextQuestion").toString())) {
                        nextQuestion = tempQestion.get("nextQuestion").toString();
                    }else {
                        nextQuestion = surveyTemplateQuestionsDao.findBySort(templateCode,tempQestion.get("nextQuestion"));
                    }*/
                    SurveyQuestionnaire surveyQuestionnaire2 = new SurveyQuestionnaire();
                    surveyQuestionnaire2.setCode(questionnaireCode);
                    surveyQuestionnaire2.setTitle(title);
                    surveyQuestionnaire2.setQuestionComment(comment);
                    surveyQuestionnaire2.setQuestionType(type);
                    surveyQuestionnaire2.setSurveyCode(surveyCode);
                    surveyQuestionnaire2.setIsRequired(isRequired);
//                   单选没有最大最小选项数
                    surveyQuestionnaire2.setMinNum(null);
                    surveyQuestionnaire2.setMaxNum(null);
                    surveyQuestionnaire2.setSort(sort);
                    surveyQuestionnaire2.setQuestionCodeNext(qstNextQuestion);
                    surveyQuestionnaire2.setDel(del);
                    surveyQuestionnaire2.setUpdateTime(new Date());
                    surveyQuestionnaire2.setCreateTime(new Date());
                    surveyQuestionnaireDao.save(surveyQuestionnaire2);
                    //                问答题保存到统计表(只负责更改数量不负责创建)
                    String statisticsCode = getCode();
                    String questionTitle = surveyQuestionnaireDao.findByIdAndQstId(surveyCode, questionnaireCode).getTitle();
                    SurveyStatistics statistics = new SurveyStatistics(statisticsCode, surveyCode, questionnaireCode, questionTitle, null, 0, null, null, type, sort, null);
                    surveyStatisticsDao.save(statistics);
                    break;
            }
        }
//        保存到问卷
        Survey survey = new Survey();
        survey.setCode(surveyCode);
        survey.setTitle(surveyName);
        survey.setSurveyComment(surveyComment);
        survey.setCreater(doctor);
        survey.setTemplateCode(templateCode);
        survey.setStatus(status);
        survey.setAmount(amount);
        survey.setCreateTime(new Date());
        survey.setUpdateTime(new Date());
        surveyDao.save(survey);
        return surveyCode;
    }
}
}

+ 15 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -8,16 +8,13 @@ package com.yihu.wlyy.service.common.account;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatient;
import com.yihu.wlyy.entity.doctor.team.sign.DoctorPatient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.ServerLabelTree;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.patient.SignFamilyRenew;
import com.yihu.wlyy.entity.patient.vo.PatientVO;
import com.yihu.wlyy.entity.patient.*;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.entity.security.Token;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.doctor.DoctorPatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientRecordLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.DateUtil;
@ -31,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
@ -53,6 +49,8 @@ public class PatientService extends TokenService {
    @Autowired
    @Autowired
    private PatientDao patientDao;
    private PatientDao patientDao;
    @Autowired
    @Autowired
    private PatientRecordLogDao patientRecordLogDao;
    @Autowired
    private DoctorDao doctorDao;
    private DoctorDao doctorDao;
    @Autowired
    @Autowired
    private DoctorPatientDao doctorPatientDao;
    private DoctorPatientDao doctorPatientDao;
@ -1134,6 +1132,17 @@ public class PatientService extends TokenService {
     */
     */
    @Transactional
    @Transactional
    public String clearOpenidByOpenid (String openid)  throws Exception{
    public String clearOpenidByOpenid (String openid)  throws Exception{
        List<Patient> patientList = patientDao.findPatientByOpenid(openid);
        for (Patient patient :patientList){
            PatientRecordLog patientRecordLog = new PatientRecordLog();
            patientRecordLog.setCzrq(new Date());
            patientRecordLog.setPatient(patient.getCode());
            patientRecordLog.setIdCard(patient.getIdcard());
            patientRecordLog.setOpenId(patient.getOpenid());
            patientRecordLog.setPatientName(patient.getName());
            patientRecordLog.setSsc(patient.getSsc());
            patientRecordLogDao.save(patientRecordLog);
        }
        patientDao.clearOpenidByOpenid(openid);
        patientDao.clearOpenidByOpenid(openid);
        return "";
        return "";
    }
    }

+ 141 - 51
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -10,6 +10,7 @@ import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.SpecialDisease;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.entity.wechat.WechatTemplateConfig;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
import com.yihu.wlyy.repository.doctor.SignPatientLabelDao;
@ -20,7 +21,10 @@ import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.PatientDiseaseServerDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
import com.yihu.wlyy.util.http.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.HashedMap;
@ -76,6 +80,10 @@ public class SpecialistService extends BaseService {
    private MessageDao messageDao;
    private MessageDao messageDao;
    @Autowired
    @Autowired
    private SignFamilyDao signFamilyDao;
    private SignFamilyDao signFamilyDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
        if (list != null && list.size() > 0) {
        if (list != null && list.size() > 0) {
@ -389,18 +397,19 @@ public class SpecialistService extends BaseService {
    public Map<String, Object> findSpecialistTeamInfo(String doctor, Long teamCode) {
    public Map<String, Object> findSpecialistTeamInfo(String doctor, Long teamCode) {
        String sql = "SELECT t.id, " +
        String sql = "SELECT t.id, " +
                " t. NAME, " +
                " t. name, " +
                " d.photo," +
                " d.photo," +
                " d.hospital," +
                " d.hospital_name AS hospitalName," +
                " d.code AS doctor," +
                " d.name AS doctorName ," +
                " d.dept," +
                " d.dept_name AS deptName" +
                " md.hospital," +
                " md.hospital_name AS hospitalName," +
                " md.code AS doctor," +
                " md.name AS doctorName ," +
                " md.dept," +
                " md.dept_name AS deptName" +
                " FROM " +
                " FROM " +
                " wlyy_admin_team t " +
                " wlyy_admin_team t " +
                " JOIN wlyy_admin_team_member m ON t.id = m.team_id " +
                " JOIN wlyy_admin_team_member m ON t.id = m.team_id " +
                " JOIN wlyy_doctor d ON d. CODE = t.leader_code " +
                " JOIN wlyy_doctor d ON d. CODE = t.leader_code " +
                " JOIN wlyy_doctor md ON md. CODE = m.doctor_code " +
                " WHERE " +
                " WHERE " +
                " m.doctor_code = '" + doctor + "' " +
                " m.doctor_code = '" + doctor + "' " +
                " AND t.available = '1' " +
                " AND t.available = '1' " +
@ -528,7 +537,7 @@ public class SpecialistService extends BaseService {
        return mes;
        return mes;
    }
    }
    public String agreeSpecialistTeam(String state, String relationCode, String remark, Long mesId) throws Exception {
    public String agreeSpecialistTeam(String token, String state, String relationCode, String remark, Long mesId) throws Exception {
        Map<String, Object> param = new HashedMap();
        Map<String, Object> param = new HashedMap();
        param.put("state", state);
        param.put("state", state);
        param.put("relationCode", relationCode);
        param.put("relationCode", relationCode);
@ -545,62 +554,74 @@ public class SpecialistService extends BaseService {
                messageDao.save(m);
                messageDao.save(m);
            }
            }
            JSONObject josn = rs.getJSONObject("obj");
            Patient p = patientDao.findByCode(josn.getString("patient"));
            Doctor d = doctorDao.findByCode(josn.getString("doctor"));
            //如果医生拒绝,置空疾病服务类型
            //如果医生拒绝,置空疾病服务类型
            if("0".equals(state)){
               List<PatientDiseaseServer> servers =  patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode,"1");
               for (PatientDiseaseServer server:servers){
                   server.setDel("0");
               }
            if ("0".equals(state)) {
                List<PatientDiseaseServer> servers = patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode, "1");
                for (PatientDiseaseServer server : servers) {
                    server.setDel("0");
                }
                patientDiseaseServerDao.save(servers);
                patientDiseaseServerDao.save(servers);
            }
            JSONObject josn =  rs.getJSONObject("obj");
            SignFamily sign =  signFamilyDao.findByPatient(josn.getString("patient"));
            //判断是否有家庭医生,有家庭医生则通知家庭医生
            if(sign!=null){
                Patient p = patientDao.findByCode(josn.getString("patient"));
                Doctor d = doctorDao.findByCode(josn.getString("doctor"));
                // 添加签约申请消息
                Message message = new Message();
                message.setCzrq(new Date());
                message.setCreateTime(new Date());
                message.setContent("您有一个居民开通共管服务!");
                message.setRead(1);//设置未读
                message.setReceiver(sign.getDoctor());//设置接受医生的code
                message.setSender(p.getCode());//设置发送的用户
                message.setSenderName(p.getName());
                message.setCode(getCode());
                message.setTitle("专科医生共管通知");
                message.setType(18);//家庭签约取消信息
                message.setReadonly(0);//是否只读消息
                message.setSex(p.getSex());
                message.setOver("1");//未处理
                message.setRelationCode(relationCode);
                message.setDel("1");
                message.setState(1);
                JSONObject dataJson = new JSONObject();
                dataJson.put("doctor",d.getCode());
                dataJson.put("doctorName",d.getName());
                dataJson.put("hospital",d.getHospital());
                dataJson.put("hospitalName",d.getHospitalName());
                dataJson.put("dept",d.getDept());
                dataJson.put("deptName",d.getDeptName());
                message.setReason(dataJson.toString());
                messageDao.save(message);
                //推送给居民模板消息
                pushWeiTemp(token, "0", remark, p, d);
            } else {
                //医生同意,推送全科医生消息
                SignFamily sign = signFamilyDao.findByPatient(josn.getString("patient"));
                //判断是否有家庭医生,有家庭医生则通知家庭医生
                if (sign != null) {
                    // 添加签约申请消息
                    Message message = new Message();
                    message.setCzrq(new Date());
                    message.setCreateTime(new Date());
                    message.setContent("您有一个居民开通共管服务!");
                    message.setRead(1);//设置未读
                    message.setReceiver(sign.getDoctor());//设置接受医生的code
                    message.setSender(p.getCode());//设置发送的用户
                    message.setSenderName(p.getName());
                    message.setCode(getCode());
                    message.setTitle("专科医生共管通知");
                    message.setType(18);//家庭签约取消信息
                    message.setReadonly(0);//是否只读消息
                    message.setSex(p.getSex());
                    message.setOver("1");//未处理
                    message.setRelationCode(relationCode);
                    message.setDel("1");
                    message.setState(1);
                    JSONObject dataJson = new JSONObject();
                    dataJson.put("doctor", d.getCode());
                    dataJson.put("doctorName", d.getName());
                    dataJson.put("hospital", d.getHospital());
                    dataJson.put("hospitalName", d.getHospitalName());
                    dataJson.put("dept", d.getDept());
                    dataJson.put("deptName", d.getDeptName());
                    message.setReason(dataJson.toString());
                    messageDao.save(message);
                    //推送给居民模板消息
                    pushWeiTemp(token, "1", "", p, d);
                }
            }
            }
            return "1";
            return "1";
        }
        }
        return "0";
        return "0";
    }
    }
    public JSONObject findPatientSigninfo(String code) throws Exception {
    public JSONObject findPatientSigninfo(String code,String messageCode) throws Exception {
        Map<String, Object> param = new HashedMap();
        Map<String, Object> param = new HashedMap();
        param.put("code", code);
        param.put("code", code);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSigninfo", param);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSigninfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
        if ("succes".equals(rs.getString("message"))) {
            if (StringUtils.isNoneBlank(messageCode)){
                Message message = messageDao.findByCode(messageCode);
                message.setRead(0);
                messageDao.save(message);
            }
            JSONObject json = rs.getJSONObject("obj");
            JSONObject json = rs.getJSONObject("obj");
            List<PatientDiseaseServer> patientDiseaseServers =  patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(code,"1");
            List<PatientDiseaseServer> patientDiseaseServers =  patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(code,"1");
            json.put("diseaseServer",patientDiseaseServers);
            json.put("diseaseServer",patientDiseaseServers);
@ -637,5 +658,74 @@ public class SpecialistService extends BaseService {
        return null;
        return null;
    }
    }
    public JSONObject findPatientSignSpecialistInfo(String patient,String doctor) throws Exception {
        Map<String, Object> param = new HashedMap();
        param.put("patient", patient);
        param.put("doctor", doctor);
        HttpResponse response = HttpUtils.doGet(specialistUrl + "svr-specialist/findPatientSignSpecialistInfo", param);
        JSONObject rs = new JSONObject(response.getContent());
        if ("succes".equals(rs.getString("message"))) {
            JSONObject j =rs.getJSONObject("obj");
            String relationCode =  j.getString("relationCode");
            j.put("server",patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(relationCode,"1"));
            return j;
        }
        return null;
    }
    public void pushWeiTemp(String token, String state, String remark, Patient patient, Doctor doctor) {
        logger.info("pushWeiTemp:"+patient.getCode()+"__openid:"+patient.getOpenid());
        if (StringUtils.isNotBlank(patient.getOpenid())) {
            WechatTemplateConfig temp;
            JSONObject json = new JSONObject();
            if ("0".equals(state)) {
                //拒绝
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspref");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark().replace("key1", StringUtils.isBlank(remark)?"详情请联系您的专科医生":remark));
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            } else {
                //同意
                temp = templateConfigDao.findByScene("template_deal_with", "tdwspagr");
                json.put("toUser", patient.getCode());
                json.put("keyword1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd"));
                json.put("keyword2", temp.getKeyword2().replace("key1", doctor.getName()));
                json.put("remark", temp.getRemark());
                json.put("first", temp.getFirst().replace("key1", patient.getName()));
            }
            logger.info("weiTempJOSN:"+json.toString());
            pushMsgTask.putWxMsg(token, 24, patient.getOpenid(), patient.getName(), json);
        }
    }
    public Long findMessagePatientCount(String doctor){
        String sql ="SELECT " +
                " COUNT(s.sender) AS total " +
                " FROM " +
                " ( " +
                "  SELECT DISTINCT " +
                "   m.sender " +
                "  FROM " +
                "   wlyy_message m " +
                "  WHERE " +
                "   m.type IN (16,17) " +
                "  AND m.receiver = '"+doctor+"' " +
                "  AND m.has_read = 1 " +
                "  AND m.over = 1 " +
                " ) s";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Long total = 0L;
        if(list!=null&&list.size()>0){
            Map<String,Object> map = list.get(0);
            total = (Long)map.get("total");
        }
        return total;
    }
}
}

+ 10 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -840,6 +840,16 @@ public class PushMsgTask {
                keyword3.setColor("#000000");
                keyword3.setColor("#000000");
                keyword3.setValue(json.getString("keyword3"));
                keyword3.setValue(json.getString("keyword3"));
                m.put("keyword3", keyword3);
                m.put("keyword3", keyword3);
            }else if (type == 24) {//结果处理通知
                temp.setTemplate_id(template_deal_with);
                WechatTemplateData keyword1 = new WechatTemplateData();
                keyword1.setColor("#000000");
                keyword1.setValue(json.getString("keyword1"));
                m.put("keyword1", keyword1);
                WechatTemplateData keyword2 = new WechatTemplateData();
                keyword2.setColor("#000000");
                keyword2.setValue(json.getString("keyword2"));
                m.put("keyword2", keyword2);
            }
            }
            temp.setData(m);
            temp.setData(m);

+ 44 - 6
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/specialist/SpecialistController.java

@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.aop.ObserverRequired;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.entity.doctor.team.sign.SignPatientLabelInfo;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -23,7 +23,7 @@ import java.util.List;
@RestController
@RestController
@RequestMapping(value = "/doctor/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/doctor/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-专病管理")
@Api(description = "医生端-专病管理")
public class SpecialistController extends BaseController {
public class SpecialistController extends WeixinBaseController {
    @Autowired
    @Autowired
    private SpecialistService specialistService;
    private SpecialistService specialistService;
@ -223,7 +223,7 @@ public class SpecialistController extends BaseController {
                                      @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false) String remark,
                                      @ApiParam(name = "remark", value = "审核失败原因") @RequestParam(required = false) String remark,
                                      @ApiParam(name = "mesId", value = "消息Id") @RequestParam(required = false) Long mesId) throws Exception {
                                      @ApiParam(name = "mesId", value = "消息Id") @RequestParam(required = false) Long mesId) throws Exception {
        try {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(state, relationCode, remark, mesId));
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return error(-1, "请求失败");
            return error(-1, "请求失败");
@ -233,9 +233,12 @@ public class SpecialistController extends BaseController {
    @RequestMapping(value = "/findPatientSigninfo", method = RequestMethod.GET)
    @RequestMapping(value = "/findPatientSigninfo", method = RequestMethod.GET)
    @ApiOperation(value = "医生审核")
    @ApiOperation(value = "医生审核")
    @ObserverRequired
    @ObserverRequired
    public String findPatientSigninfo(@ApiParam(name = "code", value = "专科医生签约code") @RequestParam(required = true) String code) {
    public String findPatientSigninfo(@ApiParam(name = "code", value = "专科医生签约code")
                                      @RequestParam(required = true) String code,
                                      @ApiParam(name = "messageCode", value = "消息code")
                                      @RequestParam(required = false) String messageCode) {
        try {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientSigninfo(code));
            return write(200, "获取成功", "data", specialistService.findPatientSigninfo(code,messageCode));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return error(-1, "请求失败");
            return error(-1, "请求失败");
@ -264,4 +267,39 @@ public class SpecialistController extends BaseController {
        }
        }
    }
    }
    }
    @RequestMapping(value = "/findPatientSignSpecialistInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民与当前专科医生有效签约信息")
    public String findPatientSignSpecialistInfo(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient,
                                                @ApiParam(name = "doctor", value = "专科医生code") @RequestParam(required = true)String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientSignSpecialistInfo(patient,doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findMessagePatientCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取等待专科医生处理消息人数")
    public String findMessagePatientCount(String doctor) {
        try {
            return write(200, "获取成功", "data", specialistService.findMessagePatientCount(doctor));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findPatientDiseaseServerList", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民专病服务信息")
    public String findPatientDiseaseServerList(@ApiParam(name = "patient", value = "患者code") @RequestParam(required = true)String patient) {
        try {
            return write(200, "获取成功", "data", specialistService.findPatientDiseaseServerList(patient));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}

文件差异内容过多而无法显示
+ 31 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/DoctorSurveyScreenResultController.java


+ 0 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/survey/ManagerQuestionnaireController.java

@ -586,5 +586,4 @@ public class ManagerQuestionnaireController extends WeixinBaseController {
        }
        }
    }
    }
}
}

+ 3 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/specialist/PatientSpecialistController.java

@ -1,9 +1,7 @@
package com.yihu.wlyy.web.patient.specialist;
package com.yihu.wlyy.web.patient.specialist;
import com.yihu.wlyy.entity.specialist.PatientDiseaseServer;
import com.yihu.wlyy.entity.specialist.TeamDiseaseRelation;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.service.specialist.SpecialistService;
import com.yihu.wlyy.web.BaseController;
import com.yihu.wlyy.web.WeixinBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
@ -14,16 +12,13 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
/**
 * Created by Trick on 2018/7/3.
 * Created by Trick on 2018/7/3.
 */
 */
@RestController
@RestController
@RequestMapping(value = "/patient/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequestMapping(value = "/patient/specialist", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "患者端-专病管理")
@Api(description = "患者端-专病管理")
public class PatientSpecialistController extends BaseController{
public class PatientSpecialistController extends WeixinBaseController{
    @Autowired
    @Autowired
    private SpecialistService specialistService;
    private SpecialistService specialistService;
@ -81,7 +76,7 @@ public class PatientSpecialistController extends BaseController{
    @ApiOperation(value = "医生审核")
    @ApiOperation(value = "医生审核")
    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception {
    public String agreeSpecialistTeam(String state,String relationCode,String remark,Long mesId)throws Exception {
        try {
        try {
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam( state, relationCode, remark, mesId));
            return write(200, "获取成功", "data", specialistService.agreeSpecialistTeam(getAccessToken(),state, relationCode, remark, mesId));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return error(-1, "请求失败");
            return error(-1, "请求失败");

+ 3 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/statistic/EsStatisticsController.java

@ -2182,7 +2182,8 @@ public class EsStatisticsController extends BaseController {
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int level,
            @RequestParam(required = true) int sort,
            @RequestParam(required = true) int sort,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String lowLevel,
            @RequestParam(required = false) String year) {
            @RequestParam(required = false) String year,
            @RequestParam(required = false,defaultValue = "3") int sortType) {//1发放量 ,2绑定量,绑定率
        try {
        try {
            //如果年度是空,按当前时间计算是年度是属于那个年度
            //如果年度是空,按当前时间计算是年度是属于那个年度
@ -2194,7 +2195,7 @@ public class EsStatisticsController extends BaseController {
                lowLevel = level - 1 + "";
                lowLevel = level - 1 + "";
            }
            }
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType));
            return write(200, "查询成功", "data", statisticsESService.getLevelDeviceAndBinding(area, elasticsearchUtil.changeLevel(level), sort, String.valueOf(elasticsearchUtil.changeLevel(Integer.valueOf(lowLevel))), year,deviceType,sortType));
        } catch (Exception e) {
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return error(-1, "查询失败");
            return error(-1, "查询失败");

+ 48 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/specialist/ThirdSpecialistController.java

@ -0,0 +1,48 @@
package com.yihu.wlyy.web.third.specialist;
import com.yihu.wlyy.service.specialist.SpecialistService;
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;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Trick on 2018/7/13.
 */
@RestController
@RequestMapping(value = "/third/specialist",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "专科医生信息")
public class ThirdSpecialistController extends BaseController{
    @Autowired
    private SpecialistService specialistService;
    @RequestMapping(value = "/findSpecialistTeamInfo", method = RequestMethod.GET)
    @ApiOperation(value = "获取专科医生所在团队信息")
    public String findSpecialistTeamInfo(@ApiParam(name = "doctor", value = "医生code") @RequestParam(required = true)String doctor,
                                         @ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode){
        try {
            return write(200, "获取成功", "data", specialistService.findSpecialistTeamInfo(doctor,teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
    @RequestMapping(value = "/findTeamDiseaseRelation", method = RequestMethod.GET)
    @ApiOperation(value = "获取团队专病服务信息")
    public String findTeamDiseaseRelation(@ApiParam(name = "teamCode", value = "团队code") @RequestParam(required = true)Long teamCode) {
        try {
            return write(200, "获取成功", "data", specialistService.findTeamDiseaseRelation(teamCode));
        } catch (Exception e) {
            error(e);
            return error(-1, "请求失败");
        }
    }
}