Bläddra i källkod

Merge branch 'dev' of yeshijie/wlyy2.0 into dev

叶仕杰 4 år sedan
förälder
incheckning
59e827c5c6

+ 2 - 0
business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java

@ -30,4 +30,6 @@ public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String
//	Page<Object> findByPatient(String patient, Pageable pageRequest);
	ConsultDo queryByRelationCode(String relationCode);
	ConsultDo queryByIdAndType(String id,Integer type);
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -243,6 +243,15 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String phone;
    private String openid;
    private Date openidTime;
    public Date getOpenidTime() {
        return openidTime;
    }
    public void setOpenidTime(Date openidTime) {
        this.openidTime = openidTime;
    }
    @Column(name = "openid")
    public String getOpenid() {
        return openid;

+ 84 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/door/DoctorQuickReply.java

@ -0,0 +1,84 @@
package com.yihu.jw.entity.door;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by lyr-pc on 2016/12/28.
 */
@Entity
@Table(name = "wlyy_doctor_quick_reply")
@SequenceGenerator(name="id_generated", sequenceName="wlyy_doctor_quick_reply")
public class DoctorQuickReply extends IdEntity {
    // 医生
    private String doctor;
    // 回复内容
    private String content;
    // 排序
    private Integer sort;
    // 更新时间
    private Date updateTime;
    // 状态 1:有效  0:无效
    private Integer status;
    // 类型 0为健康教育,1为续方咨询
    private Integer type;
    // 0为自定义消息  大于1为系统消息(1体征和生活方式 2症状 3血糖 4血压)
    private Integer systag;
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    
    public Integer getType() {
        return type;
    }
    
    public void setType(Integer type) {
        this.type = type;
    }
    
    public Integer getSystag() {
        return systag;
    }
    
    public void setSystag(Integer systag) {
        this.systag = systag;
    }
}

+ 18 - 0
svr/svr-door-serivce/sql/初始sql.sql

@ -614,6 +614,24 @@ INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('8', NULL, 'PROFESSIONAL_STATE', '7', '1', '不便分类的其他从业人员', '8', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('9', NULL, 'PROFESSIONAL_STATE', '8', '1', '无职业', '9', NULL);
CREATE TABLE `wlyy_doctor_quick_reply` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `doctor` varchar(50) NOT NULL COMMENT '医生',
  `content` varchar(255) DEFAULT NULL COMMENT '快捷回复内容',
  `sort` int(11) DEFAULT NULL COMMENT '排序',
  `update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `status` int(11) DEFAULT NULL COMMENT '状态 1:有效 0:无效',
  `type` int(11) DEFAULT NULL COMMENT '0为健康咨询,1为续方咨询',
  `systag` int(11) DEFAULT NULL COMMENT '1为默认消息,0为自定义消息',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_doctor` (`doctor`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='医生快捷回复表';
INSERT INTO `wlyy_doctor_quick_reply` ( `doctor`, `content`, `sort`, `update_time`, `status`, `type`, `systag`) VALUES ( 'default', '请填写您近期体征及生活方式调查问卷', '1', '2017-11-23 14:27:22', '1', '1', '1');
INSERT INTO `wlyy_doctor_quick_reply` ( `doctor`, `content`, `sort`, `update_time`, `status`, `type`, `systag`) VALUES ( 'default', '请填写您近期身体异常症状问卷', '2', '2017-11-23 15:46:46', '1', '1', '2');
INSERT INTO `wlyy_doctor_quick_reply` ( `doctor`, `content`, `sort`, `update_time`, `status`, `type`, `systag`) VALUES ( 'default', '请提供您最近一次的血糖检测数值及检测时间', '3', '2017-11-23 15:46:45', '1', '1', '3');
INSERT INTO `wlyy_doctor_quick_reply` ( `doctor`, `content`, `sort`, `update_time`, `status`, `type`, `systag`) VALUES ( 'default', '请提供您最近一次的血压检测数值及检测时间', '4', '2017-11-23 15:46:46', '1', '1', '4');
DROP TABLE IF EXISTS `zy_nation_dict`;

+ 56 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorConsultController.java

@ -0,0 +1,56 @@
package com.yihu.jw.door.controller.doctor;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.consult.ConsultTeamService;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.im.dao.ConsultTeamDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by yeshijie on 2020/12/31.
 */
@RestController
@RequestMapping(value = "/doctor/consult", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生端-咨询")
public class DoctorConsultController extends BaseController {
    @Autowired
    private ConsultTeamService consultTeamService;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @ApiOperation("咨询是否结束")
    @RequestMapping(value = "/getConsultStatus",method = RequestMethod.GET)
    public String getConsultStatus(@RequestParam(required = true) String consult){
        try {
            ConsultTeamDo consultTeam = consultTeamDao.findByConsult(consult);
            return write(200, "查询成功", "data", consultTeam.getStatus());
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "queryByConsultCode",method = RequestMethod.GET)
    @ApiOperation("根据咨询code查询关联业务项详情")
    public String queryByConsultCode(@ApiParam(name = "code", value = "咨询code") @RequestParam(value = "code", required = true) String code,
                                     @ApiParam(name = "type", value = "咨询类型") @RequestParam(value = "type", required = true) Integer type){
        try{
            com.alibaba.fastjson.JSONObject detail = consultTeamService.queryByConsultCode(code,type);
            return write(200, "查询成功", "data", detail.get("data"));
        }catch (Exception e){
            error(e);
            return error(-1,"查询失败");
        }
    }
}

+ 27 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorController.java

@ -3,7 +3,9 @@ package com.yihu.jw.door.controller.doctor;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.common.PatientService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
@ -27,6 +29,31 @@ public class DoctorController extends BaseController {
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private PatientService patientService;
    /**
     * 查询居民信息
     *
     * @param patient 患者
     * @return
     */
    @GetMapping(value = "/patient")
    @ApiOperation("查询居民信息")
    public String getPatient(String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONObject p = patientService.getPatient(patient,getUID());
            return write(200, "查询成功", "data", p);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 医生基本信息查询接口

+ 170 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorQuickReplyController.java

@ -0,0 +1,170 @@
package com.yihu.jw.door.controller.doctor;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.door.service.consult.DoctorQuickReplyService;
import com.yihu.jw.entity.door.DoctorQuickReply;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
@RestController
@RequestMapping(value = "/doctor/reply", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "医生快捷回复")
public class DoctorQuickReplyController extends BaseController {
    @Autowired
    DoctorQuickReplyService quickReplyService;
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ApiOperation(value = "添加快捷回复")
    public String addReply(
            @RequestParam(value = "content", required = true) @ApiParam(value = "快捷回复内容") String content,
            @ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
            @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            if (StringUtils.isEmpty(content)) {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.addReply(getUID(), content,type);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
            } else {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            return error(-1, "添加失败");
        }
    }
    @RequestMapping(value = "/modify", method = RequestMethod.POST)
    @ApiOperation(value = "修改快捷回复")
    public String modifyReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id,
                              @RequestParam @ApiParam(value = "快捷回复内容") String content,
                              @ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
                                  @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            if (id == null || id < 1) {
                return error(-1, "快捷回复ID不能为空");
            }
            if (StringUtils.isEmpty(content)) {
                return error(-1, "快捷回复内容不能为空");
            }
            DoctorQuickReply reply = quickReplyService.modifyReply(id, content,type);
            if (reply != null) {
                return write(200, "添加成功", "data", reply);
            } else {
                return error(-1, "添加失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "添加失败");
        }
    }
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ApiOperation(value = "删除快捷回复")
    public String delReply(@RequestParam @ApiParam(value = "快捷回复ID") Long id) {
        try {
            if (id == null || id < 1) {
                return error(-1, "请选择需删除的快捷回复");
            }
            int result = quickReplyService.delReply(getUID(), id);
            if (result == 1) {
                return write(200, "删除成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            } else {
                return error(-1, "删除失败");
            }
        } catch (Exception e) {
            return error(-1, "删除失败");
        }
    }
    @RequestMapping(value = "/sort", method = RequestMethod.POST)
    @ApiOperation(value = "快捷回复排序")
    public String sortReply(@RequestParam @ApiParam(value = "快捷回复ID")Long id,
                            @RequestParam @ApiParam(value = "排序位置")Integer sort) {
        try {
            if (id == null || id < 1) {
                return error(-1, "请选择排序的快捷回复");
            }
            if (sort == null || sort < 1) {
                return error(-1, "请设置快捷回复的排序位置");
            }
            int result = quickReplyService.sortReply(getUID(), id, sort);
            if (result == 1) {
                return write(200, "排序成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            }  else if (result == -2) {
                return error(-1, "快捷回复已在排序位置");
            } else {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "排序失败");
        }
    }
    @RequestMapping(value = "/sortList", method = RequestMethod.POST)
    @ApiOperation(value = "快捷回复排序")
    public String sortReplyList(@RequestParam @ApiParam(value = "快捷回复ID")String id,
                                @ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
                                @RequestParam(value = "type", required = false, defaultValue = "0") String type) {
        try {
            if (StringUtils.isEmpty(id)) {
                return error(-1, "请输入排序后的回复ID");
            }
            int result = quickReplyService.sortReplyList(id,type);
            if (result == 1) {
                return write(200, "排序成功");
            } else if (result == -1) {
                return error(-1, "快捷回复不存在或已删除");
            }  else if (result == -2) {
                return error(-1, "快捷回复已在排序位置");
            } else {
                return error(-1, "排序失败");
            }
        } catch (Exception e) {
            return error(-1, "排序失败");
        }
    }
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "快捷回复列表")
    public String replyList(@ApiParam(name = "type", value = "快捷回复类型(1为续方咨询)", defaultValue = "0")
                            @RequestParam(value = "type", required = false, defaultValue = "0") String type,
                            @ApiParam(name = "keyword", value = "搜索关键字", defaultValue = "")
                            @RequestParam(value = "keyword", required = false, defaultValue = "") String keyword) {
        try {
            List<DoctorQuickReply> replies = quickReplyService.getDoctorReplyList(getUID(),type,keyword);
            return write(200, "查询成功", "data", replies);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 1 - 4
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/ConsultController.java

@ -14,10 +14,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
/**
 * Created by yeshijie on 2020/12/29.

+ 9 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/PatientController.java

@ -10,13 +10,16 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.utils.security.MD5;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
@ -67,6 +70,11 @@ public class PatientController extends BaseController {
        }
    }
    public static void main(String[] args) {
        System.out.println(MD5.md5Hex("011633{40b56bcdf86f4c03ae230bf2104da9bb}"));
    }
    /**
     * 患者基本信息查询接口
     *

+ 40 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/consult/DoctorQuickReplyDao.java

@ -0,0 +1,40 @@
package com.yihu.jw.door.dao.consult;
import com.yihu.jw.entity.door.DoctorQuickReply;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
public interface DoctorQuickReplyDao extends PagingAndSortingRepository<DoctorQuickReply, Long> ,JpaSpecificationExecutor<DoctorQuickReply> {
    @Query("select max(q.sort) from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    Integer findMaxSort(String doctor);
    @Query("update DoctorQuickReply q set q.sort = q.sort - 1 where q.doctor = ?1 and q.sort > ?2 and q.status = 1")
    @Modifying
    int updateSort(String doctor, Integer sort);
    @Query("update DoctorQuickReply q set q.sort = q.sort - 1 where q.doctor = ?1 and q.sort > ?2 and q.sort <= ?3 and q.status = 1")
    @Modifying
    int updateSortLt(String doctor, Integer sort1, Integer sort2);
    @Query("update DoctorQuickReply q set q.sort = q.sort + 1 where q.doctor = ?1 and q.sort < ?2 and q.sort >= ?3 and q.status = 1")
    @Modifying
    int updateSortGt(String doctor, Integer sort1, Integer sort2);
    @Query("select q from DoctorQuickReply q where q.doctor = ?1 and q.status = 1")
    List<DoctorQuickReply> findDoctorReplies(String doctor, Sort sort);
    
    @Query("select q from DoctorQuickReply q where q.doctor = ?1 and q.type = ?2 and q.status = 1")
    List<DoctorQuickReply> findDoctorRepliesByType(String doctor, Integer type, Sort sort);
    @Query("select q from DoctorQuickReply q where q.doctor = ?1 and q.type = ?2 and q.content like CONCAT('%',?3,'%') and q.status = 1")
    List<DoctorQuickReply> findDoctorRepliesByType(String doctor, Integer type, String keyword, Sort sort);
}

+ 1 - 1
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java

@ -2272,7 +2272,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        this.save(doorServiceOrderDO);
        // 给医生发派单消息
        if(doorServiceOrderDO.getIsTransOtherOrg().equals(WlyyDoorServiceOrderDO.IsTransOtherOrg.yes.getType())){
        if(WlyyDoorServiceOrderDO.IsTransOtherOrg.yes.getType().equals(doorServiceOrderDO.getIsTransOtherOrg())){
            this.createMessage(orderId,doorServiceOrderDO.getTransedDispatcher(),doctor,407,"服务工单待接单","您有新的服务工单,请前往处理");
        }else{
            this.createMessage(orderId,doorServiceOrderDO.getDispatcher(),doctor,407,"服务工单待接单","您有新的服务工单,请前往处理");

+ 167 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/PatientService.java

@ -0,0 +1,167 @@
package com.yihu.jw.door.service.common;
import com.yihu.jw.door.dao.common.SignFamilyDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.door.SignFamily;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
 * Created by yeshijie on 2020/12/31.
 */
@Service
public class PatientService {
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private SignFamilyDao signFamilyDao;
    /**
     * 查询单个居民信息
     *
     * @param patient
     * @return
     * @throws Exception
     */
    public JSONObject getPatient(String patient, String doctor) throws Exception {
        JSONObject json = new JSONObject();
        BasePatientDO p = patientDao.findById(patient);
        if (p == null) {
            throw new Exception("patient info can not find");
        }
        // 设置患者标识
        json.put("code", p.getId());
        // 设置患者姓名
        json.put("name", p.getName());
        // 设置患者手机号
        json.put("mobile", p.getMobile());
        // 设置患者微信openid
        json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
        json.put("openidTime", DateUtil.dateToStr(p.getOpenidTime(), DateUtil.YYYY_MM_DD_HH_MM_SS));
        // 设置患者联系电话
        json.put("phone", p.getPhone());
        // 设置患者头像
        json.put("photo", p.getPhoto());
        // 设置患者年龄
        json.put("age", IdCardUtil.getAgeByIdcardOrBirthday(p.getIdcard(),p.getBirthday()));
        // 设置患者性别
        json.put("sex", p.getSex());
        // 身份证号
        json.put("idcard", p.getIdcard());
        //1.4.2新增medicareNumber
//        json.put("medicareNumber", p.getMedicareNumber());
        // 设置患者居住省份
        json.put("provinceName", p.getProvinceName());
        json.put("cityName", p.getCityName());
        json.put("townName", p.getTownName());
        json.put("streetName", p.getStreetName());
        // 设置患者地址
        json.put("address", p.getAddress());
        // 社保号
//        json.put("ssc", p.getSsc());
        //病情类型:0健康,1高血压,2糖尿病,(1,2)高血压+糖尿病
/*        json.put("disease",p.getDisease());
        // 病情:0绿标,1黄标,2红标,
        json.put("diseaseCondition",p.getDiseaseCondition());
        //预警状态
        json.put("standardStatus",p.getStandardStatus());
        //设备状态:0未绑定,1血糖仪,2血压仪,3血糖仪+血压仪
        json.put("deviceType",p.getDeviceType()==null?"":p.getDeviceType());
        //20190719 增加返回字段:档案状态(-2冻结 1未管理 2死亡3 正常4 高危)
        json.put("archiveStatus",p.getArchiveStatus() == null? "":p.getArchiveStatus().toString());*/
        SignFamily familySign = signFamilyDao.findSignByPatient(patient, 2);
        if (familySign != null) {
            // 设置患者紧急联系人
            json.put("signCode",familySign.getCode());
            json.put("emerMobile", StringUtils.isEmpty(familySign.getEmerMobile()) ? "" : String.valueOf(familySign.getEmerMobile()));
            // 设置签约日期
            json.put("qyrq", familySign.getApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
            // 设置签约日期
            json.put("patientApplyDate", familySign.getPatientApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getPatientApplyDate(), DateUtil.YYYY_MM_DD) : "");
            // 设置签约类型
            json.put("signType", json.has("signType") ? 3 : 2);
            // 缴费情况
            json.put("expensesStatus", StringUtils.isNotEmpty(familySign.getExpensesStatus()) ? String.valueOf(familySign.getExpensesStatus()) : "0");
            // 缴费时间
            json.put("expensesTime", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD_HH_MM) : "");
            // 缴费类型
            json.put("expensesType", StringUtils.isNotEmpty(familySign.getExpensesType()) ? String.valueOf(familySign.getExpensesType()) : "");
            // 设置签约状态
            json.put("familyStatus", familySign.getStatus());
            json.put("jtBeginDate", DateUtil.dateToStr(familySign.getBegin(), DateUtil.YYYY_MM_DD));
            json.put("jtEndDate", DateUtil.dateToStr(familySign.getEnd(), DateUtil.YYYY_MM_DD));
//            Doctor jtDoctor = doctorDao.findByCode(familySign.getDoctor());
//            json.put("jtDoctor", familySign.getDoctor());
//            json.put("jtDoctorName", familySign.getDoctorName());
//            json.put("jtDoctorSex", jtDoctor.getSex());
//            json.put("jtDoctorPhoto", jtDoctor.getPhoto());
//            json.put("jtDoctorHealth", familySign.getDoctorHealth());
//            json.put("jtDoctorHealthName", familySign.getDoctorHealthName());
//            json.put("jtSpecialist", familySign.getSpecialist());
//            json.put("jtSpecialistName", familySign.getSpecialistName());
//            json.put("jtAdminTeam", familySign.getAdminTeamId());
//            json.put("jtHospital", familySign.getHospital());
//            json.put("jtHospitalName", familySign.getHospitalName());
        }
/*        boolean epTime = false;
        try {
            epTime = redisTemplate.opsForSet().isMember("wechat:focus:remind:set", p.getCode());
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!epTime) {
            json.put("wechatFocusRemind", 0);
        } else {
            json.put("wechatFocusRemind", 1);
        }*/
/*        json.put("countryCode",p.getSickVillage()==null?"":p.getSickVillage());
        json.put("countryName",p.getSickVillageName()==null?"":p.getSickVillageName());*/
/*        //1.4.2 是否追踪居民健康体征
        if(StringUtils.isNotBlank(doctor)){
            TrackPatient tp = trackPatientDao.findByDoctorCodeAndPatientCode(doctor,patient);
            if(tp!=null){
                json.put("isTrack",tp.getDel());
            }else{
                json.put("isTrack","0");
            }
        }
        //1.4.9  是否专科医生服务
        JSONArray jsonArray =specialistService.findPatientSignSpecialist(patient);
        if(jsonArray!=null&&jsonArray.length()>0){
            json.put("isSpecialist",1);
            json.put("specialistArray", jsonArray);
        }else{
            json.put("isSpecialist",0);
        }
        //1.5.0 是否有康复计划
        JSONArray planList = rehabilitationManageService.planListByPatient(patient);
        if(planList!=null&&planList.length()>0){
            json.put("havePlan",1);
        }else{
            json.put("havePlan",0);
        }*/
        return json;
    }
}

+ 39 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/consult/ConsultTeamService.java

@ -2,6 +2,7 @@ package com.yihu.jw.door.service.consult;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.door.dao.WlyyDoorServiceOrderDao;
import com.yihu.jw.door.service.WlyyDoorServiceOrderService;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -11,6 +12,7 @@ import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -32,6 +34,43 @@ public class ConsultTeamService {
    private ImUtil imUtill;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private WlyyDoorServiceOrderService wlyyDoorServiceOrderService;
    /**
     * 根据咨询查关联业务记录
     * @param code
     * @param type
     * @return
     */
    public JSONObject queryByConsultCode(String code,Integer type){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(code) || null == type){
            return null;
        }
        ConsultDo consult = consultDao.queryByIdAndType(code,type);
        if(null == consult){
            result.put("data", "");
            return result;
        }
        switch (type) {
            case 11:
                WlyyDoorServiceOrderDO orderDO = wlyyDoorServiceOrderDao.findOne(consult.getRelationCode());
                JSONObject patientInfo = wlyyDoorServiceOrderService.queryOrderCardInfo(orderDO);
                result.put("data", patientInfo);
                break;
            default:
                break;
        }
        if(null == result.get("data")){
            result.put("data", consult);
        }
        return result;
    }
    /**
     * 添加一条咨询记录

+ 190 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/consult/DoctorQuickReplyService.java

@ -0,0 +1,190 @@
package com.yihu.jw.door.service.consult;
import com.yihu.jw.door.dao.consult.DoctorQuickReplyDao;
import com.yihu.jw.entity.door.DoctorQuickReply;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * Created by lyr-pc on 2016/12/28.
 */
@Service
@Transactional
public class DoctorQuickReplyService {
    @Autowired
    DoctorQuickReplyDao quickReplyDao;
    /**
     * 添加快捷回复
     *
     * @param doctor  医生
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply addReply(String doctor, String content, String type) {
        DoctorQuickReply reply = new DoctorQuickReply();
        Integer sort = quickReplyDao.findMaxSort(doctor);
        sort = sort == null ? 1 : sort + 1;
        reply.setDoctor(doctor);
        reply.setContent(content);
        reply.setStatus(1);
        reply.setSort(sort);
        reply.setUpdateTime(new Date());
        reply.setType(Integer.parseInt(type));
        reply.setSystag(0);
        return quickReplyDao.save(reply);
    }
    /**
     * 修改快捷回复
     *
     * @param id      回复ID
     * @param content 快捷回复内容
     * @return
     */
    public DoctorQuickReply modifyReply(long id, String content,String type) throws Exception {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        if (reply == null) {
            throw new Exception("reply not exist");
        }
        reply.setContent(content);
        reply.setType(Integer.parseInt(type));
        reply.setSystag(0);
        return quickReplyDao.save(reply);
    }
    /**
     * 删除快捷回复
     *
     * @param id
     * @return
     */
    public int delReply(String doctor, long id) {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        // 快捷回复不存在
        if (reply == null) {
            return -1;
        }
        if (reply.getStatus() == 0) {
            return -1;
        }
        reply.setStatus(0);
        quickReplyDao.save(reply);
        quickReplyDao.updateSort(doctor, reply.getSort());
        return 1;
    }
    /**
     * 获取医生快捷回复列表
     *
     * @param doctor
     * @return
     */
    public List<DoctorQuickReply> getDoctorReplyList(String doctor,String type,String keyword) throws Exception{
        Sort sort = new Sort(Sort.Direction.DESC, "sort");
        if("1".equals(type)){
            sort = new Sort(Sort.Direction.ASC, "sort");
        }
        List<DoctorQuickReply> replies = new ArrayList<>();
        if (StringUtils.isEmpty(keyword)){
            replies = quickReplyDao.findDoctorRepliesByType(doctor, Integer.parseInt(type),sort);
        }else {
            replies = quickReplyDao.findDoctorRepliesByType(doctor, Integer.parseInt(type),keyword,sort);
        }
        if(replies.isEmpty() && "1".equals(type)){
            //如果是续方咨询,拿到的列表为空,则默认添加系统消息
            List<DoctorQuickReply> defaults = quickReplyDao.findDoctorReplies("default",sort);
    
            List<DoctorQuickReply> newList = new ArrayList<>();
            
            for (DoctorQuickReply doctorQuickReply:defaults) {
                DoctorQuickReply doctorQuickReplyThis = new DoctorQuickReply();
                doctorQuickReplyThis.setDoctor(doctor);
                doctorQuickReplyThis.setType(doctorQuickReply.getType());
                doctorQuickReplyThis.setContent(doctorQuickReply.getContent());
                doctorQuickReplyThis.setSort(doctorQuickReply.getSort());
                doctorQuickReplyThis.setSystag(doctorQuickReply.getSystag());
                doctorQuickReplyThis.setStatus(doctorQuickReply.getStatus());
                doctorQuickReplyThis.setUpdateTime(new Date());
                newList.add(doctorQuickReplyThis);
            }
            quickReplyDao.save(newList);
    
            replies = quickReplyDao.findDoctorRepliesByType(doctor, Integer.parseInt(type),sort);
        }
        
        return replies;
    }
    /**
     * 排序回复
     *
     * @param id
     * @param sort
     * @return
     */
    public int sortReply(String doctor, long id, int sort) {
        DoctorQuickReply reply = quickReplyDao.findOne(id);
        // 快捷回复不存在
        if (reply == null) {
            return -1;
        }
        if (reply.getStatus() == 0) {
            return -1;
        }
        if (reply.getSort() < sort) {
            quickReplyDao.updateSortLt(doctor, reply.getSort(), sort);
        } else if (reply.getSort() > sort) {
            quickReplyDao.updateSortGt(doctor, reply.getSort(), sort);
        } else {
            return -2;
        }
        reply.setSort(sort);
        quickReplyDao.save(reply);
        return 1;
    }
    /**
     * 排序回复
     *
     * @param id
     * @param type
     * @return
     */
    public int sortReplyList(String id,String type) {
        String[] ids = id.split(",");
        for (int i = 0; i < ids.length; i++) {
            DoctorQuickReply reply = quickReplyDao.findOne(Long.valueOf(ids[i]));
            if (reply == null) {
                return -1;
            }
            if("1".equals(type)){
                reply.setSort(i+1);
            }else{
                reply.setSort(ids.length - i);
            }
            
        }
        return 1;
    }
}