Bladeren bron

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

wangjun 4 jaren geleden
bovenliggende
commit
c9df347bfa
22 gewijzigde bestanden met toevoegingen van 1216 en 27 verwijderingen
  1. 2 0
      business/base-service/src/main/java/com/yihu/jw/area/dao/BaseCityDao.java
  2. 2 0
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  3. 2 0
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java
  4. 17 0
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  5. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  6. 84 0
      common/common-entity/src/main/java/com/yihu/jw/entity/door/DoctorQuickReply.java
  7. 149 0
      svr/svr-door-serivce/sql/初始sql.sql
  8. 160 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/common/DistrictController.java
  9. 56 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorConsultController.java
  10. 27 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorController.java
  11. 170 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoctorQuickReplyController.java
  12. 8 8
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoorOrderController.java
  13. 18 5
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/ConsultController.java
  14. 31 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/patient/PatientController.java
  15. 40 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/dao/consult/DoctorQuickReplyDao.java
  16. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorOrderService.java
  17. 1 1
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/DoorServiceApplicationService.java
  18. 6 3
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/WlyyDoorServiceOrderService.java
  19. 14 9
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/HospitalService.java
  20. 167 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/PatientService.java
  21. 62 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/consult/ConsultTeamService.java
  22. 190 0
      svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/consult/DoctorQuickReplyService.java

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/area/dao/BaseCityDao.java

@ -28,5 +28,7 @@ public interface BaseCityDao extends PagingAndSortingRepository<BaseCityDO, Inte
    @Query("select code,name from BaseCityDO")
    List<BaseCityDO> getAllCity();
    @Query("select a from BaseCityDO a where a.province = ?1 order by id")
    Iterable<BaseCityDO> findByProvince(String province);
}

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java

@ -46,6 +46,8 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    List<BaseOrgDO> findByCityCode(String cityCode);
    List<BaseOrgDO> findByTownCode(String townCode);
    List<BaseOrgDO> findByCityCodeAndOrgLevel(String cityCode,Integer level);
    List<BaseOrgDO> findByDel(String del);

+ 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);
}

+ 17 - 0
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -376,6 +376,23 @@ public class ImUtil {
		}
		return HttpClientUtil.postBody(imAddr, params);
	}
	/**
	 * 更新会话成员(新增或删除) 活跃成员
	 * @param sessionId 会话id
	 * @param user 新增的成员id
	 * @param oldUserId  删除的成员id
	 */
	public String updateParticipantNew(String sessionId, String user,String oldUserId) {
		String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/updateNew";
		JSONObject params = new JSONObject();
		params.put("session_id", sessionId );
		params.put("user_id", user );
		if(!StringUtils.isEmpty(oldUserId)){
			params.put("old_user_id", oldUserId);
		}
		return HttpClientUtil.postBody(imAddr, params);
	}
	
	/**
	 * 更新消息内容

+ 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;
    }
}

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

@ -570,6 +570,155 @@ CREATE TABLE `wlyy_sign_family` (
  KEY `idx_type` (`type`,`status`,`expenses_status`,`apply_date`,`sign_year`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='家庭签约/三师签约';
CREATE TABLE `wlyy_doctor_registration_temp` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '业务无关主键',
  `code` varchar(50) NOT NULL COMMENT '二级模板标识',
  `doctor` varchar(50) DEFAULT NULL COMMENT '医生标识',
  `registration` varchar(50) DEFAULT NULL COMMENT '一级模板标识',
  `content` text COMMENT '服务登记内容',
  `send_times` int(11) DEFAULT NULL COMMENT '发送次数',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `last_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '最后一次发送时间',
  PRIMARY KEY (`id`),
  KEY `idx_code` (`code`) USING BTREE,
  KEY `idx_owner` (`doctor`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='医生登记服务模板表';
CREATE TABLE `wlyy_doctor_registration` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
  `code` varchar(50) NOT NULL COMMENT '登记服务一级模板编码',
  `model_name` varchar(50) DEFAULT NULL COMMENT '模板名称',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `is_hide` int(2) NOT NULL DEFAULT '0' COMMENT '是否隐藏 0 隐藏 1不隐藏',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('1', '1', '主诉记录', '2019-03-14 10:14:07', '0');
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('2', '2', '现病史', '2019-03-14 10:14:24', '0');
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('3', '3', '既往史、个人史、家族史', '2019-03-14 10:15:25', '0');
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('4', '4', '体格检查', '2019-03-14 10:15:49', '0');
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('5', '5', '既往辅助检查', '2019-03-14 10:16:09', '0');
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('6', '6', '诊断记录', '2019-03-14 10:16:23', '0');
INSERT INTO `wlyy_doctor_registration` (`id`, `code`, `model_name`, `create_time`, `is_hide`) VALUES ('7', '7', '治疗情况', '2019-03-14 10:16:38', '0');
INSERT INTO `base`.`base_doctor_role_dict` ( `code`, `name`, `del`, `create_user`, `create_user_name`, `create_time`, `update_user`, `update_user_name`, `update_time`) VALUES ( 'dispatcher', '调度员', '1', 'admin', '系统默认', '2020-12-29 11:38:31', NULL, NULL, '2020-12-29 11:38:26');
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('1', NULL, 'PROFESSIONAL_STATE', '0', '工单--患者职业', '国家机关、党群组织、企业、事业单位负责人', '1', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('2', NULL, 'PROFESSIONAL_STATE', '1', '1', '专业技术人员', '2', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('3', NULL, 'PROFESSIONAL_STATE', '2', '1', '办事人员和有关人员', '3', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('4', NULL, 'PROFESSIONAL_STATE', '3', '1', '商业、服务业人员', '4', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('5', NULL, 'PROFESSIONAL_STATE', '4', '1', '农、林、牧、渔、水利业生产人员', '5', '');
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('6', NULL, 'PROFESSIONAL_STATE', '5', '1', '生产、运输设备操作人员及有关人员', '6', NULL);
INSERT INTO `base`.`base_system_dict_entry` (`id`, `saas_id`, `dict_code`, `code`, `py_code`, `value`, `sort`, `remark`) VALUES ('7', NULL, 'PROFESSIONAL_STATE', '6', '1', '军人', '7', NULL);
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`;
CREATE TABLE `zy_nation_dict` (
  `ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `ORG_ID` int(11) DEFAULT NULL,
  `NATION_CODE` varchar(3) DEFAULT NULL COMMENT '民族编码',
  `NATION_NAME` varchar(50) DEFAULT NULL COMMENT '民族名称',
  `VALID_FLAG` varchar(2) DEFAULT NULL,
  `USER_CODE` varchar(50) DEFAULT NULL,
  `CUSTOM_CODE` varchar(50) DEFAULT NULL,
  `SPELL_CODE` varchar(50) DEFAULT NULL,
  `WBZX_CODE` varchar(50) DEFAULT NULL,
  `SORT_NO` varchar(50) DEFAULT NULL,
  `CREATE_TIME` datetime DEFAULT NULL,
  `CREATE_OPERATOR` varchar(50) DEFAULT NULL,
  `MODIFY_TIME` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `MODIFY_OPERATOR` varchar(50) DEFAULT NULL,
  `REMARK` varchar(50) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Records of zy_nation_dict
-- ----------------------------
INSERT INTO `zy_nation_dict` VALUES ('1', '0', '1', '汉族', '1', '', '', 'HZ', 'IY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('2', '0', '2', '蒙古族', '1', '', '', 'MGZ', 'ADY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('3', '0', '3', '回族', '1', '', '', 'HZ', 'LY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('4', '0', '4', '藏族', '1', '', '', 'CZ', 'AY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('5', '0', '5', '维吾尔族', '1', '', '', 'WWEZ', 'XGQY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('6', '0', '6', '苗族', '1', '', '', 'MZ', 'AY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('7', '0', '7', '彝族', '1', '', '', 'YZ', 'XY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('8', '0', '8', '壮族', '1', '', '', 'ZZ', 'UY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('9', '0', '9', '布依族', '1', '', '', 'BYZ', 'DWY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('10', '0', '10', '朝鲜族', '1', '', '', 'CXZ', 'FQY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('11', '0', '11', '满族', '1', '', '', 'MZ', 'IY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('12', '0', '12', '侗族', '1', '', '', 'DZ', 'WY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('13', '0', '13', '瑶族', '1', '', '', 'YZ', 'GY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('14', '0', '14', '白族', '1', '', '', 'BZ', 'RY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('15', '0', '15', '土家族', '1', '', '', 'TJZ', 'FPY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('16', '0', '16', '哈尼族', '1', '', '', 'HNZ', 'KNY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('17', '0', '17', '哈萨克族', '1', '', '', 'HSKZ', 'KADY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('18', '0', '18', '傣族', '1', '', '', 'DZ', 'WY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('19', '0', '19', '黎族', '1', '', '', 'LZ', 'TY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('20', '0', '20', '傈僳族', '1', '', '', 'LSZ', 'WWY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('21', '0', '21', '佤族', '1', '', '', 'WZ', 'WY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('22', '0', '22', '畲族', '1', '', '', 'SZ', 'WY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('23', '0', '23', '高山族', '1', '', '', 'GSZ', 'YMY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('24', '0', '24', '拉祜族', '1', '', '', 'LBZ', 'RPY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('25', '0', '25', '水族', '1', '', '', 'SZ', 'IY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('26', '0', '26', '东乡族', '1', '', '', 'DXZ', 'AXY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('27', '0', '27', '纳西族', '1', '', '', 'NXZ', 'XSY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('28', '0', '28', '景颇族', '1', '', '', 'JPZ', 'JHY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('29', '0', '29', '柯尔克孜族', '1', '', '', 'KEKZZ', 'SQDBY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('30', '0', '30', '土族', '1', '', '', 'TZ', 'FY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('31', '0', '31', '达斡尔族', '1', '', '', 'DHEZ', 'DFQY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('32', '0', '32', '仫佬族', '1', '', '', 'MLZ', 'WWY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('33', '0', '33', '羌族', '1', '', '', 'QZ', 'UY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('34', '0', '34', '布朗族', '1', '', '', 'BLZ', 'DYY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('35', '0', '35', '撒拉族', '1', '', '', 'SLZ', 'RRY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('36', '0', '36', '毛南族', '1', '', '', 'MNZ', 'TFY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('37', '0', '37', '仡佬族', '1', '', '', 'GLZ', 'WWY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('38', '0', '38', '锡伯族', '1', '', '', 'XBZ', 'QWY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('39', '0', '39', '阿昌族', '1', '', '', 'ACZ', 'BJY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('40', '0', '40', '普米族', '1', '', '', 'PMZ', 'UOY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('41', '0', '41', '塔吉克族', '1', '', '', 'TJKZ', 'FFDY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('42', '0', '42', '怒族', '1', '', '', 'NZ', 'VY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('43', '0', '43', '乌孜别克族', '1', '', '', 'WZBKZ', 'QBKDY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('44', '0', '44', '俄罗斯族', '1', '', '', 'ELSZ', 'WLAY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('45', '0', '45', '鄂温克族', '1', '', '', 'EWKZ', 'KIDY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('46', '0', '46', '德昂族', '1', '', '', 'DAZ', 'TJY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('47', '0', '47', '保安族', '1', '', '', 'BAZ', 'WPY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('48', '0', '48', '裕固族', '1', '', '', 'YGZ', 'PLY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('49', '0', '49', '京族', '1', '', '', 'JZ', 'YY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('50', '0', '50', '塔塔尔族', '1', '', '', 'TTEZ', 'FFQY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('51', '0', '51', '独龙族', '1', '', '', 'DLZ', 'QDY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('52', '0', '52', '鄂伦春族', '1', '', '', 'ELCZ', 'KWDY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('53', '0', '53', '赫哲族', '1', '', '', 'HZZ', 'FRY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('54', '0', '54', '门巴族', '1', '', '', 'MBZ', 'UCY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('55', '0', '55', '珞巴族', '1', '', '', 'LBZ', 'CY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('56', '0', '56', '基诺族', '1', '', '', 'JNZ', 'AYY', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('57', '0', '99', '其他', '1', '', '', 'QT', 'AW', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('58', '0', '57', '穿青人', '1', '', '57', 'CQZ', 'CQZ', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('59', '0', '58', 'Turkish', '1', '', '', 'teq', 'Turkish', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('60', '0', '59', 'BRITAIN', '1', '', '', 'BRITISH', 'BRITAIN', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('61', '0', '60', 'AUSTRALIAN', '1', '', '', 'AUSTRALIAN', 'AUSTRALIAN', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('62', '0', '61', '/', '1', '', '', '/', '/', '0', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('63', '0', '63', 'Ukrainian', '1', '', '', 'Ukrainian', 'Ukrainian', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('64', '0', '101', '亻革家人', '1', '', '', 'RGJR', '', '', null, '', null, '', '');
INSERT INTO `zy_nation_dict` VALUES ('65', '0', '62', '山由族', '1', '', '', 'SYZ', 'MMY', '', null, '', null, '', '');

+ 160 - 0
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/common/DistrictController.java

@ -0,0 +1,160 @@
package com.yihu.jw.door.controller.common;
import com.yihu.jw.area.dao.BaseCityDao;
import com.yihu.jw.area.dao.BaseProvinceDao;
import com.yihu.jw.area.dao.BaseStreetDao;
import com.yihu.jw.area.dao.BaseTownDao;
import com.yihu.jw.door.controller.BaseController;
import com.yihu.jw.entity.base.area.BaseCityDO;
import com.yihu.jw.entity.base.area.BaseProvinceDO;
import com.yihu.jw.entity.base.area.BaseStreetDO;
import com.yihu.jw.entity.base.area.BaseTownDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
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.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
 * Created by yeshijie on 2020/12/30.
 */
@RestController
@RequestMapping(value = "common", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "省市区三级地址")
public class DistrictController extends BaseController {
    @Autowired
    private BaseProvinceDao provinceDao;
    @Autowired
    private BaseCityDao cityDao;
    @Autowired
    private BaseTownDao townDao;
    @Autowired
    private BaseStreetDao streetDao;
    @Autowired
    private BaseOrgDao orgDao;
    /**
     * 省市一二三级查询接口
     * @param type 1一级目录,2二级目录,3三级目录,4街道目录
     * @param code 省或市标识
     * @return
     */
    @RequestMapping(value = "district",method = RequestMethod.POST)
    @ResponseBody
    public String district(int type, String code) {
        try {
            List<?> list = null;
            switch (type) {
                case 1:
                    list =  findProvince();
                    break;
                case 2:
                    list = findCity(code);
                    break;
                case 3:
                    list = findTown(code);
                    break;
                case 4:
                    list = findStreet(code);
                    break;
                case 5:
                    list = findHospital(code);
                    break;
            }
            return write(200, "查询成功!", "list", list);
        } catch (Exception e) {
            error(e);
            return error(-1, "查询失败!");
        }
    }
    /**
     * 查询所有的省份信息
     * @return
     */
    public List<BaseProvinceDO> findProvince() {
        List<BaseProvinceDO> list = new ArrayList<>();
        Iterable<BaseProvinceDO> iterable = provinceDao.findAll(new Sort(Direction.ASC, "id"));
        if (iterable != null) {
            Iterator<BaseProvinceDO> it = iterable.iterator();
            while (it != null && it.hasNext()) {
                list.add(it.next());
            }
        }
        return list;
    }
    /**
     * 查询省份下的城市信息
     * @param province 省编码
     * @return
     */
    public List<BaseCityDO> findCity(String province) {
        List<BaseCityDO> list = new ArrayList<>();
        Iterable<BaseCityDO> iterable = cityDao.findByProvince(province);
        if (iterable != null) {
            Iterator<BaseCityDO> it = iterable.iterator();
            while (it != null && it.hasNext()) {
                list.add(it.next());
            }
        }
        return list;
    }
    /**
     * 查询城市下的区县信息
     * @param city 城市编码
     * @return
     */
    public List<BaseTownDO> findTown(String city) {
        List<BaseTownDO> list = new ArrayList<>();
        Iterable<BaseTownDO> iterable = townDao.findByCityCode(city);
        if (iterable != null) {
            Iterator<BaseTownDO> it = iterable.iterator();
            while (it != null && it.hasNext()) {
                list.add(it.next());
            }
        }
        return list;
    }
    /**
     * 查询城市下的街道信息
     * @param town 区县编码
     * @return
     */
    public List<BaseStreetDO> findStreet(String town) {
        List<BaseStreetDO> list = new ArrayList<>();
        Iterable<BaseStreetDO> iterable = streetDao.findByTown(town);
        if (iterable != null) {
            Iterator<BaseStreetDO> it = iterable.iterator();
            while (it != null && it.hasNext()) {
                list.add(it.next());
            }
        }
        return list;
    }
    public List<BaseOrgDO> findHospital(String town) {
        List<BaseOrgDO> list = new ArrayList<>();
        Iterable<BaseOrgDO> iterable = orgDao.findByTownCode(town);
        if (iterable != null) {
            Iterator<BaseOrgDO> it = iterable.iterator();
            while (it != null && it.hasNext()) {
                list.add(it.next());
            }
        }
        return list;
    }
}

+ 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, "查询失败");
        }
    }
}

+ 8 - 8
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/controller/doctor/DoorOrderController.java

@ -121,7 +121,7 @@ public class DoorOrderController extends BaseController {
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = false) String orderId,
            @ApiParam(name = "level", value = "医院等级,1.三级医院,2.二级医院,3.一级及以下")
            @RequestParam(value = "level",required = true)Integer level) {
            @RequestParam(value = "level",required = false)Integer level) {
        try {
            // 没有提供工单id的情况下,则获取该医生当前最新一条的工单
            if (StringUtils.isEmpty(orderId)) {
@ -146,7 +146,7 @@ public class DoorOrderController extends BaseController {
            @ApiParam(value = "工单id", name = "orderId", required = true) @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "医生职称code", name = "jobCode", required = true) @RequestParam(value = "jobCode", required = true) String jobCode,
            @ApiParam(value = "医生职称", name = "jobCodeName", required = true) @RequestParam(value = "jobCodeName", required = true) String jobCodeName,
            @ApiParam(value = "医院级别", name = "hospitalLevel", required = true) @RequestParam(value = "hospitalLevel", required = true) int hospitalLevel) {
            @ApiParam(value = "医院级别", name = "hospitalLevel", required = false) @RequestParam(value = "hospitalLevel", required = false) int hospitalLevel) {
        try {
            doorOrderService.acceptOrder(orderId,jobCode,jobCodeName,hospitalLevel);
            return write(200, "操作成功");
@ -600,9 +600,9 @@ public class DoorOrderController extends BaseController {
            List<JSONObject> array = new ArrayList<>();
            WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
            // 被服务的居民的次数(非代理居民)
            Integer times = wlyyDoorServiceOrderService.countPatientDoorTimes(one.getPatient());
//            Integer times = wlyyDoorServiceOrderService.countPatientDoorTimes(one.getPatient());
            List<String> doctors = doorDoctorDao.findDoctors(orderId);
            List<Map<String, Object>> list = hospitalService.getDoctorsByhospitalNoPage(hospital, name, type, times);
            List<Map<String, Object>> list = hospitalService.getDoctorsByhospitalNoPage(hospital, name, type, 0);
            if (list != null) {
                for (Map<String, Object> doctor : list) {
                    if (doctor == null) {
@ -611,7 +611,7 @@ public class DoorOrderController extends BaseController {
                    JSONObject json = new JSONObject();
                    json.put("id", doctor.get("id"));
                    // 医生标识
                    json.put("code", doctor.get("code"));
                    json.put("code", doctor.get("id"));
                    // 医生姓名
                    json.put("name", doctor.get("name"));
                    // 所在医院名称
@ -622,7 +622,7 @@ public class DoorOrderController extends BaseController {
                    json.put("dept_name", (doctor.get("dept_name") == null ||
                            org.apache.commons.lang3.StringUtils.isEmpty(doctor.get("dept_name").toString())) ? " " : doctor.get("dept_name"));
                    json.put("level", doctor.get("level") );
//                    json.put("level", doctor.get("level") );
                    json.put("job", doctor.get("job") );
                    // 职称名称
                    json.put("job_name", (doctor.get("job_name") == null ||
@ -636,7 +636,7 @@ public class DoorOrderController extends BaseController {
                    json.put("flag", doctors.contains(String.valueOf(doctor.get("code"))) ? true : false);
                    json.put("fixed", one != null && String.valueOf(doctor.get("code")).equals(one.getDoctor()) ? true : false);
                    //出诊费用
                    json.put("fee", doctor.get("fee"));
                    json.put("fee", 0);
                    array.add(json);
                }
            }
@ -708,7 +708,7 @@ public class DoorOrderController extends BaseController {
    @GetMapping(value = "queryDoctorList")
    @ApiOperation(value = "服务人员列表(医生列表)")
    public String queryDoctorList(
            @ApiParam(name = "town", value = "调度员所在的机构code") @RequestParam(value = "town", required = true) String town,
            @ApiParam(name = "town", value = "调度员所在的机构code") @RequestParam(value = "town", required = false) String town,
            @ApiParam(name = "doctorName", value = "医生姓名") @RequestParam(value = "doctorName", required = false) String doctorName,
            @ApiParam(name = "status", value = "医生接单状态,状态为全部时不传") @RequestParam(value = "status", required = false) String status,
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient,

+ 18 - 5
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.
@ -38,7 +35,23 @@ public class ConsultController extends BaseController {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @RequestMapping(value = "updateMsg",method = RequestMethod.POST)
    @ApiOperation("修改会话消息内容")
    public String queryByConsultCode(@ApiParam(name = "sessionId", value = "会话id") @RequestParam(value = "sessionId", required = true) String sessionId,
                                     @ApiParam(name = "sessionType", value = "会话类型") @RequestParam(value = "sessionType", required = true) String sessionType,
                                     @ApiParam(name = "msgId", value = "消息id") @RequestParam(value = "msgId", required = true) String msgId,
                                     @ApiParam(name = "content", value = "消息内容") @RequestParam(value = "content", required = true) String content){
        JSONObject result = null;
        try{
            result = consultTeamService.updateIMMsg(sessionId,sessionType,msgId,content);
            if(result.getInteger("status") != -1){
                return write(200, "修改成功", "data", result.get("data"));
            }
        }catch (Exception e){
            error(e);
        }
        return error(-1,result.getString("data"));
    }
    /**
     * 网络咨询咨询日志查询

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

@ -10,6 +10,7 @@ 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;
@ -43,6 +44,36 @@ public class PatientController extends BaseController {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping(value = "getProfessionalDict")
    @ApiOperation("职业状态字典")
    public String getProfessionalDict(){
        try {
            String sql = "SELECT code,`value` from base_system_dict_entry WHERE dict_code = 'PROFESSIONAL_STATE' ORDER BY sort";
            List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
            return write(200, "获取成功!", "data",rs);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    @GetMapping(value = "getNationDict")
    @ApiOperation("获取民族信息列表")
    public String getNationDict(){
        try {
            String sql = "SELECT t.NATION_CODE,t.NATION_NAME FROM zy_nation_dict t";
            List<Map<String,Object>> rs = jdbcTemplate.queryForList(sql);
            return write(200, "获取成功!", "data",rs);
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "获取字典信息失败!");
        }
    }
    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/DoorOrderService.java

@ -261,7 +261,7 @@ public class DoorOrderService {
     * @return
     */
    public List<Map<String, Object>> getDoorServiceDoctor(String orderId) {
        String sql = "SELECT dd.id as id,CONCAT(d.`name`,' (',dd.doctor_job_name,')') as name, dd.doctor from wlyy_door_doctor dd join wlyy_doctor d on d.`code` = dd.doctor WHERE order_id=?";
        String sql = "SELECT dd.id as id,CONCAT(d.`name`,' (',dd.doctor_job_name,')') as name, dd.doctor from wlyy_door_doctor dd JOIN base_doctor d ON d.id = dd.doctor WHERE order_id=?";
        List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql, orderId);
        return mapList;
    }

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

@ -301,7 +301,7 @@ public class DoorServiceApplicationService {
        String sql="SELECT d.code,d.name FROM " +
                " manage_role_user ru LEFT JOIN " +
                " manage_roles r  ON ru.role_id=r.id " +
                " LEFT JOIN (select d.code,d.name from wlyy.wlyy_doctor d LEFT JOIN wlyy.wlyy_sign_family a ON d.hospital=a.hospital  " +
                " LEFT JOIN (select d.code,d.name from wlyy_doctor d LEFT JOIN wlyy_sign_family a ON d.hospital=a.hospital  " +
                "                 where a.patient = '"+patient+"' and a.status > 0  " +
                "                 AND d.status=1 and d.del=1) d ON ru.user_code=d.code " +
                " WHERE r.code='dispatcher' AND d.`code` IS NOT NULL";

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

@ -493,7 +493,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    /**
     * 获取居民所签约的机构的调度员(一个机构可以有多个调度员)
     * wlyy_doctor中,level -- 11-- 调度员
     * doctor中,level -- 11-- 调度员
     * @param hospitalCode
     * @return
     */
@ -927,6 +927,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        orderBriefInfo.put("doctorSignTime", DateUtil.dateToStr(orderDO.getDoctorSignTime(), "MM-dd HH:mm"));
        orderBriefInfo.put("completeTime", DateUtil.dateToStr(orderDO.getCompleteTime(), "MM-dd HH:mm"));
        orderBriefInfo.put("prescriptionTime", DateUtil.dateToStr(orderDO.getPrescriptionTime(), "MM-dd HH:mm"));
        orderBriefInfo.put("cancelTime", DateUtil.dateToStr(orderDO.getCancelTime(), "MM-dd HH:mm"));
        // 计算服务包支付多少钱
        List<Map<String, Object>> feeDetailDOS = doorOrderService.getDoorFeeDetailGroupByStatus(id);
@ -1882,7 +1883,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        }
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        if(StringUtils.isEmpty(hospital)){
            hospital = "350211A1002";
        }
        //
        String sql = "SELECT " +
                "  d.id as doctor, " +
@ -2269,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,"服务工单待接单","您有新的服务工单,请前往处理");

+ 14 - 9
svr/svr-door-serivce/src/main/java/com/yihu/jw/door/service/common/HospitalService.java

@ -1,6 +1,5 @@
package com.yihu.jw.door.service.common;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.org.dao.BaseOrgDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -22,35 +21,41 @@ public class HospitalService {
    private BaseOrgDao baseOrgDao;
    public List<Map<String, Object>> getDoctorsByhospitalNoPage(String hospital, String name, Integer type, Integer times) throws Exception {
        BaseOrgDO h = baseOrgDao.findByCode(hospital);
/*        BaseOrgDO h = baseOrgDao.findByCode(hospital);
        Integer level = 1;
        if(h != null && h.getOrgLevel()!=null) {
            level = h.getOrgLevel();
        }else {
            throw new Exception("未获取到机构等级");
        }
        String sql = "";
        }*/
//        String sql = "";
        //服务次数是否大于12
        if (times != null && times <= 12) {
/*        if (times != null && times <= 12) {
            sql = "select d.*,j.fee_level_" + level + " - j.subsidy as fee  from wlyy_doctor d LEFT JOIN dm_job j on d.job = j.`code` and j.del = 1 " +
                    "where d.del=1  and d.status=1 ";
        }else {
            sql = "select d.*,j.fee_level_" + level + " as fee  from wlyy_doctor d LEFT JOIN dm_job j on d.job = j.`code` and j.del = 1 " +
                    "where d.del=1  and d.status=1 ";
        }
        }*/
        String sql = "SELECT d.id," +
                " d.id name,d.name,h.org_code hospital,h.org_name hospital_name, " +
                " h.dept_name,d.job_title_code job,d.job_title_name job_name,d.photo,d.expertise,d.introduce " +
                "FROM base_doctor d, base_doctor_hospital h " +
                "WHERE d.id = h.doctor_code AND h.del = 1 AND d.del = 1";
        List<Object> params = new ArrayList<Object>();
        if (StringUtils.isNoneEmpty(hospital)) {
            sql += " and hospital =? ";
            sql += " and h.org_code =? ";
            params.add(hospital);
        }
        if (StringUtils.isNoneEmpty(name)) {
            sql += " and d.name like ? ";
            params.add("%" + name + "%");
        }
        if (type != null && type > 0) {
/*        if (type != null && type > 0) {
            sql += " and level =? ";
            params.add(type);
        }
        }*/
        return jdbcTemplate.queryForList(sql, params.toArray());
    }

+ 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;
    }
}

+ 62 - 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,61 @@ public class ConsultTeamService {
    private ImUtil imUtill;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private WlyyDoorServiceOrderService wlyyDoorServiceOrderService;
    public JSONObject updateIMMsg(String sessionId,String sessionType,String msgId,String content){
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(sessionId) || StringUtils.isEmpty(sessionType) || StringUtils.isEmpty(msgId) || StringUtils.isEmpty(content)){
            result.put("data", "参数【sessionId,sessionType,msgId,content】不可为空!");
            result.put("status", -1);
            return result ;
        }
        JSONObject contentJsonObj = null;
        try{
            contentJsonObj = JSONObject.parseObject(content);
        }catch (Exception e){
            result.put("status", -1);
            result.put("data", "【content】必须是json格式:" + e.getMessage());
            return result;
        }
        String response = imUtill.updateMessage(sessionId,sessionType,msgId,content);
        return JSONObject.parseObject(response);
    }
    /**
     * 根据咨询查关联业务记录
     * @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;
    }
    /**
     * 添加一条咨询记录
@ -135,6 +192,11 @@ public class ConsultTeamService {
            return result;
        }
        // 把医生拉入会话,作为其中一个成员
        if(StringUtils.isNotBlank(doorServiceOrderDO.getDoctor())){
            imUtill.updateParticipantNew(sessionId,doorServiceOrderDO.getDoctor(),null);
        }
        consultTeam.setStartMsgId(imResponseJson.get("start_msg_id").toString());
        consultTeamDao.save(consultTeam);
        consultDao.save(consult);

+ 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;
    }
}