Ver código fonte

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

wangjun 3 anos atrás
pai
commit
bfbe00215b
42 arquivos alterados com 2411 adições e 199 exclusões
  1. 39 0
      common/common-entity/sql记录
  2. 2 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java
  3. 70 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/course/DoctorPatientTmpDO.java
  4. 122 2
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java
  5. 3 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  6. 24 6
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  7. 18 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/course/DoctorPatientTmpDao.java
  8. 11 2
      svr/svr-base/src/main/java/com/yihu/jw/base/service/course/RecruitStudentsRecordService.java
  9. 4 4
      svr/svr-base/src/main/resources/application.yml
  10. 74 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/YsConfig.java
  11. 18 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/DoctorPatientTmpDao.java
  12. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/RecruitStudentsRecordDao.java
  13. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareOrderDao.java
  14. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/team/BaseTeamDao.java
  15. 21 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java
  16. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/PatientCourseEndpoint.java
  17. 110 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/RecruitStudentsEndpoint.java
  18. 255 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/YsDeviceController.java
  19. 24 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  20. 79 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java
  21. 11 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/team/TeamEndpoint.java
  22. 31 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/common/OrderNoService.java
  23. 30 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java
  24. 30 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java
  25. 189 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/RecruitStudentService.java
  26. 408 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java
  27. 132 22
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  28. 14 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  29. 220 39
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  30. 4 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  31. 6 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java
  32. 2 2
      svr/svr-cloud-care/src/main/resources/application.yml
  33. 1 1
      svr/svr-cloud-care/src/main/resources/wechat/weixin_menu.txt
  34. 5 0
      svr/svr-cloud-device/pom.xml
  35. 97 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/common/BaseController.java
  36. 74 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/YsConfig.java
  37. 49 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/YsDeviceController.java
  38. 123 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  39. 2 2
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/consult/FinishConsultJob.java
  40. 73 64
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  41. 5 7
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java
  42. 21 11
      svr/svr-cloud-job/src/main/resources/application.yml

+ 39 - 0
common/common-entity/sql记录

@ -992,3 +992,42 @@ alter table wlyy_outpatient ADD is_agree  varchar(2);
alter table base_doctor ADD is_sign  varchar(2);
alter table base_doctor ADD last_sign_time  timestamp;
-- 2021-06-02 ysj
CREATE TABLE `base_seq` (
  `val` int(11) NOT NULL,
  `type` tinyint(4) NOT NULL COMMENT '类型1生活照料'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='自增序列';
INSERT INTO `base`.`base_seq` (`val`, `type`) VALUES ('1000000001', '1');
CREATE FUNCTION seq(seq_type TINYINT (4)) returns int
begin
 UPDATE base_seq SET val=last_insert_id(val+1) WHERE type=seq_type;
 RETURN last_insert_id();
end;
alter table base_life_care_order add column doctor_sign_time datetime DEFAULT NULL COMMENT '医生签到时间';
alter table base_life_care_order add column doctor_sign_way tinyint(1) DEFAULT NULL COMMENT '医生签到方式:1-定位,2-扫码,3-拍照';
alter table base_life_care_order add column doctor_sign_location varchar(50) DEFAULT NULL COMMENT '医生签到位置,记录详细地址';
alter table base_life_care_order add column doctor_sign_img varchar(3000) DEFAULT NULL COMMENT '医生签到照片';
alter table base_life_care_order add column sign_doctor varchar(50) DEFAULT NULL COMMENT '签到医生';
alter table base_life_care_order add column sign_doctor_name varchar(50) DEFAULT NULL COMMENT '签到医生name';
-- 2021-06-07 ysj
alter table base_life_care_order add column conclusion_imgs varchar(3000) DEFAULT NULL COMMENT '小结照片';
alter table base_life_care_order add column conclusion_time datetime DEFAULT NULL COMMENT '小结时间';
alter table base_life_care_order add column conclusion_remark varchar(1200) DEFAULT NULL COMMENT '小结内容';
-- 2021-06-07 lb
CREATE TABLE `base_doctor_patient_tmp` (
  `id` varchar(50) NOT NULL,
  `patient` varchar(50) DEFAULT NULL,
  `type` tinyint(2) DEFAULT NULL COMMENT '1在线咨询,2上门辅导,3入学报名,4购买课程',
  `relation_code` varchar(50) DEFAULT NULL COMMENT '1:咨询code,2上门辅导工单id,3入学订单id,4课程订单id',
  `doctor_code` varchar(50) DEFAULT NULL COMMENT 'type=(1,2,4为医生id;3机构code) ',
  `status` tinyint(2) DEFAULT '0' COMMENT '入学字段 1已入学,0未入学',
  `del` tinyint(1) DEFAULT '1' COMMENT '1有效 0无效',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  PRIMARY KEY (`id`),
  KEY `patient` (`patient`),
  KEY `type_doc_code` (`type`,`doctor_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='教师医生通讯录埋点数据';

+ 2 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java

@ -24,7 +24,8 @@ public class ConsultTeamDo extends UuidIdentityEntity {
	// 6、患者名医咨询 7医生名医咨询 8续方咨询 9、16在线复诊咨询(居民直接咨询专家)
	// 10医生发起的求助 11思明区上门服务在线咨询
	// 13、互联网医院专家咨询, 20紧急救助咨询, 21上门辅导咨询, 22安防警报咨询
	// 23 在线咨询
	// 23 新生儿在线咨询
	// 24 老人在线咨询
	private String patient;         // 提问者标识
	private String name;            // 患者姓名
	private Integer sex;            // 患者性别

+ 70 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/course/DoctorPatientTmpDO.java

@ -0,0 +1,70 @@
package com.yihu.jw.entity.care.course;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/6/7.
 * 教师通讯录幼儿数据埋点
 */
@Entity
@Table(name="base_doctor_patient_tmp")
public class DoctorPatientTmpDO extends UuidIdentityEntityWithCreateTime {
    private String patient;
    private Integer type; //1在线咨询,2上门辅导,3入学报名,4购买课程
    private String relationCode; //1:咨询code,2上门辅导工单id,3入学订单id,4课程订单id
    private String doctorCode;// type=(1,2,4为医生id;3机构code)
    private Integer status; //入学字段 1已入学,0未入学
    private Integer del;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    public String getDoctorCode() {
        return doctorCode;
    }
    public void setDoctorCode(String doctorCode) {
        this.doctorCode = doctorCode;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 122 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java

@ -23,7 +23,8 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    public enum Status {
        cancel(-1, "已取消"),
        waitForAccept(1, "待(医生)接单"),
        waitForAccept(1, "待(医生)接单"),//待服务
        signIn(3, "已签到"),
        complete(2,"已完成");
        private Integer type;
@ -181,9 +182,23 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
     */
    private String completeRemark;
    /**
     * 小结照片,最多6张,逗号分隔
     */
    private String conclusionImgs;
    /**
     * 服务小结
     */
    private String conclusionRemark;
    /**
     * 工单结时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date conclusionTime;
    /**
     * 工单状态:
     * 待服务 1、已完成 2 、已取消 -1
     * 待服务 1、已完成 2 、已取消 -1 已签到 3、
     */
    private Integer status;
@ -257,7 +272,34 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    private String hospitalName;
    private Integer type;//发起工单类型(1本人发起 2家人待预约 3医生代预约)
    private String relationCode;//业务关联
    /**
     * 医生签到时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date doctorSignTime;
    /**
     * 医生签到方式:1-定位,2-扫码
     */
    private Integer doctorSignWay;
    /**
     * 医生签到位置,记录详细地址
     */
    private String doctorSignLocation;
    /**
     * 医生签到照片
     */
    private String doctorSignImg;
    /**
     *
     */
    private String signDoctor;
    /**
     * 签到医生姓名
     */
    private String signDoctorName;
    @Column(name = "number")
    public String getNumber() {
@ -585,4 +627,82 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
        this.relationCode = relationCode;
    }
    @Column(name = "doctor_sign_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDoctorSignTime() {
        return doctorSignTime;
    }
    public void setDoctorSignTime(Date doctorSignTime) {
        this.doctorSignTime = doctorSignTime;
    }
    @Column(name = "doctor_sign_way")
    public Integer getDoctorSignWay() {
        return doctorSignWay;
    }
    public void setDoctorSignWay(Integer doctorSignWay) {
        this.doctorSignWay = doctorSignWay;
    }
    @Column(name = "doctor_sign_location")
    public String getDoctorSignLocation() {
        return doctorSignLocation;
    }
    public void setDoctorSignLocation(String doctorSignLocation) {
        this.doctorSignLocation = doctorSignLocation;
    }
    @Column(name = "doctor_sign_img")
    public String getDoctorSignImg() {
        return doctorSignImg;
    }
    public void setDoctorSignImg(String doctorSignImg) {
        this.doctorSignImg = doctorSignImg;
    }
    @Column(name = "sign_doctor")
    public String getSignDoctor() {
        return signDoctor;
    }
    public void setSignDoctor(String signDoctor) {
        this.signDoctor = signDoctor;
    }
    @Column(name = "sign_doctor_name")
    public String getSignDoctorName() {
        return signDoctorName;
    }
    public void setSignDoctorName(String signDoctorName) {
        this.signDoctorName = signDoctorName;
    }
    @Column(name = "conclusion_imgs")
    public String getConclusionImgs() {
        return conclusionImgs;
    }
    public void setConclusionImgs(String conclusionImgs) {
        this.conclusionImgs = conclusionImgs;
    }
    @Column(name = "conclusion_remark")
    public String getConclusionRemark() {
        return conclusionRemark;
    }
    public void setConclusionRemark(String conclusionRemark) {
        this.conclusionRemark = conclusionRemark;
    }
    @Column(name = "conclusion_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getConclusionTime() {
        return conclusionTime;
    }
    public void setConclusionTime(Date conclusionTime) {
        this.conclusionTime = conclusionTime;
    }
}

+ 3 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java

@ -19,7 +19,9 @@ public class SystemMessageDO extends UuidIdentityEntity {
    /**
     *消息类型 上门服务400开头,生活照料500开头 ,安防监控600开头, 上门辅导700开头,紧急救助800开头
     * 在线咨询 850
     * 家属紧急预警系统消息 50
     * 新生儿在线咨询 850
     * 老人在线咨询 851
     */
    private String type;
    /**

+ 24 - 6
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -595,10 +595,28 @@ public class HttpClientUtil {
        return response;
    }
//    public static void main(String[] args) {
//        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
//        org.springframework.http.HttpEntity<JSONObject> response = aqgCookieHttp("http://api.aiqiangua.com:8888/api/device/868219010321351",null,HttpMethod.GET,
//                "user=2|1:0|10:1620279813|4:user|16:MTM1NTk0ODUyNzA=|9d8d1403e854d37b551b57c9e53581b2ba7c491ba394a2b3a1b83f4ebc3c2d34");
//        System.out.println(response.getBody().toString());
//    }
    public org.springframework.http.HttpEntity<JSONObject> assesTokenPostHttp(String url, JSONObject params,HttpMethod method){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType(MediaType.APPLICATION_JSON_VALUE);
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> request = new org.springframework.http.HttpEntity<>(params.toString(), headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
        return response;
    }
    public  org.springframework.http.HttpEntity<JSONObject> iotAssesTokenPostHttp(String url, MultiValueMap<String, String> params,HttpMethod method){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
        return response;
    }
    public static void main(String[] args)  {
    }
}

+ 18 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/course/DoctorPatientTmpDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.base.dao.course;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/6/7.
 */
public interface DoctorPatientTmpDao extends PagingAndSortingRepository<DoctorPatientTmpDO,String>,
        JpaSpecificationExecutor<DoctorPatientTmpDO> {
    DoctorPatientTmpDO findByRelationCode(String relationCode);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3")
    Integer findByPatientAndDoctorCodeAndType(String patient,String doctorCode,Integer type);
}

+ 11 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/course/RecruitStudentsRecordService.java

@ -1,9 +1,11 @@
package com.yihu.jw.base.service.course;
import com.yihu.jw.base.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.base.dao.course.PatientOrderRefundDao;
import com.yihu.jw.base.dao.course.RecruitStudentsDao;
import com.yihu.jw.base.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.base.util.WxMessageUtil;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.care.course.PatientOrderRefundDO;
import com.yihu.jw.entity.care.course.RecruitStudentsDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
@ -34,6 +36,8 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
    private RecruitStudentsDao recruitStudentsDao;
    @Autowired
    private WxMessageUtil wxMessageUtil;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    /**
     * 退费操作
@ -83,6 +87,11 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
            }else{
                re += recruitStudentsRecordDO.getPatientName()+",";
            }
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(id);
            if (tmpDO!=null){
                tmpDO.setStatus(1);
                doctorPatientTmpDao.save(tmpDO);
            }
        }
        recruitStudentsRecordDao.save(list);
        wxMessageUtil.sengdWxTemplates(list);
@ -137,7 +146,7 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
     */
    public synchronized String admission(String id){
        RecruitStudentsRecordDO recruitStudentsRecordDO = recruitStudentsRecordDao.findOne(id);
        if("1".equals(recruitStudentsRecordDO.getStatus())){
        if(!"1".equals(recruitStudentsRecordDO.getStatus())){
            return "只有待审核状态的人员才能录取";
        }
        if(isAdmissionFull(recruitStudentsRecordDO.getRecruitStudentsId())){
@ -154,7 +163,7 @@ public class RecruitStudentsRecordService extends BaseJpaService<RecruitStudents
     */
    public synchronized String refuse(String id){
        RecruitStudentsRecordDO recruitStudentsRecordDO = recruitStudentsRecordDao.findOne(id);
        if("1".equals(recruitStudentsRecordDO.getStatus())){
        if(!"1".equals(recruitStudentsRecordDO.getStatus())){
            return "只有待审核状态的人员才能拒绝";
        }
        recruitStudentsRecordDO.setStatus("4");

+ 4 - 4
svr/svr-base/src/main/resources/application.yml

@ -172,7 +172,7 @@ wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: hz_yyyzh_wx
  url: http://hzijk.cityihealth.com/
  url: https://zhyzh.hzxc.gov.cn/
  flag: false
pay:
  flag: false
@ -611,7 +611,7 @@ spring:
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://10.18.43.40:61616
    broker-url: tcp://10.18.43.41:61616
    user: admin
    password: admin
  redis:
@ -632,7 +632,7 @@ wlyy:
  url: 1
wechat:
  id: hz_yyyzh_wx
  url: http://hzijk.cityihealth.com/
  url: https://zhyzh.hzxc.gov.cn/
  flag: false
pay:
  flag: false
@ -641,4 +641,4 @@ testPattern:
  sign: 0
  remote_inner_url: 1
im:
  im_list_get: http://10.18.43.40:3000/
  im_list_get: http://10.18.43.41:3000/

+ 74 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/YsConfig.java

@ -0,0 +1,74 @@
package com.yihu.jw.care.config;
/**
 * Created by Bing on 2021/6/1.
 * 萤石摄像头配置
 */
public class YsConfig {
    //文档地址 https://www.yuque.com/u1400669/kb/lmfp6u
    public static final String AppKey="43e44c2071114743925eda34088045f8";
    public static final String Secret="82051725cf0547208f8bc8ae2bff1323";
    public static final String baseUrl = "https://esopen.ys7.com";
    public static final String iotBaseUrl = "https://open.ys7.com";
   //saas平台 https://www.yuque.com/u1400669/kb/wdvi3b#9ZP70
    public static final String saasAssesToken =baseUrl+ "/api/user/open-app/auth/gettoken";
    //开放平台  https://open.ys7.com/doc/zh/book/index/user.html
    public static final String iotAssesToken =baseUrl+ "/api/user/component-open/sso/oauth2/getEZAccessToken";
    //获取通道列表
    public static final String surveillanceWayList =baseUrl+ "/api/resource/open-app/surveillance/camera/list/page";
    //获取通道信息(通道默认为1)
    public static final String surveillanceWay =baseUrl+ "/api/resource/open-app/surveillance/camera/info";
    //设备抓拍
    public static final String deviceCapture =baseUrl +"/api/resource/device/capture";
    //获取设备有效直播地址
    public static final String getDeviceLiveAddress = iotBaseUrl+ "/api/lapp/live/address/limited";
    //设备视频加解密开关
    public static final String deviceEncrypt = baseUrl+ "/api/resource/device/encrypt/switch";
    //跌倒检测功能查询、设置(立即检测!判断是否有跌倒通过推送消息)
    public static final String deviceFailConfig = iotBaseUrl + "/api/route/device/devconfig/keyValue/{0}/{1}/op";
    //云台控制
    public static final String ptzStart = iotBaseUrl +"/api/lapp/device/ptz/start";
    //云台停止
    public static final String ptzStop = iotBaseUrl +"/api/lapp/device/ptz/stop";
    /**
     * 录像相关
     */
    //获取录像accessKey、上传录像地址
    public static final String videoKey = baseUrl +"/seastart/vod/token";
    //上传录像上传地址通过videoKey接口获取
    public static final String videoUpload = "https://seastart.ss.bscstorage.com";
    //录像列表
    public static final String videoList = baseUrl +"/seastart/vod/list";
    //批量获取录像详情
    public static final String videoDetailList = baseUrl +"/seastart/vod";
    //录像详情
    public static final String videoDetail = baseUrl +"/seastart/vod/get";
    public static final String redisKey = "ysAssesToken";
    public static final String iotRedisKey = "iotYsAssesToken";
    public static final String secretKey = "secretKey"; //设备的解密秘钥  通过iotAssesToken接口获取的
    public static final String msgDataKey = "HZADP68PNSNVZ4UW"; //消息解密密钥
}

+ 18 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/DoctorPatientTmpDao.java

@ -0,0 +1,18 @@
package com.yihu.jw.care.dao.course;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/6/7.
 */
public interface DoctorPatientTmpDao extends PagingAndSortingRepository<DoctorPatientTmpDO,String>,
        JpaSpecificationExecutor<DoctorPatientTmpDO> {
    DoctorPatientTmpDO findByRelationCode(String relationCode);
    @Query(value = "select count(1) from DoctorPatientTmpDO t where t.patient=?1 and t.doctorCode = ?2 and t.type=?3")
    Integer findByPatientAndDoctorCodeAndType(String patient,String doctorCode,Integer type);
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/course/RecruitStudentsRecordDao.java

@ -17,4 +17,6 @@ public interface RecruitStudentsRecordDao extends PagingAndSortingRepository<Rec
        JpaSpecificationExecutor<RecruitStudentsRecordDO> {
    List<RecruitStudentsRecordDO> findByRecruitStudentsIdAndStatus(String recruitStudentsId, String status);
    List<RecruitStudentsRecordDO> findByOrgCodeAndStatus(String orgCode, String status);
}

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareOrderDao.java

@ -8,4 +8,6 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by yeshijie on 2021/3/26.
 */
public interface LifeCareOrderDao extends PagingAndSortingRepository<LifeCareOrderDO, String>, JpaSpecificationExecutor<LifeCareOrderDO> {
    boolean existsByPatientAndStatusIn(String patient, Integer[] status);
}

+ 5 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/team/BaseTeamDao.java

@ -37,6 +37,11 @@ public interface BaseTeamDao extends PagingAndSortingRepository<BaseTeamDO, Stri
            "AND t.id = m.teamCode AND t.del = '1' AND m.del = '1'")
    List<BaseTeamDO> findDoctorTeams(@Param(value = "doctorCode") String doctorCode);
    @Query("SELECT t FROM BaseTeamMemberDO m, BaseTeamDO t WHERE m.doctorCode =:doctorCode " +
            "AND t.id = m.teamCode  AND t.del = '1' AND m.del = '1' and exists (select doc.id from BaseDoctorDO doc,BaseTeamMemberDO mem " +
            " where mem.teamCode = m.teamCode and doc.id = mem.doctorCode and doc.name like :name and mem.del = '1'  )")
    List<BaseTeamDO> findDoctorTeamsByDoctorName(@Param(value = "doctorCode") String doctorCode,@Param(value = "name") String name);
    @Query("from BaseTeamDO t WHERE t.del = '1'  AND t.orgCode = ?1 ")
    List<BaseTeamDO> findByOrgCode(String orgCode);
 }

+ 21 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/PatientConsultEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.service.consult.ConsultService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
@ -10,6 +11,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.hospital.family.service.WlyyFamilyMemberService;
@ -111,12 +113,14 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "sessionId", value = "会话id")
            @RequestParam(value = "sessionId",required = false) String sessionId,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
			@RequestParam(value = "patient",required = true) String patient,
			@ApiParam(name="type",value = "咨询类型 23新生儿在线咨询 24老人在线咨询")
			@RequestParam(value = "type",required = false,defaultValue = "23") Integer type)throws Exception {
		try {
			if (StringUtils.isBlank(orgCode)&&StringUtils.isBlank(sessionId)){
				return Envelop.getError("参数错误请求失败");
			}
			return success("请求成功",consultService.findLastOnlineConsult(patient, orgCode,sessionId));
			return success("请求成功",consultService.findLastOnlineConsult(patient, orgCode,sessionId,type));
		}catch (Exception e){
			return failedException(e);
		}
@ -128,9 +132,11 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@ApiParam(name = "doctor", value = "医生CODE")
			@RequestParam(value = "doctor",required = false) String doctor,
			@ApiParam(name = "patient", value = "居民CODE")
			@RequestParam(value = "patient",required = true) String patient)throws Exception {
			@RequestParam(value = "patient",required = true) String patient,
			@ApiParam(name="type",value = "咨询类型 23新生儿在线咨询 24老人在线咨询")
			@RequestParam(value = "type",required = false,defaultValue = "23") Integer type)throws Exception {
		try {
			String consultCode = consultService.getUnfinishedConsult(patient, doctor);
			String consultCode = consultService.getUnfinishedConsult(patient, doctor, type);
			return success("请求成功",consultCode);
		}catch (Exception e){
			return failedException(e);
@ -150,7 +156,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "images",required = false) String images,
			@ApiParam(name = "voice", value = "语音")
			@RequestParam(value = "voice",required = false) String voice,
			@ApiParam(name = "type", value = "咨询类型:23在线咨询")
			@ApiParam(name = "type", value = "咨询类型:23在线咨询,24老人在线咨询")
			@RequestParam(value = "type",required = false) Integer type,
			@ApiParam(name = "source", value = "咨询类型来源")
			@RequestParam(value = "source",required = false) String source)throws Exception{
@ -161,7 +167,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			type = 23;
		}
		ConsultTeamDo consult = new ConsultTeamDo();
		// 设置咨询类型:23 在线咨询
		// 设置咨询类型:23 在线咨询 24老人在线咨询
		consult.setType(type);
		// 设置主要症状
		consult.setSymptoms(symptoms);
@ -179,6 +185,9 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			SystemMessageDO systemMessageDO = new SystemMessageDO();
			systemMessageDO.setTitle("新增在线咨询");
			systemMessageDO.setType("850");
			if (type==24){
				systemMessageDO.setType("851");
			}
			systemMessageDO.setReceiver(re.getString("doctor"));
			systemMessageDO.setReceiverName(re.getString("doctorName"));
			systemMessageDO.setRelationCode(re.getString("sessiond_id"));
@ -192,8 +201,10 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			data.put("question",symptoms);
			data.put("type",1);
			systemMessageDO.setData(data.toString());
			consultService.saveMessage(systemMessageDO);
		}
		return success("操作成功", consult);
	}
@ -204,12 +215,14 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "patient",required = true) String patient,
			@ApiParam(name = "orgCode", value = "机构code")
			@RequestParam(value = "orgCode",required = true) String orgCode,
			@ApiParam(name="type",value = "咨询类型 23新生儿在线咨询 24老人在线咨询")
			@RequestParam(value = "type",required = false,defaultValue = "23") Integer type,
			@ApiParam(name = "page", value = "第几页")
			@RequestParam(value = "page",required = false) int page,
			@ApiParam(name = "pagesize", value = "分页大小")
			@RequestParam(value = "pagesize",required = false) int pagesize)throws Exception{
		try {
			List<Map<String,Object>>  data = consultService.findConsultDoctor(orgCode, patient, page,pagesize);
			List<Map<String,Object>>  data = consultService.findConsultDoctor(orgCode, patient,type,page,pagesize);
			return success(data);
		}catch (Exception e){
			return failedException(e);
@ -227,7 +240,7 @@ public class PatientConsultEndpoint extends EnvelopRestEndpoint {
			@RequestParam(value = "symptoms",required = false) String symptoms,
			@ApiParam(name = "id", value = "咨询ID")
			@RequestParam(value = "id",required = false) String id,
			@ApiParam(name = "type", value = "咨询类型")
			@ApiParam(name = "type", value = "咨询类型 23新生儿在线咨询 24老人在线咨询")
			@RequestParam(value = "type",required = true) String type,
			@ApiParam(name = "status", value = "咨询状态:0进行中,1已完成,-1患者取消,-2超时未响应自动关闭")
			@RequestParam(value = "status",required = false) Integer status,

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/PatientCourseEndpoint.java

@ -292,7 +292,7 @@ public class PatientCourseEndpoint extends EnvelopRestEndpoint {
        }
    }
    //申请退款
    //申请退款 //todo 退款需要把数据失效 base_doctor_patient_tmp表
    //直播间
}

+ 110 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/course/RecruitStudentsEndpoint.java

@ -0,0 +1,110 @@
package com.yihu.jw.care.endpoint.course;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.course.RecruitStudentService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/8
 * @Description:
 */
@RestController
@RequestMapping("recruitStudent" )
@Api(tags = "招生-在线报名", description = "招生-在线报名")
public class RecruitStudentsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private RecruitStudentService recruitStudentService;
    @GetMapping(value = "onlineRegisterCount")
    @ApiOperation("在线报名-已报名数量")
    public ObjEnvelop onlineRegisterCount(@ApiParam(name = "doctorId", value = "doctorId")
                                          @RequestParam(value = "doctorId", required = true) String doctorId){
        try {
            return ObjEnvelop.getSuccess("查询成功",recruitStudentService.onlineRegisterCount(doctorId));
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "queryInfoList")
    @ApiOperation(value = "查询在线报名记录")
    public PageEnvelop queryInfoList(
            @ApiParam(name = "doctorId", value = "教师id") @RequestParam(value = "doctorId", required = true) String doctorId,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = recruitStudentService.queryInfoList(doctorId, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }
            int count = result.getIntValue(ResponseContant.count);
            return success((List) result.get(ResponseContant.resultMsg), count, page, size);
        }catch (Exception e){
            return failedPageEnvelopException(e);
        }
    }
    @GetMapping(value = "onlineRegisterStatusCount")
    @ApiOperation(value = "统计在线报名各状态下的数量")
    public Envelop onlineRegisterStatusCount(
            @ApiParam(name = "doctorId", value = "教师id")
            @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            JSONObject result = recruitStudentService.onlineRegisterStatusCount(doctorId);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
            return success(result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = "admission")
    @ApiOperation(value = "录取")
    public Envelop admission(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        try{
            String re =  recruitStudentService.admission(id);
            if(re == null){
                return success("录取成功");
            }else {
                return Envelop.getError(re,-1);
            }
        }catch (Exception e){
            return failedException(e);
        }
    }
    @PostMapping(value = "refuse")
    @ApiOperation(value = "拒绝")
    public Envelop refuse(
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) {
        try{
            recruitStudentService.refuse(id);
            return success("拒绝成功");
        }catch (Exception e){
            return failedException(e);
        }
    }
}

+ 255 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/YsDeviceController.java

@ -0,0 +1,255 @@
package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.YsDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
 * Created by Bing on 2021/6/1.
 */
@RestController
@RequestMapping("ys/device")
@Api(description = "萤石设备设备相关服务")
public class YsDeviceController extends BaseController {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(YsDeviceController.class);
    @Autowired
    private YsDeviceService ysDeviceService;
    @ApiOperation("摄像机通道详情")
    @RequestMapping(value = "surveillanceWay", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String surveillanceWay(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = false,value="设备通道号,默认为1")
            @RequestParam(value = "channelNo",required = false,defaultValue = "1") Integer channelNo,
            @ApiParam(name="isTrust",required = false,value="是否托管设备:0-非托管,1-托管,默认0")
            @RequestParam(value = "isTrust",required = false,defaultValue = "0") Integer isTrust,
            HttpServletRequest request) {
        try {
            return write(200,"查询成功","data",ysDeviceService.surveillanceWay(deviceSerial,channelNo,isTrust,request));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("跌倒检测")
    @RequestMapping(value = "deviceFailConfig", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String surveillanceWayAddress(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="type",required = false,value="0-人或车检测,1-人形检测,2-车检测,3-画面变化检测,4-人脸检测,5-智能人体检测,6-宠物检测,7-跌倒检测")
            @RequestParam(value = "type",required = false) Integer type,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.deviceFailConfig(deviceSerial,type,request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("视频加解密")
    @RequestMapping(value = "deviceEncrypt", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String deviceEncrypt(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="isEncrypt",required = true,value="0-关闭,1-开启")
            @RequestParam(value = "isEncrypt",required = true) Integer isEncrypt,
            @ApiParam(name="validateCode",required = false,value="设备验证码,当isEncrypt=0时,需要传递此参数")
            @RequestParam(value = "validateCode",required = false) String validateCode,
            HttpServletRequest request){
        try {
            if (0==isEncrypt&& StringUtils.isBlank(validateCode)){
                return error(-1,"参数错误");
            }
            return write(200,"查询成功","data",ysDeviceService.deviceEncrypt(deviceSerial,isEncrypt,validateCode,request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("设备抓拍")
    @RequestMapping(value = "deviceCapture", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String deviceCapture(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
            @RequestParam(value = "channelNo",required = true) Integer channelNo,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.deviceCapture(deviceSerial,channelNo,request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("设备有效直播地址")
    @RequestMapping(value = "getDeviceLiveAddress", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String getDeviceLiveAddress(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
            @RequestParam(value = "channelNo",required = true,defaultValue = "1") Integer channelNo,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.getDeviceLiveAddress(deviceSerial,channelNo,request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("设备云台控制开始")//操作后都需要调用停止接口 才会停止转动
    @RequestMapping(value = "ptzStart", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String ptzStart(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
            @RequestParam(value = "channelNo",required = true) Integer channelNo,
            @ApiParam(name="direction",required = true,value="0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距")
            @RequestParam(value = "direction",required = true) Integer direction,
            @ApiParam(name="speed",required = true,value="云台速度:0-慢,1-适中,2-快,海康设备参数不可为0")
            @RequestParam(value = "speed",required = true) Integer speed,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.ptzStart(deviceSerial,channelNo,direction,speed,request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("设备云台控制结束")
    @RequestMapping(value = "ptzStop", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String ptzStop(
            @ApiParam(name="deviceSerial",required = true,value="设备序列号")
            @RequestParam(value = "deviceSerial",required = true) String deviceSerial,
            @ApiParam(name="channelNo",required = true,value="通道号,IPC设备填1")
            @RequestParam(value = "channelNo",required = true) Integer channelNo,
            @ApiParam(name="direction",required = true,value="0-上,1-下,2-左,3-右,4-左上,5-左下,6-右上,7-右下,8-放大,9-缩小,10-近焦距,11-远焦距")
            @RequestParam(value = "direction",required = true) Integer direction,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.ptzStop(deviceSerial,channelNo,direction,request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("获取上传录像授权信息")
    @RequestMapping(value = "getVideoKey", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String getVideoKey(
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.getVideoKey(request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("查询录像列表(无法区分用户)")
    @RequestMapping(value = "videoList", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String videoList(
            @ApiParam(name="name",required = false,value="录像名称,支持模糊搜索")
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name="type",required = false,value="视频类型 默认查询全部视频/录像,type=playback,表示查询直播暂存(录像);type=vod,表示查询上传、剪辑、合并视频。")
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="page",required = false,value="page")
            @RequestParam(value = "page",required = false,defaultValue = "1") int page,
            @ApiParam(name="count",required = false,value=",默认为 20")
            @RequestParam(value = "count",required = false,defaultValue = "20") int count,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.videoList(name,type,page,count));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("批量获取录像详情")
    @RequestMapping(value = "videoDetailList", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String videoDetailList(
            @ApiParam(name = "vod_ids",value="录像id",required = true)
            @RequestParam(value="vod_ids")String[] vod_ids,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.videoDetailList(vod_ids));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("查询录像详情")
    @RequestMapping(value = "videoDetail", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String videoDetail(
            @ApiParam(name = "vod_id",value="录像id",required = true)
            @RequestParam(value="vod_id")String vod_id,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.videoDetail(vod_id));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
    @ApiOperation("上传录像")
    @RequestMapping(value = "videoUpload", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String videoUpload(
            HttpServletRequest request,
            @ApiParam(value = "文件", required = true)
            @RequestParam(value = "file", required = true) MultipartFile file){
        try {
            String originalFilename = file.getOriginalFilename();
            InputStream inputStream = file.getInputStream();
            return write(200,"查询成功","data",ysDeviceService.videoUpload(request));
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"error");
        }
    }
}

+ 24 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -139,6 +139,27 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getOrgDoctorBySearch")
    @ApiOperation(value = "医生通讯录根据名字获取机构医生")
    public PageEnvelop getOrgDoctorBySearch(
            @ApiParam(name = "orgType", value = "搜索时使用 1,2医疗机构 3养老机构,4托育机构")
            @RequestParam(value = "orgType",defaultValue = " 1,2") String orgType,
            @ApiParam(name="name",required = false,value = "搜索时使用")
            @RequestParam(value = "name",required = false)String name,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size
    ){
        try {
            return doctorService.getOrgDoctorByName(getUID(),orgType,name,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "getTeacherChildren")
    @ApiOperation(value = "教师通讯录-我的儿童")
    public PageEnvelop getTeacherChildren(
@ -146,13 +167,15 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "doctor",required = true) String doctor,
            @ApiParam(name = "searchType", value = "0未入学 1已入学")
            @RequestParam(value = "searchType",defaultValue = "0") int searchType,
            @ApiParam(name="name",required = false,value = "名称")
            @RequestParam(value = "name",required = false)String name,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size
    ){
        try {
            return doctorService.getTeacherChildren(doctor,searchType,page,size);
            return doctorService.getTeacherChildren(doctor,searchType,name,page,size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");

+ 79 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java

@ -89,11 +89,17 @@ public class DoctorLifeCareEndpoint extends EnvelopRestEndpoint {
            @ApiParam(value = "附件", name = "completeImgs")
            @RequestParam(value = "completeImgs", required = false) String completeImgs,
            @ApiParam(value = "完成服务记录", name = "completeRemark")
            @RequestParam(value = "completeRemark", required = true) String completeRemark,
            @RequestParam(value = "completeRemark", required = false) String completeRemark,
            @ApiParam(value = "doctorId", name = "doctorId")
            @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
           lifeCareOrderService.completeOrder(orderId, completeImgs, completeRemark,doctorId);
            Integer result = lifeCareOrderService.completeOrder(orderId, completeImgs, completeRemark,doctorId);
            if(result == 1){
                return Envelop.getError( "签到后才能记录服务" ,-1);
            }
            if(result == 2){
                return Envelop.getError( "只有工单的签到者才能记录服务" ,-1);
            }
            return Envelop.getSuccess("记录成功");
        } catch (Exception e) {
            e.printStackTrace();
@ -101,6 +107,31 @@ public class DoctorLifeCareEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping("updateConclusion")
    @ApiOperation("编辑保存服务工单小结")
    public Envelop updateConclusion(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "附件", name = "conclusionImgs")
            @RequestParam(value = "conclusionImgs", required = false) String conclusionImgs,
            @ApiParam(value = "完成服务记录", name = "conclusionRemark")
            @RequestParam(value = "conclusionRemark", required = true) String conclusionRemark,
            @ApiParam(value = "doctorId", name = "doctorId")
            @RequestParam(value = "doctorId", required = true) String doctorId) {
        try {
            Integer result = lifeCareOrderService.updateConclusion(orderId, conclusionImgs, conclusionRemark,doctorId);
            if(result == 1){
                return Envelop.getError( "签到后才能登记服务小结" ,-1);
            }
            if(result == 2){
                return Envelop.getError( "只有工单的签到者才能登记服务小结" ,-1);
            }
            return Envelop.getSuccess("登记成功");
        } catch (Exception e) {
            return failedException(e);
        }
    }
    @GetMapping(value = "getPatientOrderList")
    @ApiOperation(value = "医生查看居民工单列表")
    public PageEnvelop getPatientOrderList(
@ -115,4 +146,50 @@ public class DoctorLifeCareEndpoint extends EnvelopRestEndpoint {
        }
        return PageEnvelop.getError("查询失败");
    }
    @PostMapping(value = "proxyCreate")
    @ApiOperation(value = "创建生活照料--医生代预约")
    public Envelop proxyCreate(
            @ApiParam(name = "doctor", value = "医生id") @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
        try{
            JSONObject result = lifeCareOrderService.create(jsonData,doctor);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
            return success(result);
        }catch (Exception e){
            e.printStackTrace();
            return failedException(e);
        }
    }
    @PostMapping("signIn")
    @ApiOperation(value = "服务签到")
    @ObserverRequired
    public Envelop signIn(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "医生id", name = "doctorId")
            @RequestParam(value = "doctorId", required = true) String doctorId,
            @ApiParam(value = "签到时间", name = "signTime")
            @RequestParam(value = "signTime", required = false) String signTime,
            @ApiParam(value = "签到方式:1-定位,2-扫码,3-拍照,4-二维码", name = "signWay")
            @RequestParam(value = "signWay", required = false) Integer signWay,
            @ApiParam(value = "签到地址", name = "signLocation")
            @RequestParam(value = "signLocation", required = false) String signLocation,
            @ApiParam(value = "签到照片", name = "signImg")
            @RequestParam(value = "signImg", required = false) String signImg,
            @ApiParam(value = "二维码内容", name = "twoDimensionalCode")
            @RequestParam(value = "twoDimensionalCode", required = false) String twoDimensionalCode) {
        try {
            LifeCareOrderDO result = lifeCareOrderService.signIn(orderId, signTime, signWay, signLocation, signImg,twoDimensionalCode,doctorId);
            if (result==null) {
                return Envelop.getError("签到失败");
            }
            return success(result);
        } catch (Exception e) {
            return failedException(e);
        }
    }
}

+ 11 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/team/TeamEndpoint.java

@ -11,10 +11,12 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
@ -171,9 +173,16 @@ public class TeamEndpoint extends EnvelopRestEndpoint {
     */
    @RequestMapping(value = "/team/{doctorCode}/teams", method = RequestMethod.GET)
    @ApiOperation(value = "获取医生团队列表")
    public ListEnvelop getDoctorTeams(@PathVariable("doctorCode") String doctorCode) {
    public ListEnvelop getDoctorTeams(@PathVariable("doctorCode") String doctorCode,
                                      @ApiParam(name="name",required = false)
                                      @RequestParam(value = "name",required = false)String name) {
        try {
            List<BaseTeamDO> teamList = teamDao.findDoctorTeams(doctorCode);
            List<BaseTeamDO> teamList = new ArrayList<>();
            if (StringUtils.isNotBlank(name)){
                teamList = teamDao.findDoctorTeamsByDoctorName(doctorCode,"%" + name + "%");
            }else {
                teamList = teamDao.findDoctorTeams(doctorCode);
            }
            return ListEnvelop.getSuccess("获取成功",teamList);
        } catch (Exception e) {
            e.printStackTrace();

+ 31 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/common/OrderNoService.java

@ -0,0 +1,31 @@
package com.yihu.jw.care.service.common;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/2
 * @Description:
 */
@Service
public class OrderNoService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 根据类型获取订单号
     * @param type
     * @return
     */
    public String getOrderNo(Integer type){
        String sql = "SELECT cast(seq("+type+") as char)";
        String orderNo = jdbcTemplate.queryForObject(sql,String.class);
        return orderNo;
    }
}

+ 30 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.consult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -10,6 +11,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamDoctorDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
@ -69,13 +71,15 @@ public class ConsultService {
    private HibenateUtils hibenateUtils;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    /**
     * 获取居民该机构的最近一次在线咨询
     * @param patient
     * @param orgCode
     */
    public Map<String,Object> findLastOnlineConsult(String patient,String orgCode,String sessionId){
    public Map<String,Object> findLastOnlineConsult(String patient,String orgCode,String sessionId,Integer type){
        Map<String,Object> map = new HashedMap();
        String sql = "SELECT " +
                " b.consult,b.doctor, " +
@ -86,7 +90,7 @@ public class ConsultService {
                "WHERE " +
                " b.doctor = h.doctor_code " +
                "AND b.patient = '"+patient+"' " +
                "AND b.type = 23 ";
                "AND b.type = "+type+" ";
        if(StringUtils.isEmpty(orgCode)){
            String doctor = sessionId.split("_")[1];
            sql += "AND b.doctor = '"+doctor+"' ";
@ -97,7 +101,7 @@ public class ConsultService {
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(list.size()>0){
            map = list.get(0);
            map.put("sessionId",patient+"_"+String.valueOf(map.get("doctor"))+"_23");
            map.put("sessionId",patient+"_"+String.valueOf(map.get("doctor"))+"_"+type);
            BaseDoctorDO doctorDO = baseDoctorDao.findById(String.valueOf(map.get("doctor")));
            map.put("doctorName",doctorDO.getName());
        }
@ -222,7 +226,7 @@ public class ConsultService {
        Map<String,Integer> unreadNum = new HashedMap();
        for (Map<String,Object> map:result){
            if(type.equals(ImUtil.SESSION_TYPE_ONLINE)){
                String sessionId = patient+"_"+String.valueOf(map.get("doctorCode"))+"_23";
                String sessionId = patient+"_"+String.valueOf(map.get("doctorCode"))+"_"+type;
                //新增未读消息数量
                if(unreadNum.containsKey(sessionId)){
                    map.put("count",0);
@ -347,7 +351,7 @@ public class ConsultService {
     * @param patient
     * @return
     */
    public List<Map<String,Object>> findConsultDoctor(String orgCode,String patient,int page,int pagesize){
    public List<Map<String,Object>> findConsultDoctor(String orgCode,String patient,Integer type,int page,int pagesize){
        String sql = "SELECT  DISTINCT " +
                " a.type AS type, " +
                " d.name AS doctorName, " +
@ -359,7 +363,7 @@ public class ConsultService {
                " FROM wlyy_consult a,wlyy_consult_team b, " +
                " base_doctor d,base_doctor_hospital h  " +
                " WHERE a.id=b.consult and d.id = h.doctor_code  " +
                " AND b.doctor=d.id  AND a.type = 23 and h.org_code = '"+orgCode+"' " +
                " AND b.doctor=d.id  AND a.type = "+type+" and h.org_code = '"+orgCode+"' " +
                " and a.patient = '"+patient +"' "+
                " ORDER BY a.czrq desc";
        List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql,page,pagesize);
@ -456,7 +460,7 @@ public class ConsultService {
            }
            if(type.equals(ImUtil.SESSION_TYPE_ONLINE)){
                String sessionId = String.valueOf(map.get("patient"))+"_"+doctor+"_23";
                String sessionId = String.valueOf(map.get("patient"))+"_"+doctor+"_"+type;
                //新增未读消息数量
                Integer count = imUtil.UserSessionsUnreadMessageCount(sessionId,doctor);
                map.put("sessionId",sessionId);
@ -495,7 +499,7 @@ public class ConsultService {
     */
    public JSONObject addTeamConsult(ConsultTeamDo ct, String patient, String doctor, String source) throws Exception {
        JSONObject re = new JSONObject();
        boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor));
        boolean boo = StringUtils.isEmpty(getUnfinishedConsult(patient, doctor,ct.getType()));
        logger.info("boo"+boo);
        WlyyHospitalSysDictDO sysDictDO = hospitalSysDictDao.findById("consultClose");
        boolean flag = false;
@ -505,7 +509,7 @@ public class ConsultService {
            }
        }
        if (!flag){
            if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor))) {
            if (!StringUtils.isEmpty(getUnfinishedConsult(patient, doctor,ct.getType()))) {
                throw new RuntimeException("居民还有未结束的在线咨询!");
            }
        }
@ -584,6 +588,21 @@ public class ConsultService {
            consultTeamDoctorDao.save(cd);
        }
        if (ct.getType()==23){
            if(doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(patient,doctor,1)==0){
                DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
                tmpDO.setDoctorCode(doctor);
                tmpDO.setPatient(patient);
                tmpDO.setType(1);
                tmpDO.setDel(1);
                tmpDO.setRelationCode(ct.getConsult());
                doctorPatientTmpDao.save(tmpDO);
            }
        }
        // 保存医生咨询信息
        // 添加咨询转发记录
        // 添加医生咨询日志
@ -607,7 +626,7 @@ public class ConsultService {
     * @param doctor  医生
     * @return
     */
    public String  getUnfinishedConsult(String patient, String doctor) {
    public String  getUnfinishedConsult(String patient, String doctor,Integer type) {
        String totalSql = "SELECT a.consult as \"consultCode\" " +
                "FROM wlyy_consult_team a,wlyy_consult_team_doctor b " +
@ -615,7 +634,7 @@ public class ConsultService {
                "AND a.patient= '" +patient+"' "+
//                "AND b.to_doctor='" +doctor+"' "+
                "AND a.del='1' " +
                "AND type = 23 " +
                "AND type = "+type+" " +
                "AND a.status=0";
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);

+ 30 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/CourseService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.course.*;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -12,6 +13,7 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.course.*;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.org.dao.BaseOrgDao;
@ -68,6 +70,8 @@ public class CourseService {
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    public String getOrderNo(String type){
        return type + System.currentTimeMillis()+(int)(Math.random() * 900)+100 +"";
@ -88,6 +92,10 @@ public class CourseService {
            }
            recordDO.setStatus("7");
            recruitStudentsRecordDao.save(recordDO);
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(recordDO.getId());
            tmpDO.setDel(0);
            doctorPatientTmpDao.save(tmpDO);
        }else  if("2".equals(type)){
            //课程
            CourseSalesOrderRecordDO recordDO = courseSalesOrderRecordDao.findOne(id);
@ -96,6 +104,10 @@ public class CourseService {
            }
            recordDO.setStatus("7");
            courseSalesOrderRecordDao.save(recordDO);
            DoctorPatientTmpDO tmpDO = doctorPatientTmpDao.findByRelationCode(recordDO.getId());
            tmpDO.setDel(0);
            doctorPatientTmpDao.save(tmpDO);
        }
        return null;
    }
@ -800,6 +812,15 @@ public class CourseService {
        //这个机构收到新的在线报名申请时,给机构联系人发送一条短信
        messageUtil.sendOnlineRegistSms(recruitStudentsDO.getOrgCode());
        DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
        tmpDO.setPatient(recordDO.getPatient());
        tmpDO.setType(3);
        tmpDO.setStatus(0);//未入取
        tmpDO.setDel(1);
        tmpDO.setDoctorCode(recordDO.getOrgCode());
        tmpDO.setRelationCode(recordDO.getId());
        doctorPatientTmpDao.save(tmpDO);
        return result;
    }
@ -834,6 +855,15 @@ public class CourseService {
        recordDO.setPayType(payType);
        recordDO.setOrderNo(getOrderNo("2"));
        courseSalesOrderRecordDao.save(recordDO);
        DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
        tmpDO.setPatient(recordDO.getPatient());
        tmpDO.setType(4);
        tmpDO.setDel(1);
        tmpDO.setDoctorCode(courseDO.getDoctor());
        tmpDO.setRelationCode(recordDO.getId());
        doctorPatientTmpDao.save(tmpDO);
        return recordDO;
    }

+ 189 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/course/RecruitStudentService.java

@ -0,0 +1,189 @@
package com.yihu.jw.care.service.course;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.course.RecruitStudentsDao;
import com.yihu.jw.care.dao.course.RecruitStudentsRecordDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.care.course.RecruitStudentsDO;
import com.yihu.jw.entity.care.course.RecruitStudentsRecordDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/6/8
 * @Description:
 */
@Service
public class RecruitStudentService {
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private RecruitStudentsRecordDao recruitStudentsRecordDao;
    @Autowired
    private RecruitStudentsDao recruitStudentsDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    /**
     * 在线报名-已报名数量
     * @param doctorId
     * @return
     */
    public Integer onlineRegisterCount(String doctorId){
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorId);
        List<RecruitStudentsRecordDO> list = recruitStudentsRecordDao.findByOrgCodeAndStatus(baseDoctorHospitalDO.get(0).getOrgCode(),"1");
        return list.size();
    }
    /**
     * 统计在线报名各状态下的数量
     *
     * @return
     */
    public JSONObject onlineRegisterStatusCount(String doctorId) {
        JSONObject result = new JSONObject();
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorId);
        int total = 0;
        Map<String,Object> res = new HashedMap();
        //状态 已报名1  已录取2 未录取4 已退学8
        res.put("1",0);
        res.put("2",0);
        res.put("4",0);
        res.put("8",0);
        String countSql = "SELECT " +
                "  count(o.id) as count, " +
                "  o.status as status " +
                " FROM " +
                "  base_recruit_students_record o " +
                " WHERE " +
                "  o.org_code = '"+ baseDoctorHospitalDO.get(0).getOrgCode() + "' and o.del = 1 "+
                " GROUP BY o.`status`";
        List<Map<String,Object>> countMapList = jdbcTemplate.queryForList(countSql);
        for(Map<String,Object> map:countMapList){
            int c = Integer.valueOf(map.get("count").toString());
            total +=c;
            res.put(String.valueOf(map.get("status")),c);
        }
        res.put("total",total);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, res);
        return result;
    }
    /**
     * 在线报名列表
     *
     * @return
     */
    public JSONObject queryInfoList(String doctorId,Integer status, int page, int size) {
        JSONObject result = new JSONObject();
        List<BaseDoctorHospitalDO> baseDoctorHospitalDO = baseDoctorHospitalDao.findByDoctorCode(doctorId);
        String orgCode = baseDoctorHospitalDO.get(0).getOrgCode();
        status = null == status ? -100 : status;
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        String sql = "SELECT o.id,o.patient,o.patient_name patientName,o.status,o.create_time createTime,p.photo  " +
                " FROM  base_recruit_students_record o" +
                " left join base_patient p on o.patient = p.id " +
                " WHERE o.org_code = '{org_code}' and o.del =1 "+
                " AND (o.`status` = {status} or -100 = {status})" +
                " ORDER BY o.create_time desc" +
                " LIMIT {start},{end} ";
        String finalSql = sql.replace("{org_code}", orgCode)
                .replace("{status}", String.valueOf(status))
                .replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        String countSql = "SELECT count(DISTINCT o.id) FROM base_recruit_students_record o " +
                " WHERE o.org_code = '{org_code}' and o.del =1 " +
                " AND (o.`status` = {status} or -100 = {status})";
        String finqlCountSql = countSql.replace("{org_code}", orgCode)
                .replace("{status}", String.valueOf(status));
        List<Map<String,Object>> sqlResultlist= jdbcTemplate.queryForList(finalSql);
        Integer count = jdbcTemplate.queryForObject(finqlCountSql, Integer.class);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 录取单个
     * @param id
     * @return
     */
    public synchronized String admission(String id){
        RecruitStudentsRecordDO recruitStudentsRecordDO = recruitStudentsRecordDao.findOne(id);
        if(!"1".equals(recruitStudentsRecordDO.getStatus())){
            return "只有已报名状态的人员才能录取";
        }
        if(isAdmissionFull(recruitStudentsRecordDO.getRecruitStudentsId())){
            return "超过录取名额,无法录取";
        }
        recruitStudentsRecordDO.setStatus("2");
        recruitStudentsRecordDao.save(recruitStudentsRecordDO);
        return null;
    }
    /**
     * 是否录取满 true录取满了
     * @param id
     * @return
     */
    public synchronized boolean isAdmissionFull(String id){
        List<RecruitStudentsRecordDO> list = findListById(id);
        RecruitStudentsDO recruitStudentsDO = recruitStudentsDao.findOne(id);
        if(recruitStudentsDO.getNum()<=list.size()){
            return true;
        }
        return false;
    }
    public List<RecruitStudentsRecordDO> findListById(String id){
        String sql = "select * from base_recruit_students_record where recruit_students_id = '"+id+"' and status in ('2','3','6') and del =1 ";
        List<RecruitStudentsRecordDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(RecruitStudentsRecordDO.class));
        return list;
    }
    /**
     * 拒绝单个
     * @param id
     */
    public synchronized String refuse(String id){
        RecruitStudentsRecordDO recruitStudentsRecordDO = recruitStudentsRecordDao.findOne(id);
        if(!"1".equals(recruitStudentsRecordDO.getStatus())){
            return "只有已报名状态的人员才能拒绝";
        }
        recruitStudentsRecordDO.setStatus("4");
        recruitStudentsRecordDao.save(recruitStudentsRecordDO);
        return null;
    }
}

+ 408 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java

@ -0,0 +1,408 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import java.security.Security;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
 * Created by Bing on 2021/6/1.
 */
@Service
public class YsDeviceService {
    private static Logger logger = LoggerFactory.getLogger(YsDeviceService.class);
    private Map<String,String> msgType = new HashMap<>();
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 获取萤石设备assesToken
     */
    public String getAccessToken() throws Exception {
        if(redisTemplate.hasKey(YsConfig.redisKey)){
            return redisTemplate.opsForValue().get(YsConfig.redisKey);
        }
        JSONObject param = new JSONObject();
        param.put("appKey",YsConfig.AppKey);
        param.put("appSecret",YsConfig.Secret);
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.saasAssesToken,param, HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        String assToken = null;
        if (responseBody.getInteger("code")==200){
            assToken = responseBody.getJSONObject("data").getString("accessToken");
            Long expireTime = responseBody.getJSONObject("data").getLong("expiresIn");//token有效期
            redisTemplate.opsForValue().set(YsConfig.redisKey,assToken,expireTime, TimeUnit.MILLISECONDS);
        }else {
            throw new Exception("获取token失败");
        }
        return assToken;
    }
    /**
     * 获取IOT开放平台assesToken
     * @return
     * @throws Exception
     */
    public String getIotAccessToken() throws Exception {
        if(redisTemplate.hasKey(YsConfig.iotRedisKey)){
            return redisTemplate.opsForValue().get(YsConfig.iotRedisKey);
        }
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.iotAssesToken,param, HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        String assToken = null;
        if (responseBody.getInteger("code")==200){
            assToken = responseBody.getJSONObject("data").getString("ezOpenAccessToken");
            Long expireTime = responseBody.getJSONObject("data").getLong("expireTime");//token有效期
            redisTemplate.opsForValue().set(YsConfig.iotRedisKey,assToken,expireTime, TimeUnit.MILLISECONDS);
            //设备解密密钥
            String secretKey = responseBody.getJSONObject("data").getString("secretKey");
            redisTemplate.opsForValue().set(YsConfig.secretKey,secretKey,expireTime, TimeUnit.MILLISECONDS);
        }else {
            throw new Exception("获取token失败");
        }
        return assToken;
    }
    /**
     * 获取设备解密密钥
     * @return
     * @throws Exception
     */
    public String getSecretKey() throws Exception {
        if(redisTemplate.hasKey(YsConfig.secretKey)){
            return redisTemplate.opsForValue().get(YsConfig.secretKey);
        }
        else {
            getIotAccessToken();
            return redisTemplate.opsForValue().get(YsConfig.secretKey);
        }
    }
    /**
     * 萤石摄像机获取通道详情
     * @param deviceSerial
     * @param channelNo
     * @param isTrust
     * @param request
     * @return
     * @throws Exception
     */
    public JSONObject surveillanceWay(String deviceSerial,Integer channelNo,Integer isTrust,HttpServletRequest request) throws Exception {
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        param.put("deviceSerial",deviceSerial);
        param.put("channelNo",channelNo);
        param.put("isTrust",0);
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.surveillanceWay,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/os58z7#p9Tfd
    }
    /**
     * 视频加解密开关
     * @param deviceSerial
     * @param isEncrypt
     * @param validateCode
     * @param request
     * @return
     * @throws Exception
     */
    public JSONObject deviceEncrypt(String deviceSerial,Integer isEncrypt,String validateCode,HttpServletRequest request) throws Exception {
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        param.put("deviceSerial",deviceSerial);
        param.put("isEncrypt",isEncrypt);
        if (0==isEncrypt){//PU4eJqa7j9GMst8P
            validateCode = messageDecrypt(validateCode,getSecretKey());
            param.put("validateCode",validateCode);
        }
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.deviceEncrypt,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/os58z7#zfqzn
    }
    /**
     * 设备抓拍
     * @param deviceSerial
     * @param channelNo
     * @param request
     * @return
     * @throws Exception
     */
    public JSONObject deviceCapture(String deviceSerial,Integer channelNo,HttpServletRequest request) throws Exception {
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        param.put("deviceSerial",deviceSerial);
        param.put("channelNo",channelNo+"");
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.deviceCapture,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/os58z7#K2AHX
    }
    /**
     * 获取视频地址
     */
    public JSONObject getDeviceLiveAddress(String deviceSerial,Integer channelNo,HttpServletRequest request) throws Exception {
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("accessToken",getIotAccessToken());
        param.add("deviceSerial",deviceSerial);
        param.add("channelNo",channelNo+"");
        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.getDeviceLiveAddress,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://open.ys7.com/doc/zh/book/index/address.html#address-api2
        /**
         * {
         *     "msg":"操作成功!",
         *     "code":"200",
         *     "data":{
         *         "deviceSerial":"F56826706",
         *         "channelNo":1,
         *         "deviceName":"C6Wi(F56826706)",
         *         "liveAddress":"http://hls01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf.m3u8",  HLS流畅直播地址
         *         "hdAddress":"http://hls01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf.hd.m3u8",  HLS高清直播地址
         *         "rtmp":"rtmp://rtmp01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf",               RTMP流畅直播地址
         *         "rtmpHd":"rtmp://rtmp01open.ys7.com/openlive/99c146f11ab042849fd4b49f7b0d86cf.hd",           RTMP高清直播地址
         *         "flvAddress":"https://flvopen.ys7.com:9188/openlive/99c146f11ab042849fd4b49f7b0d86cf.flv",    FLV流畅直播地址
         *         "hdFlvAddress":"https://flvopen.ys7.com:9188/openlive/99c146f11ab042849fd4b49f7b0d86cf.hd.flv", FLV高清直播地址
         *         "status":1,
         *         "exception":0,
         *         "beginTime":1622615659000,
         *         "endTime":1622615659000
         *     }
         * }
         */
    }
    /**
     * 云台控制开始
     * @param deviceSerial
     * @param channelNo
     * @param direction
     * @param speed
     * @param request
     * @return
     * @throws Exception
     */
    public JSONObject ptzStart(String deviceSerial,Integer channelNo,Integer direction,Integer speed,HttpServletRequest request) throws Exception {
        MultiValueMap<String,String> param = new LinkedMultiValueMap<>();
        param.add("accessToken",getIotAccessToken());
        param.add("deviceSerial",deviceSerial);
        param.add("channelNo",channelNo+"");
        param.add("direction",direction+"");
        param.add("speed",speed+"");
        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.ptzStart,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://open.ys7.com/doc/zh/book/index/device_ptz.html#device_ptz-api1
    }
    /**
     * 云台控制结束
     * @param deviceSerial
     * @param channelNo
     * @param direction
     * @param request
     * @return
     * @throws Exception
     */
    public JSONObject ptzStop(String deviceSerial,Integer channelNo,Integer direction,HttpServletRequest request) throws Exception {
        MultiValueMap<String,String> param = new LinkedMultiValueMap<>();
        param.add("accessToken",getIotAccessToken());
        param.add("deviceSerial",deviceSerial);
        param.add("channelNo",channelNo+"");
        param.add("direction",direction+"");
        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.ptzStop,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://open.ys7.com/doc/zh/book/index/device_ptz.html#device_ptz-api2
    }
    /**
     * 获取上传录像授权信息
     * @param request
     * @return
     * @throws Exception
     */
    public JSONObject getVideoKey(HttpServletRequest request) throws Exception {
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.videoKey,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/nu22ks#Kj5dG
    }
    /**
     * 录像列表(无法区分用户)
     * @return
     * @throws Exception
     */
    public JSONObject videoList(String name,String type,Integer page,Integer count) throws Exception {
        page = page>0?page-1:0;
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        if (StringUtils.isNotBlank(name)){
            param.put("name",name);
        }
        if (StringUtils.isNotBlank(type)){
            param.put("type",type);
        }
        param.put("page",page);
        param.put("count",count);
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.videoList,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/nu22ks#kF97n
    }
    /**
     * 批量获取录像详情
     * @param vod_ids
     * @return
     * @throws Exception
     */
    public JSONObject videoDetailList(String[] vod_ids) throws Exception {
        JSONArray arr = JSONArray.parseArray(JSON.toJSONString(vod_ids));
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        param.put("vod_ids",arr);
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.videoDetailList,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/nu22ks#60Fjf
    }
    /**
     * 获取录像详情
     * @return
     * @throws Exception
     */
    public JSONObject videoDetail(String vod_id) throws Exception {
        JSONObject param = new JSONObject();
        param.put("accessToken",getAccessToken());
        param.put("vod_id",vod_id);
        HttpEntity<JSONObject> response = httpClientUtil.assesTokenPostHttp(YsConfig.videoDetail,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        return responseBody;
        //https://www.yuque.com/u1400669/kb/nu22ks#xQCVK
    }
    public JSONObject deviceFailConfig(String deviceSerial,Integer type,HttpServletRequest request) throws Exception {
        JSONObject responseBody = new JSONObject();
        String url =MessageFormat.format(YsConfig.deviceFailConfig, deviceSerial,"1");
        if (null==type){//查询
            url += "?accessToken="+getIotAccessToken()+"&key=Alarm_DetectHumanCar";
            MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
            HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(url,param,HttpMethod.GET);
            responseBody = response.getBody();
        }
        else {
            MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
            param.add("accessToken",getIotAccessToken());
            param.add("key","Alarm_DetectHumanCar");
            param.add("value","{\"type\":"+type+"}");
            HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(url,param,HttpMethod.PUT);
            responseBody = response.getBody();
        }
        return responseBody;
        //https://www.yuque.com/u1400669/kb/os58z7#YYazO
    }
    public JSONObject videoUpload(HttpServletRequest request){
        return null;
        //https://www.yuque.com/u1400669/kb/nu22ks#nQXzO
    }
    /**
     * 消息解密
     * @param sSrc
     * @param sKey
     * @return
     * @throws Exception
     */
    public String messageDecrypt(String sSrc, String sKey) throws Exception {
        try {
            byte[] raw = sKey.getBytes("utf-8");
            Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
            SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
            Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
            cipher.init(Cipher.DECRYPT_MODE, skeySpec);
            byte[] encrypted1 = Base64.decode(sSrc);//先用base64解密
            byte[] original = cipher.doFinal(encrypted1);
            return new String(original, "utf-8");
        } catch (Exception ex) {
            logger.error("AES解密异常:Str"+sSrc+"\nkey:"+sKey);
            throw new Exception("解密失败");
        }
    }
//    public static void main(String[] args) throws Exception {
//        String mess = "9uFqSq7m0HCj0vboHqVI5XLmnlS+ZB4S2k2gH6CZyUMXIod2OP+UK7ibjP27v9OX";
//        String skey="PU4eJqa7j9GMst8P";
//        String response = messageDecrypt(mess,skey);
//        System.out.println(response);
//        JSONObject tmp = JSONObject.parseObject(response);
//        System.out.println("1");
//    }
    {
        msgType.put("10001","离岗检测消息");
        msgType.put("10002","身份识别消息");
        msgType.put("10003","回头客消息");
        msgType.put("10004","门禁事件消息");
        msgType.put("10005","设备报警消息");
        msgType.put("10006","设备上线离线消息");
        msgType.put("10007","门禁权限同步消息");
        msgType.put("10008","消防设备消息");
        msgType.put("10009","企业数据变更消息");
        msgType.put("10010","智能联动消息");
        msgType.put("10011","海康设备透传消息");
        msgType.put("10012","通道关联状态上报消息");
        msgType.put("10013","智能控制设备状态消息");
        msgType.put("10014","托管设备增删消息");
        msgType.put("10016","门铃消息");
    }
}

+ 132 - 22
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -161,6 +161,19 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                isSearchDoctorOrgType=true;
            }
        }
        if (1==doctorLevel) {//专科医生
            doctorOrgType=1;
            if ("1,2".equals(orgType)){
                isSearchDoctorOrgType=true;
            }
        }
        if (2==doctorLevel) {//社区医生
            doctorOrgType=2;
            if ("1,2".equals(orgType)){
                isSearchDoctorOrgType=true;
            }
        }
        //医生机构
        String sql ="select org.code from base_doctor_hospital dh inner join base_org org on dh.org_code = org.code " +
                "and dh.doctor_code='"+doctorId+"' and org.type='"+doctorOrgType+"' ORDER BY dh.create_time desc limit 1";
        List<String> doctorOrg = jdbcTemplate.queryForList(sql,String.class);
@ -177,7 +190,7 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        else if (orgType.equals("1,2")){//医疗机构
           sql+=" and org.type in(1,2) ";
        }
        else {
        else {//养老
            if (isSearchDoctorOrgType&&doctorOrg.size()>0){
                sql += " and org.code = '"+doctorOrg.get(0)+"' and org.type='"+orgType+"'  ";
            }else {
@ -198,6 +211,73 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return tmpList;
    }
    public PageEnvelop getOrgDoctorByName(String doctor,String orgType,String name,Integer page ,Integer size){
        page = page>0?page-1:0;
        JSONObject result = new JSONObject();
        if (StringUtils.isNotBlank(doctor)){
            BaseDoctorDO doctorDO = baseDoctorDao.findById(doctor);
            //教师角色登录时为本机构科室列表,点击展开人员列表
            //助老员角色登录时为本机构科室列表,点击展开人员列表
            Integer doctorLevel = doctorDO.getLevel();
            Integer doctorOrgType =0 ;
            boolean isSearchDoctorOrgType=false;
            if (3==doctorLevel){//教师
                doctorOrgType=4;
                if ("4".equals(orgType)){
                    isSearchDoctorOrgType=true;
                }
            }
            if (2==doctorLevel) {//助老员
                doctorOrgType=3;
                if ("3".equals(orgType)){
                    isSearchDoctorOrgType=true;
                }
            }
            if (1==doctorLevel) {//专科医生
                doctorOrgType=1;
                if ("1,2".equals(orgType)){
                    isSearchDoctorOrgType=true;
                }
            }
            if (2==doctorLevel) {//社区医生
                doctorOrgType=2;
                if ("1,2".equals(orgType)){
                    isSearchDoctorOrgType=true;
                }
            }
            //医生机构
            String sql ="select org.code from base_doctor_hospital dh inner join base_org org on dh.org_code = org.code " +
                    "and dh.doctor_code='"+doctor+"' and org.type in ("+doctorOrgType+") ORDER BY dh.create_time desc limit 1";
            List<String> doctorOrg = jdbcTemplate.queryForList(sql,String.class);
            sql = "select dh.org_code,dh.org_name,doc.id,doc.name,doc.mobile,doc.photo,dict.code deptCode,dict.name deptName,dh.doctor_duty_code job,dh.doctor_duty_name jobName\n" +
                    " from base_doctor_hospital dh INNER JOIN base_org org on org.`code` = dh.org_code and org.del=1 INNER JOIN base_doctor doc on dh.doctor_code = doc.id  " +
                    " and dh.del=1 LEFT JOIN " +
                    " dict_hospital_dept dict on dh.dept_code = dict.`code` and dh.org_code = dict.org_code where org.type in ("+orgType+") ";
           String countSql = "select count(doc.id)\n" +
                    " from base_doctor_hospital dh INNER JOIN base_org org on org.`code` = dh.org_code and org.del=1 INNER JOIN base_doctor doc on dh.doctor_code = doc.id  " +
                    " and dh.del=1 LEFT JOIN " +
                    " dict_hospital_dept dict on dh.dept_code = dict.`code` and dh.org_code = dict.org_code where org.type in ("+orgType+") ";
            String sqlCondition = "";
            if (StringUtils.isNotBlank(name)){
                sqlCondition += " and doc.name like '%"+name+"%' ";
            }
            if (isSearchDoctorOrgType&&doctorOrg.size()>0){//查询通讯录机构与医生身份相同,只查询医生机构下的医生
                sqlCondition += " and dh.org_code= '"+doctorOrg.get(0)+"' ";
            }
            Long count = jdbcTemplate.queryForObject(countSql+sqlCondition,Long.class);
            sqlCondition +=" limit "+page*size+","+size;
            List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql+sqlCondition);
            result.put("doctorList",tmpList);
            return PageEnvelop.getSuccessListWithPage("查询成功",tmpList,page,size,0L);
        }
       return PageEnvelop.getSuccessListWithPage("查询成功",new ArrayList(),page,size,0L);
    }
    public JSONObject getOrgDoctor(String orgCode,String deptCode,int page,int size){
        JSONObject result = new JSONObject();
        String count = "select count(Distinct doc.id)\n" +
@ -230,31 +310,53 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return result;
    }
    public PageEnvelop getTeacherChildren(String doctor,int searchType,int page,int size){
    public PageEnvelop getTeacherChildren(String doctor,int searchType,String name,int page,int size){
        page = page>0?page-1:0;
        List<Map<String,Object>> list = new ArrayList<>();
        //未入学
        String sql0 = "select Distinct sor.patient from base_course_sales_order_record sor INNER JOIN base_course bc on sor.course_id = bc.id " +
                " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =2 and not EXISTS (select DISTINCT rsr.patient " +
                " from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` and org.del=1 " +
                " INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=sor.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2  )";
        String sql0 = "select * from  " +
                " (select Distinct patient,'1' as type from base_doctor_patient_tmp where type=1 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient,'2' as type from base_doctor_patient_tmp where type=2 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient,'4' as type from base_doctor_patient_tmp where type=4 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select tmp.patient,'3' as type from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.doctor_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0)B where  " +
                " not EXISTS (select DISTINCT rsr.patient  from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                " and org.del=1  INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=B.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2 )";
        //已入学
        String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
        String sql1=" select DISTINCT rsr.patient,null as type from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
                "and rsr.del<>0  and rsr.`status` = 2   ";
        String sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2 GROUP BY p.id ";
        String sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat(tmp.type) type,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp " +
                " Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2 GROUP BY p.id limit "+page*size+","+size;
        String sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
        Long count = 0L;
        if (0==searchType){
        if (StringUtils.isNotBlank(name)){
             sql = "select p.id,p.name,p.photo,p.sex,p.idcard,p.openid,p.mobile,group_concat(tmp.type) type,group_concat( pd.category_code) deviceType from ( {sqlReplace} )tmp " +
                     " Inner JOIN base_patient p on tmp.patient  = p.id and p.name like '%"+name+"%' " +
                     " LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2 " +
                     " GROUP BY p.id limit "+page*size+","+size;
             sqlcpunt = "select count(Distinct p.id) from ( {sqlReplace} )tmp Inner JOIN base_patient p on tmp.patient  = p.id " +
                    " and p.name like '%"+name+"%' LEFT JOIN wlyy_patient_device pd on pd.`user`=p.id and pd.category_code BETWEEN 1 and 2  ";
            list = jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql0));
            count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql0),Long.class);
        }
        if (1==searchType){//
            list = jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql1));
            count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql1),Long.class);
            list .addAll(jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql1)));
            count += jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql1),Long.class);
        }else {
            if (0==searchType){
                list = jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql0));
                count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql0),Long.class);
            }
            if (1==searchType){//
                list = jdbcTemplate.queryForList(sql.replace("{sqlReplace}",sql1));
                count = jdbcTemplate.queryForObject(sqlcpunt.replace("{sqlReplace}",sql1),Long.class);
            }
        }
        for (Map<String,Object>map:list){
            if (map.get("idcard")!=null){
@ -280,12 +382,19 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    public Map<String,Long> getTeacherChildrenCount(String doctor){
        Map<String,Long> result = new HashMap<>();
        //未入学
        String sql0 = "select Distinct sor.patient from base_course_sales_order_record sor INNER JOIN base_course bc on sor.course_id = bc.id " +
                " and bc.del=1 where bc.doctor ='"+doctor+"'  and sor.`status` =2 and not EXISTS (select DISTINCT rsr.patient " +
                " from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` and org.del=1 " +
                " INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=sor.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2  )";
        //未入学 (发起咨询的幼儿列表,发起上门辅导的幼儿列表,已报名但是未录取的幼儿)
        String sql0 = "select * from  " +
                " (select Distinct patient from base_doctor_patient_tmp where type=1 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient from base_doctor_patient_tmp where type=2 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select Distinct patient from base_doctor_patient_tmp where type=4 and doctor_code='"+doctor+"' and del=1 " +
                " UNION " +
                " select tmp.patient from base_doctor_patient_tmp tmp INNER JOIN base_doctor_hospital dh on dh.org_code = tmp.doctor_code " +
                " and dh.del =1 where tmp.type=3 and dh.doctor_code='"+doctor+"' and tmp.del=1 and tmp.`status`=0)B where  " +
                " not EXISTS (select DISTINCT rsr.patient  from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                " and org.del=1  INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where rsr.patient=B.patient and " +
                " dh.doctor_code='"+doctor+"'   and rsr.del<>0  and rsr.`status` = 2 )";
        //已入学
        String sql1=" select DISTINCT rsr.patient from base_recruit_students_record rsr INNER JOIN  base_org org on rsr.org_code = org.`code` " +
                "and org.del=1 INNER JOIN base_doctor_hospital dh on rsr.org_code = dh.org_code and dh.del =1  where dh.doctor_code='"+doctor+"' " +
@ -313,7 +422,8 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            object.put("unreadMessageCount",unreadMessageCount);//未读消息数量
            object.put("doorCoachOrder",coachOrderDOList.size());//上门辅导待完成数量
            Integer unConsultMsgCount = imService.SessionsUnreadMessageCount(doctor,"23");
            object.put("unConsultMsgCount",unConsultMsgCount);//咨询未读消息数量
            Integer unConsultMsgCount2 = imService.SessionsUnreadMessageCount(doctor,"24");
            object.put("unConsultMsgCount",unConsultMsgCount+unConsultMsgCount2);//咨询未读消息数量
            return object;
//        }

+ 14 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java

@ -4,19 +4,20 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.doorCoach.*;
import com.yihu.jw.care.dao.course.DoctorPatientTmpDao;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.BaseDoctorRoleDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorRoleDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.care.doorCoach.*;
import com.yihu.jw.entity.care.course.DoctorPatientTmpDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
@ -119,6 +120,8 @@ public class DoctorDoorCoachOrderService {
    private BasePatientWechatDao basePatientWechatDao;
    @Autowired
    private BaseDoctorRoleDao baseDoctorRoleDao;
    @Autowired
    private DoctorPatientTmpDao doctorPatientTmpDao;
    /**
     * 根据id获取服务工单信息
@ -454,6 +457,16 @@ public class DoctorDoorCoachOrderService {
        }
        //  待接单消息设为已操作, 434 医生接单-- 王五接受了服务工单12345678
        messageUtil.updateDoorCoachMessage(doorServiceOrder,new String[]{"703","707"},"734",null,null);
        if(doctorPatientTmpDao.findByPatientAndDoctorCodeAndType(doorServiceOrder.getPatient(),doorServiceOrder.getDoctor(),2)==0){
            DoctorPatientTmpDO tmpDO = new DoctorPatientTmpDO();
            tmpDO.setDoctorCode(doorServiceOrder.getDoctor());
            tmpDO.setPatient(doorServiceOrder.getPatient());
            tmpDO.setType(2);
            tmpDO.setDel(1);
            tmpDO.setRelationCode(doorServiceOrder.getId());
            doctorPatientTmpDao.save(tmpDO);
        }
    }
    /**

+ 220 - 39
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -1,10 +1,12 @@
package com.yihu.jw.care.service.lifeCare;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.lifeCare.LifeCareCancelLogDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareFeeDetailDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareItemDictDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareOrderDao;
import com.yihu.jw.care.service.common.OrderNoService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -21,9 +23,11 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -70,6 +74,29 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    private BaseOrgDao baseOrgDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private OrderNoService orderNoService;
    /**
     * 记录完成情况
     * @param orderId
     * @param conclusionImgs
     * @param conclusionRemark
     */
    public Integer updateConclusion(String orderId,String conclusionImgs,String conclusionRemark,String doctorId){
        LifeCareOrderDO lifeCareOrderDO = lifeCareOrderDao.findOne(orderId);
        if(!lifeCareOrderDO.getStatus().equals(LifeCareOrderDO.Status.signIn.getType())){
            return 1;
        }
        if(!doctorId.equals(lifeCareOrderDO.getSignDoctor())){
            return 2;
        }
        lifeCareOrderDO.setConclusionImgs(conclusionImgs);
        lifeCareOrderDO.setConclusionRemark(conclusionRemark);
        lifeCareOrderDO.setConclusionTime(new Date());
        lifeCareOrderDao.save(lifeCareOrderDO);
        return 0;
    }
    /**
     * 记录完成情况
@ -77,18 +104,23 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
     * @param complereImgs
     * @param completeRemark
     */
    public void completeOrder(String orderId,String complereImgs,String completeRemark,String doctorId){
    public Integer completeOrder(String orderId,String complereImgs,String completeRemark,String doctorId){
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        LifeCareOrderDO lifeCareOrderDO = lifeCareOrderDao.findOne(orderId);
        if(lifeCareOrderDO.getStatus().equals(LifeCareOrderDO.Status.waitForAccept.getType())){
            lifeCareOrderDO.setDoctor(doctorId);
            lifeCareOrderDO.setDoctorName(doctorDO.getName());
            lifeCareOrderDO.setStatus(2);
            lifeCareOrderDO.setCompleteImgs(complereImgs);
            lifeCareOrderDO.setCompleteRemark(completeRemark);
            lifeCareOrderDO.setCompleteTime(new Date());
            lifeCareOrderDao.save(lifeCareOrderDO);
        if(!lifeCareOrderDO.getStatus().equals(LifeCareOrderDO.Status.signIn.getType())){
            return 1;
        }
        if(!doctorId.equals(lifeCareOrderDO.getSignDoctor())){
            return 2;
        }
        lifeCareOrderDO.setDoctor(doctorId);
        lifeCareOrderDO.setDoctorName(doctorDO.getName());
        lifeCareOrderDO.setStatus(2);
        lifeCareOrderDO.setCompleteImgs(complereImgs);
        lifeCareOrderDO.setCompleteRemark(completeRemark);
        lifeCareOrderDO.setCompleteTime(new Date());
        lifeCareOrderDao.save(lifeCareOrderDO);
        return 0;
    }
@ -140,9 +172,10 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        sql +=  "  WHERE  a.hospital = ? group BY a.status";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, hospital);
        Map<String, Integer> map = new HashMap<>();
        //状态 待服务 1、已完成 2 、已取消 -1
        //状态 待服务 1、已完成 2 、已取消 -1 已签到 3
        map.put("1",0);
        map.put("2",0);
        map.put("3",0);
        map.put("-1",0);
        int total = 0;
        for (Map<String, Object> one:list){
@ -200,7 +233,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
                " ( base_life_care_order o " +
                " LEFT JOIN base_patient p ON o.patient = p.id ) "+
                " WHERE " +
                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+
                "  o.hospital = '{hospital}' " +buffer+
                " AND ( o.`status` = {status} OR -100 = {status} ) " +
                " ORDER BY o.create_time desc " +
                " LIMIT {start},{end};";
@ -319,6 +352,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        //状态 待服务 1、已完成 2 、已取消 -1
        res.put("1",0);
        res.put("2",0);
        res.put("3",0);
        res.put("-1",0);
        String countSql = "SELECT " +
                "  count(o.id) as count, " +
@ -401,6 +435,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        return result;
    }
    /**
     * 申请生活照料
     *
@ -413,40 +448,33 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
        LifeCareOrderDO orderDO = null;
        try {
            jsonObjectParam = JSONObject.parseObject(jsonData);
            if (jsonObjectParam.getJSONObject("order").getInteger("type")==1||jsonObjectParam.getJSONObject("order").getInteger("type")==2){
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
            Integer type = orderDO.getType();
            if (type==1||type==2){
                //本人或家人代发起
                BasePatientDO patientDO = patientDao.findById(proxyPatient);
                jsonObjectParam.put("proxyPatient",proxyPatient);
                jsonObjectParam.put("proxyPatientName",patientDO.getName());
                jsonObjectParam.put("proxyPatientPhone",patientDO.getMobile());
            }
            if (jsonObjectParam.getJSONObject("order").getInteger("type")==3) {//医生代发起
                orderDO.setProxyPatient(proxyPatient);
                orderDO.setProxyPatientName(patientDO.getName());
                orderDO.setProxyPatientPhone(patientDO.getMobile());
            }else if (type==3) {
                //医生代发起
                BaseDoctorDO doctorDO = doctorDao.findById(proxyPatient);
                jsonObjectParam.put("proxyPatient",proxyPatient);
                jsonObjectParam.put("proxyPatientName",doctorDO.getName());
                jsonObjectParam.put("proxyPatientPhone",doctorDO.getMobile());
                orderDO.setProxyPatient(proxyPatient);
                orderDO.setProxyPatientName(doctorDO.getName());
                orderDO.setProxyPatientPhone(doctorDO.getMobile());
            }
        } catch (Exception e) {
            e.printStackTrace();
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "参数转换成JSON对象异常:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        LifeCareOrderDO orderDO = null;
        try {
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "生活照料工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        orderDO.setCreateTime(new Date());
        orderDO.setCreateUser(orderDO.getProxyPatient());
        orderDO.setCreateUserName(orderDO.getProxyPatientName());
@ -470,14 +498,9 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
            BaseOrgDO orgDO = baseOrgDao.findByCode(orderDO.getHospital());
            orderDO.setHospitalName(orgDO.getName());
        }
        orderDO.setNumber(orderNoService.getOrderNo(1));
        orderDO.setCreateTime(new Date());
        //判断创建生活照料类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        if(orderDO.getProxyPatient().equals(orderDO.getPatient())){
            orderDO.setType(1);
        }else if(!orderDO.getProxyPatient().equals(orderDO.getPatient())){
            orderDO.setType(2);
        }
        orderDO.setStatus(1);
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
@ -498,7 +521,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
            totalFee = new BigDecimal(0);
        }
        for ( LifeCareFeeDetailDO feeDetailDO : feeDetailDOList) {
        for (LifeCareFeeDetailDO feeDetailDO : feeDetailDOList) {
            try {
                //工单主表中记录总费用
                totalFee = totalFee.add(feeDetailDO.getFee().multiply(BigDecimal.valueOf(feeDetailDO.getNumber())));
@ -542,6 +565,30 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        return false;
    }
    @Transactional(rollbackFor = Exception.class)
    public boolean orderWithFeeDelete(JSONObject jsonObjectParam,LifeCareOrderDO orderDO) {
        BigDecimal totalFee = orderDO.getTotalFee();
        //删除的服务项
        JSONArray itemArray = jsonObjectParam.getJSONArray("deleteItemArr");
        if (!CollectionUtils.isEmpty(itemArray)) {
            List<LifeCareFeeDetailDO> list = new ArrayList<>();
            //删除的服务项要减去服务项费用
            BigDecimal itemFee = new BigDecimal(0);
            for(Object oneId : itemArray) {
                JSONObject oneIdJson = (JSONObject) oneId;
                LifeCareFeeDetailDO doorFeeDetail = lifeCareFeeDetailDao.findOne(String.valueOf(oneIdJson.get("id")));
                if(doorFeeDetail.getPayStatus()==0){
                    doorFeeDetail.setStatus(3);
                    doorFeeDetail.setUpdateTime(new Date());
                    list.add(doorFeeDetail);
                    itemFee = itemFee.add(doorFeeDetail.getFee().multiply(BigDecimal.valueOf(doorFeeDetail.getNumber())));
                }
            }
            lifeCareFeeDetailDao.save(list);
        }
        return false;
    }
    public PageEnvelop getPatientOrderList(String patient, Integer status, int page, int size) {
        page = page>0?page-1:0;
@ -561,4 +608,138 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
    }
    /**
     * 签到保存
     * @param orderId
     * @param signTime
     * @param signWay
     * @param signLocation
     * @param signImg
     * @return
     */
    public LifeCareOrderDO signIn(String orderId, String signTime, Integer signWay, String signLocation,
                             String signImg, String twoDimensionalCode,String doctorId) throws Exception {
        LifeCareOrderDO lifeCareOrderDO = this.lifeCareOrderDao.findOne(orderId);
        if(!LifeCareOrderDO.Status.waitForAccept.getType().equals(lifeCareOrderDO.getStatus())){
            //待服务状态才能签到
            logger.info("签到失败"+lifeCareOrderDO.getId()+":"+lifeCareOrderDO.getStatus());
            return null;
        }
        lifeCareOrderDO.setDoctorSignTime(DateUtil.strToDate(signTime));
        lifeCareOrderDO.setDoctorSignWay(signWay);
        // 签到方式-2扫码时,需要去解析地址
        lifeCareOrderDO.setDoctorSignLocation(signLocation);
        lifeCareOrderDO.setDoctorSignImg(StringUtils.isEmpty(signImg) ? null : signImg);
        //3 已签到
        lifeCareOrderDO.setStatus(3);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        lifeCareOrderDO.setSignDoctor(doctorId);
        lifeCareOrderDO.setSignDoctorName(doctorDO.getName());
        lifeCareOrderDO.setUpdateTime(new Date());
        lifeCareOrderDO.setUpdateUser(doctorId);
        lifeCareOrderDO.setUpdateUserName(doctorDO.getName());
        if(signWay == 4 ){//扫码签到
            if (twoDimensionalCode.equals(lifeCareOrderDO.getNumber())){
                lifeCareOrderDO = lifeCareOrderDao.save(lifeCareOrderDO);
                return lifeCareOrderDO;
            }else {
                logger.info("扫码签到失败");
                return null;
            }
        }else {
            lifeCareOrderDO = lifeCareOrderDao.save(lifeCareOrderDO);
            return lifeCareOrderDO;
        }
    }
    /**
     * 生活照料代预约-- 废弃用原来的接口
     * @param jsonData
     * @param doctorCode
     * @return
     */
    @Transactional
    public JSONObject proxyCreate(String jsonData,String doctorCode) {
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
        try {
            jsonObjectParam = JSONObject.parseObject(jsonData);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "参数转换成JSON对象异常:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        LifeCareOrderDO orderDO = null;
        try {
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "生活照料工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if(StringUtils.isEmpty(orderDO.getPatient())){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        //医生代预约
        orderDO.setType(3);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorCode);
        orderDO.setProxyPatient(doctorCode);
        orderDO.setProxyPatientName(doctorDO.getName());
        orderDO.setProxyPatientPhone(doctorDO.getMobile());
        //判断工单是否已存在,新建或者编辑
        if(StringUtils.isBlank(orderDO.getId())) {
            //已取消的订单也可以申请
            boolean bool = lifeCareOrderDao.existsByPatientAndStatusIn(orderDO.getPatient(),
                    new Integer[]{LifeCareOrderDO.Status.waitForAccept.getType()
                    });
            if(bool){
                String failMsg = "当前服务对象存在未完成的生活照料,请先完成该服务!";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                logger.error(failMsg);
                return result;
            }
            orderDO.setNumber(orderNoService.getOrderNo(1));
            orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
            orderDO.setCreateTime(new Date());
            orderDO.setCreateUser(orderDO.getProxyPatient());
            orderDO.setCreateUserName(orderDO.getProxyPatientName());
        }else {
            LifeCareOrderDO serviceOrderDO = lifeCareOrderDao.findOne(orderDO.getId());
            // 删除出诊医生或服务项
            Boolean b = this.orderWithFeeDelete(jsonObjectParam, serviceOrderDO);
            if(b){
                String failMsg = "删除服务项失败!";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                return result;
            }
            orderDO.setNumber(serviceOrderDO.getNumber());
            orderDO.setHospital(serviceOrderDO.getHospital());
            orderDO.setUpdateTime(new Date());
            orderDO.setUpdateUser(orderDO.getProxyPatient());
            orderDO.setUpdateUserName(orderDO.getProxyPatientName());
        }
        orderDO.setStatus(2);
        orderDO.setType(3);
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,doctorCode)) {return result;}
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        return result;
    }
}

+ 4 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java

@ -83,7 +83,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    }
    public PageEnvelop<List<Map<String,Object>>> archiveList(String doctorId, int page, int size,Integer signStatus,String name){
        String sql = "SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,p.photo,CAST(a.sign_status AS char) sign_status ";
        String sql = " select * from ( SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,p.photo,CAST(a.sign_status AS char) sign_status ";
        String countSql = "SELECT count(*) from ( ";
        String filters = "from wlyy_archive a,base_patient p " +
@ -97,7 +97,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        if(StringUtils.isNotBlank(name)){
            filters += " and p.name like '%"+name+"%'";
        }
        if (signStatus!=null&&signStatus==1){//已签约不按建档查询,是要该居民服务医生就在列表中
        if (signStatus!=null&&signStatus==1){//已签约不按建档查询,只要该居民服务医生就在列表中
            filters+=" UNION " +
                    " SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,p.photo,CAST(a.sign_status AS char) sign_status \n" +
                    "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
@ -113,8 +113,9 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
            }
            filters+= " and m.del = '1' and sr.`status`=1 ) ";
        }
        filters+= " )tmp GROUP BY tmp.id ";
        String orderBy = " ORDER BY create_time DESC " +
        String orderBy = "  ORDER BY tmp.create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);

+ 6 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java

@ -144,36 +144,36 @@ public class WeiXinEventProcess {
    public void setUrlItems(List<Map<String, String>> articles) {
        Map<String, String> articleBooking = new HashMap<>();
        // 图文URL
        String urlBooking = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2Fhome%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlBooking = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fmedical-care-patient%2Fhome%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlBooking = urlBooking.replace("{appId}", appId);
        articleBooking.put("Url", urlBooking);
        articleBooking.put("Title", "你好啊,欢迎来到朝晖云照护!");
        articleBooking.put("Description", "这里是智慧养老和健康管理服务社区+幼儿成长教育服务平台\n" +
                "我们陪你一起,关爱老人,呵护孩子!\n" +
                "感谢关注,点击下方菜单直接进入朝晖云照护平台");
        articleBooking.put("PicUrl", "http://hzijk.cityihealth.com/image/index.png");
        articleBooking.put("PicUrl", "https://zhyzh.hzxc.gov.cn/image/index.png");
        articles.add(articleBooking);
        Map<String, String> articleDevice = new HashMap<>();
        // 图文URL
        String urlDevice = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2FonlineRegistration%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlDevice = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fmedical-care-patient%2FonlineRegistration%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlDevice = urlDevice.replace("{appId}", appId);
        articleDevice.put("Url", urlDevice);
        articleDevice.put("Title", "在线入园");
        articleDevice.put("Description", "申请专业托育机构入园资格");
        articleDevice.put("PicUrl", "http://hzijk.cityihealth.com/image/doorCoach.png");
        articleDevice.put("PicUrl", "https://zhyzh.hzxc.gov.cn/image/doorCoach.png");
        articles.add(articleDevice);
        Map<String, String> articleFamily = new HashMap<>();
        // 图文URL
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2FlifeCare%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        String urlFamily = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={appId}&amp;redirect_uri=https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fmedical-care-patient%2FlifeCare%2Findex&amp;response_type=code&amp;scope=snsapi_base&amp;state=STATE#wechat_redirect";
        urlFamily = urlFamily.replace("{appId}", appId);
        articleFamily.put("Url", urlFamily);
        articleFamily.put("Title", "上门预约");
        articleFamily.put("Description", "预约幼儿教育专家上门育儿指导");
        articleFamily.put("PicUrl", "http://hzijk.cityihealth.com/image/online.png");
        articleFamily.put("PicUrl", "https://zhyzh.hzxc.gov.cn/image/online.png");
        articles.add(articleFamily);
    }

+ 2 - 2
svr/svr-cloud-care/src/main/resources/application.yml

@ -440,13 +440,13 @@ wechat:
  appId: wx2c55f5b7b2f3cb56
  appSecret: 0dd9927e58125ad5f0efb9299860d145
  wechat_token: 27eb3bb24f149a7760cf1bb154b08041
  wechat_base_url: http%3A%2F%2Fhzijk.cityihealth.com%2Fcityihealth%2FcloudCare%2F
  wechat_base_url: https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fcityihealth%2FcloudCare%2F
  accId: gh_da06ed9e5751
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
  flag: true #演示环境  true走Mysql数据库  false走Oracle
im:
  im_list_get: http://10.18.43.40:3000/
  im_list_get: http://10.18.43.41:3000/
  data_base_name: im_internet_hospital
es:
  pwflag: 2 # 1需要密码,2不需要密码

+ 1 - 1
svr/svr-cloud-care/src/main/resources/wechat/weixin_menu.txt

@ -3,7 +3,7 @@
   {
	  "name":"进入云照护",
	  "type":"view",
      "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2c55f5b7b2f3cb56&redirect_uri=http%3A%2F%2Fhzijk.cityihealth.com%2Fmedical-care-patient%2Fhome%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
      "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx2c55f5b7b2f3cb56&redirect_uri=https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fmedical-care-patient%2Fhome%2Findex&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
   }
]
}

+ 5 - 0
svr/svr-cloud-device/pom.xml

@ -140,6 +140,11 @@
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-ext-jdk16</artifactId>
            <version>1.46</version>
        </dependency>
    </dependencies>

+ 97 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/common/BaseController.java

@ -0,0 +1,97 @@
package com.yihu.jw.care.common;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.util.date.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
 *
 */
public class BaseController {
    private static Logger logger = LoggerFactory.getLogger("error_logger");
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @return
     */
    public String error(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", code);
            map.put("msg", msg);
            map.put("success", false);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 接口处理成功
     * @return
     */
    public String success() {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", 200);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public String write(int code, String msg) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", code);
            map.put("msg", msg);
            map.put("success", true);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 返回接口处理结果
     *
     * @param code  结果码,成功为200
     * @param msg   结果提示信息
     * @param value 结果数据
     * @return
     */
    public String write(int code, String msg, String key, Object value) {
        try {
            Map<Object, Object> map = new HashMap<Object, Object>();
            ObjectMapper mapper = new ObjectMapper();
            map.put("code", code);
            map.put("msg", msg);
            map.put(key, value);
            return mapper.writeValueAsString(map);
        } catch (Exception e) {
            error(e);
            return error(-1, "服务器异常,请稍候再试!");
        }
    }
    public void error(Exception e) {
        logger.error(DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+":"+getClass().getName() + ":", e.getMessage());
        e.printStackTrace();
    }
}

+ 74 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/YsConfig.java

@ -0,0 +1,74 @@
package com.yihu.jw.care.config;
/**
 * Created by Bing on 2021/6/1.
 * 萤石摄像头配置
 */
public class YsConfig {
    //文档地址 https://www.yuque.com/u1400669/kb/lmfp6u
    public static final String AppKey="43e44c2071114743925eda34088045f8";
    public static final String Secret="82051725cf0547208f8bc8ae2bff1323";
    public static final String baseUrl = "https://esopen.ys7.com";
    public static final String iotBaseUrl = "https://open.ys7.com";
   //saas平台 https://www.yuque.com/u1400669/kb/wdvi3b#9ZP70
    public static final String saasAssesToken =baseUrl+ "/api/user/open-app/auth/gettoken";
    //开放平台  https://open.ys7.com/doc/zh/book/index/user.html
    public static final String iotAssesToken =baseUrl+ "/api/user/component-open/sso/oauth2/getEZAccessToken";
    //获取通道列表
    public static final String surveillanceWayList =baseUrl+ "/api/resource/open-app/surveillance/camera/list/page";
    //获取通道信息(通道默认为1)
    public static final String surveillanceWay =baseUrl+ "/api/resource/open-app/surveillance/camera/info";
    //设备抓拍
    public static final String deviceCapture =baseUrl +"/api/resource/device/capture";
    //获取设备有效直播地址
    public static final String getDeviceLiveAddress = iotBaseUrl+ "/api/lapp/live/address/limited";
    //设备视频加解密开关
    public static final String deviceEncrypt = baseUrl+ "/api/resource/device/encrypt/switch";
    //跌倒检测功能查询、设置(立即检测!判断是否有跌倒通过推送消息)
    public static final String deviceFailConfig = iotBaseUrl + "/api/route/device/devconfig/keyValue/{0}/{1}/op";
    //云台控制
    public static final String ptzStart = iotBaseUrl +"/api/lapp/device/ptz/start";
    //云台停止
    public static final String ptzStop = iotBaseUrl +"/api/lapp/device/ptz/stop";
    /**
     * 录像相关
     */
    //获取录像accessKey、上传录像地址
    public static final String videoKey = baseUrl +"/seastart/vod/token";
    //上传录像上传地址通过videoKey接口获取
    public static final String videoUpload = "https://seastart.ss.bscstorage.com";
    //录像列表
    public static final String videoList = baseUrl +"/seastart/vod/list";
    //批量获取录像详情
    public static final String videoDetailList = baseUrl +"/seastart/vod";
    //录像详情
    public static final String videoDetail = baseUrl +"/seastart/vod/get";
    public static final String redisKey = "ysAssesToken";
    public static final String iotRedisKey = "iotYsAssesToken";
    public static final String secretKey = "secretKey"; //设备的解密秘钥  通过iotAssesToken接口获取的
    public static final String msgDataKey = "HZADP68PNSNVZ4UW"; //消息解密密钥
}

+ 49 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/YsDeviceController.java

@ -0,0 +1,49 @@
package com.yihu.jw.care.endpoint;
import com.yihu.jw.care.common.BaseController;
import com.yihu.jw.care.service.YsDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
 * Created by Bing on 2021/6/1.
 */
@RestController
@RequestMapping("ys/device")
@Api(value = "萤石设备设备相关服务", description = "设备相关服务")
public class YsDeviceController  extends BaseController {
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(YsDeviceController.class);
    @Autowired
    private YsDeviceService ysDeviceService;
    @ApiOperation("萤石摄像机消息通知数据接收")
    @RequestMapping(value = "pushdata", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String pushdata(
            HttpServletRequest request) {
        try {
            StringBuilder sb = new StringBuilder();
            BufferedReader in=new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8"));
            String line = null;
            while ((line = in.readLine()) != null) {
                sb.append(line);
            }
            return write(200,"查询成功","data",ysDeviceService.pushdata(sb.toString(),request));
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"error");
        }
    }
}

Diferenças do arquivo suprimidas por serem muito extensas
+ 123 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java


+ 2 - 2
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/consult/FinishConsultJob.java

@ -59,7 +59,7 @@ public class FinishConsultJob implements Job {
            sql.append("SELECT s.id session_id, s.name session_name, s.create_date session_create_time, s.last_message_time, ")
            .append("t.id topic_id, t.name topic_name, t.create_time topic_create_time, t.start_message_id ")
            .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
            .append("WHERE s.id = t.session_id AND s.type=23  AND t.end_message_id IS NULL AND s.last_content_type in(1,2,3,4,15,16,17) and s.last_sender_id IN ( ")
            .append("WHERE s.id = t.session_id AND s.type in(23,24)  AND t.end_message_id IS NULL AND s.last_content_type in(1,2,3,4,15,16,17) and s.last_sender_id IN ( ")
            .append("SELECT id FROM ").append(imDb).append(".doctors d where d.id<>t.patient) ")
            .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600 ")
            .append("ORDER BY t.create_time");
@ -82,7 +82,7 @@ public class FinishConsultJob implements Job {
            sql = new StringBuffer();
            sql.append("SELECT s.id session_id,t.id topic_id, t.name topic_name ")
             .append("FROM ").append(imDb).append(".sessions s,").append(imDb).append(".wlyy_consults t ")
             .append("WHERE s.id = t.session_id AND s.type=23 AND t.end_message_id IS NULL AND t.reply=1 AND s.last_content_type =14 ")
             .append("WHERE s.id = t.session_id AND s.type in (23,24) AND t.end_message_id IS NULL AND t.reply=1 AND s.last_content_type =14 ")
             .append("AND UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(s.last_message_time) > 24*3600  ");
            StringBuffer sql2 = new StringBuffer();

+ 73 - 64
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
@ -32,75 +33,80 @@ public class MessageUtil {
    @Autowired
    private TXYSmsService txySmsService;
    @Value("${sendTXMessage.flag}")
    private Boolean sendTXMessageFlag;
    private static Logger logger = LoggerFactory.getLogger(MessageUtil.class);
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first
            ,String url, String remark, Integer type,JSONObject json,String ...keywords) {
        try {
            System.out.println(wechatId);
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (sendTXMessageFlag){
                System.out.println(wechatId);
                WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (wxAccessTokenDO == null) {
                logger.info("wx_access_token表获取为空,wechatId" + wechatId);
                return;
            }
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            BeanUtils.copyProperties(templateConfig,newConfig);
            if (newConfig == null) {
                logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                return;
            }
            logger.info("微信模板推送前");
            if (StringUtils.isNoneBlank(first)){
                newConfig.setFirst(first);
            }
            if (StringUtils.isNoneBlank(url)){
                newConfig.setUrl(url);
            }
            if (StringUtils.isNoneBlank(remark)){
                newConfig.setRemark(remark);
            }
            newConfig = setTemPlateUrl(newConfig,type,openId,json);
            int keyLength = keywords.length;
            if (keyLength >= 1) {
                if(StringUtils.isNoneBlank(keywords[0])){
                    newConfig.setKeyword1(keywords[0]);
                if (wxAccessTokenDO == null) {
                    logger.info("wx_access_token表获取为空,wechatId" + wechatId);
                    return;
                }
            }
            if (keyLength >= 2) {
                if(StringUtils.isNoneBlank(keywords[1])){
                    newConfig.setKeyword2(keywords[1]);
                WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
                WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
                BeanUtils.copyProperties(templateConfig,newConfig);
                if (newConfig == null) {
                    logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                    return;
                }
            }
            if (keyLength >= 3) {
                if(StringUtils.isNoneBlank(keywords[2])){
                    newConfig.setKeyword3(keywords[2]);
                logger.info("微信模板推送前");
                if (StringUtils.isNoneBlank(first)){
                    newConfig.setFirst(first);
                }
            }
            if (keyLength >= 4) {
                if(StringUtils.isNoneBlank(keywords[3])){
                    newConfig.setKeyword4(keywords[3]);
                if (StringUtils.isNoneBlank(url)){
                    newConfig.setUrl(url);
                }
            }
            if (keyLength >= 5) {
                if(StringUtils.isNoneBlank(keywords[4])){
                    newConfig.setKeyword5(keywords[4]);
                if (StringUtils.isNoneBlank(remark)){
                    newConfig.setRemark(remark);
                }
            }
            if (keyLength >= 6) {
                if(StringUtils.isNoneBlank(keywords[5])){
                    newConfig.setKeyword6(keywords[5]);
                newConfig = setTemPlateUrl(newConfig,type,openId,json);
                int keyLength = keywords.length;
                if (keyLength >= 1) {
                    if(StringUtils.isNoneBlank(keywords[0])){
                        newConfig.setKeyword1(keywords[0]);
                    }
                }
            }
            if (keyLength >= 7) {
                if(StringUtils.isNoneBlank(keywords[6])){
                    newConfig.setKeyword7(keywords[6]);
                if (keyLength >= 2) {
                    if(StringUtils.isNoneBlank(keywords[1])){
                        newConfig.setKeyword2(keywords[1]);
                    }
                }
                if (keyLength >= 3) {
                    if(StringUtils.isNoneBlank(keywords[2])){
                        newConfig.setKeyword3(keywords[2]);
                    }
                }
                if (keyLength >= 4) {
                    if(StringUtils.isNoneBlank(keywords[3])){
                        newConfig.setKeyword4(keywords[3]);
                    }
                }
                if (keyLength >= 5) {
                    if(StringUtils.isNoneBlank(keywords[4])){
                        newConfig.setKeyword5(keywords[4]);
                    }
                }
                if (keyLength >= 6) {
                    if(StringUtils.isNoneBlank(keywords[5])){
                        newConfig.setKeyword6(keywords[5]);
                    }
                }
                if (keyLength >= 7) {
                    if(StringUtils.isNoneBlank(keywords[6])){
                        newConfig.setKeyword7(keywords[6]);
                    }
                }
                //发起微信消息模板推送
                weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
                logger.info("微信模板消息推送后");
            }
            //发起微信消息模板推送
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
            logger.info("微信模板消息推送后");
        } catch (Exception e) {
            logger.info("微信模板推送异常");
            e.printStackTrace();
@ -121,15 +127,18 @@ public class MessageUtil {
    }
    public String sendTXYSJson(String templateCode,String mobile,String ...params)throws Exception{
        JSONObject sendObj = new JSONObject();
        sendObj.put("templateCode",templateCode);
        if (params.length>0){
            JSONArray paramArr =JSONArray.parseArray(JSON.toJSONString(params));
            sendObj.put("templateParamArr",paramArr);
        }else {
            JSONArray paramArr =new JSONArray();
            sendObj.put("templateParamArr",paramArr);
        if (sendTXMessageFlag){
            JSONObject sendObj = new JSONObject();
            sendObj.put("templateCode",templateCode);
            if (params.length>0){
                JSONArray paramArr =JSONArray.parseArray(JSON.toJSONString(params));
                sendObj.put("templateParamArr",paramArr);
            }else {
                JSONArray paramArr =new JSONArray();
                sendObj.put("templateParamArr",paramArr);
            }
            return txySmsService.sendMessageJson(mobile,sendObj);
        }
        return txySmsService.sendMessageJson(mobile,sendObj);
        return null;
    }
}

+ 5 - 7
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java

@ -257,14 +257,12 @@ public class JobController extends BaseController {
    @RequestMapping(value = "/testNow", method = RequestMethod.POST)
    @ApiOperation("立即执行")
    public String executeSignFamilyPayResultJob() {
    public String executeSignFamilyPayResultJob(String className) {
        try {
//            quartzHelper.removeJob("finish_consult_job3");
//            quartzHelper.removeJob("finish_consult_job4");
            quartzHelper.removeJob("PATIENT_SEND_UNREAD_MES_JOB3");
//            quartzHelper.startNow(FinishConsultJob.class, "finish_consult_job3", null);
//            quartzHelper.startNow(DoctorSendUnreadJob.class, "finish_consult_job4", null);
            quartzHelper.startNow(PatientSendUnreadJob.class, "PATIENT_SEND_UNREAD_MES_JOB3", null);
            String uuid = getUID();
            Class c1 = Class.forName(className);//com.yihu.jw.care.job.consult.FinishConsultJob
            quartzHelper.startNow(c1, uuid, null);
            quartzHelper.removeJob(uuid);
            return write(200, "启动成功");
        } catch (Exception e) {
            error(e);

+ 21 - 11
svr/svr-cloud-job/src/main/resources/application.yml

@ -24,7 +24,7 @@ spring:
    time-between-eviction-runs-millis: 300000 #在空闲连接回收器线程运行期间休眠的时间值,以毫秒为单位,一般比minEvictableIdleTimeMillis小
fast-dfs:
  tracker-server: 172.26.0.110:22122 #服务器地址
  tracker-server: 10.18.43.40:22122 #服务器地址
  connect-timeout: 2 #链接超时时间
  network-timeout: 30
  charset: ISO8859-1 #编码
@ -100,6 +100,10 @@ cloudServer:
  server_url: http://172.26.0.107:10301/
pay:
  flag: true
##是否发送短信消息 无测试公众号测试线也不发送模板消息
sendTXMessage:
  flag: false
---
spring:
  profiles: jwprod
@ -134,7 +138,7 @@ wechat:
  appId: wx2c55f5b7b2f3cb56
  appSecret: 0dd9927e58125ad5f0efb9299860d145
  wechat_token: 27eb3bb24f149a7760cf1bb154b08041
  wechat_base_url: http%3A%2F%2Fhzijk.cityihealth.com%2Fcityihealth%2FcloudCare%2F
  wechat_base_url: https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fcityihealth%2FcloudCare%2F
  accId: gh_da06ed9e5751
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
  flag: true #演示环境  true走Mysql数据库  false走Oracle
@ -142,14 +146,17 @@ cloudServer:
  server_url: http://172.26.0.12:10301/
pay:
  flag: true
##是否发送短信消息
sendTXMessage:
  flag: true
---
spring:
  profiles: hzprod
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://172.26.0.13:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: root
    password: '*ukOOSl&c0!y'
    url: jdbc:mysql://10.18.43.40:3306/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy
    password: '0XxS3W*!cRj'
  #  elasticsearch:
  #    cluster-name: jkzl #集群名 默认elasticsearch
  #    cluster-nodes: 172.26.0.115:9300,172.26.0.115:9300 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
@ -159,7 +166,7 @@ spring:
  #      connection-timeout: 60000 # Connection timeout in milliseconds.
  #      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://172.26.0.13:61616
    broker-url: tcp://10.18.43.40:61616
    user: admin
    password: admin
  redis:
@ -167,9 +174,9 @@ spring:
    port: 6379  # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://172.26.0.13:8888/
  fastdfs_file_url: http://10.18.43.40:8888/
fast-dfs:
  tracker-server: 172.26.0.13:22122 #服务器地址
  tracker-server: 10.18.43.40:22122 #服务器地址
# mq 是否获取his数据,flag代表获取演示数据,false代表获取his真实数据
demo:
  flag: false
@ -180,7 +187,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
im:
  im_list_get: http://172.26.0.12:3000/
  im_list_get: http://10.18.43.41:3000/
  data_base_name: im_internet_hospital
wlyy:
@ -189,11 +196,14 @@ wechat:
  appId: wx2c55f5b7b2f3cb56
  appSecret: 0dd9927e58125ad5f0efb9299860d145
  wechat_token: 27eb3bb24f149a7760cf1bb154b08041
  wechat_base_url: http%3A%2F%2Fhzijk.cityihealth.com%2Fcityihealth%2FcloudCare%2F
  wechat_base_url: https%3A%2F%2Fzhyzh.hzxc.gov.cn%2Fcityihealth%2FcloudCare%2F
  accId: gh_da06ed9e5751
  id: hz_yyyzh_wx  # base库中,wx_wechat 的id字段
  flag: true #演示环境  true走Mysql数据库  false走Oracle
cloudServer:
  server_url: http://172.26.0.12:10301/
  server_url: http://10.18.43.41:10301/
pay:
  flag: true
##是否发送短信消息
sendTXMessage:
  flag: true