Jelajahi Sumber

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

LiTaohong 6 tahun lalu
induk
melakukan
c977d0e9b3
31 mengubah file dengan 690 tambahan dan 180 penghapusan
  1. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java
  2. 26 0
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java
  3. 5 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java
  4. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java
  5. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  6. 57 21
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java
  7. 4 11
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java
  8. 5 12
      svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java
  9. 9 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java
  10. 193 0
      svr/svr-base/src/main/java/com/yihu/jw/base/util/SendEmailUtils.java
  11. 1 0
      svr/svr-base/src/main/resources/application.yml
  12. 1 4
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictEntryController.java
  13. 0 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesServerController.java
  14. 1 3
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FacilityUsedRecordController.java
  15. 0 5
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FeedBackController.java
  16. 0 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/dict/SystemDictEntryDao.java
  17. 0 13
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/interceptor/ActivatedInterceptor.java
  18. 0 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/dict/SystemDictEntry.java
  19. 0 1
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/FeedBack.java
  20. 0 2
      svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/dict/SystemDictEntryService.java
  21. 6 0
      svr/svr-wlyy-specialist/pom.xml
  22. 50 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java
  23. 13 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java
  24. 54 12
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java
  25. 4 2
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java
  26. 10 2
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java
  27. 3 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java
  28. 111 51
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java
  29. 73 7
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java
  30. 30 25
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java
  31. 14 1
      svr/svr-wlyy-specialist/src/main/resources/application.yml

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/SpecialistPatientRelationDO.java

@ -77,6 +77,8 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntityWithOperator
    private String signCertificate;//签约证明
    @Column(name = "health_status_code")
    private String healthStatusCode;//健康状况编码
    @Column(name = "disease_code")
    private String diseaseCode;//签约疾病编码,多个使用逗号隔开
    public String getSaasId() {
@ -256,4 +258,12 @@ public class SpecialistPatientRelationDO extends UuidIdentityEntityWithOperator
    public void setHealthStatusCode(String healthStatusCode) {
        this.healthStatusCode = healthStatusCode;
    }
    public String getDiseaseCode() {
        return diseaseCode;
    }
    public void setDiseaseCode(String diseaseCode) {
        this.diseaseCode = diseaseCode;
    }
}

+ 26 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/PatientRehabilitationPlanDO.java

@ -1,11 +1,14 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import org.springframework.data.annotation.CreatedDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
 * Created by humingfen on 2018/8/10.
@ -36,6 +39,10 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntityWithOperator
    private String servicePackageId;//服务包id
    @Column(name = "status")
    private Integer status;//状态(0已中止,1进行中,2已完成)
    @Column(name = "abort_reason")
    private String abortReason;//中止原因
    @Column(name = "abort_time")
    private Date abortTime;//中止时间
    @Column(name = "saas_id")
    public String getSaasId() {
@ -135,4 +142,23 @@ public class PatientRehabilitationPlanDO extends UuidIdentityEntityWithOperator
    public void setDiseaseName(String diseaseName) {
        this.diseaseName = diseaseName;
    }
    @Column(name = "abort_reason")
    public String getAbortReason() {
        return abortReason;
    }
    public void setAbortReason(String abortReason) {
        this.abortReason = abortReason;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "abort_time")
    public Date getAbortTime() {
        return abortTime;
    }
    public void setAbortTime(Date abortTime) {
        this.abortTime = abortTime;
    }
}

+ 5 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -40,6 +40,8 @@ public class SpecialistMapping {
        public static final String searchPatientInSpecialist ="/searchPatientInSpecialist";
        public static final String searchPatientInSpeciaInfo ="/searchPatientInSpeciaInfo";
        public static final String createPatientInSpeciaRelation ="/createPatientInSpeciaRelation";
        public static final String updateRedisFindPatientTeamList ="/updateRedisFindPatientTeamList";
        public static final String selectByAssistant="/selectByAssistant";
@ -90,7 +92,9 @@ public class SpecialistMapping {
        public static final String planListByPatient = "/planListByPatient";
        public static final String patientCount = "/patientCount";
        public static final String selectByIds = "/selectByIds";
        public static final String selectByLabelAndPatient = "/selectByLabelAndPatient";
        public static final String sendToFamilyDoctor = "/sendToFamilyDoctor";
        public static final String abortPlanById = "/abortPlanById";
    }
    public static class serviceItem{
@ -112,5 +116,6 @@ public class SpecialistMapping {
        public static final String importData1 = "/importData1";
        public static final String importData2 = "/importData2";
        public static final String selectByDoctor = "/selectByDoctor";
        public static final String getServiceItemsAfterStop="getServiceItemsAfterStop";
    }
}

+ 9 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/MixEnvelop.java

@ -164,4 +164,13 @@ public class MixEnvelop<T, J> extends Envelop {
        envelop.setStatus(200);
        return envelop;
    }
    public static MixEnvelop getSuccess(String message, Object obj, List objList) {
        MixEnvelop envelop = new MixEnvelop();
        envelop.setMessage(message);
        envelop.setObj(obj);
        envelop.setDetailModelList(objList);
        envelop.setStatus(200);
        return envelop;
    }
}

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -134,7 +134,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
            return "账号已被锁定,请5分钟后重试!";
        } else {
            addFailureCount(username,loginFailureCount);
            return "密码错误,还可以再试" + (5 - loginFailureCount) + "次!";
            return "账号或密码错误,还可以再试" + (5 - loginFailureCount) + "次!";
        }
    }

+ 57 - 21
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/open/register/RegisterEndpoint.java

@ -5,6 +5,7 @@ import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.SendEmailUtils;
import com.yihu.jw.base.util.ValidateUtil;
import com.yihu.jw.entity.base.saas.BaseEmailTemplateConfigDO;
import com.yihu.jw.entity.base.saas.SaasDO;
@ -14,6 +15,7 @@ import com.yihu.jw.restmodel.base.saas.SaasTypeDictVO;
import com.yihu.jw.restmodel.base.saas.SaasVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
@ -27,7 +29,15 @@ import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.*;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
/**
@ -146,41 +156,67 @@ public class RegisterEndpoint extends EnvelopRestEndpoint {
    @PostMapping(value = BaseRequestMapping.RegisterSaas.SEND_EMAIL)
    @ApiOperation(value = "邮件发送")
    public Envelop send(@ApiParam(name = "email", value = "邮箱地址", required = true)
                         @RequestParam String email) throws Exception {
                        @RequestParam String email) throws Exception {
        if(!ValidateUtil.isValidEmail(email)){
        if (!ValidateUtil.isValidEmail(email)) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_NOT_FORMAT), Envelop.class);
        }
        //建立邮件消息
        SimpleMailMessage mainMessage = new SimpleMailMessage();
        //发送者
        mainMessage.setFrom(username);
        //接收者
        mainMessage.setTo(email);
        //发送的标题
        //查找发送模板
        BaseEmailTemplateConfigDO emailTemplateConfigDO = emailTemplateConfigDao.findByTemplateName("租户注册-验证码");
        StringBuilder content = null;
        String captcha = String.valueOf(Math.random()).substring(2, 8);
        if(emailTemplateConfigDO == null){
        if (emailTemplateConfigDO == null) {
            //发送的内容
            content =  new StringBuilder("您好!\n感谢您注册健康之路城市i健康。\n");
            content = new StringBuilder("您好!\n感谢您注册健康之路城市i健康。\n");
            content.append("您的验证码是:").append(captcha);
            content.append("。 (验证码10分钟内有效)");
        }else {
        } else {
            //发送的内容
            content =  new StringBuilder(emailTemplateConfigDO.getFirst());
            content = new StringBuilder(emailTemplateConfigDO.getFirst());
            content.append("\n").append(emailTemplateConfigDO.getKeyword1()).append("\n")
                .append(emailTemplateConfigDO.getKeyword2()).append(captcha)
                .append(emailTemplateConfigDO.getKeyword3()).append("\n")
                .append(emailTemplateConfigDO.getKeyword5()).append(emailTemplateConfigDO.getUrl())
                .append("\n").append("\n").append(emailTemplateConfigDO.getRemark());
                    .append(emailTemplateConfigDO.getKeyword2()).append(captcha)
                    .append(emailTemplateConfigDO.getKeyword3()).append("\n")
                    .append(emailTemplateConfigDO.getKeyword5()).append(emailTemplateConfigDO.getUrl())
                    .append("\n").append("\n").append(emailTemplateConfigDO.getRemark());
        }
        mainMessage.setSubject("租户注册-验证码");
        mainMessage.setText(content.toString());
        jms.send(mainMessage);
        String subject = "租户注册验证码";
        boolean blo = SendEmailUtils.sendMessage(email, content.toString(), subject);
        redisTemplate.opsForValue().set(redisPrefix + email, captcha, 10, TimeUnit.MINUTES);
        return success("发送成功");
        if (blo) {
            return success("success", true);
        } else {
            return failed("failed", ObjEnvelop.class);
        }
    }
    @PostMapping(value = "/testSendEmailMethod")
    @ApiOperation(value = "测试邮件发送")
    public Envelop testSendEmailMethod(@ApiParam(name = "email", value = "邮箱地址", required = true)
                                       @RequestParam String email) throws Exception {
        if (!ValidateUtil.isValidEmail(email)) {
            return failed(errorCodeUtil.getErrorMsg(BaseErrorCode.Saas.EMAIL_IS_NOT_FORMAT), Envelop.class);
        }
        try {
            // 设置主题
            String subject = "租户注册验证码";
            //发送的内容
            String captcha = String.valueOf(Math.random()).substring(2, 8);
            StringBuilder content = new StringBuilder("您好!\n感谢您注册健康之路城市i健康。\n");
            content.append("您的验证码是:").append(captcha);
            content.append("。 (验证码10分钟内有效)");
            boolean blo = SendEmailUtils.sendMessage(email, content.toString(), subject);
            if (blo) {
                return success("success", true);
            } else {
                return failed("failed", ObjEnvelop.class);
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed(e.getMessage(), ObjEnvelop.class);
        }
    }
}

+ 4 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/saas/SaasEndpoint.java

@ -7,6 +7,7 @@ import com.yihu.jw.base.service.saas.SaasService;
import com.yihu.jw.base.service.saas.SaasTypeDictService;
import com.yihu.jw.base.service.user.UserService;
import com.yihu.jw.base.util.ErrorCodeUtil;
import com.yihu.jw.base.util.SendEmailUtils;
import com.yihu.jw.base.util.ValidateUtil;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.module.SaasModuleDO;
@ -291,19 +292,11 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop<SaasDO> send(SaasDO saasDO) {
        try {
            SaasDO.Status status = saasDO.getStatus();
            String password = saasDO.getMobile().substring(0, 6);
            String password = saasDO.getMobile().substring(saasDO.getMobile().length()-6);
            BaseEmailTemplateConfigDO baseEmailTemplateConfigDO = baseEmailTemplateConfigService.findByCode(status.name());
            if (null == baseEmailTemplateConfigDO) {
                failed(status.name() + "邮件模板不存在!");
            }
            //建立邮件消息
            SimpleMailMessage mainMessage = new SimpleMailMessage();
            //发送者
            mainMessage.setFrom(username);
            //接收者
            mainMessage.setTo(saasDO.getEmail());
            //发送的标题
            mainMessage.setSubject(baseEmailTemplateConfigDO.getTemplateName());
            //发送的内容
            StringBuffer content = new StringBuffer();
            content.append(baseEmailTemplateConfigDO.getFirst() + "\n").append(baseEmailTemplateConfigDO.getKeyword1() + "\n");
@ -319,8 +312,8 @@ public class SaasEndpoint extends EnvelopRestEndpoint {
            }
            content.append(baseEmailTemplateConfigDO.getKeyword5() + baseEmailTemplateConfigDO.getUrl() + "\n");
            content.append(baseEmailTemplateConfigDO.getRemark());
            mainMessage.setText(content.toString());
            jms.send(mainMessage);
            boolean blo = SendEmailUtils.sendMessage(saasDO.getEmail(), content.toString(), baseEmailTemplateConfigDO.getTemplateName());
            System.out.println("sendEmail--"+blo);
        } catch (MailException e) {
            e.printStackTrace();
            return failed("邮件发送失败!"+e.getMessage(),ObjEnvelop.class);

+ 5 - 12
svr/svr-base/src/main/java/com/yihu/jw/base/service/saas/SaasService.java

@ -13,6 +13,7 @@ import com.yihu.jw.base.dao.system.SystemDictDao;
import com.yihu.jw.base.dao.system.SystemDictEntryDao;
import com.yihu.jw.base.dao.user.UserDao;
import com.yihu.jw.base.service.dict.DictHospitalDeptService;
import com.yihu.jw.base.util.SendEmailUtils;
import com.yihu.jw.entity.base.dict.*;
import com.yihu.jw.entity.base.module.ModuleDO;
import com.yihu.jw.entity.base.module.SaasModuleDO;
@ -146,19 +147,11 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
    public void send(SaasDO saasDO) {
        try {
            SaasDO.Status status = saasDO.getStatus();
            String password = saasDO.getMobile().substring(0, 6);
            String password = saasDO.getMobile().substring(saasDO.getMobile().length()-6);
            BaseEmailTemplateConfigDO baseEmailTemplateConfigDO = baseEmailTemplateConfigService.findByCode(status.name());
            if (null == baseEmailTemplateConfigDO) {
                return;
            }
            //建立邮件消息
            SimpleMailMessage mainMessage = new SimpleMailMessage();
            //发送者
            mainMessage.setFrom(username);
            //接收者
            mainMessage.setTo(saasDO.getEmail());
            //发送的标题
            mainMessage.setSubject(baseEmailTemplateConfigDO.getTemplateName());
            //发送的内容
            StringBuffer content = new StringBuffer();
            content.append(baseEmailTemplateConfigDO.getFirst() + "\n").append(baseEmailTemplateConfigDO.getKeyword1() + "\n");
@ -174,8 +167,8 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
            }
            content.append(baseEmailTemplateConfigDO.getKeyword5() + baseEmailTemplateConfigDO.getUrl() + "\n");
            content.append(baseEmailTemplateConfigDO.getRemark());
            mainMessage.setText(content.toString());
            jms.send(mainMessage);
            boolean blo = SendEmailUtils.sendMessage(saasDO.getEmail(), content.toString(), baseEmailTemplateConfigDO.getTemplateName());
            System.out.println("sendEmail--"+blo);
        } catch (MailException e) {
            e.printStackTrace();
        }
@ -342,7 +335,7 @@ public class SaasService extends BaseJpaService<SaasDO, SaasDao> {
            String password = user.getPassword();
            //密码默认手机号后6位
            if (StringUtils.isEmpty(password)) {
                password = user.getMobile().substring(0, 6);
                password = user.getMobile().substring(user.getMobile().length()-6);
            }
            user.setPassword(MD5.md5Hex(password + "{" + user.getSalt() + "}"));
            user.setSaasId(saas.getId());

+ 9 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/wx/WechatService.java

@ -400,6 +400,14 @@ public class WechatService {
                wxReplySceneDao.delete(list);
            }
        }
        wxReplySceneDO.setCreateUser(userAgent.getUID());
        wxReplySceneDO.setCreateUserName(userAgent.getUNAME());
        wxReplySceneDO.setCreateTime(new Date());
        wxReplySceneDO.setUpdateUser(userAgent.getUID());
        wxReplySceneDO.setUpdateUserName(userAgent.getUNAME());
        wxReplySceneDO.setUpdateTime(new Date());
        wxReplySceneDao.save(wxReplySceneDO);
        return Envelop.getSuccess(BaseRequestMapping.WeChat.api_success);
    }
@ -504,7 +512,7 @@ public class WechatService {
        if(status!=null){
            sql += " AND s.status = "+status;
        }
        sql+=" LIMIT  " + (page - 1) * size + "," + size + "";
        sql+=" ORDER BY s.create_time DESC LIMIT  " + (page - 1) * size + "," + size + "";
        List<WxReplySceneVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(WxReplySceneVO.class));
        return MixEnvelop.getSuccessListWithPage(BaseRequestMapping.WeChat.api_success, list, page, size, count);

+ 193 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/util/SendEmailUtils.java

@ -0,0 +1,193 @@
package com.yihu.jw.base.util;
import com.sun.mail.util.MailSSLSocketFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import java.io.UnsupportedEncodingException;
import java.util.Calendar;
import java.util.Properties;
/**
 * Created by zdm on 2018/11/21.
 */
@Component
public class SendEmailUtils {
    private static String username;
    private  static  String smtp;
    private  static  String host;
    private  static  String port;
    private  static  String auth;
    private  static  String timeout;
    private  static  String password;
    /**
     * mimeMessage发送邮件
     * @param email 目标邮箱
     * @param content 邮件主体内容
     * @param subject 邮件标题
     * @return
     */
    public static  boolean mimeMessage(String email,String content,String subject){
        // 1.创建一个程序与邮件服务器会话对象 Session
        Properties props = new Properties();
        props.setProperty("mail.transport.protocol", smtp);// 连接协议
        props.setProperty("mail.smtp.host", host);// 连接协议
        props.setProperty("mail.smtp.port", port);// 连接协议
        // 指定验证为true
        props.setProperty("mail.smtp.auth", auth);
        props.setProperty("mail.smtp.timeout",timeout);
        props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        // 验证账号及密码,密码需要是第三方授权码
        Authenticator auth = new Authenticator() {
            public PasswordAuthentication getPasswordAuthentication(){
                return new PasswordAuthentication(username, password);
            }
        };
        Session session = Session.getInstance(props, auth);
        // 2.创建一个Message,它相当于是邮件内容
        MimeMessage message = new MimeMessage(session);
        try {
            //防止成为垃圾邮件,披上outlook的马甲
            message.addHeader("X-Priority", "3");
            message.addHeader("X-MSMail-Priority", "Normal");
            message.addHeader("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869");   //本文以outlook名义发送邮件,不会被当作垃圾邮件
            message.addHeader("X-MimeOLE", "Produced By Microsoft MimeOLE V6.00.2900.2869");
            message.addHeader("ReturnReceipt", "1");
            // 设置发送者
            String nick=javax.mail.internet.MimeUtility.encodeText("厦门i健康");
            message.setFrom(new InternetAddress(nick+" <"+username+">"));
            // 设置发送方式与接收者
            message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(email));
            // 设置主题
            message.setSubject(subject);
            //创建消息主体
            MimeBodyPart messageBodyPart = new MimeBodyPart();
            //发送的内容
            messageBodyPart.setText(content);
            // 创建多重消息
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(messageBodyPart);
            // 设置邮件消息发送的时间
            message.setSentDate(Calendar.getInstance().getTime());
            // 设置内容
            message.setContent(multipart, "text/html;charset=utf-8");
            // 3.创建 Transport用于将邮件发送
            Transport.send(message);
        }catch (Exception e){
            e.printStackTrace();
        }
            return  true;
    }
    /**
     * 邮件发送
     * @param email 目标邮箱
     * @param content 邮件主体内容
     * @param subject 邮件主题
     * @return
     */
    public static boolean  sendMessage(String email,String content,String subject){
        // 配置
        Properties prop=new Properties();
        // 设置邮件服务器主机名,这里是163
        prop.put("mail.host",host );
        // 发送邮件协议名称
        prop.put("mail.transport.protocol",smtp);
        // 是否认证
        prop.put("mail.smtp.auth", auth);
        try {
            // SSL加密
            MailSSLSocketFactory sf = null;
            sf = new MailSSLSocketFactory();
            // 设置信任所有的主机
            sf.setTrustAllHosts(true);
            prop.put("mail.smtp.ssl.enable", true);
            prop.put("mail.smtp.ssl.socketFactory", sf);
            // 创建会话对象
            Session session = Session.getInstance(prop, new Authenticator() {
                // 认证信息,需要提供"用户账号","授权码"
                public PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(username, password);
                }
            });
            // 是否打印出debug信息
//            session.setDebug(true);
            // 创建邮件
            Message message = new MimeMessage(session);
            // 邮件发送者
            message.setFrom(new InternetAddress(username));
            // 邮件接受者
            message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
            // 邮件主题
            message.setSubject(subject);
            message.setContent(content, "text/html;charset=UTF-8");
            // Transport.send(message);
            // 邮件发送
            Transport transport = session.getTransport();
            transport.connect();
            transport.sendMessage(message, message.getAllRecipients());
            transport.close();
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
        return true;
    }
    @Value("${spring.mail.username}")
    public void setUsername(String username) {
        SendEmailUtils.username = username;
    }
    @Value("${spring.mail.protocol}")
    public void setSmtp(String smtp) {
        SendEmailUtils.smtp = smtp;
    }
    @Value("${spring.mail.host}")
    public void setHost(String host) {
        SendEmailUtils.host = host;
    }
    @Value("${spring.mail.port}")
    public void setPort(String port) {
        SendEmailUtils.port = port;
    }
    @Value("${spring.mail.properties.mail.smtp.auth}")
    public void setAuth(String auth) {
        SendEmailUtils.auth = auth;
    }
    @Value("${spring.mail.timeout}")
    public void setTimeout(String timeout) {
        SendEmailUtils.timeout = timeout;
    }
    @Value("${spring.mail.password}")
    public void setPassword(String password) {
        SendEmailUtils.password = password;
    }
}

+ 1 - 0
svr/svr-base/src/main/resources/application.yml

@ -41,6 +41,7 @@ spring:
    properties.mail.smtp.auth: true
    properties.mail.smtp.starttls.enable: true
    properties.mail.smtp.starttls.required: true
    timeout: 1000
    host: smtp.163.com
#发送者的邮箱密码
    password: xmijk181016jkzl

+ 1 - 4
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/dict/SystemDictEntryController.java

@ -7,17 +7,14 @@ import com.yihu.jw.healthyhouse.model.dict.SystemDict;
import com.yihu.jw.healthyhouse.model.dict.SystemDictEntry;
import com.yihu.jw.healthyhouse.service.dict.SystemDictEntryService;
import com.yihu.jw.healthyhouse.service.dict.SystemDictService;
import com.yihu.jw.restmodel.web.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.health.house.HealthyHouseMapping;
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.web.bind.annotation.*;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**

+ 0 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/facilities/FacilitiesServerController.java

@ -17,7 +17,6 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

+ 1 - 3
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FacilityUsedRecordController.java

@ -1,9 +1,8 @@
package com.yihu.jw.healthyhouse.controller.user;
import com.google.common.base.Joiner;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.model.facility.Facility;
import com.yihu.jw.healthyhouse.model.facility.FacilityServerRelation;
import com.yihu.jw.healthyhouse.model.user.FacilityUsedRecord;
import com.yihu.jw.healthyhouse.model.user.NavigationServiceEvaluation;
@ -24,7 +23,6 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.ArrayList;

+ 0 - 5
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/controller/user/FeedBackController.java

@ -3,7 +3,6 @@ package com.yihu.jw.healthyhouse.controller.user;
import com.yihu.jw.exception.business.ManageException;
import com.yihu.jw.healthyhouse.model.user.FeedBack;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.service.user.FeedBackService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -16,15 +15,11 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**

+ 0 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/dao/dict/SystemDictEntryDao.java

@ -2,8 +2,6 @@ package com.yihu.jw.healthyhouse.dao.dict;
import com.yihu.jw.healthyhouse.model.dict.DictEntryKey;
import com.yihu.jw.healthyhouse.model.dict.SystemDictEntry;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

+ 0 - 13
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/interceptor/ActivatedInterceptor.java

@ -1,38 +1,25 @@
package com.yihu.jw.healthyhouse.interceptor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.healthyhouse.constant.LoginInfo;
import com.yihu.jw.healthyhouse.model.user.User;
import com.yihu.jw.healthyhouse.service.user.UserService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.wlyy.HouseUserContant;
import javassist.*;
import javassist.bytecode.CodeAttribute;
import javassist.bytecode.LocalVariableAttribute;
import javassist.bytecode.MethodInfo;
import net.sf.json.JSON;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

+ 0 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/dict/SystemDictEntry.java

@ -2,14 +2,12 @@ package com.yihu.jw.healthyhouse.model.dict;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import com.yihu.jw.healthyhouse.util.PinyinUtil;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

+ 0 - 1
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/model/user/FeedBack.java

@ -7,7 +7,6 @@ import org.hibernate.annotations.Formula;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
/**
 * 意见反馈

+ 0 - 2
svr/svr-healthy-house/src/main/java/com/yihu/jw/healthyhouse/service/dict/SystemDictEntryService.java

@ -7,8 +7,6 @@ import com.yihu.jw.healthyhouse.model.dict.SystemDictEntry;
import com.yihu.mysql.query.BaseJpaService;
import org.hibernate.SQLQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

+ 6 - 0
svr/svr-wlyy-specialist/pom.xml

@ -115,6 +115,12 @@
            <artifactId>jxl</artifactId>
            <version>2.6</version>
        </dependency>
        <!-- redis start  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!-- redis end  -->
    </dependencies>

+ 50 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -15,6 +15,7 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -31,6 +32,8 @@ public class SpecialistController extends EnvelopRestEndpoint {
    private SpecialistService specialistService;
    @Autowired
    private Tracer tracer;
    @Autowired
    private StringRedisTemplate redisTemplate;
    @PostMapping(value = SpecialistMapping.specialist.createSpecialistRelation)
    @ApiOperation(value = "创建专科医生与患者匹配关系")
@ -396,7 +399,7 @@ public class SpecialistController extends EnvelopRestEndpoint {
    public ObjEnvelop<Object> searchPatientInSpecialist(
            @ApiParam(name = "doctorCode", value = "医生code",required = true)
            @RequestParam(value = "doctorCode",required = true)String doctorCode,
            @ApiParam(name = "patientCode", value = "居民id")
            @ApiParam(name = "patientCode", value = "居民id",required = true)
            @RequestParam(value = "patientCode",required = true)String patientCode){
        try {
            JSONObject object=specialistService.doctorForSpecialistInfo(doctorCode,patientCode);
@ -438,6 +441,52 @@ public class SpecialistController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "/redisFindPatientTeamList")
    @ApiOperation(value = "text-redis获取居民所有有效签约团队信息")
    public ObjEnvelop<Boolean> redisFindPatientTeamList(@ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient){
        try {
            String key = "specialist_patient_relation:" +patient +"_"+ ":text";
            return success(redisTemplate.opsForValue().get(key)==null?false:true);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return failed(e.getMessage(),ObjEnvelop.class);
        }
    }
    @GetMapping(value =SpecialistMapping.specialist.updateRedisFindPatientTeamList)
    @ApiOperation(value = "更新-redis获取居民所有有效签约团队信息")
    public ObjEnvelop<Integer> updateRedisFindPatientTeamList(){
        try {
            return success(specialistService.updateRedisFindPatientTeamList());
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return failed(e.getMessage(),ObjEnvelop.class);
        }
    }
    /**
     * 根据共管医生和居民code查询专科签约信息
     * @param patient
     * @param doctor
     * @return
     */
    @GetMapping(value =SpecialistMapping.specialist.selectByAssistant)
    @ApiOperation(value = "根据共管医生和居民code查询专科签约信息")
    public MixEnvelop<SpecialistPatientRelationDO,SpecialistPatientRelationDO> selectByAssistant(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(required = true)String patient,
            @ApiParam(name = "doctor", value = "共管医生code") @RequestParam(required = true)String doctor){
        try {
            MixEnvelop envelop = new MixEnvelop();
            envelop.setDetailModelList(specialistService.selectByAssistant(patient,doctor));
            return envelop;
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 13 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java

@ -391,4 +391,17 @@ public class RehabilitationManageController {
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.serviceItem.getServiceItemsAfterStop)
    @ApiOperation(value = "康复管理-中止康复计划结算项目清单")
    public ObjEnvelop getServiceItemsAfterStop(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                  @RequestParam(value = "planId", required = true)String planId){
        try {
            return rehabilitationManageService.getServiceItemsAfterStop(planId);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}

+ 54 - 12
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java

@ -3,15 +3,9 @@ package com.yihu.jw.controller.rehabilitation;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.dao.rehabilitation.RehabilitationOperateRecordsDao;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -28,8 +22,8 @@ import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -265,16 +259,22 @@ public class RehabilitationPlanController extends EnvelopRestEndpoint {
    @PostMapping(value = SpecialistMapping.rehabilitation.updatePlanStatusById)
    @ApiOperation(value = "康复管理-更新康复计划状态")
    public Envelop updatePlanStatusById(@ApiParam(name = "planId", value = "康复计划id", required = true)
    public MixEnvelop updatePlanStatusById(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                              @RequestParam(value = "planId", required = true)String planId,
                                              @ApiParam(name = "status", value = "状态", required = true)
                                              @RequestParam(value = "status", required = true)Integer status){
                                              @RequestParam(value = "status", required = true)Integer status,
                                              @ApiParam(name = "abortReason", value = "中止原因", required = true)
                                              @RequestParam(value = "abortReason", required = false)String abortReason){
        try {
            return rehabilitationPlanService.updatePlanStatusById(status,planId);
            if(status!=0){
                return rehabilitationPlanService.updatePlanStatusById(status,planId);
            }else {
                return rehabilitationPlanService.abortPlanById(planId,abortReason);
            }
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
@ -299,4 +299,46 @@ public class RehabilitationPlanController extends EnvelopRestEndpoint {
            return Envelop.getError(e.getMessage());
        }
    }
    /*@PostMapping(value = SpecialistMapping.rehabilitation.abortPlanById)
    @ApiOperation(value = "康复管理-中止康复计划填写中止原因")
    public Envelop abortPlanById(@ApiParam(name = "planId", value = "康复计划id", required = true)
                                           @RequestParam(value = "planId", required = true)String planId,
                                           @ApiParam(name = "abortReason", value = "中止原因", required = true)
                                           @RequestParam(value = "abortReason", required = true)String abortReason){
        try {
            return rehabilitationPlanService.abortPlanById(planId,abortReason);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    }*/
    /**
     * 根据居民code和标签code获取康复计划
     *
     * @param patient
     * @param label
     * @return
     */
    @GetMapping(value = SpecialistMapping.rehabilitation.selectByLabelAndPatient)
    @ApiOperation(value = "根据标签获取康复计划")
    public MixEnvelop selectByLabelAndPatient(@ApiParam(name = "patient", value = "居民code")
                                                 @RequestParam(required = true)String patient,
                                                 @ApiParam(name = "label", value = "标签code")
                                                 @RequestParam(required = false)String label){
        try {
            MixEnvelop envelop = new MixEnvelop();
            List<PatientRehabilitationPlanDO> planDOS = rehabilitationPlanService.selectByLabelAndPatient(patient,label);
            envelop.setDetailModelList(planDOS);
            return envelop;
        } catch (Exception e) {
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return MixEnvelop.getError(e.getMessage());
        }
    }
}

+ 4 - 2
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/SpecialistPatientRelationDao.java

@ -14,9 +14,11 @@ public interface SpecialistPatientRelationDao extends PagingAndSortingRepository
        JpaSpecificationExecutor<SpecialistPatientRelationDO> {
    public List<SpecialistPatientRelationDO> findByDoctorAndStatus(String doctor,String status);
    @Query("select p from SpecialistPatientRelationDO p where p.doctor=?1 and p.patient =?2 and p.status>=0")
    @Query("select p from SpecialistPatientRelationDO p where p.doctor=?1 and p.patient =?2 and p.status>=0 and p.signStatus=1")
    public SpecialistPatientRelationDO findByDoctorAndPatient(String doctor,String patient);
    @Query("select p from SpecialistPatientRelationDO p where p.doctor=?1 and (p.patient=?2 or p.healthAssistant=?2) and p.signStatus='1' and p.status>=0 ")
    SpecialistPatientRelationDO findByPatientAndDoctor(String doctor,String patient);
    SpecialistPatientRelationDO findByPatientAndDoctor(String doctor, String patient);
    List<SpecialistPatientRelationDO> findAllBySignStatus(String signStatus);
}

+ 10 - 2
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/PatientRehabilitationPlanDao.java

@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -35,6 +36,13 @@ public interface PatientRehabilitationPlanDao extends PagingAndSortingRepository
    @Query("select count(distinct p.patient) from PatientRehabilitationPlanDO p where p.createUser=?1  and p.status>0 ")
    Integer patientCount(String doctorCode);
    @Query("select count(distinct p.patient) from PatientRehabilitationPlanDO p where p.createUser=?1  and p.status=1 ")
    Integer patientCountByUnfinish(String doctorCode);
    @Query("select count(distinct p.patient) from PatientRehabilitationPlanDO p where p.createUser=?1  and p.status=2 ")
    Integer getFinishPatientCount(String doctorCode);
//    @Query("update PatientRehabilitationPlanDO a set a.status=0,a.abortReason=?1,a.abortTime=?3 where a.id =?2 ")
//    @Modifying
//    int abortPlanById(String abortReason, String id, Date abortTime);
    @Query("select p from PatientRehabilitationPlanDO p where p.disease =?1 and p.status=1 and p.patient=?2")
    List<PatientRehabilitationPlanDO> selectByDiseaseAndPatient(String disease,String patient);
}

+ 3 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java

@ -68,4 +68,7 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    @Query(value ="select p.patient from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.id=?1",nativeQuery = true)
    List<String> findPatientById(String planDetailId);
    @Query
    List<RehabilitationDetailDO> findByPlanIdAndStatus(String planId,int status);
}

+ 111 - 51
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -1,10 +1,11 @@
package com.yihu.jw.service;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dao.*;
import com.yihu.jw.entity.specialist.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.dao.PatientHospitalRecordDao;
import com.yihu.jw.dao.SpecialistPatientRelationDao;
import com.yihu.jw.entity.specialist.SpecialistPatientRelationDO;
import com.yihu.jw.restmodel.specialist.*;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.util.common.IdCardUtil;
@ -12,12 +13,12 @@ import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@ -43,6 +44,8 @@ public class SpecialistService{
    private JdbcTemplate jdbcTemplate;
    @Value("${basedb.name}")
    private String basedb;
    @Autowired
    private StringRedisTemplate redisTemplate;
    public MixEnvelop<Boolean, Boolean> createSpecialistsPatientRelation(SpecialistPatientRelationDO specialistPatientRelationDO){
        specialistPatientRelationDao.save(specialistPatientRelationDO);
@ -200,8 +203,8 @@ public class SpecialistService{
                " lb.labelType, " +
                " lb.label, " +
                " p.photo, " +
                " h.label_name as health, " +
                " h.label AS healthcode ," +
                " lb.labelName as health, " +
                " lb.label AS healthcode ," +
                " s.health_assistant AS healthAssistant," +
                " s.health_assistant_name AS healthAssistantName" +
                " FROM " +
@ -220,20 +223,9 @@ public class SpecialistService{
                " ) lb " +
                " JOIN "+basedb+".wlyy_patient p ON p. CODE = lb.patient " +
                " JOIN wlyy_specialist_patient_relation s ON s.patient = lb.patient " +
                " LEFT JOIN ( " +
                " SELECT " +
                "  t.label, " +
                "  t.label_name, " +
                "  t.patient " +
                " FROM " +
                "  "+basedb+".wlyy_sign_patient_label_info t " +
                " WHERE " +
                "  t.label_type = '8' " +
                " AND t.`status` = '1' " +
                " ) h ON h.patient = lb.patient " +
                " WHERE s.doctor ='"+doctor+"' AND s.status >=0  AND s.sign_status >0"+
                " WHERE ( s.doctor ='"+doctor+"' OR s.health_doctor='"+doctor+"' OR s.health_assistant='"+doctor+ "') AND s.status >=0  AND s.sign_status >0"+
                " LIMIT "+(page-1)*size+","+size;
        
        System.out.print("日志:"+sql);
        if("7".equals(labelType)){
            sql = "SELECT " +
                    "c.CODE," +
@ -250,8 +242,8 @@ public class SpecialistService{
                    "JOIN "+basedb+".wlyy_patient_disease_server b ON a.id=b.specialist_relation_code AND b.disease=" +labelCode+" and b.del=1 "+
                    "JOIN "+basedb+".wlyy_patient c ON a.patient=c.CODE " +
                    "LEFT JOIN "+basedb+".wlyy_sign_patient_label_info d ON a.patient=d.patient AND d.label_type=8 AND d.`status`=1" +
                    " WHERE a.sign_status> 0 AND a.`status`>=0 AND a.doctor='"+doctor+"'"+
                    " LIMIT "+(page-1)*size+","+size;
                    " WHERE a.sign_status> 0 AND a.`status`>=0 AND a.doctor='"+doctor+"' OR a.health_assistant= '"+doctor+
                    "' LIMIT "+(page-1)*size+","+size;
        }
@ -260,26 +252,27 @@ public class SpecialistService{
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,PatientLabelVOs);
    }
    public MixEnvelop<Long, Long> getLabelpatientCount(String doctor, String label, String labelType){
    public MixEnvelop<Long, Long> getLabelpatientCount(String doctor, String labelType, String label){
        String sql = "SELECT " +
                " COUNT(1) as total " +
                " FROM " +
                " ( " +
                "  SELECT " +
                "   i.label_type AS labelType, " +
                "   i.label, " +
                "   i.label_name AS labelName, " +
                "   i.patient " +
                "  FROM " +
//                " ( " +
//                "  SELECT " +
//                "   i.label_type AS labelType, " +
//                "   i.label, " +
//                "   i.label_name AS labelName, " +
//                "   i.patient " +
//                "  FROM " +
                "   "+basedb+".wlyy_sign_patient_label_info i " +
                "  WHERE " +
                "   i.label = '"+label+"' "+
                "  AND i.label_type = '"+labelType+"' " +
                "  AND i.`status` = '1' " +
                " ) lb " +
                " JOIN wlyy_specialist_patient_relation s ON s.patient = lb.patient " +
                " WHERE " +
                " s.doctor = '"+doctor+"' AND s.status >=0  AND s.sign_status >0";
                " AND i.patient in ( " +
                " select patient from  wlyy_specialist_patient_relation  WHERE " +
                "( doctor = '"+doctor+"' OR health_doctor = '"+doctor+"' OR health_assistant='"+doctor+ "' ) AND STATUS >= 0 AND sign_status > 0 )";
//                +" ) lb ";
        System.out.print("日志:"+sql);
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sql);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
@ -504,6 +497,9 @@ public class SpecialistService{
            relation.setHealthAssistantName(health_assistant_name);
            relation.setSignDate(new Date());
            specialistPatientRelationDao.save(relation);
            //签约成功之后,将签约关系保存在redis中
            String key = "specialist_patient_relation:" + relation.getPatient() +"_"+ ":text";
            redisTemplate.opsForValue().set(key,"true");
        }
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,relation);
    }
@ -576,6 +572,7 @@ public class SpecialistService{
    public MixEnvelop findPatientSignSpecialist(String patient){
        String sql = "SELECT " +
                " r.id AS relationCode, " +
                " r.patient, " +
                " r.team_code AS teamCode," +
                " r.patient_name AS patientName, " +
@ -774,23 +771,32 @@ public class SpecialistService{
//    }
    /**
     * 专科-模糊搜索注册居民
     * 专科-模糊搜索注册居民(未与该医生所在团队医生签约的居民)
     * @param doctorCode
     * @param keywords
     */
    public MixEnvelop searchPatientInSpecialist(String doctorCode,String keywords,Integer page,Integer pageSize) throws Exception{
        String sql1 = " select count(1) as num ";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo,CASE WHEN wsf.status ='-4' THEN '已到期' WHEN wsf.status ='0' THEN '待签约' WHEN wsf.status ='1' THEN '已签约' WHEN wsf.status ='2' THEN '已签约' WHEN wsf.status ='3' THEN '已签约' ELSE '待签约' END  status  ";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo ";
        String whereSql ="";
        if(!StringUtils.isEmpty(keywords)){
            whereSql+=" and (p.name like '%"+keywords+"%' or p.idcard like '%"+keywords+"%' or p.mobile like '%"+keywords+"%') ";
//            whereSql+=" and (p.name like '%"+keywords+"%' or p.idcard like '%"+keywords+"%' or p.mobile like '%"+keywords+"%') ";
            whereSql+=" and  p.mobile ='"+keywords+"'";
        }
        String centerSql =" from "+basedb+".wlyy_patient p LEFT JOIN  "+basedb+".wlyy_sign_family wsf ON p.code=wsf.patient AND wsf.type='1'" +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' and doctor='"+doctorCode+"')"+" AND p.openid IS NOT NULL "+
        String centerSql =" from "+basedb+".wlyy_patient p  " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' " +
                " AND doctor in (SELECT m.doctor_code FROM  "+basedb+".wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  "+basedb+".wlyy_admin_team dt LEFT JOIN  "+basedb+".wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1'))"
                +" AND p.openid IS NOT NULL "+
               whereSql;
        String countCenterSql =" from "+basedb+".wlyy_patient p " +
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1' and doctor='"+doctorCode+"')"+" AND p.openid IS NOT NULL "+
                " WHERE p.code not in (SELECT r.patient FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE r.sign_status = '1'" +
                " AND doctor in (SELECT m.doctor_code FROM  "+basedb+".wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  "+basedb+".wlyy_admin_team dt LEFT JOIN  "+basedb+".wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctorCode+"') AND  m.available='1'))"
                +" AND p.openid IS NOT NULL "+
                whereSql;
        String sqlCount=sql1+countCenterSql;
        String sql=sql2+centerSql+" LIMIT "+(page-1)*pageSize+","+pageSize;
@ -802,13 +808,16 @@ public class SpecialistService{
        String sex = null;
        String sexName="";
        for(Map<String,Object> one:map){
            StringBuffer statusSql =new StringBuffer( " select CASE WHEN wsf.status ='-4' THEN '已到期' WHEN wsf.status ='0' THEN '待签约' WHEN wsf.status ='1' THEN '已签约' WHEN wsf.status ='2' THEN '已签约' WHEN wsf.status ='3' THEN '已签约' ELSE '待签约' END  status  ");
            statusSql.append("FROM wlyy.wlyy_sign_family wsf, (SELECT patient,Max(apply_date) applyDate FROM wlyy.wlyy_sign_family WHERE type = '2' AND patient='"+one.get("code")+"' GROUP BY patient) temp WHERE wsf.patient=temp.patient AND wsf.apply_date=temp.applyDate");
            List<Map<String,Object>> strMap= jdbcTemplate.queryForList(statusSql.toString());
            m = new HashMap();
            age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
            sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
            m.put("name",one.get("name"));
            m.put("age",age);
            m.put("sex",sex);
            m.put("status",one.get("status"));
            m.put("status", !(null != strMap && strMap.size() > 0) ? "待签约" : strMap.get(0).get("status"));
            if("1".equals(sex)){
                sexName="男";
            }else if("2".equals(sex)){
@ -834,14 +843,24 @@ public class SpecialistService{
    public JSONObject doctorForSpecialistInfo(String doctorCode, String patientCode)  throws Exception{
        JSONObject jsonObject = new JSONObject();
        //1、获取居民基础信息
        String preSql = "SELECT p.name as name,CASE p.sex WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END as sex,IFNULL(year( from_days( datediff( now(), p.birthday))),'未知') as age," +
                " p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wsf.doctor_name is null THEN '无' ELSE wsf.doctor_name END as doctorName,CASE  WHEN wsf.hospital_name is NULL THEN '无' ELSE wsf.hospital_name END as hospitalName,CASE  WHEN wsf.mobile is NULL THEN '无' ELSE wsf.mobile END as doctorMobole ";
        String preSql = "SELECT p.name as name, p.photo as photo,p.idcard as idcard,p.mobile as mobile,p.medicare_number as medicareNumber,p.ssc as ssc," +
                " CASE  WHEN wd.name is null THEN '无' ELSE wd.name END as doctorName,CASE  WHEN wd.hospital_name is NULL THEN '无' ELSE wd.hospital_name END as hospitalName,CASE  WHEN wd.mobile is NULL THEN '无' ELSE wd.mobile END as doctorMobole ";
        String patientSql = " from " + basedb + ".wlyy_patient p LEFT JOIN " + basedb + ".wlyy_sign_family wsf " +
                " ON p.code=wsf.patient AND wsf.type='2' AND wsf.status='1' " +
                " LEFT JOIN " + basedb + ".wlyy_doctor wd ON wsf.doctor =wd.code WHERE p.code='" + patientCode + "'";
        //一个居民 生效的家签信息只会有一条
        Map<String, Object> map = jdbcTemplate.queryForMap(preSql + patientSql);
        map.put("age",IdCardUtil.getAgeForIdcard(map.get("idcard")+""));
        String sexCode=IdCardUtil.getSexForIdcard_new(map.get("idcard")+"");
        String sexName="";
        if("1".equals(sexCode)){
            sexName="男";
        }else if("2".equals(sexCode)){
            sexName="女";
        }else{
            sexName="未知";
        }
        map.put("sex",sexName);
        jsonObject.put("patientInfo", map);
        //2、获取医生信息(所属医院、科室、姓名)
@ -859,17 +878,26 @@ public class SpecialistService{
            objectMap.put("teamId", i);
            objectMap.put("teamName", m.get(i).get(0).get("teamName"));
            objectMap.put("teamDoctors", m.get(i));
            //获取专科团队疾病标签
           String disSql = "SELECT wtdr.disease_code, wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code ='" + i + "'" +"  AND wtdr.del='1'";
            //new BeanPropertyRowMapper(
            List<Map<String, Object>>  stringList = jdbcTemplate.queryForList(disSql);
            String areaSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1'";
            List<String> signDiseaseList = jdbcTemplate.queryForList(areaSql,String.class);
            Set<String> stringSet =new HashSet<>(signDiseaseList);
//            stringSet.addAll(new HashSet<>(signDiseaseList));
            //已签约的疾病状态改成1
            stringList.stream().forEach(item->{
                item.put("status",stringSet.contains( item.get("disease_code"))?1:0) ;
            });
            objectMap.put("teamDisease", stringList);
            mapList.add(objectMap);
        }
        jsonObject.put("teamAndDoctors", mapList);
        //获取专科团队疾病标签
        teamSql = "SELECT wtdr.disease_name from  wlyy.wlyy_team_disease_relation wtdr WHERE wtdr.team_code IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND wtdr.del='1'";
        //new BeanPropertyRowMapper(
        List<String> stringList = jdbcTemplate.queryForList(teamSql, String.class);
        jsonObject.put("teamDisease", stringList.stream().collect(Collectors.joining(" ")));
        //疾病标签
        teamSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(teamSql);
        //康复情况标签
        String labelSql = "SELECT wspl.label_code,wspl.label_name from  wlyy.wlyy_sign_patient_label wspl WHERE wspl.label_type='8' AND status='1'";
        List<Map<String, Object>> signPatientLabelList = jdbcTemplate.queryForList(labelSql);
        jsonObject.put("signPatientLabels", signPatientLabelList);
        return jsonObject;
    }
@ -883,13 +911,45 @@ public class SpecialistService{
    public ObjEnvelop<SpecialistPatientRelationDO> createPatientInSpeciaRelation(SpecialistPatientRelationDO specialistPatientRelationDO) throws Exception {
        specialistPatientRelationDO.setSignStatus("1");
        specialistPatientRelationDO.setSignDate(new Date());
        specialistPatientRelationDO.setCreateTime(new Date());
        specialistPatientRelationDO.setCreateUser(specialistPatientRelationDO.getDoctor());
        specialistPatientRelationDO.setCreateUserName(specialistPatientRelationDO.getDoctorName());
        specialistPatientRelationDO.setStatus("1");//计管师分配状态
        specialistPatientRelationDO.setSignYear(String.valueOf(DateUtil.getNowYear()));
        specialistPatientRelationDO.setSignDate(new Date());
        specialistPatientRelationDO = specialistPatientRelationDao.save(specialistPatientRelationDO);
        //签约成功之后,将签约关系保存在redis中
        String key = "specialist_patient_relation:" + specialistPatientRelationDO.getPatient() +"_"+ ":text";
        redisTemplate.opsForValue().set(key,"true");
        return ObjEnvelop.getSuccess("success", specialistPatientRelationDO);
    }
    public Integer updateRedisFindPatientTeamList(){
        List<SpecialistPatientRelationDO> specialistPatientRelationDOList=specialistPatientRelationDao.findAllBySignStatus("1");
        List<SpecialistPatientRelationDO> unique = specialistPatientRelationDOList.stream().collect(
                Collectors.collectingAndThen(
                        Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SpecialistPatientRelationDO::getPatient))), ArrayList::new)
        );
        unique.stream().forEach(item->{
            //签约成功之后,将签约关系保存在redis中
            String key = "specialist_patient_relation:" + item.getPatient() +"_"+ ":text";
            redisTemplate.opsForValue().set(key,"true");
        });
        return null==unique?0:unique.size();
    }
    /**
     * 根据共管医生和居民code查询专科签约信息
     *
     * @param patient
     * @param doctor
     * @return
     */
    public List<SpecialistPatientRelationDO> selectByAssistant(String patient,String doctor){
        String sql = "select * from wlyy_specialist_patient_relation r where r.health_assistant = '"+doctor+"' and r.patient = '"+patient+"' ";
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
        return relationDOS;
    }
}

+ 73 - 7
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -66,16 +66,19 @@ public class RehabilitationManageService {
     */
    public MixEnvelop<Map<String,Object>, Map<String,Object>> findRehabilitationPlan(Integer doctorType,String doctorCode, String diseaseCode, Integer planType,Integer todaybacklog, String patientCondition,Integer page, Integer pageSize) throws Exception{
        String leftSql =" join "+basedb+".wlyy_sign_family f on f.patient=p.patient and f.expenses_status='1' and f.status=1 ";
//        if(StringUtils.isNotEmpty(diseaseCode)){
//            leftSql += " left join "+basedb+".wlyy_patient_disease_server s on p.patient=s.patient and s.del=1 and s.disease ='"+diseaseCode+"'" ;
//        }
        String leftSql = "";
        String sql = " select p.*  from wlyy_specialist.wlyy_patient_rehabilitation_plan p  " ;
        if(doctorType==2){//家医是根据签约关系过滤
            leftSql =" join "+basedb+".wlyy_sign_family f on f.patient=p.patient and f.expenses_status='1' and f.status=1 ";
            leftSql+=" and (f.doctor='"+doctorCode+"' or f.doctor_health='"+doctorCode+"') ";
            sql.replace("from", ",f.idcard,f.hospital_name from");
            sql += leftSql;
        }
        String sql = " select p.*,f.idcard,f.hospital_name from wlyy_specialist.wlyy_patient_rehabilitation_plan p  " +leftSql+
                " where 1=1 " ;
        sql += " where p.`status` > 0 ";
        if(planType!=null){
            sql += " and p.plan_type="+planType;
        }
@ -573,7 +576,8 @@ public class RehabilitationManageService {
     */
    public ObjEnvelop serviceItem(String planDetailId,String doctorCode) throws Exception{
        String sql = "select i.title,i.content,i.type as itemType,i.reserve,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as executeDoctor, " +
                " d.doctor_name as executeDoctorName,p.patient ,p.name as patientName,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus" +
                " d.doctor_name as executeDoctorName,p.patient ,p.name as patientName,p.create_user as createDoctor,p.create_user_name as createDoctorName, p.status as planStatus," +
                " p.disease,p.disease_name as diseaseName,p.title as planTitle"+
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_service_item i on i.id = h.service_item_id " +
@ -616,6 +620,9 @@ public class RehabilitationManageService {
        }
        resultMap.put("statusName",statusName);//状态名称
        resultMap.put("status",status);//状态
        resultMap.put("disease",one.get("disease"));
        resultMap.put("diseaseName",one.get("diseaseName"));
        resultMap.put("planTitle",one.get("planTitle"));
        //指导与汇报
        List<GuidanceMessageLogDO> messageList = guidanceMessageLogDao.findByPlanDetailId(one.get("id").toString());
        List<Map<String,Object>> messageMapList = new ArrayList<>();
@ -1156,8 +1163,15 @@ public class RehabilitationManageService {
        Map<String,Object> resultMap = new HashMap<>();
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
        Integer finishedCount = rehabilitationDetailDao.findByStatusAndPlanId(1,planId);
        PatientRehabilitationPlanDO p =patientRehabilitationPlanDao.findById(planId);
        resultMap.put("allCount",allCount);
        resultMap.put("finishedCount",finishedCount);
        if (p!=null){
            resultMap.put("disease",p.getDisease());
            resultMap.put("diseaseName",p.getDiseaseName());
            resultMap.put("createUser",p.getCreateUser());
            resultMap.put("planTitle",p.getTitle());
        }
//        resultMap.put("healthyCondition",healthyCondition);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,resultMap);
    }
@ -1179,10 +1193,10 @@ public class RehabilitationManageService {
     */
    public ObjEnvelop patientCount(String doctorCode){
        Integer count =patientRehabilitationPlanDao.patientCount(doctorCode);
        Integer unfinishCount = patientRehabilitationPlanDao.patientCountByUnfinish(doctorCode);
        Integer finishCount = patientRehabilitationPlanDao.getFinishPatientCount(doctorCode);
        Map<String,Object> map = new HashMap<>();
        map.put("planCount",count);
        map.put("finishedPlanCount",count-unfinishCount);
        map.put("finishedPlanCount",finishCount);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,map);
    }
@ -1233,4 +1247,56 @@ public class RehabilitationManageService {
        envelop.setObj(rehabilitationDetailDOS);
        return envelop;
    }
    public ObjEnvelop getServiceItemsAfterStop(String planId)throws Exception{
        Map<String,Object> reslutMap = new HashMap<>();
        String sql ="SELECT" +
                " p.patient," +
                " p.`name`," +
                " p.title," +
                " p.disease_name,p.abort_reason,p.abort_time," +
                " a.*" +
                " FROM" +
                " wlyy_patient_rehabilitation_plan p" +
                " LEFT JOIN (" +
                "  SELECT" +
                "  d.id," +
                "  d.plan_id," +
                "  d.hospital," +
                "  d.hospital_name," +
                "  i.service_item_id," +
                "  i.service_item_name," +
                "  d.expense," +
                "  r.doctor_code," +
                "  r.doctor_name," +
                "  r.complete_time" +
                "  FROM" +
                "  wlyy_rehabilitation_plan_detail d" +
                "  LEFT JOIN wlyy_hospital_service_item i ON d.hospital_service_item_id = i.id" +
                "  LEFT JOIN wlyy_rehabilitation_operate_records r ON d.id = r.rehabilitation_detail_id" +
                "  WHERE" +
                "  r.`status` = 1" +
                " ) a ON p.id = a.plan_id" +
                " WHERE" +
                " p.id = '"+planId+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        Integer allCount = rehabilitationDetailDao.findAllByPlanId(planId);//计划总服务项目数
        Integer finishCount = list.size();//完成服务项目数
        double totalExpense = 0;
        DecimalFormat df = new DecimalFormat("0.00");
        for (Map<String,Object> map : list){
            double expense = 0;
            if (StringUtils.isNotEmpty(String .valueOf(map.get("expense"))) && !"null".equals(String .valueOf(map.get("expense")))){
                expense =Integer.valueOf(String .valueOf(map.get("expense")));
            }
            totalExpense += expense;
            map.put("expense",df.format(expense/100));
        }
        reslutMap.put("totalExpense",df.format(totalExpense/100));
        reslutMap.put("allCount",allCount);
        reslutMap.put("finishCount",finishCount);
        reslutMap.put("serviceList",list);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,reslutMap);
    }
}

+ 30 - 25
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

@ -1,24 +1,12 @@
package com.yihu.jw.service.rehabilitation;
import com.yihu.jw.dao.rehabilitation.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationDetailDao;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.dao.rehabilitation.*;
import com.yihu.jw.entity.rehabilitation.RehabilitationPlanningDO;
import com.yihu.jw.dao.rehabilitation.RehabilitationPlanTemplateDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationTemplateDetailDao;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationTemplateDetailDO;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.specialist.PatientSignInfoVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -28,13 +16,10 @@ import com.yihu.jw.service.FileUploadService;
import com.yihu.jw.service.SpecialistHospitalServiceItemService;
import com.yihu.jw.service.SpecialistService;
import com.yihu.jw.util.HttpClientUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
@ -42,11 +27,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
@ -392,11 +372,36 @@ public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlan
     * @param planId
     * @return
     */
    public Envelop updatePlanStatusById(Integer status, String planId) throws Exception{
    public MixEnvelop updatePlanStatusById(Integer status, String planId) throws Exception{
        if(patientRehabilitationPlanDao.updateStatusById(status,planId)>0){
            return Envelop.getSuccess(SpecialistMapping.api_success);
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRehabilitationPlanDao.findById(planId));
        }
        return MixEnvelop.getError("更新失败!");
    }
    public MixEnvelop abortPlanById(String planId,String abortReason){
        PatientRehabilitationPlanDO patientRehabilitationPlanDO=patientRehabilitationPlanDao.findById(planId);
        List<RehabilitationDetailDO> detailDOList = rehabilitationDetailDao.findByPlanIdAndStatus(planId,0);
        if(null!=patientRehabilitationPlanDO){
            patientRehabilitationPlanDO.setAbortReason(abortReason);
            patientRehabilitationPlanDO.setAbortTime(new Date());
            patientRehabilitationPlanDO.setStatus(0);
            patientRehabilitationPlanDao.save(patientRehabilitationPlanDO);
            return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientRehabilitationPlanDO,detailDOList);
        }
        return Envelop.getError("更新失败!");
        return MixEnvelop.getError("更新失败!");
    }
    /**
     * 根据标签和居民code查找康复计划
     *
     * @param patient
     * @param label
     * @return
     */
    public List<PatientRehabilitationPlanDO> selectByLabelAndPatient(String patient,String label){
        return patientRehabilitationPlanDao.selectByDiseaseAndPatient(label,patient);
    }
}

+ 14 - 1
svr/svr-wlyy-specialist/src/main/resources/application.yml

@ -75,6 +75,9 @@ spring:
    url: jdbc:mysql://172.19.103.77:3306/wlyy_specialist?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: root
    password: 123456
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
@ -109,6 +112,9 @@ spring:
    url: jdbc:mysql://172.17.110.160/wlyy_specialist?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: ssgg
    password: ssgg
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
@ -142,6 +148,9 @@ spring:
    url: jdbc:mysql://172.19.103.85/wlyy_specialist?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: linzhou
    password: linzhou
  redis:
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
@ -173,6 +182,10 @@ spring:
    url: jdbc:mysql://59.61.92.90:9069/wlyy_specialist?useUnicode=true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: wlyy
    password: jkzlehr@123
  redis:
    host: 27.155.101.77 # Redis server host.
    port: 6380 # Redis server port.
    password: jkzl_ehr
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
@ -185,7 +198,7 @@ neiwang:
  wlyy: http://59.61.92.90:9099/iot/
base:
  url: http://192.168.120.167:10020/svr-base/
  url: http://192.168.120.96:10020/svr-base/
wechat:
  appId: wxad04e9c4c5255acf