浏览代码

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

huangwenjie 7 年之前
父节点
当前提交
7eeccfd57d
共有 23 个文件被更改,包括 588 次插入119 次删除
  1. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/admin/AdminTeam.java
  2. 100 2
      patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java
  3. 3 3
      patient-co/patient-co-doctor-assistant/src/main/resources/application-prod.yml
  4. 1 1
      patient-co/patient-co-doctor-assistant/src/main/resources/wechat/weixin_menu_feldsher.txt
  5. 1 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java
  6. 5 1
      patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java
  7. 二进制
      patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx
  8. 5 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java
  9. 48 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java
  10. 43 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  11. 43 39
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java
  12. 14 11
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSignService.java
  13. 0 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/BaseController.java
  14. 1 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  15. 1 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/PatientInfoController.java
  16. 3 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  17. 63 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java
  18. 0 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java
  19. 40 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java
  20. 12 1
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java
  21. 7 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java
  22. 82 25
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java
  23. 106 22
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/doctor/team/admin/AdminTeam.java

@ -26,6 +26,7 @@ public class AdminTeam extends IdEntity {
    private String orgName;
    private String orgName;
    private String townCode;
    private String townCode;
    private String townName;
    private String townName;
    private String mappingCode;
    public String getName() {
    public String getName() {
        return name;
        return name;
@ -78,6 +79,15 @@ public class AdminTeam extends IdEntity {
        this.available = available;
        this.available = available;
    }
    }
    @Column(name = "mapping_code")
    public String getMappingCode() {
        return mappingCode;
    }
    public void setMappingCode(String mappingCode) {
        this.mappingCode = mappingCode;
    }
    @Transient
    @Transient
    public String getOrgName() {
    public String getOrgName() {
        return orgName;
        return orgName;

+ 100 - 2
patient-co/patient-co-doctor-assistant/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java

@ -1,6 +1,9 @@
package com.yihu.wlyy.web.third.gateway.controller.doctor;
package com.yihu.wlyy.web.third.gateway.controller.doctor;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.wechat.WechatTemplateData;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.util.NetworkUtil;
import com.yihu.wlyy.util.NetworkUtil;
@ -10,6 +13,7 @@ import com.yihu.wlyy.wechat.util.WeiXinTempMsgSendUtils;
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;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
@ -19,8 +23,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutionException;
/**
/**
@ -40,6 +43,8 @@ public class GcMessageController {
    private PatientService patientService;
    private PatientService patientService;
    @Autowired
    @Autowired
    private SMSService smsService;
    private SMSService smsService;
    @Autowired
    private DoctorDao doctorDao;
    @RequestMapping(value = "/sendWXTemplate", method = RequestMethod.POST)
    @RequestMapping(value = "/sendWXTemplate", method = RequestMethod.POST)
    @ApiOperation("给患者发送微信模板消息")
    @ApiOperation("给患者发送微信模板消息")
@ -101,4 +106,97 @@ public class GcMessageController {
            return new ResultBatchModel(BaseResultModel.statusEm.error_no_ip.getCode(), "获取IP失败", success, error, errorLiust);
            return new ResultBatchModel(BaseResultModel.statusEm.error_no_ip.getCode(), "获取IP失败", success, error, errorLiust);
        }
        }
    }
    }
    /**
     * 客服系统发送消息接口 居民没有有openID只发手机短信 有openID发微信模板消息、手机短信
     *
     * @param doctorCodes 医生code
     * @param content     消息内容限制字数70
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ApiOperation("客服系统发送消息接口")
    public ResultBatchModel sendMessage(
            @ApiParam(name = "doctorCodes", value = "医生code(批量逗号分割)", required = true) @RequestParam(value = "doctorCodes", required = true) String doctorCodes,
            @ApiParam(name = "content", value = "消息内容", required = true) @RequestParam(value = "content", required = true) String content) {
        Integer success = 0;
        Integer error = 0;
        List<String> errorLiust = new ArrayList<>();
        try {
            String templateId = "OqQXrb-e43_TJpq_70_K_y6vYJgY5mpjFYY4c5RWFP4";
//            String templateId = "";
            String url = "www.baidu.com";//要带基本地址
            String[] codeArr = doctorCodes.split(",");
            for (String code : codeArr) {
                Doctor doctor = doctorDao.findByCode(code);
                String openId = doctor.getOpenid();
                String name = doctor.getName();
                String mobile = doctor.getMobile();
//                String openId = "o7NFZw1QM4YR1O19mLjwfX1Hh11A";
//                String name = "吴家莲";
//                String mobile = "13611153674";
                if (StringUtils.isEmpty(openId) && StringUtils.isNotEmpty(mobile)) {
                    try {
                        smsService.sendMsg(mobile, content);
                        success++;
                    } catch (Exception e) {
                        logger.error("mobile " + mobile + " send message error:" + e.getMessage());
                        error++;
                        errorLiust.add(mobile);
                    }
                } else if (StringUtils.isNotEmpty(openId) && StringUtils.isNotEmpty(mobile)) {
                    try {
                        smsService.sendMsg(mobile, content);
                        success++;
                    } catch (Exception e) {
                        logger.error("mobile " + mobile + " send message error:" + e.getMessage());
                        error++;
                        errorLiust.add(mobile);
                    }
                    try {
                        JSONObject sendJson = packageTemplate("消息头","备注","续方提醒","2017年9月16日 18:00");
                        weiXinTempMsgSendUtils.sendTemplateMessage(templateId, openId, url, sendJson);
                        success++;
                    } catch (Exception e) {
                        logger.error("code " + code + " send Template error:" + e.getMessage());
                        error++;
                        errorLiust.add(code);
                    }
                }
            }
            return new ResultBatchModel(success, error, errorLiust);
        } catch (Exception e) {
            return new ResultBatchModel(-1, "找不到该医生!", success, error, errorLiust);
        }
    }
    /**
     * 构建微信模板内容消息体 默认字体黑色
     * @param first
     * @param remark
     * @param keywords
     * @return
     */
    public JSONObject packageTemplate(String first,String remark,String ... keywords) {
        JSONObject data = new JSONObject();
        Map keywordFirst = new HashMap();
        keywordFirst.put("color","#000000");
        keywordFirst.put("value",first);
        Map keywordRemark = new HashMap();
        keywordRemark.put("color","#000000");
        keywordRemark.put("value",remark);
        data.put("first",keywordFirst);
        data.put("remark",keywordRemark);
        for (int i=0;i<keywords.length;i++) {
            Map keyword1 = new HashMap();
            keyword1.put("color","#000000");
            keyword1.put("value",keywords[i]);
            data.put("keyword"+(i+1),keyword1);
        }
        System.out.println(data.toString());
        return data;
    }
}
}

+ 3 - 3
patient-co/patient-co-doctor-assistant/src/main/resources/application-prod.yml

@ -25,11 +25,11 @@ im:
  data_base_name: im
  data_base_name: im
wechat:
wechat:
  appId: wxad04e9c4c5255acf
  appSecret: ae77c48ccf1af5d07069f5153d1ac8d3
  appId: wx088a4d8e8208e6ce
  appSecret: ab3cdd509fb76fd0149e8864c97e8ddb
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_token: 27eb3bb24f149a7760cf1bb154b08040
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fwlyy
  wechat_base_url: http%3a%2f%2fwww.xmtyw.cn%2fwlyy
  accId: gh_ffd64560fb21
  accId: gh_b0f086d0d2f5
  message:
  message:
   ##医生追加建议提醒 --签约邀请
   ##医生追加建议提醒 --签约邀请
   doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA
   doctor_invitel_template: MQn79bx1ofb6hekhmRIuqLU7KjySJQzaBzrimgqVrzA

+ 1 - 1
patient-co/patient-co-doctor-assistant/src/main/resources/wechat/weixin_menu_feldsher.txt

@ -3,7 +3,7 @@
        {
        {
            "name": "我的资料",
            "name": "我的资料",
            "type": "view",
            "type": "view",
		    "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fgrzx%2fhtml%2fmy-detail.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		    "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx088a4d8e8208e6ce&redirect_uri=http%3a%2f%2fwww.xmtyw.cn%2fwlyy%2fwx_doctor%2fhtml%2fhome%2fhtml%2fjumpApp.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
        }
    ]
    ]
}
}

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/activemq/HealthArtListener.java

@ -82,7 +82,7 @@ public class HealthArtListener implements MessageListener {
                json.put("represented", patient.getCode());//被代理人
                json.put("represented", patient.getCode());//被代理人
                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                json.put("date", DateUtil.dateToStrLong(DateUtil.getNowDate()));
                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());
                json.put("remark", org.springframework.util.StringUtils.isEmpty(one.getAttachedMessage()) ? "  " : one.getAttachedMessage());
                json.put("articleUrl",one.getArticleUrl());
                if (StringUtils.isNotBlank(patient.getOpenid())) {
                if (StringUtils.isNotBlank(patient.getOpenid())) {
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9,
                    pushMsgTask.putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 9,
                            patient.getOpenid(),
                            patient.getOpenid(),

+ 5 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/task/PushMsgTask.java

@ -100,7 +100,6 @@ public class PushMsgTask {
            json.put("name", name);
            json.put("name", name);
            json.put("data", data);
            json.put("data", data);
            queue.put(json);
            queue.put(json);
            String str = "";
        } catch (Exception e) {
        } catch (Exception e) {
            logger.error("添加到微信消息列队列失败!", e);
            logger.error("添加到微信消息列队列失败!", e);
            e.printStackTrace();
            e.printStackTrace();
@ -438,6 +437,11 @@ public class PushMsgTask {
                m.put("remark", keyword4);
                m.put("remark", keyword4);
            } else if (type == 9) {
            } else if (type == 9) {
                temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                temp.setUrl(url + "jkjy/html/article.html?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                //默认是推送本地数据库文章,如有传url说明是集美宣教系统推送文章
                String articleUrl = json.has("articleUrl") ? json.getString("articleUrl") : null;
                if(StringUtils.isNotEmpty(articleUrl)){
                    temp.setUrl(articleUrl+"?openid=" + openid + "&dataId=" + json.getString("article") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&represented=" + json.getString("represented"));
                }
                temp_id = template_healthy_article;
                temp_id = template_healthy_article;
                temp.setTemplate_id(temp_id);
                temp.setTemplate_id(temp_id);
                WechatTemplateData keyword1 = new WechatTemplateData();
                WechatTemplateData keyword1 = new WechatTemplateData();

二进制
patient-co/patient-co-wlyy/doc/接口文档/对外接口文档/集美健康教育/集美健康教育对外接口文档.docx


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

@ -35,7 +35,6 @@ import com.yihu.wlyy.util.*;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.sql.Select;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
@ -344,6 +343,11 @@ public class FamilyContractService extends BaseService {
            services.put(service);
            services.put(service);
        }
        }
        json.put("services", services);
        json.put("services", services);
        //是否签约上限
        int signLimit = signWebService.getSickFamilyDoctorSignLimit(doctor);
        json.put("signLimit", signLimit);
        return json;
        return json;
    }
    }

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

@ -18,6 +18,7 @@ import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.charge.ChargeDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.consult.ConsultTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
@ -30,6 +31,7 @@ import com.yihu.wlyy.service.common.SMSService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
@ -37,6 +39,8 @@ import com.yihu.wlyy.wechat.util.WeiXinOpenIdUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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;
@ -55,6 +59,7 @@ import java.util.*;
@Component
@Component
@Transactional
@Transactional
public class SignWebService extends BaseService {
public class SignWebService extends BaseService {
    private static Logger logger = LoggerFactory.getLogger(SignWebService.class);
    @Autowired
    @Autowired
    private SignWebDao signWebDao;
    private SignWebDao signWebDao;
@ -98,7 +103,10 @@ public class SignWebService extends BaseService {
    private SignFamilyServerDao signFamilyServerDao;
    private SignFamilyServerDao signFamilyServerDao;
    @Autowired
    @Autowired
    private ChargeDao chargeDao;
    private ChargeDao chargeDao;
    @Autowired
    private JwSignService jwSignService;
    @Autowired
    private DoctorAdminTeamMemberDao doctorAdminTeamMemberDao;
    @Autowired
    @Autowired
    private TownDao townDao;
    private TownDao townDao;
    @Autowired
    @Autowired
@ -2606,4 +2614,43 @@ public class SignWebService extends BaseService {
        json.put("signFamilyServer",ja);
        json.put("signFamilyServer",ja);
        return json;
        return json;
    }
    }
    /**
     * 判断医生所属行政团队是否已达上限
     * @param doctorCode
     * @return
     */
    public Integer getSickFamilyDoctorSignLimit(String doctorCode){
        Integer re = 0;//0未达上线 1 已达上限
        List<AdminTeam> adminTeams = doctorAdminTeamMemberDao.findDoctorTeams(doctorCode);
        int limitNum = 0;
        for(AdminTeam one:adminTeams){
            //获取团队签约数
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            try{
                String response = jwSignService.getSickFamilyDoctorSignLimit(jwCode);
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(response);
                if(json.getInteger("status")==200){
                    com.alibaba.fastjson.JSONObject data = json.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        int sign_limit_number = data.getJSONArray("DATA").getJSONObject(0).getInteger("SIGN_LIMIT_NUMBER");//签约上线
                        if(signCount>=sign_limit_number){
                            limitNum++;
                        }
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if(adminTeams.size()==limitNum){
            re = 1;
        }
        return re;
    }
}
}

+ 43 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -16,6 +16,7 @@ import com.yihu.wlyy.repository.organization.HospitalDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.repository.patient.SignFamilyRenewDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.third.jw.JwSignService;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
import org.json.JSONArray;
@ -47,7 +48,8 @@ public class AdminTeamService extends BaseService {
    @Autowired
    @Autowired
    DoctorAdminTeamMemberDao memberDao;
    DoctorAdminTeamMemberDao memberDao;
    @Autowired
    private JwSignService jwSignService;
    @Autowired
    @Autowired
    DoctorTeamMemberDao signingTeamMemberDao;
    DoctorTeamMemberDao signingTeamMemberDao;
@ -235,6 +237,46 @@ public class AdminTeamService extends BaseService {
        return memberDao.findDoctorTeams(doctorCode);
        return memberDao.findDoctorTeams(doctorCode);
    }
    }
    /**
     * 获取行政团队
     * @param doctorCode
     * @return
     */
    public com.alibaba.fastjson.JSONArray getAdminTeams(String doctorCode){
        List<AdminTeam> adminTeams = memberDao.findDoctorTeams(doctorCode);
        com.alibaba.fastjson.JSONArray re = new com.alibaba.fastjson.JSONArray();
        for(AdminTeam one:adminTeams){
            //获取团队签约数
            Integer signCount = signFamilyDao.findByAdminTeamIdAndStatus(one.getId(),0);
            //获取智业团队签约上线
            String jwCode = one.getMappingCode();//智业服务团队的code
            int sign_limit_number = 0;
            try{
                String response = jwSignService.getSickFamilyDoctorSignLimit(jwCode);
                com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(response);
                if(json.getInteger("status")==200){
                    com.alibaba.fastjson.JSONObject data = json.getJSONObject("data");
                    if("1".equals(data.getString("CODE"))){
                        sign_limit_number = data.getJSONArray("DATA").getJSONObject(0).getInteger("SIGN_LIMIT_NUMBER");//签约上线
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
            }
            com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
            json.put("id",one.getId());
            json.put("name",one.getName());
            json.put("createTime",one.getCreateTime());
            json.put("leaderCode",one.getLeaderCode());
            json.put("available",one.isAvailable());
            json.put("orgCode",one.getOrgCode());
            json.put("signCount",signCount);
            json.put("signLimitNumber",sign_limit_number);
            re.add(json);
        }
        return re;
    }
    /**
    /**
     * 添加成员。
     * 添加成员。
     *
     *

+ 43 - 39
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwPrescriptionService.java

@ -164,45 +164,7 @@ public class JwPrescriptionService {
                            pre.put("hospital",recipe.getString("HEALTH_ORG_CODE"));
                            pre.put("hospital",recipe.getString("HEALTH_ORG_CODE"));
                        }
                        }
//                        pre.put("diagnoseCode",recipe.getString("DIAGNOSE_CODE"));//诊断代码
//                        pre.put("diagnoseName",recipe.getString("DIAGNOSE_NAME"));//诊断名称
//                        pre.put("diagnoseSubCode",recipe.getString("DIAGNOSE_SUB_CODE"));//次诊断编码
//                        pre.put("diagnoseSubName",recipe.getString("DIAGNOSE_SUB_NAME"));//次诊断名称
                        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
                        String diagnoseCode = recipe.getString("DIAGNOSE_CODE");
                        String diagnoseName = recipe.getString("DIAGNOSE_NAME");
                        diagnosis.setCode(diagnoseCode);//诊断代码
                        diagnosis.setName(diagnoseName);//诊断名称
                        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                        if(!StringUtils.isEmpty(icd10)){
                            JSONObject icd = JSONObject.parseObject(icd10);
                            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                        }else{
                            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                        }
                        JSONArray jsonArrayDt = new JSONArray();
                        jsonArrayDt.add(diagnosis);
                        if(recipe.getString("DIAGNOSE_SUB_CODE")!=null){
                            diagnosis = new PrescriptionDiagnosis();
                            diagnoseCode = recipe.getString("DIAGNOSE_CODE");
                            diagnoseName = recipe.getString("DIAGNOSE_NAME");
                            diagnosis.setCode(diagnoseCode);//诊断代码
                            diagnosis.setName(diagnoseName);//诊断名称
                            icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
                            if(!StringUtils.isEmpty(icd10)){
                                JSONObject icd = JSONObject.parseObject(icd10);
                                diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
                                diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
                            }else{
                                diagnosis.setHealthProblemName(diagnoseName);//诊断名称
                                diagnosis.setHealthProblem(diagnoseCode);//诊断代码
                            }
                            jsonArrayDt.add(diagnosis);
                        }
                        pre.put("prescriptionDt",jsonArrayDt);
                        pre.put("prescriptionDt",getDiagnosis(recipe));
                        jsonArray.add(pre);
                        jsonArray.add(pre);
                    }
                    }
                }
                }
@ -215,6 +177,48 @@ public class JwPrescriptionService {
        return re;
        return re;
    }
    }
    /**
     * 诊断类型转换
     * @param recipe
     * @return
     */
    private JSONArray getDiagnosis(JSONObject recipe){
        JSONArray jsonArrayDt = new JSONArray();
        PrescriptionDiagnosis diagnosis = new PrescriptionDiagnosis();
        String diagnoseCode = recipe.getString("DIAGNOSE_CODE");//诊断代码
        String diagnoseName = recipe.getString("DIAGNOSE_NAME");//诊断名称
        diagnosis.setCode(diagnoseCode);//诊断代码
        diagnosis.setName(diagnoseName);//诊断名称
        String icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
        if(!StringUtils.isEmpty(icd10)){
            JSONObject icd = JSONObject.parseObject(icd10);
            diagnosis.setHealthProblemName(icd.getString("value"));//诊断名称
            diagnosis.setHealthProblem(icd.getString("key"));//诊断代码
        }else{
            diagnosis.setHealthProblemName(diagnoseName);//诊断名称
            diagnosis.setHealthProblem(diagnoseCode);//诊断代码
        }
        jsonArrayDt.add(diagnosis);
        if(recipe.getString("DIAGNOSE_SUB_CODE")!=null){
            diagnosis = new PrescriptionDiagnosis();
            diagnoseCode = recipe.getString("DIAGNOSE_SUB_CODE");
            diagnoseName = recipe.getString("DIAGNOSE_SUB_NAME");
            diagnosis.setCode(diagnoseCode);//次诊断代码
            diagnosis.setName(diagnoseName);//次诊断名称
            icd10 = icd10DictServcie.getHealthProblemsByIcd10Code(diagnoseCode);
            if(!StringUtils.isEmpty(icd10)){
                JSONObject icd = JSONObject.parseObject(icd10);
                diagnosis.setHealthProblemName(icd.getString("value"));//次诊断名称
                diagnosis.setHealthProblem(icd.getString("key"));//次诊断代码
            }else{
                diagnosis.setHealthProblemName(diagnoseName);//次诊断名称
                diagnosis.setHealthProblem(diagnoseCode);//次诊断代码
            }
            jsonArrayDt.add(diagnosis);
        }
        return jsonArrayDt;
    }
    /**
    /**
     * 获取单条历史处方
     * 获取单条历史处方
     * @param recipeNo
     * @param recipeNo

+ 14 - 11
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/jw/JwSignService.java

@ -1,25 +1,14 @@
package com.yihu.wlyy.service.third.jw;
package com.yihu.wlyy.service.third.jw;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.ehr.EhrService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.List;
import java.util.Map;
/**
/**
 * Created by hzp on 2016/12/19.
 * Created by hzp on 2016/12/19.
@ -74,4 +63,18 @@ public class JwSignService {
        return HttpClientUtil.post(url, params, "UTF-8");
        return HttpClientUtil.post(url, params, "UTF-8");
    }
    }
    /**
     * 获取医生团队的签约上线
     * @param jwTeamCode
     * @return
     */
    public String getSickFamilyDoctorSignLimit(String jwTeamCode){
        String url = jwUrl + "/third/sign/getSickFamilyDoctorSignLimit";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("jwTeamCode", jwTeamCode));
        return HttpClientUtil.post(url, params, "UTF-8");
    }
}
}

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

@ -44,8 +44,6 @@ public class BaseController {
                userAgent = request.getHeader("User-Agent");
                userAgent = request.getHeader("User-Agent");
            }
            }
            JSONObject json = new JSONObject(userAgent);
            JSONObject json = new JSONObject(userAgent);
            logger.info("json:"+json.toString());
            System.out.println("json:"+json.toString());
            return json.getString("uid");
            return json.getString("uid");
        } catch (Exception e) {
        } catch (Exception e) {

+ 1 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -90,6 +90,7 @@ public class LoginController extends BaseController {
                return write(200, "公钥获取成功!", "data", json);
                return write(200, "公钥获取成功!", "data", json);
            }
            }
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            return error(-1, "公钥获取失败!");
            return error(-1, "公钥获取失败!");
        }
        }
    }
    }

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

@ -96,7 +96,7 @@ public class PatientInfoController extends BaseController {
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient,brithday, jwCountryCode, nation, blood, marry,adress));
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient,brithday, jwCountryCode, nation, blood, marry,adress));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return invalidUserException(e, -1, "获取患者信息失败!");
            return invalidUserException(e, -1, "档案建立失败!");
        }
        }
    }
    }

+ 3 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -265,9 +265,9 @@ public class AdminTeamController extends BaseController {
    @ApiOperation(value = "获取医生团队列表")
    @ApiOperation(value = "获取医生团队列表")
    public String getDoctorTeams(@PathVariable("doctor_code") String doctorCode) {
    public String getDoctorTeams(@PathVariable("doctor_code") String doctorCode) {
        try {
        try {
            List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
            return write(200, "OK", "data", new JSONArray(teamList));
//            List<AdminTeam> teamList = teamService.getDoctorTeams(doctorCode);
//            return write(200, "OK", "data", new JSONArray(teamList));
            return write(200, "OK", "data", teamService.getAdminTeams(doctorCode));
        } catch (Exception e) {
        } catch (Exception e) {
            error(e);
            error(e);
            return error(-1, e.getMessage());
            return error(-1, e.getMessage());

+ 63 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -1,5 +1,6 @@
package com.yihu.wlyy.web.patient.account;
package com.yihu.wlyy.web.patient.account;
import com.yihu.wlyy.aop.ObserverRequired;
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.patient.Patient;
import com.yihu.wlyy.entity.patient.Patient;
@ -21,6 +22,7 @@ import com.yihu.wlyy.web.WeixinBaseController;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
import com.yihu.wlyy.wechat.util.WeiXinTagUtil;
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 org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONObject;
@ -918,4 +920,65 @@ public class PatientController extends WeixinBaseController {
            return error(-1, "切换账号失败");
            return error(-1, "切换账号失败");
        }
        }
    }
    }
    @RequestMapping(value = "createProfile",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation("档案建立")
    @ObserverRequired
    public String createProfile(@ApiParam(value = "医生code", name = "doctorCode") @RequestParam(required = true)String doctorCode ,
                                @ApiParam(value = "患者code", name = "patient") @RequestParam(required = true)String patient,
                                @ApiParam(value = "生日(yyyy-MM-dd)", name = "brithday") @RequestParam(required = true)String brithday,
                                @ApiParam(value = "居委会", name = "jwCountryCode") @RequestParam(required = true)String jwCountryCode,
                                @ApiParam(value = "民族", name = "nation") @RequestParam(required = true)String nation,
                                @ApiParam(value = "血型", name = "blood") @RequestParam(required = true)String blood,
                                @ApiParam(value = "婚姻状况", name = "marry") @RequestParam(required = true)String marry,
                                @ApiParam(value = "详细地址", name = "adress") @RequestParam(required = true)String adress){
        try {
            // 获取医生下的患者
            return write(200, "档案建立成功!", "data", patientInfoService.createProfile(doctorCode , patient,brithday, jwCountryCode, nation, blood, marry,adress));
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "档案建立失败!");
        }
    }
    @RequestMapping(value = "getNationDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("获取民族信息列表")
    public String getNationDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getNationDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getMarryDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("婚姻状态字典")
    public String getMarryDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getMarryDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @RequestMapping(value = "getBloodDict",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation("血型状态字典")
    public String getBloodDict(){
        try {
            // 获取医生下的患者
            return write(200, "获取成功!", "data",patientInfoService.getBloodDict());
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
}
}

+ 0 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcDoctorController.java

@ -108,8 +108,6 @@ public class GcDoctorController extends BaseController {
    @ApiOperation("获取医生所属团队")
    @ApiOperation("获取医生所属团队")
    public ResultListModel<AdminTeamModel> doctors(
    public ResultListModel<AdminTeamModel> doctors(
    ) {
    ) {
        logger.info("getUID:"+getUID());
        System.out.println("getUID:"+getUID());
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());//hxmD201703150222"
        List<AdminTeam> teams = adminTeamService.getDoctorTeams(getUID());//hxmD201703150222"
        List<AdminTeamModel> adminTeamModelList = new ArrayList<>();
        List<AdminTeamModel> adminTeamModelList = new ArrayList<>();
        if (teams != null && teams.size() > 0) {
        if (teams != null && teams.size() > 0) {

+ 40 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcEduArticleController.java

@ -131,7 +131,8 @@ public class GcEduArticleController extends WeixinBaseController {
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ) {
    ) {
        try {
        try {
            String[] patients = receiveCodes.split(",");//接收人的code
            String[] patients = receiveCodes.split(",");//接收人的code
@ -141,7 +142,7 @@ public class GcEduArticleController extends WeixinBaseController {
            //得到需要发送的患者
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            gcEduArticleService.initPatient(patientSet, patients, unPatients, labelType, labelCode, teamId);
            //获取保存发送记录
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level);
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, sendCode, sendName, sendType, sendMessage, teamId, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            //推送微信模板消息和发送im消息
            new Thread(() -> {
            new Thread(() -> {
                //发送任务到redis
                //发送任务到redis
@ -172,4 +173,41 @@ public class GcEduArticleController extends WeixinBaseController {
        });
        });
    }
    }
    @RequestMapping(value = "sendPatients", method = RequestMethod.POST)
    @ApiOperation("文章群推送")
    public BaseResultModel sendPatients(
            @ApiParam(name = "sendType", value = "发送类型 1医生发送 2卫纪委发送", required = false) @RequestParam(value = "sendType", required = false,defaultValue = "2") Integer sendType,
            @ApiParam(name = "labelUnitType", value = "标签类型  1:下属单位,多个用逗号分隔", required = false) @RequestParam(value = "labelUnitType", required = false, defaultValue = "") String labelUnitType,
            @ApiParam(name = "labelSexType", value = "标签类型  2:性别,多个用逗号分隔", required = false) @RequestParam(value = "labelSexType", required = false, defaultValue = "") String labelSexType,
            @ApiParam(name = "labelServeType", value = "标签类型  3:服务类型,多个用逗号分隔", required = false) @RequestParam(value = "labelServeType", required = false, defaultValue = "") String labelServeType,
            @ApiParam(name = "labelDiseaseType", value = "标签类型  4:疾病类型,多个用逗号分隔", required = false) @RequestParam(value = "labelDiseaseType", required = false, defaultValue = "") String labelDiseaseType,
            @ApiParam(name = "labelHealthType", value = "标签类型  5:健康情况,多个用逗号分隔", required = false) @RequestParam(value = "labelHealthType", required = false, defaultValue = "") String labelHealthType,
            @ApiParam(name = "articleId", value = "文章ID", required = true) @RequestParam(value = "articleId", required = true) String articleId,
            @ApiParam(name = "articlePic", value = "文章封面", required = true) @RequestParam(value = "articlePic", required = true) String articlePic,
            @ApiParam(name = "articleTitle", value = "文章标题", required = true) @RequestParam(value = "articleTitle", required = true) String articleTitle,
            @ApiParam(name = "articleContent", value = "文章内容", required = true) @RequestParam(value = "articleContent", required = true) String articleContent,
            @ApiParam(name = "articleType", value = "文章类别", required = true) @RequestParam(value = "articleType", required = true) String articleType,
            @ApiParam(name = "level1Type", value = "一级分类", required = true) @RequestParam(value = "level1Type", required = true) String level1Type,
            @ApiParam(name = "level2Type", value = "二级分类", required = true) @RequestParam(value = "level2Type", required = true) String level2Type,
            @ApiParam(name = "level", value = "等级", required = true) @RequestParam(value = "level", required = true) String level,
            @ApiParam(name = "articleUrl", value = "宣教文章获取的url", required = true) @RequestParam(value = "articleUrl", required = true) String articleUrl
    ){
        try {
            Set<String> patientSet = new HashSet<>(); //放入set中可以去重复
            //得到需要发送的患者
            gcEduArticleService.initPatient(patientSet,labelUnitType,labelSexType,labelServeType,labelDiseaseType,labelHealthType);
            //获取保存发送记录
            List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = gcEduArticleService.getSaveArticle(patientSet, "", "", sendType, "", 0L, articleId, articlePic, articleTitle, articleContent, articleType, level1Type, level2Type, level,articleUrl);
            //推送微信模板消息和发送im消息
            new Thread(() -> {
                //发送任务到redis
                sender(healthEduArticlePatients);
            }).start();
            return new BaseResultModel();
        }catch (Exception e) {
            return new BaseResultModel(BaseResultModel.statusEm.opera_error.getCode(), BaseResultModel.statusEm.opera_error.getMessage() + ":" + e.getMessage());
        }
    }
}
}

+ 12 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcLableController.java

@ -122,5 +122,16 @@ public class GcLableController extends BaseController {
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
            return new ResultPageListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
        }
    }
    }
    @RequestMapping(value = "/unitLabels", method = RequestMethod.GET)
    @ApiOperation("根据地区查找卫计委下属单位标签")
    public ResultListModel<List<PatientLabelModel>> unitLabels(
            @ApiParam(name = "areas", value = "", required = true) @RequestParam(value = "areas", required = true) String areas
    ) {
        try {
            List<DictModel> dictModels = labelService.getUnitLabels(areas);
            return new ResultListModel(dictModels);
        } catch (Exception e) {
            return new ResultListModel(BaseResultModel.statusEm.find_error.getCode(), BaseResultModel.statusEm.find_error.getMessage() + "," + e.getMessage());
        }
    }
}
}

+ 7 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/controller/doctor/GcMessageController.java

@ -101,4 +101,11 @@ public class GcMessageController {
            return new ResultBatchModel(BaseResultModel.statusEm.error_no_ip.getCode(), "获取IP失败", success, error, errorLiust);
            return new ResultBatchModel(BaseResultModel.statusEm.error_no_ip.getCode(), "获取IP失败", success, error, errorLiust);
        }
        }
    }
    }
    @RequestMapping(value = "/sendEduArticle", method = RequestMethod.POST)
    @ApiOperation("给手机号码发送短信消息")
    public ResultBatchModel sendEduArticle(){
        return null;
    }
}
}

+ 82 - 25
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcEduArticleService.java

@ -62,31 +62,52 @@ public class GcEduArticleService {
        StringBuffer sb = new StringBuffer();//sql
        StringBuffer sb = new StringBuffer();//sql
        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
        //1 服务类型  2 健康情况 3 疾病类型 4 自定义标签
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
        if (!org.springframework.util.StringUtils.isEmpty(labelType)) {
//            switch (labelType) {
//                case "1": {
//                    sb.append(" SELECT " +
//                            "  w.patient " +
//                            "FROM " +
//                            "  wlyy_sign_family w " +
//                            " WHERE " +
//                            "  w.`status` > 0 " +
//                            " AND w.code in ( select sign_code from  " +
//                            "  wlyy_sign_family_server where server_type=? ) ");
//                    params.add(labelCode);
//
//                    if (teamId != null && teamId > 0) {
//                        sb.append(" and w.admin_team_code=? ");
//                        params.add(teamId);
//                    }
//                    break;
//                }
//                case "2":
//                case "3":
//                case "4": {
//                    sb.append("SELECT w.patient FROM wlyy_sign_family w " +
//                            "WHERE " +
//                            "  w.patient in (SELECT  l.patient FROM  wlyy_sign_patient_label_info l WHERE l.label_type = ? AND l.label = ? and l.status=1) " +
//                            "AND w.`status` > 0");
//                    params.add(labelType);
//                    params.add(labelCode);
//                    if (teamId != null && teamId > 0) {
//                        sb.append(" and w.admin_team_code=? ");
//                        params.add(teamId);
//                    }
//                    break;
//                }
//            }
            switch (labelType) {
            switch (labelType) {
                case "1": {
                    sb.append(" SELECT " +
                            "  w.patient " +
                            "FROM " +
                            "  wlyy_sign_family w " +
                            " WHERE " +
                            "  w.`status` > 0 " +
                            " AND w.code in ( select sign_code from  " +
                            "  wlyy_sign_family_server where server_type=? ) ");
                case "1":{
                    sb.append(" select w.patient FROM wlyy_sign_family w  left join wlyy_sign_family_server s on w.code=s.sign_code " +
                            "where w.`status` > 0 and s.server_type=? ");
                    params.add(labelCode);
                    params.add(labelCode);
                    if (teamId != null && teamId > 0) {
                        sb.append(" and w.admin_team_code=? ");
                        params.add(teamId);
                    }
                    break;
                }
                }
                case "2":
                case "2":
                case "3":
                case "3":
                case "4": {
                    sb.append("SELECT w.patient FROM wlyy_sign_family w " +
                            "WHERE " +
                            "  w.patient in (SELECT  l.patient FROM  wlyy_sign_patient_label_info l WHERE l.label_type = ? AND l.label = ? and l.status=1) " +
                            "AND w.`status` > 0");
                case "4":{
                    sb.append(" SELECT w.patient FROM wlyy_sign_family w left join wlyy_sign_patient_label_info l on w.patient = l.patient " +
                            "where w.`status` > 0 and l.label_type = ? AND l.label = ? and l.status=1 ");
                    params.add(labelType);
                    params.add(labelType);
                    params.add(labelCode);
                    params.add(labelCode);
                    if (teamId != null && teamId > 0) {
                    if (teamId != null && teamId > 0) {
@ -138,7 +159,8 @@ public class GcEduArticleService {
                                                                        String articleType,
                                                                        String articleType,
                                                                        String level1Type,
                                                                        String level1Type,
                                                                        String level2Type,
                                                                        String level2Type,
                                                                        String level) {
                                                                        String level,
                                                                        String articleUrl) {
        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
        List<com.yihu.es.entity.HealthEduArticlePatient> healthEduArticlePatients = new ArrayList<>();
        Doctor doctor = doctorDao.findByCode(sendCode);
        Doctor doctor = doctorDao.findByCode(sendCode);
@ -161,12 +183,12 @@ public class GcEduArticleService {
                healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
                healthEduArticlePatient.setHospitalName(doctor.getHospitalName());
                healthEduArticlePatient.setTown(doctor.getTown());
                healthEduArticlePatient.setTown(doctor.getTown());
                healthEduArticlePatient.setTownName(doctor.getTownName());
                healthEduArticlePatient.setTownName(doctor.getTownName());
                healthEduArticlePatient.setSendLevel(doctor.getLevel()!=null?String.valueOf(doctor.getLevel()):"");
                healthEduArticlePatient.setSendPic(doctor.getPhoto());
                healthEduArticlePatient.setSendSex(doctor.getSex()!=null?String.valueOf(doctor.getSex()):"");
            }
            }
            healthEduArticlePatient.setBatchNo(batchNo);
            healthEduArticlePatient.setBatchNo(batchNo);
            healthEduArticlePatient.setCreateTime(createTime);
            healthEduArticlePatient.setCreateTime(createTime);
            healthEduArticlePatient.setSendLevel(doctor.getLevel()!=null?String.valueOf(doctor.getLevel()):"");
            healthEduArticlePatient.setSendPic(doctor.getPhoto());
            healthEduArticlePatient.setSendSex(doctor.getSex()!=null?String.valueOf(doctor.getSex()):"");
            healthEduArticlePatient.setArticleId(articleId);
            healthEduArticlePatient.setArticleId(articleId);
            healthEduArticlePatient.setAttachedTitle(articleTitle);
            healthEduArticlePatient.setAttachedTitle(articleTitle);
@ -178,7 +200,7 @@ public class GcEduArticleService {
            healthEduArticlePatient.setLevel1Type(level1Type);
            healthEduArticlePatient.setLevel1Type(level1Type);
            healthEduArticlePatient.setLevel2Type(level2Type);
            healthEduArticlePatient.setLevel2Type(level2Type);
            healthEduArticlePatient.setType("1");//文章
            healthEduArticlePatient.setType("1");//文章
            healthEduArticlePatient.setArticleUrl(articleUrl);
            healthEduArticlePatients.add(healthEduArticlePatient);
            healthEduArticlePatients.add(healthEduArticlePatient);
        }
        }
@ -268,4 +290,39 @@ public class GcEduArticleService {
    private String changeDate(String quotaDate) {
    private String changeDate(String quotaDate) {
        return quotaDate + "T00:00:00+0800";
        return quotaDate + "T00:00:00+0800";
    }
    }
    public void initPatient(Set<String> patientSet,String labelUnit,String labelSex,String labelServe,String labelDisease,String labelHealth){
        String tableSql = " select w.patient from wlyy_sign_family w ";
        String whereSql = " where w.status>0  ";
        if(!StringUtils.isEmpty(labelServe)){
            tableSql += " left join wlyy_sign_family_server s on w.code= s.sign_code ";
            whereSql += " and s.server_type in ("+labelServe+" ) ";
        }
        if(!StringUtils.isEmpty(labelHealth)||!StringUtils.isEmpty(labelDisease)){
            tableSql += " left join wlyy_sign_patient_label_info l on w.patient=l.patient ";
            whereSql += " and l.status=1 ";
            whereSql += " and ( ";
        }
        if(!StringUtils.isEmpty(labelHealth)){
            whereSql += " (l.label_type = 2 AND l.label in ("+labelHealth+")) ";
        }
        if(!StringUtils.isEmpty(labelDisease)){
            if(!whereSql.endsWith(" and ( ")) {
                whereSql += " or (l.label_type = 3 AND l.label in ("+labelDisease+"))) ";
            }else{
                whereSql += " (l.label_type = 1 AND l.label in ("+labelDisease+"))) ";
            }
        }
        if(!StringUtils.isEmpty(labelSex)){
            tableSql += " left join wlyy_patient p on p.code=w.patient ";
            whereSql += " and p.sex in ("+labelSex+") ";
        }
        if(!StringUtils.isEmpty(labelUnit)){
            whereSql += " and w.hospital in ("+labelUnit+") ";
        }
        List<String> groupPatient = jdbcTemplate.queryForList(tableSql+whereSql, String.class);
        patientSet.addAll(groupPatient);
    }
}
}

+ 106 - 22
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/third/gateway/service/GcLabelService.java

@ -87,6 +87,81 @@ public class GcLabelService {
            labels.add(labelNo);
            labels.add(labelNo);
        }
        }
//        if (labels != null) {
//            for (SignPatientLabel label : labels) {
//                if (isAll) {//查询所有
//                    labelType = label.getLabelType();
//                }
//                JSONObject json = new JSONObject();
//
//                json.put("labelCode", label.getLabelCode());
//                json.put("labelName", label.getLabelName());
//                json.put("isSystem", label.getIsSystem());
//
//                int amount = 0;
//                String sql = "";
//                Object[] args;
//                if (label.getLabelCode().equals("0")) {
//                    sql = " SELECT " +
//                            "     count(DISTINCT t1.patient) count" +
//                            " FROM" +
//                            "     wlyy_sign_family t1 " +
//                            " left join " +
//                            "    (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
//                            " on t1.patient = t2.patient ," +
//                            " wlyy_patient t3 " +
//                            " WHERE" +
//                            "     t2.patient is null " +
//                            "    AND t1.patient = t3.code" +
//                            "     AND t1.status > 0 " +
//                            "     AND t1.admin_team_code = ? ";
//
//                    args = new Object[]{teamCode, labelType, teamCode};
//                } else {
//                    sql = " SELECT " +
//                            "     count(DISTINCT t1.patient) count" +
//                            " FROM" +
//                            "     wlyy_sign_family t1, " +
//                            "     wlyy_sign_patient_label_info t2, " +
//                            "     wlyy_patient t3 " +
//                            " WHERE" +
//                            "     t1.patient = t2.patient " +
//                            "     AND t1.patient = t3.code " +
//                            "     AND t2.label = ? " +
//                            "     AND t2.label_type = ? " +
//                            "     AND t2.status = 1 " +
//                            "     AND t1.status > 0 " +
//                            "    AND t1.admin_team_code = ? ";
//
//                    args = new Object[]{label.getLabelCode(), labelType, teamCode};
//                }
//
//
//                List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
//
//                if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
//                    amount = Integer.valueOf(String.valueOf(count.get(0).get("count")));
//                }
//
//                json.put("amount", amount);
//
//                int focusAmount = 0;
//                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
//                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
//
//                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
//                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
//                }
//
//                json.put("focusAmount", focusAmount);
//
//                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
//                    continue;
//                }
//                result.put(json);
//            }
//        }
        if (labels != null) {
        if (labels != null) {
            for (SignPatientLabel label : labels) {
            for (SignPatientLabel label : labels) {
                if (isAll) {//查询所有
                if (isAll) {//查询所有
@ -103,31 +178,34 @@ public class GcLabelService {
                Object[] args;
                Object[] args;
                if (label.getLabelCode().equals("0")) {
                if (label.getLabelCode().equals("0")) {
                    sql = " SELECT " +
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            "     t3.openid openid " +
                            " FROM" +
                            " FROM" +
                            "     wlyy_sign_family t1 " +
                            "     wlyy_sign_family t1 " +
                            " left join " +
                            " left join " +
                            "    (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                            "    (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                            " on t1.patient = t2.patient ," +
                            " on t1.patient = t2.patient " +
                            " left join " +
                            " wlyy_patient t3 " +
                            " wlyy_patient t3 " +
                            " on t1.patient = t3.code " +
                            " WHERE" +
                            " WHERE" +
                            "     t2.patient is null " +
                            "     t2.patient is null " +
                            "    AND t1.patient = t3.code" +
                            "     AND t1.status > 0 " +
                            "     AND t1.status > 0 " +
                            "     AND t1.admin_team_code = ? ";
                            "     AND t1.admin_team_code = ? ";
                    args = new Object[]{teamCode, labelType, teamCode};
                    args = new Object[]{teamCode, labelType, teamCode};
                } else {
                } else {
                    sql = " SELECT " +
                    sql = " SELECT " +
                            "     count(DISTINCT t1.patient) count" +
                            "     t3.openid openid " +
                            " FROM" +
                            " FROM" +
                            "     wlyy_sign_family t1, " +
                            "     wlyy_sign_patient_label_info t2, " +
                            "     wlyy_patient t3 " +
                            "     wlyy_sign_family t1 " +
                            " LEFT JOIN " +
                            "     wlyy_sign_patient_label_info t2 " +
                            " ON t1.patient = t2.patient " +
                            " LEFT JOIN " +
                            " wlyy_patient t3 " +
                            " ON t1.patient = t3.code " +
                            " WHERE" +
                            " WHERE" +
                            "     t1.patient = t2.patient " +
                            "     AND t1.patient = t3.code " +
                            "     AND t2.label = ? " +
                            "      t2.label = ? " +
                            "     AND t2.label_type = ? " +
                            "     AND t2.label_type = ? " +
                            "     AND t2.status = 1 " +
                            "     AND t2.status = 1 " +
                            "     AND t1.status > 0 " +
                            "     AND t1.status > 0 " +
@ -137,23 +215,23 @@ public class GcLabelService {
                }
                }
                List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, args);
                if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
                    amount = Integer.valueOf(String.valueOf(count.get(0).get("count")));
                }
//                if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
//                    amount = Integer.valueOf(String.valueOf(count.get(0).get("count")));
//                }
                amount = list.size();
                json.put("amount", amount);
                json.put("amount", amount);
                int focusAmount = 0;
                sql += labelType.equals("5") ? " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 " : " AND LENGTH(TRIM(IFNULL(t3.openid,''))) > 0 ";
                List<Map<String, Object>> focusCount = jdbcTemplate.queryForList(sql, args);
                List<Map<String, Object>> temp = new ArrayList<>();
                list.forEach(map-> {
                    if(map.get("openid")!=null&&String.valueOf(map.get("openid")).trim().length()>0){
                        temp.add(map);
                    }
                });
                if (focusCount != null && focusCount.size() > 0 && focusCount.get(0).containsKey("count")) {
                    focusAmount = Integer.valueOf(String.valueOf(focusCount.get(0).get("count")));
                }
                json.put("focusAmount", focusAmount);
                json.put("focusAmount", temp.size());
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                    continue;
@ -163,4 +241,10 @@ public class GcLabelService {
        }
        }
        return result;
        return result;
    }
    }
    public List<DictModel> getUnitLabels(String areas) {
        String sql = "select code, name  from dm_hospital  where level=2 and town in ("+areas+" ) " ;
        List<DictModel> returnList = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DictModel.class));
        return returnList;
    }
}
}