Ver código fonte

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

humingfen 6 anos atrás
pai
commit
b81c5e3d4b

+ 38 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationDetailDO.java

@ -1,6 +1,7 @@
package com.yihu.jw.entity.specialist.rehabilitation;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
@ -32,7 +33,8 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
    private String doctor;//计划完成者标识
    @Column(name = "doctor_name")
    private String doctorName;//计划完成者标识
    @Column(name = "execute_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "execute_time", nullable = false, length = 0,updatable = false)
    private Date executeTime;//服务项目执行时间
    @Column(name = "status")
    private Integer status;//状态(0未完成,1已完成,2已预约)
@ -40,6 +42,12 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
    private Integer expense;
    @Column(name = "service_qr_code")
    private String serviceQrCode;//服务码
    @Column(name = "frequency_code")
    private String frequencyCode;//频次
    @Column(name = "time_type")
    private Integer timeType;//时间类型
    @Column(name = "remark")
    private String remark;//备注
    @Column(name = "saas_id")
    public String getSaasId() {
@ -77,7 +85,8 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
        this.hospital = hospital;
    }
    @Column(name = "execute_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "execute_time", nullable = false, length = 0,updatable = false)
    public Date getExecuteTime() {
        return executeTime;
    }
@ -148,4 +157,31 @@ public class RehabilitationDetailDO extends UuidIdentityEntityWithOperator imple
    public void setServiceQrCode(String serviceQrCode) {
        this.serviceQrCode = serviceQrCode;
    }
    @Column(name = "frequency_code")
    public String getFrequencyCode() {
        return frequencyCode;
    }
    public void setFrequencyCode(String frequencyCode) {
        this.frequencyCode = frequencyCode;
    }
    @Column(name = "time_type")
    public Integer getTimeType() {
        return timeType;
    }
    public void setTimeType(Integer timeType) {
        this.timeType = timeType;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
}

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

@ -84,10 +84,13 @@ public class SpecialistMapping {
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String dailyJob = "/dailyJob";
        public static final String tomorrowJob = "/tomorrowJob";
        public static final String dailyByJob ="/dailyByJob";
        public static final String dailyJobReserve = "/dailyJobReserve";
        public static final String appCalendarPlanDetailList = "/appCalendarPlanDetailList";
        public static final String updatePlanDetailStatusById = "/updatePlanDetailStatusById";
        public static final String updatePlanStatusById = "/updatePlanStatusById";
        public static final String updatePlanDetailExecuteTimeById = "/updatePlanDetailExecuteTimeById";
        public static final String planSchedule = "/planSchedule";
        public static final String planListByPatient = "/planListByPatient";
        public static final String patientCount = "/patientCount";

+ 5 - 3
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/SpecialistController.java

@ -381,12 +381,12 @@ public class SpecialistController extends EnvelopRestEndpoint {
    @GetMapping(value = SpecialistMapping.specialist.searchPatientInSpecialist)
    @ApiOperation(value = "搜索注册居民")
    public MixEnvelop searchPatientInSpecialist(
//            @ApiParam(name = "doctorCode", value = "医生code",required = true) @RequestParam(required = true)String doctorCode,
            @ApiParam(name = "doctorCode", value = "医生code",required = true) @RequestParam(required = true)String doctorCode,
            @ApiParam(name = "keywords", value = "居民姓名,手机号,身份证") @RequestParam(required = false)String keywords,
            @ApiParam(name = "page", value = "第几页,1开始",defaultValue = "1") @RequestParam(required = true,defaultValue = "1")Integer page,
            @ApiParam(name = "pageSize", value = "每页大小",defaultValue = "5") @RequestParam(required = true,defaultValue = "5")Integer pageSize){
        try {
            return specialistService.searchPatientInSpecialistNew(keywords,page,pageSize);
            return specialistService.searchPatientInSpecialistNew(doctorCode,keywords,page,pageSize);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
@ -399,10 +399,12 @@ 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 = "signStatus", value = "签约状态,待审核:0;未签约:-1",required = true)
            @RequestParam(value = "signStatus",required = true)String signStatus,
            @ApiParam(name = "patientCode", value = "居民id",required = true)
            @RequestParam(value = "patientCode",required = true)String patientCode){
        try {
            JSONObject object=specialistService.doctorForSpecialistInfo(doctorCode,patientCode);
            JSONObject object=specialistService.doctorForSpecialistInfoNew(signStatus,doctorCode,patientCode);
            return  success(object);
        }catch (Exception e){
            e.printStackTrace();

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

@ -6,6 +6,7 @@ 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.service.rehabilitation.RehabilitationManageService;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.Tracer;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.Map;
/**
@ -288,6 +290,37 @@ public class RehabilitationManageController {
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.tomorrowJob)
    @ApiOperation(value = "明日康复服务通知")
    public ObjEnvelop tomorrowJob(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "startTime", required = true)String startTime,
                               @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "endTime", required = true)String endTime){
        try {
            return rehabilitationManageService.tomorrowJob(startTime,endTime);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.dailyByJob)
    @ApiOperation(value = "每日康复计划提醒")
    public ObjEnvelop dailyByJob(@ApiParam(name = "startTime", value = "开始时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "startTime", required = true)String startTime,
                               @ApiParam(name = "endTime", value = "结束时间(格式:yyyy-MM-dd HH:mm:ss)", required = true)
                               @RequestParam(value = "endTime", required = true)String endTime){
        try {
            return rehabilitationManageService.dailyByJob(startTime,endTime);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.updateNoteAndImageRehabilitationOperate)
    @ApiOperation(value = "康复计划完成时更新服务完成笔记和图片接口并且确认完成")
    public ObjEnvelop updateNoteAndImageRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)@RequestParam(value = "planDetailId", required = true)String planDetailId,
@ -319,6 +352,24 @@ public class RehabilitationManageController {
        }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.updatePlanDetailExecuteTimeById)
    @ApiOperation(value = "康复管理-修改康复计划项目执行时间")
    public Envelop updatePlanDetailExecuteTimeById(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)
                                              @RequestParam(value = "planDetailId", required = true)String planDetailId,
                                              @ApiParam(name = "executeTime", value = "状态", required = true)
                                              @RequestParam(value = "executeTime", required = true)String executeTime){
        try {
            Date date = DateUtil.strToDateLong(executeTime);
            return rehabilitationManageService.updatePlanDetailExecuteTimeById(date,planDetailId);
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return Envelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = SpecialistMapping.rehabilitation.planSchedule)
    @ApiOperation(value = "康复管理-计划总进度")
    public ObjEnvelop planSchedule(@ApiParam(name = "planId", value = "计划id", required = true)

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

@ -71,4 +71,9 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    @Query
    List<RehabilitationDetailDO> findByPlanIdAndStatus(String planId,int status);
    @Modifying
    @Query("update RehabilitationDetailDO t set t.executeTime = ?1 where t.id=?2 ")
    int updateExecuteTime(Date executeTime,String id);
}

+ 173 - 17
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/SpecialistService.java

@ -187,8 +187,6 @@ public class SpecialistService{
    public MixEnvelop<PatientLabelVO, PatientLabelVO> getPatientByLabel(String doctor, String labelType, String labelCode, Integer page, Integer size){
    
    
        String sql="SELECT " +
                " p. NAME, " +
                " p. CODE, " +
@ -223,7 +221,11 @@ 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 " +
                " WHERE ( s.doctor ='"+doctor+"' OR s.health_doctor='"+doctor+"' OR s.health_assistant='"+doctor+ "') AND s.status >=0  AND s.sign_status >0"+
                " WHERE s.doctor in " +
                " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in " +
                " (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1') "+
                " AND s.status >=0  AND s.sign_status >0"+
                " LIMIT "+(page-1)*size+","+size;
        System.out.print("日志:"+sql);
        if("7".equals(labelType)){
@ -242,13 +244,15 @@ 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+"' OR a.health_assistant= '"+doctor+
                    "' LIMIT "+(page-1)*size+","+size;
                    " WHERE a.sign_status> 0 AND a.`status`>=0 " +
//                    "AND a.doctor='"+doctor+"' OR a.health_assistant= '"+doctor+
                    " AND a.doctor in " +
                    " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in " +
                    " (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id " +
                    " WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1') "+
                    " LIMIT "+(page-1)*size+","+size;
        }
        List<PatientLabelVO> PatientLabelVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientLabelVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,PatientLabelVOs);
    }
@ -616,15 +620,19 @@ public class SpecialistService{
                " d.hospital_name AS hospital_name, " +
                " d.`level` " +
                " FROM " +
                " wlyy_specialist_patient_relation r " +
                " wlyy_specialist.wlyy_specialist_patient_relation r " +
                " JOIN "+basedb+".wlyy_doctor d ON r.doctor = d.`code` " +
                " WHERE  " +
                " r.patient ='"+patient+"' " +
                " AND r.doctor ='"+doctor+"' " +
                " AND r.doctor in" +
                " (SELECT m.doctor_code FROM  wlyy.wlyy_admin_team_member m where m.team_id in  " +
                "  (SELECT dt.id FROM  wlyy.wlyy_admin_team dt LEFT JOIN  wlyy.wlyy_admin_team_member watm ON dt.id=watm.team_id  " +
                "  WHERE dt.available='1' AND watm.available='1' AND watm.doctor_code='"+doctor+"') AND  m.available='1')" +
                " AND r.`status`>=0 " +
                " AND r.sign_status >0 ) r join "+basedb+".wlyy_patient p on r.patient = p.code order by p.czrq DESC ";
        List<PatientSignInfoVO> patientSignInfoVOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(PatientSignInfoVO.class));
        return MixEnvelop.getSuccess(SpecialistMapping.api_success,patientSignInfoVOs.get(0));
        PatientSignInfoVO patientSignInfoVO = (null != patientSignInfoVOs && patientSignInfoVOs.size() > 0 )? patientSignInfoVOs.get(0):null;
        return MixEnvelop.getSuccess(SpecialistMapping.api_success, patientSignInfoVO);
    }
    
    public MixEnvelop findDoctorAndDoctorHealthBySpecialDoctor(String doctor,String name) {
@ -839,9 +847,15 @@ public class SpecialistService{
     * 病人的家签信息、专科开通信息
     * @param doctorCode 医生code
     * @param patientCode 病人id
     * @param signStatus 签约状态,待审核:0;未签约:-1
     */
    public JSONObject doctorForSpecialistInfo(String doctorCode, String patientCode)  throws Exception{
    public JSONObject doctorForSpecialistInfo(String signStatus,String doctorCode, String patientCode)  throws Exception{
        JSONObject jsonObject = new JSONObject();
        SpecialistPatientRelationDO specialistPatientRelationDO = new SpecialistPatientRelationDO();
        //待审核
        if ("0".equals(signStatus)) {
            specialistPatientRelationDO = specialistPatientRelationDao.findByDoctorAndPatient(doctorCode, patientCode);
        }
        //1、获取居民基础信息
        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 ";
@ -902,6 +916,118 @@ public class SpecialistService{
        return jsonObject;
    }
    /**
     * 病人的家签信息、专科开通信息
     * @param doctorCode 医生code
     * @param patientCode 病人id
     * @param signStatus 签约状态,待审核:0;未签约:-1
     */
    public JSONObject doctorForSpecialistInfoNew(String signStatus,String doctorCode, String patientCode)  throws Exception{
        JSONObject jsonObject = new JSONObject();
        SpecialistPatientRelationDO specialistPatientRelationDO = new SpecialistPatientRelationDO();
        //待审核
        if ("0".equals(signStatus)) {
            specialistPatientRelationDO = selectByDoctorAndPatient(doctorCode, patientCode);
        }
        jsonObject.put("specialistPatientRelationId", null == specialistPatientRelationDO ? null : specialistPatientRelationDO.getId());
        //1、获取居民基础信息
        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、获取医生信息(所属医院、科室、姓名)
        String doctorSql = "SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + doctorCode + "'";;
        if("0".equals(signStatus)){
            doctorSql="SELECT wd.hospital_name as hospitalName,wd.dept_name as deptName,wd.name as name FROM " + basedb + ".wlyy_doctor wd WHERE wd.code='" + specialistPatientRelationDO.getDoctor() + "'";
        }
        Map<String,Object> result =jdbcTemplate.queryForMap(doctorSql);
        if(doctorCode.equals(specialistPatientRelationDO.getDoctor())){
            result.put("buttonShowFlag",true);
        }else{
            result.put("buttonShowFlag",false);
        }
        jsonObject.put("doctorInfo", result);
        //3、获取该医生所属团队及团队成员信息
        String teamSql = "SELECT at.name teamName, tm.team_id , tm.doctor_code, wd.NAME as doctorName  FROM " + basedb + ".wlyy_doctor wd LEFT JOIN  " + basedb + ".wlyy_admin_team_member tm ON wd. CODE = tm.doctor_code, " + basedb + ".wlyy_admin_team at " +
                "WHERE tm.team_id IN ( SELECT watm.team_id teamId FROM  " + basedb + ".wlyy_admin_team_member watm WHERE watm.doctor_code ='" + doctorCode + "'" + " AND watm.available = '1' ) AND tm.available='1' AND `at`.id=tm.team_id";
        List<Map<String, Object>> teamList = jdbcTemplate.queryForList(teamSql);
        Map<Integer, List<Map<String, Object>>> m = teamList.stream().collect(Collectors.groupingBy(tem -> ((Integer) tem.get("team_id")).intValue(), Collectors.toList()));
        List<Map<String, Object>> mapList = new ArrayList<>();
        for (Integer i : m.keySet()) {
            Map<String, Object> objectMap = new HashMap<>();
            if ("0".equals(signStatus) && i.equals(specialistPatientRelationDO.getTeamCode())) {
                objectMap.put("checkFlag", true);
            } else {
                objectMap.put("checkFlag", false);
            }
            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);
            List<String> speciaSignDiseaseList = new ArrayList<>();
            if("0".equals(signStatus) ){
                String speciaSignSql = "SELECT wpds.disease FROM wlyy.wlyy_patient_disease_server wpds WHERE wpds.patient='" + patientCode + "'" + " AND wpds.del='1' and wpds.specialist_relation_code='" + specialistPatientRelationDO.getId() + "'";
                speciaSignDiseaseList = jdbcTemplate.queryForList(speciaSignSql,String.class);
            }
            Set<String> speciaSignSet =new HashSet<>(speciaSignDiseaseList);
            //已签约的疾病状态改成1
            stringList.stream().forEach(item->{
                int status=0;
                if(stringSet.contains( item.get("disease_code"))){
                    //已签约过的疾病
                    status=1;
                }
                if(null!=speciaSignSet&& speciaSignSet.contains(item.get("disease_code"))){
                    //本次专病签约的疾病
                    status=2;
                }
                item.put("status",status) ;
            });
            objectMap.put("teamDisease", stringList);
            mapList.add(objectMap);
        }
        jsonObject.put("teamAndDoctors", mapList);
        //康复情况标签
        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);
        //居民的康复情况
        String patientLabelSql = "SELECT wspl.label from  wlyy.wlyy_sign_patient_label_info wspl WHERE wspl.patient='"+patientCode+"' and  wspl.label_type='8' AND status='1'";
        List<String> patientLabelList = jdbcTemplate.queryForList(patientLabelSql,String.class);
        Set<String> patientLabelSet =new HashSet<>(patientLabelList);
        signPatientLabelList.stream().forEach(item->{
            item.put("status",patientLabelSet.contains(item.get("label_code").toString())?1:0) ;
        });
        jsonObject.put("signPatientLabels", signPatientLabelList);
        return jsonObject;
    }
    /**
     * 专科医生发起签约
     * @param specialistPatientRelationDO
@ -958,21 +1084,33 @@ public class SpecialistService{
     * 专科-通过手机号码精确搜索注册居民
     * @param keywords
     */
    public MixEnvelop searchPatientInSpecialistNew(String keywords,Integer page,Integer pageSize) throws Exception{
    public MixEnvelop searchPatientInSpecialistNew(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 ,r.sign_status";
        String sql2 = " select p.name as name,p.idcard,p.code,p.photo";
        String whereSql ="";
        if(!StringUtils.isEmpty(keywords)){
            whereSql+=" and  p.mobile ='"+keywords+"'";
        }
        //根据手机号码精确查找居民
        String centerSql =" from "+basedb+".wlyy_patient p LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r ON p.code=r.patient where  p.openid IS NOT NULL "+whereSql;
        String centerSql =" from "+basedb+".wlyy_patient p /*LEFT JOIN wlyy_specialist.wlyy_specialist_patient_relation r ON p.code=r.patient */where  p.openid IS NOT NULL "+whereSql;
        String signSql ="SELECT r.patient,r.sign_status  FROM  wlyy_specialist.wlyy_specialist_patient_relation r WHERE (r.sign_status = '1' or r.sign_status = '0') " +
                " 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')";
        List<Map<String,Object>> map1=jdbcTemplate.queryForList(signSql);
        String sqlCount=sql1+centerSql;
        String sql=sql2+centerSql+" LIMIT "+(page-1)*pageSize+","+pageSize;
        List<Map<String,Object>> map = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> countMap = jdbcTemplate.queryForList(sqlCount);
        //根据居民查找专科签约状态
        //已签约专科,获取签约信息
        Map<String,String> patientMap = new HashMap<>();
        if(null!=map1){
            map1.stream().forEach(temp->{
                patientMap.put(temp.get("patient").toString(),temp.get("sign_status").toString()) ;
            });
        }
        //未签约,获取居民信息,及专科医生信息
        List<Map<String,Object>> resultList = new ArrayList<>();
        Map m = null;
@ -983,13 +1121,14 @@ public class SpecialistService{
            m = new HashMap();
            age = IdCardUtil.getAgeForIdcard(one.get("idcard")+"");
            sex = IdCardUtil.getSexForIdcard_new(one.get("idcard")+"");
            String patientCode=null==one.get("code")?"":one.get("code").toString();
            m.put("name",one.get("name"));
            m.put("age",age);
            m.put("sex",sex);
            //1已签约,0待审核,-1未签约或已取消或已拒绝
            if(null != one.get("sign_status")&& one.get("sign_status").toString().equals("1")){
            if(patientMap.containsKey(patientCode)&&"1".equals(patientMap.get(patientCode))){
                m.put("sign_status", 1);
            }else if(null != one.get("sign_status")&& one.get("sign_status").toString().equals("0")){
            }else if(patientMap.containsKey(patientCode)&&"0".equals(patientMap.get(patientCode))){
                m.put("sign_status", 0);
            }else {
                m.put("sign_status", -1);
@ -1008,4 +1147,21 @@ public class SpecialistService{
        }
        return MixEnvelop.getSuccessListWithPage(SpecialistMapping.api_success,resultList,page,pageSize,countMap.size()>0?Long.valueOf(countMap.get(0).get("num")+""):0);
    }
    /**
     * 根据医生和居民code查询居民与该医生所在团队的待审核专科签约信息
     *
     * @param patient
     * @param doctor
     * @return
     */
    public SpecialistPatientRelationDO selectByDoctorAndPatient(String doctor,String patient){
        String sql = "select * from wlyy_specialist.wlyy_specialist_patient_relation r where r.doctor in ( " +
                " SELECT m.doctor_code  FROM wlyy.wlyy_admin_team_member m " +
                " WHERE  m.team_id IN ( SELECT dt.id  FROM  wlyy.wlyy_admin_team dt LEFT JOIN wlyy.wlyy_admin_team_member watm ON dt.id = watm.team_id   WHERE " +
                " dt.available = '1' AND watm.available = '1'  AND watm.doctor_code = '"+doctor+"') AND m.available = '1'  ) and r.patient = '"+patient+"' and r.sign_status=0";
        List<SpecialistPatientRelationDO> relationDOS = jdbcTemplate.query(sql,new BeanPropertyRowMapper(SpecialistPatientRelationDO.class));
        SpecialistPatientRelationDO specialistPatientRelationDO=null!=relationDOS&&relationDOS.size()>0?relationDOS.get(0):new SpecialistPatientRelationDO();
        return specialistPatientRelationDO;
    }
}

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

@ -1086,6 +1086,61 @@ public class RehabilitationManageService {
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
    }
    /**
     * 明日康复计划提醒
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public ObjEnvelop tomorrowJob(String startTime,String endTime){
        String sql = "select d.doctor,p.patient,count(1) as num from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient";
//        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String doctorCode = "";
        String patientCode = "";
        List<String> listMap  = null;
        for(Map<String,Object> one:list){
            doctorCode = one.get("doctor")+"";
            patientCode = one.get("patient")+"";
            listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode);
            String ids = "";
            for(String one2 : listMap){
                ids += ","+one2;
            }
            one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
        }
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
    }
    /**
     * 每日康复计划提醒
     *
     * @param startTime
     * @param endTime
     * @return
     */
    public ObjEnvelop dailyByJob(String startTime,String endTime){
        String sql = "select d.doctor,p.patient,h.service_item_name AS serviceItemName,d.time_type AS timeType from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id left join wlyy_hospital_service_item h ON h.id=d.hospital_service_item_id where d.status!=1 and p.status=1 and d.execute_time>='"+startTime+"' and d.execute_time<='"+endTime+"' GROUP BY d.doctor,p.patient";
//        List<Object> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
         String doctorCode = "";
        String patientCode = "";
        List<String> listMap  = null;
       for(Map<String,Object> one:list){
            doctorCode = one.get("doctor")+"";
            patientCode = one.get("patient")+"";
            listMap = rehabilitationDetailDao.findByPatientAndDoctor(startTime,endTime,doctorCode,patientCode);
            String ids = "";
            for(String one2 : listMap){
                ids += ","+one2;
            }
            one.put("planDetailIds",StringUtils.isNotEmpty(ids)?ids.substring(1):"");
        }
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
    }
    /**
     * 更新康复计划项目操作日志并且确认完成更新status.
     * @param node
@ -1140,6 +1195,8 @@ public class RehabilitationManageService {
        return resultMap;
    }
    /**
     * 更新康复计划项目状态
     * @param status
@ -1154,6 +1211,16 @@ public class RehabilitationManageService {
        return Envelop.getError("更新失败!");
    }
    public Envelop updatePlanDetailExecuteTimeById(Date executeTime,String planDetailId) throws Exception{
        if(rehabilitationDetailDao.updateExecuteTime(executeTime,planDetailId)>0){
            return Envelop.getSuccess(SpecialistMapping.api_success);
        }
        return Envelop.getError("更新失败!");
    }
    /**
     * 计划总进度
     * @param planId