소스 검색

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

wangzhinan 1 년 전
부모
커밋
22ad4580c6
46개의 변경된 파일2684개의 추가작업 그리고 851개의 파일을 삭제
  1. 11 5
      business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java
  2. 8 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxTemplateConfigDao.java
  3. 1 1
      business/im-service/src/main/java/com/yihu/jw/im/dao/ConsultDao.java
  4. 36 18
      business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java
  5. 78 3
      common/common-entity/sql/2023.sql
  6. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDO.java
  7. 9 8
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultTeamDo.java
  9. 27 7
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java
  10. 37 38
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java
  11. 44 2
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageRecordDO.java
  12. 231 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java
  13. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/door/WlyyDoorServiceOrderDO.java
  14. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  15. 1 3
      common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java
  16. 24 0
      common/common-util/src/main/java/com/yihu/jw/util/common/IdCardUtil.java
  17. 10 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/followup/FollowupTemplateDao.java
  18. 106 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/followup/FollowupTemplatePoint.java
  19. 34 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java
  20. 6 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageItemEndpoint.java
  21. 100 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/followup/FollowupTemplateService.java
  22. 2 2
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java
  23. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageSubItemService.java
  24. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/common/CommonController.java
  25. 7 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/dict/DictEndpoint.java
  26. 55 58
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  27. 4 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java
  28. 251 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  29. 343 319
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java
  30. 54 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java
  31. 480 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  32. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java
  33. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  34. 1 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/PostConstructUtil.java
  35. 217 68
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/controller/ConsultController.java
  36. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultService.java
  37. 31 21
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultTeamService.java
  38. 24 6
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/DoorOrderController.java
  39. 24 3
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/WlyyDoorServiceOrderController.java
  40. 74 92
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/DoorOrderService.java
  41. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorPrescriptionService.java
  42. 252 81
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java
  43. 12 0
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/pay/service/PayService.java
  44. 58 50
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/task/PushMsgTask.java
  45. 1 1
      svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/utils/CommonUtil.java
  46. 1 1
      svr/svr-visit-behind/src/main/resources/bootstrap.yml

+ 11 - 5
business/base-service/src/main/java/com/yihu/jw/order/dao/BusinessOrderDao.java

@ -1,20 +1,19 @@
package com.yihu.jw.order.dao;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrderDO, String>, JpaSpecificationExecutor<BusinessOrderDO>  {
public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrderDO, String>, JpaSpecificationExecutor<BusinessOrderDO> {
    @Query("from BusinessOrderDO w where w.traceNo = ?1 and w.orderNo=?2")
    BusinessOrderDO selectByTraceNoAndorderNo(String traceNo,String orderNo);
    BusinessOrderDO selectByTraceNoAndorderNo(String traceNo, String orderNo);
    @Query("from BusinessOrderDO w where w.orderNo = ?1 ")
    BusinessOrderDO selectByOrderNo(String orderNo);
@ -33,8 +32,15 @@ public interface BusinessOrderDao extends PagingAndSortingRepository<BusinessOrd
    List<BusinessOrderDO> selectByStatus(Integer status);
    @Query("from BusinessOrderDO w where w.patient = ?1 and w.status=?2  and w.orderCategory =?3")
    List<BusinessOrderDO> selectByPatientAndStatusAndOrderCategory(String patient,Integer status,String orderCategory);
    List<BusinessOrderDO> selectByPatientAndStatusAndOrderCategory(String patient, Integer status, String orderCategory);
    @Query("from BusinessOrderDO  w where w.status=0 and w.lastPayTime<=?1")
    List<BusinessOrderDO> selectByLastPayTime(Long lastPayTime);
    /**
     * 查询未付款的订单
     * status 医养支付状态 0待支付、1已支付、2已取消、3申请退款中、4已售后
     */
    @Query("from BusinessOrderDO  w where w.relationCode=?1 and w.status=0")
    BusinessOrderDO findByOrderId(String orderId);
}

+ 8 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/WxTemplateConfigDao.java

@ -2,7 +2,9 @@ package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.wechat.WechatTemplateConfig;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -13,7 +15,13 @@ import java.util.List;
public interface WxTemplateConfigDao extends PagingAndSortingRepository<WxTemplateConfigDO, String>, JpaSpecificationExecutor<WxTemplateConfigDO> {
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndSceneAndStatus(String wechatId, String templateName, String scene, Integer status);
    WxTemplateConfigDO findByWechatIdAndTemplateNameAndScene(String wechatId, String templateName, String scene);
    List<WxTemplateConfigDO> findByWechatIdAndScene(String wechatId, String scene);
    //根据自定义模板名称、场景值查询有效模板内容
    @Query("select t  from WxTemplateConfigDO t where t.templateName=?1 and t.scene=?2 and t.status = 1 ")
    WxTemplateConfigDO findByScene(String template_process_feedback, String smyyyqx);
}

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

@ -14,7 +14,7 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 */
public interface ConsultDao extends PagingAndSortingRepository<ConsultDo, String>, JpaSpecificationExecutor<ConsultDo> {
	ConsultDo findByCode(String code);
//	ConsultDo findByCode(String code);
	
	@Query("from ConsultDo a where a.relationCode = ?1")
	ConsultDo findByRelationCode(String outpatientid);

+ 36 - 18
business/im-service/src/main/java/com/yihu/jw/im/util/ImUtil.java

@ -401,6 +401,7 @@ public class ImUtil {
        params.put("topic_id", topicId);
        params.put("agent", agent);
        String response = HttpClientUtil.postBody(url, params);
        System.out.println("[sendTopicIM]发送消息给IM==>" + response);
        return response;
    }
@ -458,13 +459,15 @@ public class ImUtil {
     */
    public String updateParticipant(String sessionId, String user, String oldUserId) {
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/update";
        System.out.println("更新会话成员-地址:" + imAddr);
        JSONObject params = new JSONObject();
        params.put("session_id", sessionId);
        params.put("user_id", user);
        if (!StringUtils.isEmpty(oldUserId)) {
            params.put("old_user_id", oldUserId);
        }
        return HttpClientUtil.postBody(imAddr, params);
        String res = HttpClientUtil.postBody(imAddr, params);
        return res;
    }
    /**
@ -475,14 +478,23 @@ public class ImUtil {
     * @param oldUserId 删除的成员id
     */
    public String updateParticipantNew(String sessionId, String user, String oldUserId) {
        String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/updateNew";
        JSONObject params = new JSONObject();
        params.put("session_id", sessionId);
        params.put("user_id", user);
        if (!StringUtils.isEmpty(oldUserId)) {
            params.put("old_user_id", oldUserId);
        try {
            String imAddr = im_host + "api/v2/sessions/" + sessionId + "/participant/updateNew";
            System.out.println("更新会话成员-地址:" + imAddr);
            JSONObject params = new JSONObject();
            params.put("session_id", sessionId);
            params.put("user_id", user);
            if (!StringUtils.isEmpty(oldUserId)) {
                params.put("old_user_id", oldUserId);
            }
            System.out.println("参数:" + JSON.toJSONString(params));
            String res = HttpClientUtil.postBody(imAddr, params);
            System.out.println("响应结果:" + res);
            return res;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return HttpClientUtil.postBody(imAddr, params);
        return null;
    }
    /**
@ -560,10 +572,13 @@ public class ImUtil {
            params.put("messages", messages.toString());
            params.put("session_id", sessionId);
            params.put("session_type", sessionType);
            String ret = HttpClientUtil.postBody(imAddr, params);
            obj = JSON.parseObject(ret);
            System.out.println("创建议题==>" + "\n地址:" + imAddr + "\n参数:" + JSON.toJSONString(params));
            String res = HttpClientUtil.postBody(imAddr, params);
            System.out.println("结果:" + res);
            obj = JSON.parseObject(res);
        } catch (Exception e) {
			System.out.println("创建议题失败:topicId=>" + topicId);
            e.printStackTrace();
            System.out.println("创建议题失败:topicId=>" + topicId);
            return null;
        }
        return obj;
@ -639,21 +654,23 @@ public class ImUtil {
    }
    public JSONObject getTopicMessage(String topicId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
        JSONObject jsonObject = new JSONObject();
        String url = im_host
                + "api/v2/sessions/topic/" + topicId + "/messages?topic_id=" + topicId + "&end=" + startMsgId
                + "&start=" + (endMsgId == null ? "" : endMsgId) + "&page=" + page + "&pagesize=" + pagesize + "&user=" + uid;
        try {
            System.out.println("地址:" + url);
            String ret = httpClientUtil.get(url, "UTF-8");
            System.out.println("响应结果==>" + ret);
            JSONObject obj = JSON.parseObject(ret);
            if (obj.getInteger("status") == -1) {
                throw new RuntimeException(obj.getString("message"));
            } else {
                return obj.getJSONObject("data");
            }
            return obj.getJSONObject("data");
        } catch (Exception e) {
            return null;
            e.printStackTrace();
            jsonObject.put("msg", e.getMessage());
            return jsonObject;
        }
    }
    public JSONArray getSessionMessage(String sessionId, String startMsgId, String endMsgId, int page, int pagesize, String uid) {
@ -724,6 +741,7 @@ public class ImUtil {
        String url = im_host + "api/v2/sessions/topics/" + topicId + "?topic_id=" + topicId;
        try {
            String ret = httpClientUtil.get(url, "utf-8");
            System.out.println("getTopic结果==>" + ret);
            JSONObject obj = JSON.parseObject(ret);
            if (obj.getInteger("status") == -1) {
                throw new RuntimeException("获取议题失败!");

+ 78 - 3
common/common-entity/sql/2023.sql

@ -105,16 +105,91 @@ ALTER TABLE `base`.`base_service_package_item`
CREATE TABLE `base_followup_template` (
    `id` varchar(100) NOT NULL,
    `template_name` varchar(255) DEFAULT NULL,
    `followup_statrt_time_type` varchar(100) DEFAULT NULL,
    `followup_count` varchar(10) DEFAULT NULL,
    `description` varchar(255) DEFAULT NULL,
    `template_detail_json` text,
    `status` varchar(10) DEFAULT NULL,
    `leased_code` varchar(100) DEFAULT NULL,
    `leased_name` varchar(100) DEFAULT NULL,
    `org_code` varchar(100) DEFAULT NULL,
    `org_name` varchar(255) DEFAULT NULL,
    `create_time` datetime DEFAULT NULL,
    `update_time` datetime DEFAULT NULL,
    `create_user` varchar(100) DEFAULT NULL,
    `create_user_name` varchar(100) DEFAULT NULL,
    `update_user` varchar(100) DEFAULT NULL,
    `update_user_name` varchar(100) DEFAULT NULL,
    PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
ALTER TABLE `base`.`base_service_package_sign_record`
ADD COLUMN `price` decimal(10,2) NULL COMMENT '价格',
ADD COLUMN `payment_time` datetime NULL COMMENT '付款时间',
ADD COLUMN `pay_status` tinyint(1) NULL COMMENT '支付状态 0待扣费 1已扣费 2已退费',
ADD COLUMN `pay_way` tinyint(1) NULL COMMENT '付款方式:1-微信支付,2-线下支付(居民自己向医院支付,具体怎么支付由医院来定)',
ADD COLUMN `revoker` varchar(50) NULL COMMENT '撤销人code',
ADD COLUMN `revoker_name` varchar(50) NULL COMMENT '撤销人姓名',
ADD COLUMN `revoke_time` varchar(50) NULL COMMENT '撤销时间',
ADD COLUMN `check_doctor` varchar(50) NULL COMMENT '审核人code',
ADD COLUMN `check_doctor_name` varchar(50) NULL COMMENT '审核人姓名',
ADD COLUMN `check_time` varchar(50) NULL COMMENT '审核时间',
ADD COLUMN `refuse_type` varchar(1) NULL COMMENT '拒绝原因',
ADD COLUMN `refuse_reason` varchar(500) NULL COMMENT '拒绝说明',
ADD COLUMN `pay_time` varchar(50) NULL COMMENT '剩余付款时间(审核后3天 无需审核的10分钟)',
ADD COLUMN `update_time` datetime NULL COMMENT '更新时间',
ADD COLUMN `service_package_id` varchar(50) NULL COMMENT '服务包id',
ADD COLUMN `proxy_patient` varchar(50) NULL COMMENT '代理人code',
ADD COLUMN `proxy_patient_name` varchar(50) NULL COMMENT '代理人',
ADD COLUMN `mobile` varchar(50) NULL COMMENT '联系方式',
ADD COLUMN `service_address` varchar(200) NULL COMMENT '服务地址',
ADD COLUMN `serve_lat` varchar(50) NULL COMMENT '服务地址纬度',
ADD COLUMN `serve_lon` varchar(50) NULL COMMENT '服务地址经度',
ADD COLUMN `remark` varchar(2000) NULL COMMENT '备注说明',
ADD COLUMN `type` varchar(1) NULL COMMENT '类型(1本人发起 2家人代 3医生代)';
ALTER TABLE `base`.`base_service_package_record`
ADD COLUMN `package_item_id` varchar(50) NULL COMMENT '服务项id ',
ADD COLUMN `type` varchar(1) NULL COMMENT '类型 1预约后分配 2直接分配服务者 ',
ADD COLUMN `doctor` varchar(50) NULL COMMENT '服务者',
ADD COLUMN `doctor_name` varchar(50) NULL COMMENT '服务者姓名';
-- 数据处理
SELECT s.service_package_id,r.service_package_id from base_service_package_sign_record s,base_service_package_record r
WHERE s.id =r.sign_id;
update base_service_package_sign_record s,base_service_package_record r set s.service_package_id=r.service_package_id
WHERE s.id =r.sign_id;
UPDATE base_service_package_item set leased_code = 'system' WHERE leased_code is null and service_package_id = 'system';
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status1', NULL, 'sign_status', '0', '待审核', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status0', NULL, 'sign_status', '1', '已签约', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status2', NULL, 'sign_status', '2', '待支付', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status3', NULL, 'sign_status', '3', '已拒绝', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status4', NULL, 'sign_status', '-1', '已过期', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status5', NULL, 'sign_status', '-2', '已失效', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_status6', NULL, 'sign_status', '-3', '已撤销', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约状态');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_refuse_type1', NULL, 'sign_refuse_type', '0', '其他', NULL, '4', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约拒绝原因');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_refuse_type2', NULL, 'sign_refuse_type', '1', '基本资料错误', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约拒绝原因');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_refuse_type3', NULL, 'sign_refuse_type', '2', '超出服务范围', NULL, '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约拒绝原因');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('sign_refuse_type4', NULL, 'sign_refuse_type', '3', '签约用户已满', NULL, '3', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '签约拒绝原因');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('wxPayNotify', NULL, 'notifyUrl', 'wxpay', 'https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/wxPayNotify', '微信支付回调', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '回调地址');
INSERT INTO `base`.`wlyy_hospital_sys_dict` (`id`, `saas_id`, `dict_name`, `dict_code`, `dict_value`, `py_code`, `sort`, `hospital`, `create_time`, `create_user`, `create_user_name`, `update_time`, `update_user`, `update_user_name`, `img_url`, `model_name`) VALUES ('cloudPayNotify', NULL, 'notifyUrl', 'cloudWxPay', 'https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/cloudPayNotify', '云照护支付回调', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '回调地址');
===========================20231024上门服务开始====================================
ALTER TABLE `base`.`wlyy_door_service_order`
ADD COLUMN `fee_after` varchar(10) NULL COMMENT '服务后收费标识(1是0否)' AFTER `nursing_staff_type`,
    ADD COLUMN `fee_after` varchar(10) NULL COMMENT '服务后收费标识(1是0否)' AFTER `nursing_staff_type`,
ADD COLUMN `package_id` varchar(50) NULL COMMENT '服务包id' AFTER `fee_after`;
ALTER TABLE `base`.`wlyy_door_order_item`
ADD COLUMN `order_id` varchar(50) NULL COMMENT '订单id' AFTER `create_time`;
    ADD COLUMN `order_id` varchar(50) NULL COMMENT '订单id' AFTER `create_time`;
ALTER TABLE `base`.`base_service_package_item`
ADD COLUMN `assign_status` varchar(10) NULL COMMENT '是否分配服务者【1是0否】' AFTER `template_code`,
    ADD COLUMN `assign_status` varchar(10) NULL COMMENT '是否分配服务者【1是0否】' AFTER `template_code`,
ADD COLUMN `server_user_id` varchar(50) NULL COMMENT '服务者id' AFTER `assign_status`,
ADD COLUMN `server_user_name` varchar(50) NULL COMMENT '服务者name' AFTER `server_user_id`,
ADD COLUMN `server_user_type` varchar(10) NULL COMMENT '服务者类型' AFTER `server_user_name`;

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorRoleDO.java

@ -26,7 +26,7 @@ public class BaseDoctorRoleDO extends IntegerIdentityEntity {
    /**
	 * 医生角色id
	 */
	private String roleCode;
	private String roleCode;//dispatcher 调度员
    /**
     * 是否生效 1生效 0失效(默认1)

+ 9 - 8
common/common-entity/src/main/java/com/yihu/jw/entity/base/im/ConsultDo.java

@ -15,7 +15,7 @@ import java.util.Date;
@Table(name = "wlyy_consult")
public class ConsultDo extends UuidIdentityEntity {
	private String code;//新补充字段
//	private String code;//新补充字段
	// 患者标识
	private String patient;
@ -37,6 +37,7 @@ public class ConsultDo extends UuidIdentityEntity {
	private String del;
	// 结束时间
	private Date endTime;
	//关联业务表的code
	private String relationCode;
	//支付状态
@ -44,13 +45,13 @@ public class ConsultDo extends UuidIdentityEntity {
	//来源
	private String source;
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
//	public String getCode() {
//		return code;
//	}
//
//	public void setCode(String code) {
//		this.code = code;
//	}
	public String getSource() {
		return source;

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

@ -17,7 +17,7 @@ import java.util.Date;
@Table(name = "wlyy_consult_team")
public class ConsultTeamDo extends UuidIdentityEntity {
	
	private String consult;         // 咨询标识
	private String consult;         // 咨询标识  --这个对应的是wlyy_consult的Id
	private String doctor;          // 医生标识
	private String team;            // 三师团队标识
	private Integer type;           //  1、15三师咨询,2、家庭医生咨询,

+ 27 - 7
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java

@ -40,13 +40,15 @@ public class ServicePackageDO extends UuidIdentityEntityWithOperator implements
    /**
     * 新增字段
     */
    private String  checkDoctor;//服务包审核人code
    private String  checkDoctorName;//服务包审核人name
    private String  leasedCode;//租户code
    private String  leasedName;//租户name
    private String  serverTimeType;//服务时间类型
    private String  serverTime;//服务期限
    private String  serverTimeDescription;//服务时间说明
    private String checkDoctor;//服务包审核人code
    private String checkDoctorName;//服务包审核人name
    private String leasedCode;//租户code
    private String leasedName;//租户name
    private String serverTimeType;//服务时间类型 1固定 2自定义 3无期限
    private String serverTime;//服务期限 *号间隔
    private String serverTimeDescription;//服务时间说明
    private String isCheck;//是否开启审核 1是0否
    private String feeAfter;//'服务后收费标识(1是0否)
    private String pageItemName;//服务包服务项名称
@ -262,4 +264,22 @@ public class ServicePackageDO extends UuidIdentityEntityWithOperator implements
    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }
    @Column(name = "is_check")
    public String getIsCheck() {
        return isCheck;
    }
    public void setIsCheck(String isCheck) {
        this.isCheck = isCheck;
    }
    @Column(name = "fee_after")
    public String getFeeAfter() {
        return feeAfter;
    }
    public void setFeeAfter(String feeAfter) {
        this.feeAfter = feeAfter;
    }
}

+ 37 - 38
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java

@ -43,44 +43,10 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    private String subItemId;
    private String serverCount;//服务次数
    private String assignStatus;//是否分配服务者【1是0否】
    private String serverUserId;//服务者id
    private String serverUserName;//服务者name
    private String serverUserType;//服务者类型
    public String getAssignStatus() {
        return assignStatus;
    }
    public void setAssignStatus(String assignStatus) {
        this.assignStatus = assignStatus;
    }
    public String getServerUserId() {
        return serverUserId;
    }
    public void setServerUserId(String serverUserId) {
        this.serverUserId = serverUserId;
    }
    public String getServerUserName() {
        return serverUserName;
    }
    public void setServerUserName(String serverUserName) {
        this.serverUserName = serverUserName;
    }
    public String getServerUserType() {
        return serverUserType;
    }
    public void setServerUserType(String serverUserType) {
        this.serverUserType = serverUserType;
    }
    private String recordId;//分配记录id
    private String serviceType;//类型 1预约后分配 2直接分配服务者 3服务团队
    private String doctor;//服务者
    private String doctorName;//服务者姓名
    @Column(name = "service_package_item_id")
    public String getServicePackageItemId() {
@ -270,4 +236,37 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    public void setServerCount(String serverCount) {
        this.serverCount = serverCount;
    }
    @Transient
    public String getRecordId() {
        return recordId;
    }
    public void setRecordId(String recordId) {
        this.recordId = recordId;
    }
    @Transient
    public String getServiceType() {
        return serviceType;
    }
    public void setServiceType(String serviceType) {
        this.serviceType = serviceType;
    }
    @Transient
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Transient
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
}

+ 44 - 2
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageRecordDO.java

@ -16,11 +16,11 @@ import java.io.Serializable;
public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime implements Serializable {
    /**
     * '签约id'
     * 签约id
     */
    private String signId;
    /**
     * '服务包id'
     * 服务包id
     */
    private String servicePackageId;
    /**
@ -29,6 +29,13 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
    private String patient;
    private String teamCode;//服务团队id
    //新增字段
    private String packageItemId;//服务项id
    private String type;//类型 1预约后分配 2直接分配服务者 3服务团队
    private String doctor;//服务者
    private String doctorName;//服务者姓名
    @Column(name = "sign_id")
    public String getSignId() {
        return signId;
    }
@ -37,6 +44,7 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
        this.signId = signId;
    }
    @Column(name = "service_package_id")
    public String getServicePackageId() {
        return servicePackageId;
    }
@ -45,6 +53,7 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
        this.servicePackageId = servicePackageId;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
@ -61,4 +70,37 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
    @Column(name = "package_item_id")
    public String getPackageItemId() {
        return packageItemId;
    }
    public void setPackageItemId(String packageItemId) {
        this.packageItemId = packageItemId;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
}

+ 231 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java

@ -8,6 +8,7 @@ import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -26,7 +27,33 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntityWithCreateTime
    private String signDoctorName;//签约医生名称
    private Date startTime;//服务开始时间
    private Date endTime;//服务结束时间
    private Integer status;//状态 0新增,1生效,-1已过期
    //状态新- 0待审核 1已签约 2待支付 -4已拒绝 -1已过期 -2已失效 -3已撤销 -5已退款
    private Integer status;//状态旧 0新增,1生效,-1已过期 字典(sign_status)
    private String servicePackageId;//服务包id
    private String proxyPatient;//代理人code
    private String proxyPatientName;//代理人/申请人
    private String mobile;//联系方式
    private String serviceAddress;//服务地址
    private String serveLat;//服务地址纬度
    private String serveLon;//服务地址经度
    private String remark;//备注说明
    private String refuseType;//拒绝原因 1基本资料错误 2超出服务范围  3签约用户已满   0其他  字典(sign_refuse_type)
    private String refuseReason;//拒绝说明
    private String type;//类型(1本人发起 2家人代 3医生代)
    private String payTime;//剩余付款时间(审核后3天 无需审核的10分钟) 时间单位分钟
    private BigDecimal price;//价格
    private Date paymentTime;//付款时间
    private Integer payStatus;//支付状态 0待支付 1已扣费 2已退费
    private Integer payWay;//付款方式:1-微信支付,2-线下支付(居民自己向医院支付,具体怎么支付由医院来定)
    private Date updateTime;//更新时间
    private String checkDoctor;//审核人code
    private String checkDoctorName;//审核人姓名
    private String checkTime;//审核时间
    private String revoker;//撤销人code
    private String revokerName;//撤销人姓名
    private String revokeTime;//撤销时间
    /**
     * 签约的服务包
@ -138,4 +165,207 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntityWithCreateTime
        this.packageList = packageList;
    }
    @Column(name = "proxy_patient")
    public String getProxyPatient() {
        return proxyPatient;
    }
    public void setProxyPatient(String proxyPatient) {
        this.proxyPatient = proxyPatient;
    }
    @Column(name = "proxy_patient_name")
    public String getProxyPatientName() {
        return proxyPatientName;
    }
    public void setProxyPatientName(String proxyPatientName) {
        this.proxyPatientName = proxyPatientName;
    }
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "service_address")
    public String getServiceAddress() {
        return serviceAddress;
    }
    public void setServiceAddress(String serviceAddress) {
        this.serviceAddress = serviceAddress;
    }
    @Column(name = "serve_lat")
    public String getServeLat() {
        return serveLat;
    }
    public void setServeLat(String serveLat) {
        this.serveLat = serveLat;
    }
    @Column(name = "serve_lon")
    public String getServeLon() {
        return serveLon;
    }
    public void setServeLon(String serveLon) {
        this.serveLon = serveLon;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "service_package_id")
    public String getServicePackageId() {
        return servicePackageId;
    }
    public void setServicePackageId(String servicePackageId) {
        this.servicePackageId = servicePackageId;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "update_time", nullable = false,updatable = false)
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Column(name = "pay_time")
    public String getPayTime() {
        return payTime;
    }
    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }
    @Column(name = "refuse_type")
    public String getRefuseType() {
        return refuseType;
    }
    public void setRefuseType(String refuseType) {
        this.refuseType = refuseType;
    }
    @Column(name = "refuse_reason")
    public String getRefuseReason() {
        return refuseReason;
    }
    public void setRefuseReason(String refuseReason) {
        this.refuseReason = refuseReason;
    }
    @Column(name = "check_doctor")
    public String getCheckDoctor() {
        return checkDoctor;
    }
    public void setCheckDoctor(String checkDoctor) {
        this.checkDoctor = checkDoctor;
    }
    @Column(name = "check_doctor_name")
    public String getCheckDoctorName() {
        return checkDoctorName;
    }
    public void setCheckDoctorName(String checkDoctorName) {
        this.checkDoctorName = checkDoctorName;
    }
    @Column(name = "check_time")
    public String getCheckTime() {
        return checkTime;
    }
    public void setCheckTime(String checkTime) {
        this.checkTime = checkTime;
    }
    @Column(name = "revoker")
    public String getRevoker() {
        return revoker;
    }
    public void setRevoker(String revoker) {
        this.revoker = revoker;
    }
    @Column(name = "revoker_name")
    public String getRevokerName() {
        return revokerName;
    }
    public void setRevokerName(String revokerName) {
        this.revokerName = revokerName;
    }
    @Column(name = "revoke_time")
    public String getRevokeTime() {
        return revokeTime;
    }
    public void setRevokeTime(String revokeTime) {
        this.revokeTime = revokeTime;
    }
    @Column(name = "payment_time")
    public Date getPaymentTime() {
        return paymentTime;
    }
    public void setPaymentTime(Date paymentTime) {
        this.paymentTime = paymentTime;
    }
    @Column(name = "pay_status")
    public Integer getPayStatus() {
        return payStatus;
    }
    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }
    @Column(name = "pay_way")
    public Integer getPayWay() {
        return payWay;
    }
    public void setPayWay(Integer payWay) {
        this.payWay = payWay;
    }
    @Column(name = "price")
    public BigDecimal getPrice() {
        return price;
    }
    public void setPrice(BigDecimal price) {
        this.price = price;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/door/WlyyDoorServiceOrderDO.java

@ -471,6 +471,7 @@ public class WlyyDoorServiceOrderDO extends UuidIdentityEntityWithOperator {
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date cancelTime;
    /**
     * 付款方式:1-微信支付,2-线下支付(居民自己向医院支付,具体怎么支付由医院来定)
     */

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

@ -30,6 +30,7 @@ public class SystemMessageDO extends UuidIdentityEntity {
     * 老人健康咨询 852
     *
     * 体征设备测量系统消息 42  老人pad语音
     * 签约分配消息 980
     * 智能手表佩戴提示 991
     * 智能手表电量提示 992
     * 报警器电量提示 993

+ 1 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/order/BusinessOrderDO.java

@ -2,12 +2,10 @@ package com.yihu.jw.entity.order;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import java.util.Date;
@ -31,7 +29,7 @@ public class BusinessOrderDO extends UuidIdentityEntity {
    private Integer orderType;
    /**
     * 互联网医院- 1:专家咨询|2:图文诊室|3:视频诊室|4处方结算|5就诊卡充值)
     * 医养项目 订单分类 orderType=1 时 1招生,2 课程,3 上门辅导托幼) 4 生活照料
     * 医养项目 订单分类 orderType=1 时 1招生,2 课程,3 上门辅导托幼) 4 生活照料 5签约服务包
     */
    private String orderCategory;
    private String relationCode;//业务关联code

+ 24 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/IdCardUtil.java

@ -250,6 +250,13 @@ public class IdCardUtil {
        }
        return age;
    }
    public static int getAgeByBirthdayStrOrIdcard(String idcard,String birthday){
        int age = getAgeByBirthdayStr(birthday);
        if(age<=0){
            return getAgeForIdcard(idcard);
        }
        return age;
    }
    public static int getAgeByBirthday(Date birthday){
        int age = 0;
        if(birthday!=null){
@ -267,6 +274,23 @@ public class IdCardUtil {
        }
        return age;
    }
    public static int getAgeByBirthdayStr(String birthday){
        int age = 0;
        if(!StringUtils.isEmpty(birthday)&&!"null".equals(birthday)){
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(DateUtil.strToDate(birthday));
            int year = calendar.get(Calendar.YEAR);
            int month = calendar.get(Calendar.MONTH);
            int day = calendar.get(Calendar.DATE);
            Calendar cal = Calendar.getInstance();
            age = cal.get(Calendar.YEAR) - year;
            //周岁计算
            if (cal.get(Calendar.MONTH) < (month - 1) || (cal.get(Calendar.MONTH) == (month - 1) && cal.get(Calendar.DATE) < day)) {
                age--;
            }
        }
        return age;
    }
    public static String getSexNameForIdcard_new(String idCard){
        String sex = getSexForIdcard_new(idCard);

+ 10 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/followup/FollowupTemplateDao.java

@ -0,0 +1,10 @@
package com.yihu.jw.base.dao.followup;
import com.yihu.jw.entity.followup.FollowupTemplate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface FollowupTemplateDao extends JpaRepository<FollowupTemplate, String>, JpaSpecificationExecutor<FollowupTemplate> {
}

+ 106 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/followup/FollowupTemplatePoint.java

@ -0,0 +1,106 @@
package com.yihu.jw.base.endpoint.followup;
import com.alibaba.fastjson.JSON;
import com.yihu.jw.base.service.followup.FollowupTemplateService;
import com.yihu.jw.entity.followup.FollowupTemplate;
import com.yihu.jw.restmodel.qvo.ParamQvo;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.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.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "followupTemplate")
@Api(value = "随访模板", description = "随访模板", tags = {"随访模板"})
public class FollowupTemplatePoint extends EnvelopRestEndpoint {
    @Autowired
    private FollowupTemplateService followupTemplateService;
    @GetMapping(value = "findFrequencyList")
    @ApiOperation(value = "获取频次列表")
    public ListEnvelop findFrequencyList() {
        try {
            ListEnvelop envelop = followupTemplateService.findFrequencyList();
            return envelop;
        } catch (Exception e) {
            e.printStackTrace();
            return ListEnvelop.getError(e.getMessage());
        }
    }
    @GetMapping(value = "findList")
    @ApiOperation(value = "获取模板列表")
    public PageEnvelop<Map<String, Object>> findList(
            @ApiParam(name = "jsonStr", value = "jsonStr") @RequestParam(value = "jsonStr", required = false) String jsonStr
    ) throws Exception {
        ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
        HashMap<String, Object> map = followupTemplateService.findList(qvo);
        List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("list");
        Integer count = (Integer) map.get("count");
        return success(list, count, qvo.getPage(), qvo.getPageSize());
    }
    /**
     * 创建模板和更新模板
     */
    @PostMapping(value = "createTemplate")
    @ApiOperation(value = "创建模板")
    public ObjEnvelop createTemplate(
            @ApiParam(name = "jsonStr", value = "jsonStr") @RequestParam(value = "jsonStr", required = false) String jsonStr
    ) throws Exception {
        FollowupTemplate vo = JSON.parseObject(jsonStr, FollowupTemplate.class);
        FollowupTemplate entity = followupTemplateService.createTemplate(vo);
        return success("创建成功", entity);
    }
    /**
     * 改变模板状态
     */
    @PostMapping(value = "changeTemplateStatus")
    @ApiOperation(value = "改变模板状态")
    public ObjEnvelop changeTemplateStatus(
            @ApiParam(name = "jsonStr", value = "jsonStr") @RequestParam(value = "jsonStr", required = false) String jsonStr
    ) throws Exception {
        ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
        try {
            FollowupTemplate entity = followupTemplateService.changeTemplateStatus(qvo);
            return success("改变模板状态成功", entity);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
    /**
     * 删除模板
     */
    @PostMapping(value = "deleteTemplate")
    @ApiOperation(value = "删除模板")
    public Envelop deleteTemplate(
            @ApiParam(name = "jsonStr", value = "jsonStr") @RequestParam(value = "jsonStr", required = false) String jsonStr
    ) throws Exception {
        ParamQvo qvo = JSON.parseObject(jsonStr, ParamQvo.class);
        try {
            followupTemplateService.deleteTemplate(qvo);
            return success("删除成功");
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
    }
}

+ 34 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java

@ -22,6 +22,7 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import java.net.URLDecoder;
@ -47,12 +48,44 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private ServiceItemConfigService itemConfigService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping(value = "findDoctorByOrg")
    @ApiOperation(value = "查询机构医生")
    public PageEnvelop findDoctorByOrg(@ApiParam(name = "orgCode", value = "机构code", required = false)
                                       @RequestParam(value = "orgCode",required = false) String orgCode,
                                       @ApiParam(name = "name", value = "医生姓名", required = false)
                                       @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 {
            String sql = "SELECT d.id,d.name,h.dept_name deptName,d.mobile ";
            String countSql = "SELECT count(d.id)";
            String filter = " from base_doctor_hospital h,base_doctor d WHERE h.doctor_code=d.id and d.del='1' and d.enabled='1' and h.del='1'";
            if(StringUtils.isNotBlank(orgCode)){
                filter += " and h.org_code='"+orgCode+"'  ";
            }
            if(StringUtils.isNotBlank(name)){
                filter += " and d.name like '%"+name+"%'  ";
            }
            String orderBy = " limit "+(page-1)*size+","+size;
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
            Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = BaseRequestMapping.ServicePackage.CREATE)
    @ApiOperation(value = "创建")
    public Envelop create (
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) throws Exception {
            @RequestParam String jsonData){
        try {
            ServicePackageDO servicePackageDO = toEntity(jsonData, ServicePackageDO.class);
            servicePackageService.create(servicePackageDO,getUID());

+ 6 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageItemEndpoint.java

@ -132,6 +132,9 @@ public class ServicePackageItemEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        if("servicePackageId=system;".equals(filters)){
            filters += "leasedCode=system;";
        }
        List<ServicePackageItemDO> servicePackageItemDOS = servicePackageItemService.search(fields, filters, sorts, page, size);
        for (ServicePackageItemDO servicePackageItemDO:servicePackageItemDOS){
            List<WlyyHospitalSysDictDO> wlyyHospitalSysDictDO = wlyyHospitalSysDictDao.findByDictName("isEffect");
@ -154,6 +157,9 @@ public class ServicePackageItemEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "filters", required = false) String filters,
            @ApiParam(name = "sorts", value = "排序,规则参见说明文档")
            @RequestParam(value = "sorts", required = false) String sorts) throws Exception {
        if("servicePackageId=system;".equals(filters)){
            filters += "leasedCode=system;";
        }
        List<ServicePackageItemDO> servicePackageItemDOS = servicePackageItemService.search(fields, filters, sorts);
        return success(servicePackageItemDOS);
    }

+ 100 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/followup/FollowupTemplateService.java

@ -0,0 +1,100 @@
package com.yihu.jw.base.service.followup;
import com.yihu.jw.base.dao.followup.FollowupTemplateDao;
import com.yihu.jw.entity.followup.FollowupTemplate;
import com.yihu.jw.entity.hospital.doctor.Frequency;
import com.yihu.jw.restmodel.qvo.ParamQvo;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
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.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class FollowupTemplateService extends BaseJpaService<FollowupTemplate, FollowupTemplateDao> {
    @Autowired
    private FollowupTemplateDao followupTemplateDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    public ListEnvelop findFrequencyList() {
        String sql = " SELECT * FROM `base`.`wlyy_frequency` WHERE del='1' ";
        List<Frequency> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(Frequency.class));
        return ListEnvelop.getSuccess(SpecialistMapping.api_success, list);
    }
    public HashMap<String, Object> findList(ParamQvo qvo) {
        String detailSql = "SELECT * ";
        String countSql = "SELECT COUNT(1) ";
        String conditionSql = " FROM base_followup_template WHERE 1=1 ";
        String pageSql = "";
        if (StringUtils.isNotBlank(qvo.getId())) {
            conditionSql += " AND `id`='" + qvo.getId() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getSearchKey())) {
            conditionSql += " AND `template_name`='" + qvo.getSearchKey() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getStatus())) {
            conditionSql += " AND `status`='" + qvo.getStatus() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getLeasedCode())) {
            conditionSql += " AND `leased_code`='" + qvo.getLeasedCode() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getOrgCode())) {
            conditionSql += " AND `org_code`='" + qvo.getOrgCode() + "'";
        }
        if (StringUtils.isNotBlank(qvo.getPageIf())) {
            pageSql = "limit " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize();
        }
        //查询
        detailSql += conditionSql + pageSql;
        countSql += conditionSql;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(detailSql);
        Integer count = jdbcTemplate.queryForObject(countSql, Integer.class);
        HashMap<String, Object> map = new HashMap<>();
        map.put("list", list);
        map.put("count", count);
        return map;
    }
    /**
     * 创建模板
     */
    public FollowupTemplate createTemplate(FollowupTemplate vo) {
        FollowupTemplate entity = followupTemplateDao.save(vo);
        return entity;
    }
    /**
     * 改变模板状态
     */
    public FollowupTemplate changeTemplateStatus(ParamQvo qvo) throws Exception {
        FollowupTemplate entity = followupTemplateDao.findOne(qvo.getId());
        if (entity != null) {
            entity.setStatus(qvo.getStatus());
            FollowupTemplate save = followupTemplateDao.save(entity);
            return save;
        } else {
            throw new Exception("没找到模板信息");
        }
    }
    /**
     * 删除模板
     */
    public void deleteTemplate(ParamQvo qvo) {
        String sql = "DELETE FROM base_followup_template WHERE 1=1 AND id='" + qvo.getId() + "'";
        jdbcTemplate.execute(sql);
    }
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java

@ -104,7 +104,7 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
        String countSql = "SELECT count(1) ";
        String pageSql = "";
        String sql = " FROM base_service_package_item a WHERE 1=1 \n";
        if (StringUtils.isNotBlank(qvo.getConfigureIf())) {
        if ("1".equals(qvo.getConfigureIf())) {
            //添加的项
            sql += " AND a.service_package_id ='system'  ";
        }
@ -126,7 +126,7 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
        if (StringUtils.isNotBlank(qvo.getItemName())) {
            sql += " AND a.`name` LIKE '%" + qvo.getItemName() + "%'";
        }
        if (StringUtils.isNotBlank(qvo.getPageIf())) {
        if ("1".equals(qvo.getPageIf())) {
            //需要分页
            pageSql = " limit " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize();
        }

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageSubItemService.java

@ -60,7 +60,7 @@ public class ServicePackageSubItemService extends BaseJpaService<ServicePackageS
        }
        //分页
        if (StringUtils.isNotBlank(qvo.getPageIf())) {
        if ("1".equals(qvo.getPageIf())) {
            pageSql += " limit " + (qvo.getPage() - 1) * qvo.getPageSize() + "," + qvo.getPageSize();
        }
        detailSql += sql + pageSql;

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/common/CommonController.java

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@ -55,6 +56,8 @@ public class CommonController extends EnvelopRestEndpoint {
    private WechatInfoService wechatInfoService;
    @Resource
    private WechatDao wechatDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @PostMapping(value = "open/getSign")
    @ApiOperation(value = "获取微信签名", notes = "获取微信签名")
@ -120,6 +123,23 @@ public class CommonController extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "open/findArticle")
    @ApiOperation(value = "获取文章")
    public ObjEnvelop findArticle(@RequestParam(value = "articleId",required = true)String articleId) {
        try {
            //sign_illustrate 签约说明
            JSONObject json = new JSONObject();
            String sql = "SELECT title,content from wlyy_knowledge_article_dict WHERE id = '"+articleId+"'";
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            if(list.size()>0){
                json.put("title",list.get(0).get("title"));
                json.put("content",list.get(0).get("content"));
            }
            return ObjEnvelop.getSuccess("获取成功",json);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "open/saveRegisterInfo")
    @ApiOperation(value = "保存登记信息")

+ 7 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/dict/DictEndpoint.java

@ -44,7 +44,7 @@ public class DictEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private DictService dictService;
    @ApiOperation("查询字典")
    @ApiOperation("查询字典-通用字典接口")
    @GetMapping(value= "findDict")
    public MixEnvelop findDict(@ApiParam(name = "name", value = "name", required = false)
                               @RequestParam(value = "name", required = false)String name,
@ -58,8 +58,12 @@ public class DictEndpoint extends EnvelopRestEndpoint {
                               @RequestParam(value = "page", required = false) Integer page,
                               @ApiParam(name = "pageSize", value = "pageSize", required = false)
                               @RequestParam(value = "pageSize", required = false)Integer pageSize){
        return dictService.findDictsByNameCode(modelName,name,code,value,page,pageSize);
        try {
            return dictService.findDictsByNameCode(modelName,name,code,value,page,pageSize);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询是吧",-1);
        }
    }
    @GetMapping(value = BaseHospitalRequestMapping.Prescription.findCommity)

+ 55 - 58
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -2,12 +2,9 @@ package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.RedisLock;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
@ -41,61 +38,61 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    private BasePatientDao patientDao;
    public int num = 20;
    @GetMapping(value = "testException")
    @ApiOperation(value = "测试异常")
    public String testException2(String type) throws Exception {
//        patientService.intiPatient();
        if("1".equals(type)){
            throw new NullPointerException();
        }else if("2".equals(type)){
            throw new ApiException("111");
        }
        return "获取成功";
    }
    @GetMapping(value = "testRedisLock")
    @RedisLock(key = "#patientDO.id")
    public Envelop testRedisLock(BasePatientDO patientDO) {
        try {
            String s = Thread.currentThread().getName() + "=====================" + patientDO.getId();
            if (num > 0) {
                System.out.println(s + "排号成功,号码是:" + num);
                num--;
            } else {
                System.out.println(s + "排号失败,号码已经被抢光");
            }
            return success(patientDO);
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @GetMapping(value = "testServicesAuth1")
    @ApiOperation(value = "测试居民服务项权限操作")
    @ServicesAuth(item = "auth")
    public Envelop testServicesAuth1(
            @ApiParam(name = "patientId", value = "居民id")
            @RequestParam(value = "patientId", required = true) String patientId) {
        try{
            return success("获取成功");
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = "testServicesAuth2")
    @ApiOperation(value = "测试居民服务项权限操作")
    @ServicesAuth(item = "healthEducation")
    public Envelop testServicesAuth2(
            @ApiParam(name = "patientId", value = "居民id")
            @RequestParam(value = "patientId", required = true) String patientId) {
        try{
            return success("获取成功");
        }catch (Exception e){
            return failedException2(e);
        }
    }
//    @GetMapping(value = "testException")
//    @ApiOperation(value = "测试异常")
//    public String testException2(String type) throws Exception {
////        patientService.intiPatient();
//        if("1".equals(type)){
//            throw new NullPointerException();
//        }else if("2".equals(type)){
//            throw new ApiException("111");
//        }
//
//        return "获取成功";
//    }
//
//    @GetMapping(value = "testRedisLock")
//    @RedisLock(key = "#patientDO.id")
//    public Envelop testRedisLock(BasePatientDO patientDO) {
//        try {
//            String s = Thread.currentThread().getName() + "=====================" + patientDO.getId();
//            if (num > 0) {
//                System.out.println(s + "排号成功,号码是:" + num);
//                num--;
//            } else {
//                System.out.println(s + "排号失败,号码已经被抢光");
//            }
//            return success(patientDO);
//        } catch (Exception e) {
//            return failedException2(e);
//        }
//    }
//
//    @GetMapping(value = "testServicesAuth1")
//    @ApiOperation(value = "测试居民服务项权限操作")
//    @ServicesAuth(item = "auth")
//    public Envelop testServicesAuth1(
//            @ApiParam(name = "patientId", value = "居民id")
//            @RequestParam(value = "patientId", required = true) String patientId) {
//        try{
//            return success("获取成功");
//        }catch (Exception e){
//            return failedException2(e);
//        }
//    }
//
//    @GetMapping(value = "testServicesAuth2")
//    @ApiOperation(value = "测试居民服务项权限操作")
//    @ServicesAuth(item = "healthEducation")
//    public Envelop testServicesAuth2(
//            @ApiParam(name = "patientId", value = "居民id")
//            @RequestParam(value = "patientId", required = true) String patientId) {
//        try{
//            return success("获取成功");
//        }catch (Exception e){
//            return failedException2(e);
//        }
//    }
    @GetMapping(value = "myPatientPage")
    @ApiOperation(value = "通讯录-我的居民分页")

+ 4 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PayEndpoint.java

@ -8,15 +8,11 @@ import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.WxpayUtil;
import com.yihu.jw.care.util.XMLUtil;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -36,7 +32,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -135,7 +130,7 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop existWaitForPay(
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient,
            @ApiParam(name ="orderCategory",value = "订单分类 1招生,2 课程,3 上门辅导托幼) 4 生活照料")
            @ApiParam(name ="orderCategory",value = "订单分类 1招生,2 课程,3 上门辅导托幼 4 生活照料 5签约服务包")
            @RequestParam(value = "orderCategory")String orderCategory) {
        try{
            JSONObject result =  result = payService.existWaitForPay(patient,orderCategory);
@ -150,7 +145,7 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop getPayInfo(
            @ApiParam(name = "orderId", value = "工单id", required = true)
            @RequestParam String orderId,
            @ApiParam(name ="orderCategory",value = "3 上门辅导托幼 4 生活照料")
            @ApiParam(name ="orderCategory",value = "3 上门辅导托幼 4 生活照料 5签约服务包")
            @RequestParam(value = "orderCategory")String orderCategory) {
        try {
            JSONObject result = payService.getPayInfo(orderId,orderCategory);
@ -168,7 +163,7 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "微信wap支付")
    @ObserverRequired
    public ObjEnvelop wxWapPay(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上面辅导id")
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上门辅导id 签约记录id")
            @RequestParam(value = "relationId", required = false) String relationId,
            @ApiParam(name = "orderId", value = "订单id")
            @RequestParam(value = "orderId", required = false) String orderId,HttpServletRequest request) {
@ -289,7 +284,7 @@ public class PayEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "微信native支付")
    @ObserverRequired
    public ObjEnvelop wxNativePay(
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上门辅导id")
            @ApiParam(name = "relationId", value = "业务id,如生活照料id 上门辅导id 签约服务包id")
            @RequestParam(value = "relationId", required = false) String relationId,
            @ApiParam(name = "orderId", value = "订单id")
            @RequestParam(value = "orderId", required = false) String orderId,HttpServletRequest request) {

+ 251 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -4,11 +4,12 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.aop.RedisLock;
import com.yihu.jw.care.dao.sign.ArchiveDao;
import com.yihu.jw.care.dao.sign.CapacityAssessmentRecordDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.service.sign.ArchiveService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
@ -17,6 +18,8 @@ import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -44,14 +47,254 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private CapacityAssessmentRecordService capacityAssessmentRecordService;
    @Autowired
    private CapacityAssessmentRecordDao capacityAssessmentRecordDao;
    private ServicePackageSignRecordDao servicePackageSignRecordDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @GetMapping(value = "mySign")
    @ApiOperation(value = "我的签约服务")
    public ObjEnvelop mySign(
            @ApiParam(name = "patientId", value = "居民id", required = true)
            @RequestParam String patientId) {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.mySign(patientId));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "mySignDoctor")
    @ApiOperation(value = "我的医养团队")
    public ObjEnvelop mySignDoctor(
            @ApiParam(name = "patientId", value = "居民id", required = true)
            @RequestParam String patientId) {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.mySignDoctor(patientId));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "allocationDoctor")
    @ObserverRequired
    @ApiOperation(value = "分配服务者")
    public Envelop allocationDoctor (
            @ApiParam(name = "jsonData", value = "json数组", required = true)
            @RequestParam(value = "jsonData",required = true) String jsonData) {
        try{
            servicePackageService.allocationDoctor(jsonData);
            return Envelop.getSuccess("操作成功");
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @PostMapping(value = "check")
    @ObserverRequired
    @ApiOperation(value = "签约审核")
    public Envelop check (
            @ApiParam(name = "id", value = "申请id", required = true)
            @RequestParam(value = "id",required = true) String id,
            @ApiParam(name = "status", value = "1同意 2拒绝", required = true)
            @RequestParam(value = "status",required = true) String status,
            @ApiParam(name = "refuseType", value = "拒绝原因", required = false)
            @RequestParam(value = "refuseType",required = false) String refuseType,
            @ApiParam(name = "refuseReason", value = "拒绝说明", required = false)
            @RequestParam(value = "refuseReason",required = false) String refuseReason) {
        try{
            servicePackageService.check(id,getUID(),status, refuseType, refuseReason);
            return Envelop.getSuccess("操作成功");
        }catch (ServiceException se){
            return Envelop.getError(se.getMessage());
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = "signNumPage")
    @ApiOperation(value = "签约人数列表")
    public PageEnvelop signNumPage (
            @ApiParam(name = "name", value = "居民姓名", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "doctorId", value = "医生code", required = false)
            @RequestParam(value = "doctorId",required = false) String doctorId,
            @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 servicePackageService.signNumPage(doctorId,name, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "signTopNum")
    @ApiOperation(value = "签约管理-签约各状态数")
    public ObjEnvelop signTopNum(
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.signTopNum(doctorId));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "doctorSignTopNum")
    @ApiOperation(value = "签约管理-获取签约人数/签约服务包数")
    public ObjEnvelop doctorSignTopNum(
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
            int doctorSignTotal = servicePackageService.doctorSignTotal(doctorId);
            int doctorSignServerPackageTotal = servicePackageService.doctorSignServerPackageTotal(doctorId);
            JSONObject json = new JSONObject();
            json.put("signTotal",doctorSignTotal);
            json.put("packageTotal",doctorSignServerPackageTotal);
            return ObjEnvelop.getSuccess("查询成功",json);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "revokeSign")
    @ObserverRequired
    @ApiOperation(value = "撤销签约")
    public Envelop revokeSign(
            @ApiParam(name = "id", value = "签约记录id", required = true)
            @RequestParam String id) {
        try{
            ServicePackageSignRecordDO signRecordDO = servicePackageSignRecordDao.findOne(id);
            if(signRecordDO.getStatus()==0||signRecordDO.getStatus()==2){
                signRecordDO.setStatus(-3);
                BasePatientDO patientDO = patientDao.findById(getUID());
                if(patientDO!=null){
                    signRecordDO.setRevoker(patientDO.getId());
                    signRecordDO.setRevokerName(patientDO.getName());
                }
                signRecordDO.setRevokeTime(DateUtil.getStringDate());
                servicePackageSignRecordDao.save(signRecordDO);
                return Envelop.getSuccess("撤销成功");
            }else {
                return Envelop.getError("只有待审核和待支付才能撤销");
            }
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @GetMapping(value = "signInfo")
    @ApiOperation(value = "根据签约记录获取签约详情")
    public ObjEnvelop signInfo(
            @ApiParam(name = "id", value = "签约记录id", required = true)
            @RequestParam String id,
            @ApiParam(name = "type", value = "1返回分配情况  0不返回", required = false)
            @RequestParam(required = false) String type) {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.signInfo(id,type));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "signPage")
    @ApiOperation(value = "获取签约记录分页")
    public PageEnvelop signPage (
            @ApiParam(name = "name", value = "居民姓名", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "doctorId", value = "医生code", required = false)
            @RequestParam(value = "doctorId",required = false) String doctorId,
            @ApiParam(name = "patientId", value = "居民id", required = false)
            @RequestParam(value = "patientId",required = false) String patientId,
            @ApiParam(name = "status", value = "状态 不传全部 0待审核 1已签约 2待支付 -4已拒绝 -1已过期 -2已失效 -3已撤销", required = false)
            @RequestParam(value = "status",required = false) String 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{
            return servicePackageService.signPage(patientId, doctorId,name,status, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "servicePackageList")
    @ApiOperation(value = "服务包列表")
    public PageEnvelop servicePackageList (
            @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 servicePackageService.servicePackageList(page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "servicePackageInfo")
    @ApiOperation(value = "服务包详情")
    public ObjEnvelop servicePackageInfo(
            @ApiParam(name = "id", value = "服务包id", required = true)
            @RequestParam String id) {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.servicePackageInfo(id));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "isSignPackage")
    @ApiOperation(value = "是否签约服务包")
    public ObjEnvelop isSignPackage(
            @ApiParam(name = "patientId", value = "居民id", required = true)
            @RequestParam String patientId,
            @ApiParam(name = "servicePackageId", value = "服务包id", required = true)
            @RequestParam String servicePackageId) {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.isSignPackage(patientId,servicePackageId));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "patient/sign")
    @ApiOperation(value = "申请签约")
    public ObjEnvelop patientSign(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) {
        try{
            return ObjEnvelop.getSuccess("申请成功",servicePackageService.sign(jsonData,getUID(),"1"));
        }catch (ServiceException se){
            return ObjEnvelop.getError(se.getMessage());
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "doctor/sign")
    @ObserverRequired
    @ApiOperation(value = "申请签约")
    public ObjEnvelop doctorSign(
            @ApiParam(name = "jsonData", value = "Json数据", required = true)
            @RequestParam String jsonData) {
        try{
            return ObjEnvelop.getSuccess("申请成功",servicePackageService.sign(jsonData,getUID(),"2"));
        }catch (ServiceException se){
            return ObjEnvelop.getError(se.getMessage());
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    /*************************************************************************************************************/
    @PostMapping(value = "addPatientSignList")
    @ApiOperation(value = "添加签约数据")
    @ObserverRequired
    public Envelop addPatientSignList () throws Exception {
    public Envelop addPatientSignList () {
        try{
            servicePackageService.addPatientSignList();
            return success("添加成功");
@ -68,7 +311,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "name", value = "机构名称", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "type", value = "类型 3 养老 4 教育,1 医疗", required = false)
            @RequestParam(value = "type",required = false) String type) throws Exception {
            @RequestParam(value = "type",required = false) String type) {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findSignOrg(patient,name,type));
        }catch (Exception e){
@ -84,7 +327,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "name", value = "机构名称", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "type", value = "类型 3 养老 4 教育,1 医疗", required = false)
            @RequestParam(value = "type",required = false) String type) throws Exception {
            @RequestParam(value = "type",required = false) String type) {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findOrgWithoutSigned(patient,name,type));
        }catch (Exception e){
@ -98,7 +341,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "patient", value = "居民code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "orgCode", value = "医院code", required = false)
            @RequestParam(value = "orgCode",required = false) String orgCode) throws Exception {
            @RequestParam(value = "orgCode",required = false) String orgCode) {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findSignDoctor(patient,orgCode));
        }catch (Exception e){
@ -112,7 +355,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "patient", value = "居民code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "orgCode", value = "医院code", required = false)
            @RequestParam(value = "orgCode",required = false) String orgCode) throws Exception {
            @RequestParam(value = "orgCode",required = false) String orgCode) {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findSignDoctor(patient,orgCode));
        }catch (Exception e){
@ -130,7 +373,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @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) throws Exception {
            @RequestParam(value = "size") int size) {
        try{
            return servicePackageService.signRecordPage(name, doctorId, page, size);
        }catch (Exception e){

+ 343 - 319
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/PatientDoorCoachOrderService.java

@ -129,6 +129,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        }
        BaseDoorCoachOrderDO orderDO = null;
        try {
            System.out.println(jsonObjectParam.get("order").toString());
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), BaseDoorCoachOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
@ -149,7 +150,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        orderDO.setPayStatus(0);//待付款
//        orderDO.setConclusionStatus(1);
        if(StringUtils.isEmpty(orderDO.getPatient())){
        if (StringUtils.isEmpty(orderDO.getPatient())) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient();
            result.put(ResponseContant.resultMsg, failMsg);
@ -157,7 +158,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            return result;
        }
        if(StringUtils.isEmpty(orderDO.getProxyPatient())){
        if (StringUtils.isEmpty(orderDO.getProxyPatient())) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前代理对象code为空,请联系管理员检查参数!proxyPatient = " + orderDO.getProxyPatient();
            result.put(ResponseContant.resultMsg, failMsg);
@ -175,7 +176,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                        BaseDoorCoachOrderDO.Status.accept.getType(),
                });
        if(bool){
        if (bool) {
            String failMsg = "当前服务对象存在未支付或未完成的上门预约,无法再次申请!";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
@ -186,9 +187,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        orderDO.setHospital(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        orderDO.setCreateTime(new Date());
        //判断创建上门预约类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        if(orderDO.getProxyPatient().equals(orderDO.getPatient())){
        if (orderDO.getProxyPatient().equals(orderDO.getPatient())) {
            orderDO.setType(1);
        }else if(!orderDO.getProxyPatient().equals(orderDO.getPatient())){
        } else if (!orderDO.getProxyPatient().equals(orderDO.getPatient())) {
            orderDO.setType(2);
        }
        orderDO.setServiceStatus("1");
@ -208,25 +209,27 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                baseAdminServiceDynamic.setPhoto(patientDO.getPhoto());
            }
            baseAdminServiceDynamicDao.save(baseAdminServiceDynamic);
        }catch (Exception e) {
        } catch (Exception e) {
            logger.info(e.getMessage());
        }
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        result.put("orderId", orderDO.getId());
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, orderDO);
        orderDO.setTotalFee(new BigDecimal(0));
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO, null)) {
            return result;
        }
        //发起支付订单
        payService.submitOrder(orderDO.getPatient(),"3",orderDO.getId(),orderDO.getTotalFee().doubleValue());
        payService.submitOrder(orderDO.getPatient(), "3", orderDO.getId(), orderDO.getTotalFee().doubleValue());
        return result;
    }
    @Transactional
    public JSONObject proxyCreate(String jsonData,String doctorCode) {
    public JSONObject proxyCreate(String jsonData, String doctorCode) {
        JSONObject result = new JSONObject();
        //医养暂无该功能--屏蔽
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
@ -337,25 +340,25 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        JSONObject result = new JSONObject();
        try {
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
            if (businessOrderDO==null){
            if (businessOrderDO == null) {
                String failMsg = "未查询到该订单";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
                return result;
            }
            BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO!=null){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO != null) {
                orderDO.setPayStatus(1);
                orderDO.setPayWay(1);
                orderDO.setPayTime(new Date());
                if (orderDO.getType()== 3){//医生代预约
                if (orderDO.getType() == 3) {//医生代预约
                    orderDO.setStatus(2);//待接单
                    this.save(orderDO);
                    // 给服务医生发接单消息
                    this.createMessage("服务工单待接单","707",orderDO.getProxyPatient(),orderDO.getProxyPatientName(), orderDO.getId(),orderDO.getDoctor(),orderDO.getDoctorName(), null,"您有新的服务工单,请前往处理");
                    this.createMessage("服务工单待接单", "707", orderDO.getProxyPatient(), orderDO.getProxyPatientName(), orderDO.getId(), orderDO.getDoctor(), orderDO.getDoctorName(), null, "您有新的服务工单,请前往处理");
                    //发送智能助手消息
                    sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
                }else {
                    sendWeixinMessage(4, orderDO.getDoctor(), orderDO.getPatient());
                } else {
                    //创建咨询
                    JSONObject successOrNot = null;
                    try {
@ -372,47 +375,46 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                        return JSONObject.parseObject(successOrNot.toString());
                    }
                    ConsultTeamDo consultTeam = (ConsultTeamDo)successOrNot.get(ResponseContant.resultMsg);
                    ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
                    //发送智能助手消息
                    sendWeixinMessage(4,orderDO.getDoctor(),orderDO.getPatient());
                    sendWeixinMessage(4, orderDO.getDoctor(), orderDO.getPatient());
                    //发送 预约卡片信息(2201类型)
                    JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
                    orderInfoContent.put("re_msg_type",0);//居民预约
                    orderInfoContent.put("re_msg_type", 0);//居民预约
                    this.qucikSendIM(orderDO.getId(), "system", "智能助手", "2201", orderInfoContent.toJSONString());
                    if(StringUtils.isNoneBlank(orderDO.getDoctor())){
                    if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
                        //期望服务医生存在,直接转派
                        BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
                        sendOrderToDoctor(orderDO.getId(),null,"system","系统",transDoctor.getId(),transDoctor.getName(),transDoctor.getJobTitleName());
                    }else {
                        sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
                    } else {
                        orderDO.setStatus(1);//待派单
                        this.save(orderDO);
                        JSONObject dispatcherJson = queryDispatcherInfoByPatient(orderDO.getHospital());
                        if (dispatcherJson.getInteger("resultFlag")==1){
                            List<Map<String,Object>> dispatcherInfoList = (List<Map<String, Object>>) dispatcherJson.get(ResponseContant.resultMsg);
                            for(Map<String,Object> map: dispatcherInfoList){
                        if (dispatcherJson.getInteger("resultFlag") == 1) {
                            List<Map<String, Object>> dispatcherInfoList = (List<Map<String, Object>>) dispatcherJson.get(ResponseContant.resultMsg);
                            for (Map<String, Object> map : dispatcherInfoList) {
                                String dispatcher = map.get("code").toString();
                                BaseDoctorDO doctorVO = doctorDao.findById(dispatcher);
                                // 派单消息-首页
                                this.createMessage("新增居民预约服务申请","702","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                                this.createMessage("新增居民预约服务申请", "702", "system", "system", orderDO.getId(), dispatcher, doctorVO.getName(), doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                                // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
                                this.createMessage("居民提交工单申请","730","system","system", orderDO.getId(), dispatcher,doctorVO.getName() ,doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务工单"+orderDO.getNumber()+"申请");
                                this.createMessage("居民提交工单申请", "730", "system", "system", orderDO.getId(), dispatcher, doctorVO.getName(), doctorVO.getIdcard(), orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
                            }
                        }
                    }
                    serviceNewsService.addServiceNews(orderDO.getPatientName(),orderDO.getPatient(),"1",null,orderId,1);
                    serviceNewsService.addServiceNews(orderDO.getPatientName(), orderDO.getPatient(), "1", null, orderId, 1);
                    String failMsg = "success";
                    result.put(ResponseContant.resultFlag, ResponseContant.success);
                    result.put(ResponseContant.resultMsg, failMsg);
                }
            }
            else {
            } else {
                String failMsg = "工单不存在";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
            }
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
@ -422,8 +424,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    public JSONObject refundOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        try {
            BaseDoorCoachOrderDO orderDO= baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO == null){
            BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
            if (orderDO == null) {
                String failMsg = "工单不存在";
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, failMsg);
@ -434,7 +436,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            String failMsg = "success";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
        }catch (Exception e){
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
@ -442,26 +444,27 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 根据接单医生code获取最近一次服务orderId
     *
     * @return
     */
    public String getOrderIdByPatient(String patient) {
        String sql = "SELECT id as orderId from base_door_coach_order where patient=? and status in(1,2,3,4,5,6) ORDER BY patient_expected_serve_time desc,update_time desc,create_time desc, status ASC limit 1";
        List<String> orderId = jdbcTemplate.queryForList(sql, String.class, new Object[]{patient});
        if (orderId.size()>0){
        if (orderId.size() > 0) {
            return orderId.get(0);
        }
        return null;
    }
    public List<Map<String,Object>> selectItemsByHospital(String hospital,String serverItemName){
        String sql ="select org_code,dict_code code,dict_value name,ext1 fee from base_business_sys_dict where dict_name='DOOR_APPLY_ITEM' ";
        if (StringUtils.isNotBlank(hospital)){
            sql +=" and org_code='"+hospital+"' ";
    public List<Map<String, Object>> selectItemsByHospital(String hospital, String serverItemName) {
        String sql = "select org_code,dict_code code,dict_value name,ext1 fee from base_business_sys_dict where dict_name='DOOR_APPLY_ITEM' ";
        if (StringUtils.isNotBlank(hospital)) {
            sql += " and org_code='" + hospital + "' ";
        }
        if (StringUtils.isNotBlank(serverItemName)){
            sql += " and dict_value like '%"+serverItemName+"%' ";
        if (StringUtils.isNotBlank(serverItemName)) {
            sql += " and dict_value like '%" + serverItemName + "%' ";
        }
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
@ -471,7 +474,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     *
     * @return
     */
    public JSONObject queryDoctorListWithNotStopped(String hospital,int page, int size) {
    public JSONObject queryDoctorListWithNotStopped(String hospital, int page, int size) {
        JSONObject result = new JSONObject();
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
@ -480,26 +483,26 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                " from base_door_coach_doctor_status ds " +
                "        JOIN (select b.* from base_doctor b,base_doctor_hospital dh where b.id=dh.doctor_code and dh.del = 1 and dh.org_code='" + hospital + "')  d on ds.doctor = d.id " +
                "  where ds.status in (1,2,3,4)  " +
                " limit " + start + "," + end ;
                " limit " + start + "," + end;
        String countSql = "select DISTINCT count(ds.id) " +
                "from base_door_coach_doctor_status ds " +
                "         JOIN (select b.* from base_doctor b,base_doctor_hospital dh where b.id=dh.doctor_code and dh.del = 1 and dh.org_code= '" + hospital + "') d on ds.doctor = d.id " +
                " LEFT JOIN base_doctor_role dr ON dr.doctor_code = d.id where ds.status in (1,2,3,4)  ";
        List<Map<String,Object>> doctorList = new ArrayList<>();
        List<Map<String, Object>> doctorList = new ArrayList<>();
        try {
            doctorList = jdbcTemplate.queryForList(sql);
        } catch (Exception e) {
            String failMsg = "从数据库查询 可接单状态的服务医生人员 列表信息失败:" + e.getMessage();
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg );
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        Integer count = 0;
        try {
            count = jdbcTemplate.queryForObject(countSql,Integer.class);
            count = jdbcTemplate.queryForObject(countSql, Integer.class);
        } catch (Exception e) {
            String failMsg = "从数据库统计  可接单状态的服务医生人员 数量失败:" + e.getMessage();
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
@ -548,25 +551,25 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 删除出诊医生或服务项
     * @param jsonObjectParam
     * {
     *     "deleteItemArr":[
     *        {
     *           "id":""
     *       },
     *        {
     *           "id":""
     *      }
     *     ],
     *     "deleteDoctorArr":[
     *     {
     *         "id":""
     *     },
     *      {
     *         "id":""
     *     }
     *     ]
     * }
     *
     * @param jsonObjectParam {
     *                        "deleteItemArr":[
     *                        {
     *                        "id":""
     *                        },
     *                        {
     *                        "id":""
     *                        }
     *                        ],
     *                        "deleteDoctorArr":[
     *                        {
     *                        "id":""
     *                        },
     *                        {
     *                        "id":""
     *                        }
     *                        ]
     *                        }
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
@ -578,10 +581,10 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            List<BaseDoorCoachFeeDetailDO> list = new ArrayList<>();
            //删除的服务项要减去服务项费用
            BigDecimal itemFee = new BigDecimal(0);
            for(Object oneId : itemArray) {
            for (Object oneId : itemArray) {
                JSONObject oneIdJson = (JSONObject) oneId;
                BaseDoorCoachFeeDetailDO doorFeeDetail = baseDoorCoachFeeDetailDao.findOne(String.valueOf(oneIdJson.get("id")));
                if(doorFeeDetail.getPayStatus()==0){
                if (doorFeeDetail.getPayStatus() == 0) {
                    doorFeeDetail.setStatus(3);
                    doorFeeDetail.setUpdateTime(new Date());
                    list.add(doorFeeDetail);
@ -618,7 +621,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 查询预约简要卡片信息
     *
     * <p>
     * 服务时间:2019-01-01   12:30
     * 服务对象:张三
     * 联系电话:13125256565(儿子)
@ -627,54 +630,56 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     * @param orderDO
     * @return
     */
    public JSONObject queryOrderCardInfo(BaseDoorCoachOrderDO orderDO){
    public JSONObject queryOrderCardInfo(BaseDoorCoachOrderDO orderDO) {
        JSONObject result = new JSONObject();
        result.put("patientCode", orderDO.getPatient());
        BasePatientDO patientDO = patientDao.findById(orderDO.getPatient());
        result.put("title","预约服务信息如下:");
        result.put("orderId",orderDO.getId());
        result.put("status",orderDO.getStatus());
        result.put("number",orderDO.getNumber());
        result.put("serveDesc",orderDO.getServeDesc());
        result.put("expectedDoctor",orderDO.getExpectedDoctorName());
        result.put("serviceStatus",orderDO.getServiceStatus());
        if(orderDO.getStatus() < 4){
            if(StringUtils.isBlank(orderDO.getPatientExpectedServeTime())){
                result.put("time","工作时间");
            }else {
        result.put("title", "预约服务信息如下:");
        result.put("orderId", orderDO.getId());
        result.put("status", orderDO.getStatus());
        result.put("number", orderDO.getNumber());
        result.put("serveDesc", orderDO.getServeDesc());
        result.put("expectedDoctor", orderDO.getExpectedDoctorName());
        result.put("serviceStatus", orderDO.getServiceStatus());
        if (orderDO.getStatus() < 4) {
            if (StringUtils.isBlank(orderDO.getPatientExpectedServeTime())) {
                result.put("time", "工作时间");
            } else {
                result.put("time", orderDO.getPatientExpectedServeTime());
            }
        }else {
            if(StringUtils.isBlank(orderDO.getDoctorArrivingTime())){
                result.put("time","工作时间");
            }else{
        } else {
            if (StringUtils.isBlank(orderDO.getDoctorArrivingTime())) {
                result.put("time", "工作时间");
            } else {
                result.put("time", orderDO.getDoctorArrivingTime());
            }
        }
        result.put("patientName",patientDO.getName());
        result.put("patientName", patientDO.getName());
        result.put("patientSex", IdCardUtil.getSexNameForIdcard_new(patientDO.getIdcard()));
        result.put("patientAge", IdCardUtil.getAgeByIdcardOrBirthday(patientDO.getIdcard(),patientDO.getBirthday()));
        result.put("phone",orderDO.getPatientPhone());
        result.put("serveDesc",orderDO.getServeDesc());
        if(StringUtils.equalsIgnoreCase(orderDO.getPatient(),orderDO.getProxyPatient())){
            result.put("relation","");
        }else{
            result.put("relation",orderDO.getPatientRelation());
        }
        result.put("serveTown",orderDO.getServeTown());
        result.put("serveAddress",orderDO.getServeAddress());
        result.put("type",21);
        result.put("patientAge", IdCardUtil.getAgeByIdcardOrBirthday(patientDO.getIdcard(), patientDO.getBirthday()));
        result.put("phone", orderDO.getPatientPhone());
        result.put("serveDesc", orderDO.getServeDesc());
        if (StringUtils.equalsIgnoreCase(orderDO.getPatient(), orderDO.getProxyPatient())) {
            result.put("relation", "");
        } else {
            result.put("relation", orderDO.getPatientRelation());
        }
        result.put("serveTown", orderDO.getServeTown());
        result.put("serveAddress", orderDO.getServeAddress());
        result.put("type", 21);
        return result;
    }
    /**
     * 【调度员,医生】快速发送IM消息
     *
     * @param orderId
     * @param sendId
     * @param sendName
     * @param content
     * @return
     */
    public int qucikSendIM(String orderId,String sendId,String sendName,String contentType,String content) {
    public int qucikSendIM(String orderId, String sendId, String sendName, String contentType, String content) {
        int result = -1;
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        if (null == consult) {
@ -685,14 +690,14 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        BaseDoorCoachOrderDO baseDoorCoachOrderDO = null;
        String response = null;
        if(StringUtils.isBlank(sendId)){
        if (StringUtils.isBlank(sendId)) {
            baseDoorCoachOrderDO = baseDoorCoachOrderDao.findOne(orderId);
            String sender = "system";
            if(StringUtils.isNoneBlank(baseDoorCoachOrderDO.getDispatcher())){
            if (StringUtils.isNoneBlank(baseDoorCoachOrderDO.getDispatcher())) {
                sender = baseDoorCoachOrderDO.getDispatcher();
            }
            response = imUtill.sendTopicIM(sender, "智能助手", consult.getId(), contentType, content, null);
        }else{
        } else {
            response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
        }
        JSONObject resObj = JSONObject.parseObject(response);
@ -712,11 +717,11 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject sendOrderToDoctor(String orderId,String remark,String dispatcher,String dispathcherName,String doctor,String doctorName,String doctorJobName){
    public JSONObject sendOrderToDoctor(String orderId, String remark, String dispatcher, String dispathcherName, String doctor, String doctorName, String doctorJobName) {
        JSONObject result = new JSONObject();
        BaseDoorCoachOrderDO doorServiceOrderDO = baseDoorCoachOrderDao.findOne(orderId);
        if(null == doorServiceOrderDO){
        if (null == doorServiceOrderDO) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前工单不存在,id:" + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
@ -724,19 +729,19 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            return result;
        }
        BaseDoorCoachDoctorStatusDO doorDoctorStatusDO = baseDoorCoachDoctorStatusDao.queryByDoctorAndStatusIn(doctor,new Integer[]{BaseDoorCoachOrderDO.Status.waitForSend.getType(),
        BaseDoorCoachDoctorStatusDO doorDoctorStatusDO = baseDoorCoachDoctorStatusDao.queryByDoctorAndStatusIn(doctor, new Integer[]{BaseDoorCoachOrderDO.Status.waitForSend.getType(),
                BaseDoorCoachDoctorStatusDO.Status.waitForAccept.getType(),
                BaseDoorCoachDoctorStatusDO.Status.waitForServe.getType(),
                BaseDoorCoachDoctorStatusDO.Status.serving.getType(),
        });
        if(null == doorDoctorStatusDO){
        if (null == doorDoctorStatusDO) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前派单的医生不存在或禁止接单,doctor:" + doctor;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if (StringUtils.isNotBlank(remark)&&!"null".equals(remark)){
        if (StringUtils.isNotBlank(remark) && !"null".equals(remark)) {
            doorServiceOrderDO.setRemark(remark);
        }
        doorServiceOrderDO.setDoctor(doctor);
@ -751,19 +756,19 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        this.save(doorServiceOrderDO);
        // 给医生发派单消息
        if(BaseDoorCoachOrderDO.IsTransOtherOrg.yes.getType().equals(doorServiceOrderDO.getIsTransOtherOrg())){
            this.createMessage("服务工单待接单","707",doorServiceOrderDO.getTransedDispatcher(),doorServiceOrderDO.getTransedDispatcherName(), orderId,doctor,doctorName, null,"您有新的服务工单,请前往处理");
        }else{
            this.createMessage("服务工单待接单","707",doorServiceOrderDO.getDispatcher(),doorServiceOrderDO.getDispatcherName(), orderId,doctor,doctorName, null,"您有新的服务工单,请前往处理");
        if (BaseDoorCoachOrderDO.IsTransOtherOrg.yes.getType().equals(doorServiceOrderDO.getIsTransOtherOrg())) {
            this.createMessage("服务工单待接单", "707", doorServiceOrderDO.getTransedDispatcher(), doorServiceOrderDO.getTransedDispatcherName(), orderId, doctor, doctorName, null, "您有新的服务工单,请前往处理");
        } else {
            this.createMessage("服务工单待接单", "707", doorServiceOrderDO.getDispatcher(), doorServiceOrderDO.getDispatcherName(), orderId, doctor, doctorName, null, "您有新的服务工单,请前往处理");
        }
        //发送智能助手消息//·
        sendWeixinMessage(4,doctor,doorServiceOrderDO.getPatient());
        sendWeixinMessage(4, doctor, doorServiceOrderDO.getPatient());
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getType();
        imUtill.updateParticipantNew(sessionId,doctor,null);
        messageUtil.updateDoorCoachMessage(doorServiceOrderDO,new String[]{"702","703","730","735"},"731",dispatcher,dispatcher);
        imUtill.updateParticipantNew(sessionId, doctor, null);
        messageUtil.updateDoorCoachMessage(doorServiceOrderDO, new String[]{"702", "703", "730", "735"}, "731", dispatcher, dispatcher);
        // 工单状态变更记录
        BaseDoorCoachProcessLogDO processLogDO = new BaseDoorCoachProcessLogDO();
@ -778,8 +783,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        result.put(ResponseContant.resultMsg, doorServiceOrderDO);
        // 发送IM消息通知患者医生已派单
        String noticeContent = "已分派"+doorServiceOrderDO.getDoctorName()+"医生为您服务,请耐心等待医生接单";
        this.qucikSendIM(doorServiceOrderDO.getId(), doorServiceOrderDO.getDispatcher(), "智能助手","1", noticeContent);
        String noticeContent = "已分派" + doorServiceOrderDO.getDoctorName() + "医生为您服务,请耐心等待医生接单";
        this.qucikSendIM(doorServiceOrderDO.getId(), doorServiceOrderDO.getDispatcher(), "智能助手", "1", noticeContent);
        return result;
    }
@ -791,10 +796,10 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject transferOrder(String orderId,String remark,String dispatcher,String dispathcherName,String doctor,String doctorName,String doctorJobName){
    public JSONObject transferOrder(String orderId, String remark, String dispatcher, String dispathcherName, String doctor, String doctorName, String doctorJobName) {
        JSONObject result = new JSONObject();
        BaseDoorCoachOrderDO doorServiceOrderDO = baseDoorCoachOrderDao.findOne(orderId);
        if(null == doorServiceOrderDO){
        if (null == doorServiceOrderDO) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前工单不存在,id:" + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
@ -802,12 +807,12 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            return result;
        }
        BaseDoorCoachDoctorStatusDO doorDoctorStatusDO = baseDoorCoachDoctorStatusDao.queryByDoctorAndStatusIn(doctor,new Integer[]{BaseDoorCoachDoctorStatusDO.Status.waitForSend.getType(),
        BaseDoorCoachDoctorStatusDO doorDoctorStatusDO = baseDoorCoachDoctorStatusDao.queryByDoctorAndStatusIn(doctor, new Integer[]{BaseDoorCoachDoctorStatusDO.Status.waitForSend.getType(),
                BaseDoorCoachDoctorStatusDO.Status.waitForAccept.getType(),
                BaseDoorCoachDoctorStatusDO.Status.waitForServe.getType(),
                BaseDoorCoachDoctorStatusDO.Status.serving.getType(),
        });
        if(null == doorDoctorStatusDO){
        if (null == doorDoctorStatusDO) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前转派单的医生不存在或禁止接单,doctor:" + doctor;
            result.put(ResponseContant.resultMsg, failMsg);
@ -824,26 +829,26 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        doorServiceOrderDO.setUpdateUserName(dispathcherName);
        doorServiceOrderDO.setDispatcherResponseTime(new Date());
        System.out.println(dispathcherName+"医生派单给"+doctorName+"医生");
        System.out.println(dispathcherName + "医生派单给" + doctorName + "医生");
//        String sql = "DELETE FROM wlyy_door_doctor WHERE order_id ='"+orderId+"' AND doctor = '"+dispatcher+"'";
//        jdbcTemplate.execute(sql);
        this.save(doorServiceOrderDO);
        // 给医生发派单消息
        if(BaseDoorCoachOrderDO.IsTransOtherOrg.yes.getType().equals(doorServiceOrderDO.getIsTransOtherOrg())){
            this.createMessage("服务工单待接单","707",doorServiceOrderDO.getTransedDispatcher(),doorServiceOrderDO.getTransedDispatcherName(), orderId,doctor,doctorName, null,"您有新的服务工单,请前往处理");
        }else{
            this.createMessage("服务工单待接单","707",doorServiceOrderDO.getDispatcher(),doorServiceOrderDO.getDispatcherName(), orderId,doctor,doctorName, null,"您有新的服务工单,请前往处理");
        if (BaseDoorCoachOrderDO.IsTransOtherOrg.yes.getType().equals(doorServiceOrderDO.getIsTransOtherOrg())) {
            this.createMessage("服务工单待接单", "707", doorServiceOrderDO.getTransedDispatcher(), doorServiceOrderDO.getTransedDispatcherName(), orderId, doctor, doctorName, null, "您有新的服务工单,请前往处理");
        } else {
            this.createMessage("服务工单待接单", "707", doorServiceOrderDO.getDispatcher(), doorServiceOrderDO.getDispatcherName(), orderId, doctor, doctorName, null, "您有新的服务工单,请前往处理");
        }
        //发送智能助手消息
        sendWeixinMessage(4,doctor,doorServiceOrderDO.getPatient());
        sendWeixinMessage(4, doctor, doorServiceOrderDO.getPatient());
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getType();
        imUtill.updateParticipantNew(sessionId,doctor,null);
        imUtill.updateParticipantNew(sessionId, doctor, null);
        messageUtil.updateDoorCoachMessage(doorServiceOrderDO,new String[]{"702","703","730","735"},"731",dispatcher,dispatcher);
        messageUtil.updateDoorCoachMessage(doorServiceOrderDO, new String[]{"702", "703", "730", "735"}, "731", dispatcher, dispatcher);
        // 工单状态变更记录
        BaseDoorCoachProcessLogDO processLogDO = new BaseDoorCoachProcessLogDO();
@ -858,29 +863,30 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        result.put(ResponseContant.resultMsg, doorServiceOrderDO);
        // 发送IM消息通知患者医生已派单
        String noticeContent = "已转派"+doorServiceOrderDO.getDoctorName()+"医生为您服务,请耐心等待医生接单";
        this.qucikSendIM(doorServiceOrderDO.getId(), dispatcher, "智能助手","1", noticeContent);
        String noticeContent = "已转派" + doorServiceOrderDO.getDoctorName() + "医生为您服务,请耐心等待医生接单";
        this.qucikSendIM(doorServiceOrderDO.getId(), dispatcher, "智能助手", "1", noticeContent);
        return result;
    }
    /**
     * 取消工单
     *
     * @param orderId
     * @param type 取消类型
     * @param reason 取消理由
     * @param type    取消类型
     * @param reason  取消理由
     */
    public JSONObject cancelOrder(String orderId,int type,String reason,String dispatcher,String dispatcherName){
    public JSONObject cancelOrder(String orderId, int type, String reason, String dispatcher, String dispatcherName) {
        JSONObject result = new JSONObject();
        BaseDoorCoachOrderDO orderDO = baseDoorCoachOrderDao.findOne(orderId);
        if(null == orderDO){
        if (null == orderDO) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "【取消工单】该工单不存在:," + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if(type==2){//v0.5.1 患者仅未支付的订单能取消此时未正式开始工单,未创建咨询
            if(orderDO.getStatus() != BaseDoorCoachOrderDO.Status.waitForPay.getType()){
        if (type == 2) {//v0.5.1 患者仅未支付的订单能取消此时未正式开始工单,未创建咨询
            if (orderDO.getStatus() != BaseDoorCoachOrderDO.Status.waitForPay.getType()) {
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                String failMsg = "无法取消工单,已支付的工单需要到我的订单中进行申请退款," + orderId;
                result.put(ResponseContant.resultMsg, failMsg);
@ -890,60 +896,59 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
            businessOrderDO.setStatus(2);
            businessOrderDao.save(businessOrderDO);
        }else{//调度员拒单,此时工单已支付抵达调度员
        } else {//调度员拒单,此时工单已支付抵达调度员
            try {
                if (orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForPay.getType()&&1==orderDO.getPayWay()){
                if (orderDO.getStatus() > BaseDoorCoachOrderDO.Status.waitForPay.getType() && 1 == orderDO.getPayWay()) {
                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderDO.getId());
                    if (businessOrderDO!=null){
                    if (businessOrderDO != null) {
                        //1.4.2 上门辅导费用0时 无需走退款流程
                        if (1 == businessOrderDO.getStatus()&&businessOrderDO.getPayPrice()>0.0){
                        if (1 == businessOrderDO.getStatus() && businessOrderDO.getPayPrice() > 0.0) {
                            //退款流程
                            try {
                                payService.dispatcherOrderRefund(businessOrderDO.getOrderNo(),"调度员拒单退款");
                                payService.dispatcherOrderRefund(businessOrderDO.getOrderNo(), "调度员拒单退款");
                                orderDO.setPayStatus(2);
                            }catch (Exception e){
                            } catch (Exception e) {
                                e.printStackTrace();
                                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                                result.put(ResponseContant.resultMsg,"退款失败,无法拒绝工单!");
                                result.put(ResponseContant.resultMsg, "退款失败,无法拒绝工单!");
                                return result;
                            }
                        }
                    }
                }
                //如果是调度员取消,推送IM取消工单json消息,
                if (StringUtils.isNotBlank(dispatcher)){
                    if (!consultTeamService.finishConsult(orderDO.getId(),orderDO.getPatient(),dispatcher,2)){
                if (StringUtils.isNotBlank(dispatcher)) {
                    if (!consultTeamService.finishConsult(orderDO.getId(), orderDO.getPatient(), dispatcher, 2)) {
                        String failMsg = "咨询结束失败 无法取消工单";
                        result.put(ResponseContant.resultFlag, ResponseContant.fail);
                        result.put(ResponseContant.resultMsg,failMsg);
                        result.put(ResponseContant.resultMsg, failMsg);
                        return result;
                    }
                }
                if(!StringUtils.isEmpty(dispatcher)){
                if (!StringUtils.isEmpty(dispatcher)) {
                    orderDO.setDoctor(dispatcher);
                    orderDO.setDoctorName(dispatcherName);
                    orderDO.setDispatcher(dispatcher);
                    orderDO.setDispatcherName(dispatcherName);
                }
                if(type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()){
                    messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"732",dispatcher,dispatcher);
                }
                else if(type == BaseDoorCoachOrderDO.CancelType.patient.getType()){                   //居民取消,消息列表也应该不显示
                    messageUtil.updateDoorCoachMessage(orderDO,new String[]{"702","703","730"},"patientCancel",dispatcher,dispatcher);
                if (type == BaseDoorCoachOrderDO.CancelType.dispatcher.getType()) {
                    messageUtil.updateDoorCoachMessage(orderDO, new String[]{"702", "703", "730"}, "732", dispatcher, dispatcher);
                } else if (type == BaseDoorCoachOrderDO.CancelType.patient.getType()) {                   //居民取消,消息列表也应该不显示
                    messageUtil.updateDoorCoachMessage(orderDO, new String[]{"702", "703", "730"}, "patientCancel", dispatcher, dispatcher);
                }
                ConsultDo consult = consultDao.queryByRelationCode(orderId);
                // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
                String first = "key1您好,您的上门预约订单已退回,点击查看原因";
                BasePatientDO patient = patientDao.findById(orderDO.getPatient());
                first  = first.replace("key1", null != patient.getName() ? patient.getName() : "");
                first = first.replace("key1", null != patient.getName() ? patient.getName() : "");
                JSONObject json = new JSONObject();
                json.put("id", orderDO.getId());
                List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
                if (basePatientWechatDos.size()>0){
                List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId, patient.getId());
                if (basePatientWechatDos.size() > 0) {
                    String openId = basePatientWechatDos.get(0).getOpenid();
                    messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,2,json, DateUtil.dateToChineseDate(new Date()),"上门预约已取消","已取消");
                    messageUtil.putTemplateWxMessage(wxId, "template_process_feedback", "smyyyqx", openId, first, null, null, 2, json, DateUtil.dateToChineseDate(new Date()), "上门预约已取消", "已取消");
                }
            }catch (Exception e){
            } catch (Exception e) {
                e.printStackTrace();
                String failMsg = "退款失败,无法取消工单:," + orderId;
                result.put(ResponseContant.resultMsg, failMsg);
@ -969,14 +974,14 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        //保存居民确认取消记录
        JSONObject confirmInfo = new JSONObject();
        confirmInfo.put("orderId",orderId);
        confirmInfo.put("patient",orderDO.getProxyPatient());
        confirmInfo.put("patientName",orderDO.getProxyPatientName());
        confirmInfo.put("type",4);
        confirmInfo.put("description",reason);
        confirmInfo.put("orderId", orderId);
        confirmInfo.put("patient", orderDO.getProxyPatient());
        confirmInfo.put("patientName", orderDO.getProxyPatientName());
        confirmInfo.put("type", 4);
        confirmInfo.put("description", reason);
        JSONObject confirmInfoJson = new JSONObject();
        confirmInfoJson.put("confirmInfo",confirmInfo);
        this.orderWithConfirmLogAdd(result,confirmInfo,orderId);
        confirmInfoJson.put("confirmInfo", confirmInfo);
        this.orderWithConfirmLogAdd(result, confirmInfo, orderId);
        // 工单状态变更记录
@ -994,14 +999,14 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 服务工单居民确认操作日志记录
     *
     * <p>
     * {
     *     "confirmInfo":{
     *         "patient":"",
     *         "patientName":"",
     *         "type":"",
     *         "description":""
     *     }
     * "confirmInfo":{
     * "patient":"",
     * "patientName":"",
     * "type":"",
     * "description":""
     * }
     * }
     *
     * @param result
@ -1039,8 +1044,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        return false;
    }
    public void sendWeixinMessage(Integer type,String doctorCode,String patient){
        if (type==3){
    public void sendWeixinMessage(Integer type, String doctorCode, String patient) {
        if (type == 3) {
            //上门预约申请
            try {
/*                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","zztj");
@ -1065,7 +1070,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            } catch (Exception e) {
                e.printStackTrace();
            }
        }else if (type==4){
        } else if (type == 4) {
            try {
                //社区调度员指派服务工单给家签医生
/*                WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_doctor_survey","zztj");
@ -1096,6 +1101,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 调度员进入聊天室
     *
     * @param dispatcher
     * @param orderId
     */
@ -1110,21 +1116,23 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            return result;
        }
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = orderDO.getPatient() + "_" +  consult.getType();
        String sessionId = orderDO.getPatient() + "_" + consult.getType();
        // 把调度员拉入会话,作为其中一个成员,第一个进入会话的调度员,系统发送欢迎语和居民的预约卡片信息
        if (org.apache.commons.lang3.StringUtils.isEmpty(orderDO.getDispatcher())) {
            orderDO.setDispatcher(dispatcher);
            orderDO.setDispatcherName(dispatcherName);
            this.save(orderDO);
            // 先进入会话,再聊天
            imUtill.updateParticipantNew(sessionId,dispatcher,null);
            String imMsg = imUtill.updateParticipantNew(sessionId, dispatcher, null);
            System.out.println("先进入会话,再聊天==>" + imMsg);
            String noticeContent = hospitalName + dispatcherName + "为您服务";
            this.qucikSendIM(orderId, dispatcher, "智能助手", "1", noticeContent);
        }
        // 把调度员拉入会话,作为其中一个成员
        imUtill.updateParticipantNew(sessionId,dispatcher,null);
        String imMsg = imUtill.updateParticipantNew(sessionId, dispatcher, null);
        System.out.println("把调度员拉入会话,作为其中一个成员:" + imMsg);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "调度员["+dispatcherName+"]进入会话成功");
        result.put(ResponseContant.resultMsg, "调度员[" + dispatcherName + "]进入会话成功");
        return result;
    }
@ -1133,30 +1141,28 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     *
     * @param result
     * @param jsonObjectParam
     * @param order
     * {
     *     "packageItemArr":[
     *     {
     *    "type": null,
     *    "code": null,
     *    "name": null,
     *    "fee": null,
     *    "feeDiscount": null,
     *    "number": null,
     *    "status": null
     *  },
     *     ],
     *     "orderId": null,
     *     "status":""
     * }
     *
     * @param order           {
     *                        "packageItemArr":[
     *                        {
     *                        "type": null,
     *                        "code": null,
     *                        "name": null,
     *                        "fee": null,
     *                        "feeDiscount": null,
     *                        "number": null,
     *                        "status": null
     *                        },
     *                        ],
     *                        "orderId": null,
     *                        "status":""
     *                        }
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public boolean orderWithPackageItemFeeAdd(JSONObject result, JSONObject jsonObjectParam, BaseDoorCoachOrderDO order, String doctorId) {
        List<BaseDoorCoachFeeDetailDO> feeDetailDOList = new ArrayList<>();
        BigDecimal totalFee = order.getTotalFee();
        if(null == totalFee){
        if (null == totalFee) {
            totalFee = new BigDecimal(0);
        }
@ -1167,7 +1173,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        if (!CollectionUtils.isEmpty(packageItemArray)) {
            for (Object one : packageItemArray) {
                BaseDoorCoachFeeDetailDO feeDetailDO = null;
                JSONObject oneJson = (JSONObject)one;
                JSONObject oneJson = (JSONObject) one;
                try {
                    feeDetailDO = EntityUtils.jsonToEntity(one.toString(), BaseDoorCoachFeeDetailDO.class);
                } catch (Exception e) {
@ -1190,20 +1196,20 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                // 服务项可能一开始由居民预约,后期由医生新增或医生删除
                Integer status = jsonObjectParam.getInteger("status");
                if(null == status || status == 1){
                if (null == status || status == 1) {
                    feeDetailDO.setStatus(BaseDoorCoachFeeDetailDO.Status.patient.getType());
                }else{
                } else {
                    feeDetailDO.setStatus(status);
                }
//                feeDetailDO.setNumber(1);
                feeDetailDO.setOrderId(order.getId());
                if(StringUtils.isBlank(feeDetailDO.getId())) {
                if (StringUtils.isBlank(feeDetailDO.getId())) {
                    feeDetailDO.setCreateTime(new Date());
                }else {
                } else {
                    feeDetailDO.setUpdateTime(new Date());
                }
                if(StringUtils.isBlank(feeDetailDO.getId())){
                if (StringUtils.isBlank(feeDetailDO.getId())) {
                    feeDetailDO.setPayStatus(0);
                    addNum++;
                    feeDetailDOList.add(feeDetailDO);
@ -1225,8 +1231,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        return false;
    }
    public List<Map<String,Object>> queryDispatcherInfoByHospital(String hospital){
        String sql ="    SELECT" +
    public List<Map<String, Object>> queryDispatcherInfoByHospital(String hospital) {
        String sql = "    SELECT" +
                "                 d.`code`, " +
                "                 d.`name`, " +
                "                 d.`hospital_name` as hospitalName " +
@ -1234,7 +1240,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
                "                 base_doctor_role m " +
                "                 JOIN base_doctor_role_dict r ON m.role_code = r.code " +
                "                 JOIN (select a.id code,a.name,o.org_name hospital_name from base_doctor_hospital o,base_doctor a " +
                " where a.id = o.doctor_code and o.del=1 and o.org_code = '"+hospital+"') as d ON m.doctor_code = d.code" +
                " where a.id = o.doctor_code and o.del=1 and o.org_code = '" + hospital + "') as d ON m.doctor_code = d.code" +
                "                 WHERE " +
                "                 r.code = 'dispatcher'";
        return jdbcTemplate.queryForList(sql);
@ -1243,6 +1249,7 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 获取居民所签约的机构的调度员(一个机构可以有多个调度员)
     * doctor中,level -- 11-- 调度员
     *
     * @param hospitalCode
     * @return
     */
@ -1250,8 +1257,8 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    public JSONObject queryDispatcherInfoByPatient(String hospitalCode) {
        JSONObject result = new JSONObject();
        List<Map<String,Object>> dispatcherInfoList = queryDispatcherInfoByHospital(hospitalCode);
        if(CollectionUtils.isEmpty(dispatcherInfoList)){
        List<Map<String, Object>> dispatcherInfoList = queryDispatcherInfoByHospital(hospitalCode);
        if (CollectionUtils.isEmpty(dispatcherInfoList)) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前居民所签约机构【" + hospitalCode + "】没有调度员,请联系管理员分配!";
            result.put(ResponseContant.resultMsg, failMsg);
@ -1267,11 +1274,12 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 顶部状态栏订单各分类总条数
     *
     * @param patient
     * @return
     */
    public Map<String, Integer> getNumGroupByStatus(String patient) throws Exception {
        String sql = "SELECT a.status, COUNT(DISTINCT a.id) as num FROM base_door_coach_order a  where a.patient = '"+patient+"' group BY a.status " ;
        String sql = "SELECT a.status, COUNT(DISTINCT a.id) as num FROM base_door_coach_order a  where a.patient = '" + patient + "' group BY a.status ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        Map<String, Integer> map = new HashMap<>();
@ -1282,49 +1290,48 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        Integer served = 0;//已完成
        Integer cancel = 0;//已取消
        // -1已取消 [1,4]待服务 [5,6]已服务
        for (Map<String, Object> tmp:list){
            switch (String.valueOf(tmp.get("status"))){
        for (Map<String, Object> tmp : list) {
            switch (String.valueOf(tmp.get("status"))) {
                case "-1":
                    cancel += Integer.valueOf(tmp.get("num").toString()) ;
                    cancel += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "0":
                    waitForPay += Integer.valueOf(tmp.get("num").toString()) ;
                    waitForPay += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "1":
                    waitForAccept += Integer.valueOf(tmp.get("num").toString()) ;
                    waitForAccept += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "2":
                    waitForAccept += Integer.valueOf(tmp.get("num").toString()) ;
                    waitForAccept += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "3":
                    waitForServe += Integer.valueOf(tmp.get("num").toString()) ;
                    waitForServe += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "4":
                    waitForServe += Integer.valueOf(tmp.get("num").toString()) ;
                    waitForServe += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "5":
                    waitForServe += Integer.valueOf(tmp.get("num").toString()) ;
                    waitForServe += Integer.valueOf(tmp.get("num").toString());
                    break;
                case "6":
                    served += Integer.valueOf(tmp.get("num").toString()) ;
                    served += Integer.valueOf(tmp.get("num").toString());
                    break;
                default: {
                    throw new Exception("类型错误!"+String.valueOf(tmp.get("status")));
                    throw new Exception("类型错误!" + String.valueOf(tmp.get("status")));
                }
            }
        }
        all = waitForAccept+waitForServe+served+cancel;
        map.put("all",all);
        map.put("waitForPay",waitForPay);
        map.put("waitForAccept",waitForAccept);
        map.put("waitForServe",waitForServe);
        map.put("served",served);
        map.put("cancel",cancel);
        all = waitForAccept + waitForServe + served + cancel;
        map.put("all", all);
        map.put("waitForPay", waitForPay);
        map.put("waitForAccept", waitForAccept);
        map.put("waitForServe", waitForServe);
        map.put("served", served);
        map.put("cancel", cancel);
        return map;
    }
    /**
     *
     * @param orderId
     * @param patientName
     * @param patientPhone
@ -1342,111 +1349,126 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
     */
    public JSONObject getDoorOrderList(String orderId, String patientName, String patientPhone, String hospitalCode,
                                       StringBuffer status, String createTimeStart, String createTimeEnd, String serverDoctorName,
                                       String patientId, Integer page, Integer pageSize, Integer type)throws Exception{
                                       String patientId, Integer page, Integer pageSize, Integer type) throws Exception {
        String sqlList = "select DISTINCT o.id as orderId,o.status,h.code orgCode,h.name as orgName,o.is_trans_other_org," +
                "o.transed_org_code, o.patient_name, o.patient_phone,o.remark,o.serve_desc,o.create_time,o.patient as patientCode," +
                "o.exam_paper_status as examPaperStatus,o.number as serverCode,o.total_fee,h.org_level as hosLevel, o.doctor," +
                "o.doctor_name as doctorName, o.doctor_type as doctorType"
                ;
                "o.doctor_name as doctorName, o.doctor_type as doctorType";
        String sqlCount = " select count(DISTINCT o.id) as total ";
        String sql = " from base_door_coach_order o LEFT JOIN base_org h on h.code=o.hospital and h.del=1 where 1=1";
        if(!org.apache.commons.lang.StringUtils.isEmpty(orderId)){
            sql+=" and o.number = '"+orderId+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(orderId)) {
            sql += " and o.number = '" + orderId + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(patientName)){
            sql+=" and o.patient_name like '%"+patientName+"%'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(patientName)) {
            sql += " and o.patient_name like '%" + patientName + "%'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(patientPhone)){
            sql+=" and o.patient_phone ='"+patientPhone+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(patientPhone)) {
            sql += " and o.patient_phone ='" + patientPhone + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(hospitalCode)&&!"350200%".equals(hospitalCode)){
            sql+=" and (o.hospital like '"+hospitalCode+"' or o.transed_org_code like '"+hospitalCode+"') ";
        if (!org.apache.commons.lang.StringUtils.isEmpty(hospitalCode) && !"350200%".equals(hospitalCode)) {
            sql += " and (o.hospital like '" + hospitalCode + "' or o.transed_org_code like '" + hospitalCode + "') ";
        }
        if(status!=null){
            sql+=" and o.status in ("+status+")";
        if (status != null) {
            sql += " and o.status in (" + status + ")";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(createTimeStart)){
            sql+=" and o.create_time >='"+createTimeStart+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(createTimeStart)) {
            sql += " and o.create_time >='" + createTimeStart + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(createTimeEnd)){
            sql+=" and o.create_time <='"+createTimeEnd+"'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(createTimeEnd)) {
            sql += " and o.create_time <='" + createTimeEnd + "'";
        }
        if(!org.apache.commons.lang.StringUtils.isEmpty(serverDoctorName)){
            sql+=" and o.doctor_name like '%"+serverDoctorName+"%'";
        if (!org.apache.commons.lang.StringUtils.isEmpty(serverDoctorName)) {
            sql += " and o.doctor_name like '%" + serverDoctorName + "%'";
        }
        //获取医生代预约记录
        if (type!=null){
            sql += " and o.type = " + type +" ";
        if (type != null) {
            sql += " and o.type = " + type + " ";
        }
        if(org.apache.commons.lang.StringUtils.isNotBlank(patientId)){
            sql += " and o.patient= '"+patientId+"' ";
        if (org.apache.commons.lang.StringUtils.isNotBlank(patientId)) {
            sql += " and o.patient= '" + patientId + "' ";
        }
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(sqlCount+sql);
        sql+=" order by o.create_time desc LIMIT "+(page-1)*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sqlList+sql);
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(sqlCount + sql);
        sql += " order by o.create_time desc LIMIT " + (page - 1) * pageSize + "," + pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sqlList + sql);
        Long count = 0L;
        if(rstotal!=null&&rstotal.size()>0){
        if (rstotal != null && rstotal.size() > 0) {
            count = (Long) rstotal.get(0).get("total");
        }
        JSONArray jsonArray = new JSONArray();
        for(Map<String,Object> one:list){
        for (Map<String, Object> one : list) {
            JSONObject object = new JSONObject();
            object.put("id",one.get("orderId"));
            object.put("serverCode",one.get("serverCode"));
            Integer statustemp = Integer.valueOf(one.get("status")+"");
            object.put("id", one.get("orderId"));
            object.put("serverCode", one.get("serverCode"));
            Integer statustemp = Integer.valueOf(one.get("status") + "");
            String statusName = "";
            switch (statustemp){
                case -1:statusName="已取消";break;
                case 0:statusName="待付款";break;
                case 1:statusName="待接单";break;
                case 2:statusName="待接单";break;
                case 3:statusName="待服务";break;
                case 4:statusName="待服务";break;
                case 5:statusName="待服务";break;
                case 6:statusName="已完成";break;
            switch (statustemp) {
                case -1:
                    statusName = "已取消";
                    break;
                case 0:
                    statusName = "待付款";
                    break;
                case 1:
                    statusName = "待接单";
                    break;
                case 2:
                    statusName = "待接单";
                    break;
                case 3:
                    statusName = "待服务";
                    break;
                case 4:
                    statusName = "待服务";
                    break;
                case 5:
                    statusName = "待服务";
                    break;
                case 6:
                    statusName = "已完成";
                    break;
            }
            object.put("status",statustemp);
            object.put("statusName",statusName);
            object.put("status", statustemp);
            object.put("statusName", statusName);
            //工单是否转给其他机构,0-不转,1-已转
            String transOtherOrg = one.get("is_trans_other_org")+"";
            String transOtherOrg = one.get("is_trans_other_org") + "";
            Object hospitalName = null;
            Object hospital = null;
            hospital = one.get("orgCode");
            hospitalName = one.get("orgName");//签约表中的机构
            object.put("hospital",hospital);
            object.put("hospitalName",hospitalName);
            object.put("patient",one.get("patientCode"));
            object.put("patientName",one.get("patient_name"));
            object.put("patientPhone",one.get("patient_phone"));
            object.put("remark",one.get("remark"));
            object.put("serveDesc",one.get("serve_desc"));
            object.put("hosLevel",one.get("hosLevel"));
            Date date = (Date)one.get("create_time");
            object.put("createTime",DateUtil.dateToStrLong(date));
            object.put("examPaperStatus",one.get("examPaperStatus"));
            object.put("totalFee",one.get("total_fee"));
            List<BaseDoorCoachFeeDetailDO> feeDetailDOs = doorFeeDetailDao.findByOrderIdAndType(one.get("orderId")+"", 1);
            List<Map<String,Object>> feeDetailResultList = new ArrayList();
            for(BaseDoorCoachFeeDetailDO d:feeDetailDOs){
                Map<String,Object> map = new HashMap<>();
                map.put("code",d.getCode());
                map.put("name",d.getName());
                map.put("fee",d.getFee());
                map.put("number",d.getNumber());
            object.put("hospital", hospital);
            object.put("hospitalName", hospitalName);
            object.put("patient", one.get("patientCode"));
            object.put("patientName", one.get("patient_name"));
            object.put("patientPhone", one.get("patient_phone"));
            object.put("remark", one.get("remark"));
            object.put("serveDesc", one.get("serve_desc"));
            object.put("hosLevel", one.get("hosLevel"));
            Date date = (Date) one.get("create_time");
            object.put("createTime", DateUtil.dateToStrLong(date));
            object.put("examPaperStatus", one.get("examPaperStatus"));
            object.put("totalFee", one.get("total_fee"));
            List<BaseDoorCoachFeeDetailDO> feeDetailDOs = doorFeeDetailDao.findByOrderIdAndType(one.get("orderId") + "", 1);
            List<Map<String, Object>> feeDetailResultList = new ArrayList();
            for (BaseDoorCoachFeeDetailDO d : feeDetailDOs) {
                Map<String, Object> map = new HashMap<>();
                map.put("code", d.getCode());
                map.put("name", d.getName());
                map.put("fee", d.getFee());
                map.put("number", d.getNumber());
                feeDetailResultList.add(map);
            }
            object.put("feeDetailResultList",feeDetailResultList);
            object.put("feeDetailResultList", feeDetailResultList);
            // 获取或者基本信息
            BasePatientDO patient = patientInfoService.findById(String.valueOf(one.get("patientCode")));
            if (patient != null) {
                object.put("sex", IdCardUtil.getSexForIdcard(patient.getIdcard()));
                object.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday()));
                object.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(), patient.getBirthday()));
                object.put("photo", patient.getPhoto());
//                object.put("typeValue", "儿童");
@ -1456,9 +1478,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
            //获取咨询
            ConsultDo consult = consultDao.queryByRelationCode(id);
            if (null != consult) {
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() +  "_" +  consult.getType());
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getType());
            }
            object.put("sessionId",doorServiceOrder.getSessionId());
            object.put("sessionId", doorServiceOrder.getSessionId());
            // 获取服务次数
            Integer serviceCount = doctorDoorCoachOrderService.serviceCount(doorServiceOrder.getPatient());
@ -1472,15 +1494,15 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        }
        JSONObject object = new JSONObject();
        object.put("total",count);
        object.put("detailModelList",jsonArray);
        object.put("currPage",page);
        object.put("pageSize",pageSize);
        object.put("total", count);
        object.put("detailModelList", jsonArray);
        object.put("currPage", page);
        object.put("pageSize", pageSize);
        return object;
    }
    @Transactional(rollbackFor = Exception.class)
    public JSONObject updateOrderCardInfo(String jsonData){
    public JSONObject updateOrderCardInfo(String jsonData) {
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
@ -1498,41 +1520,41 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        wlyyDoorServiceOrder.setPatientName(jsonObjectParam.getString("patientName"));
        // 居民电话
        if(!StringUtils.isEmpty(jsonObjectParam.getString("phone"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("phone"))) {
            wlyyDoorServiceOrder.setPatientPhone(jsonObjectParam.getString("phone"));
        }
        // 医生预计达到时间
        if(!StringUtils.isEmpty(jsonObjectParam.getString("doctorArrivingTime"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("doctorArrivingTime"))) {
            wlyyDoorServiceOrder.setDoctorArrivingTime(jsonObjectParam.get("doctorArrivingTime").toString());
        }
        // 居民期望服务时间
        if(!StringUtils.isEmpty(jsonObjectParam.getString("patientExpectedServeTime"))){
        wlyyDoorServiceOrder.setPatientExpectedServeTime(jsonObjectParam.get("patientExpectedServeTime").toString());
        if (!StringUtils.isEmpty(jsonObjectParam.getString("patientExpectedServeTime"))) {
            wlyyDoorServiceOrder.setPatientExpectedServeTime(jsonObjectParam.get("patientExpectedServeTime").toString());
        }
        // 服务区
        if(!StringUtils.isEmpty(jsonObjectParam.getString("serveTown"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("serveTown"))) {
            wlyyDoorServiceOrder.setServeTown(jsonObjectParam.getString("serveTown"));
        }
        // 服务地址
        if(!StringUtils.isEmpty(jsonObjectParam.getString("serveAddress"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("serveAddress"))) {
            wlyyDoorServiceOrder.setServeAddress(jsonObjectParam.getString("serveAddress"));
        }
        wlyyDoorServiceOrder.setServeAddress(jsonObjectParam.getString("serveAddress"));
        if(!StringUtils.isEmpty(jsonObjectParam.getString("serveLat"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("serveLat"))) {
            wlyyDoorServiceOrder.setServeLat(jsonObjectParam.getString("serveLat"));
        }
        if(!StringUtils.isEmpty(jsonObjectParam.getString("serveLon"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("serveLon"))) {
            wlyyDoorServiceOrder.setServeLon(jsonObjectParam.getString("serveLon"));
        }
        // 服务描述
        if(!StringUtils.isEmpty(jsonObjectParam.getString("serveDesc"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("serveDesc"))) {
            wlyyDoorServiceOrder.setServeDesc(jsonObjectParam.getString("serveDesc"));
        }
        //服务类型    医生端和居民端公用接口
        if(!StringUtils.isEmpty(jsonObjectParam.getString("serviceStatus"))){
        if (!StringUtils.isEmpty(jsonObjectParam.getString("serviceStatus"))) {
            wlyyDoorServiceOrder.setServiceStatus(jsonObjectParam.getString("serviceStatus"));
        }else {
        } else {
            wlyyDoorServiceOrder.setServiceStatus("1");//默认为1  预约项目
        }
//        wlyyDoorServiceOrder.setIsPatientConfirm(WlyyDoorServiceOrderDO.IsPatientConfirm.yes.getType());
@ -1540,7 +1562,9 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        this.save(wlyyDoorServiceOrder);
        //新增工单居民确认操作日志记录
        if (orderWithConfirmLogAdd(result, jsonObjectParam, wlyyDoorServiceOrder.getId())) {return result;}
        if (orderWithConfirmLogAdd(result, jsonObjectParam, wlyyDoorServiceOrder.getId())) {
            return result;
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, wlyyDoorServiceOrder);
@ -1548,16 +1572,15 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
        //发送 预约卡片信息(2101类型)
        JSONObject orderInfoContent = this.queryOrderCardInfo(wlyyDoorServiceOrder);
        orderInfoContent.put("re_msg_type",1);//医生修改待确认
        orderInfoContent.put("re_msg_type", 1);//医生修改待确认
        this.qucikSendIM(wlyyDoorServiceOrder.getId(), wlyyDoorServiceOrder.getDispatcher(), "智能助手", "2201", orderInfoContent.toJSONString());
        return result;
    }
    /**
     * 添加【工单派单,转单】等系统消息
     */
    public void createMessage(String title,String type,String sender,String senderName,String relationCode,String Receiver,String ReceiverName,String idCard,String msg){
    public void createMessage(String title, String type, String sender, String senderName, String relationCode, String Receiver, String ReceiverName, String idCard, String msg) {
        SystemMessageDO messageDO = new SystemMessageDO();
        messageDO.setTitle(title);
        messageDO.setType(type);//401为资质申请审核
@ -1575,22 +1598,23 @@ public class PatientDoorCoachOrderService extends BaseJpaService<BaseDoorCoachOr
    /**
     * 统计居民已经服务的次数
     *
     * @param patient
     * @return
     */
    public Integer countPatientDoorTimes(String patient){
    public Integer countPatientDoorTimes(String patient) {
        Integer count = 0;
        String sql = "SELECT count(o.id) as count FROM base_door_coach_order o where  o.patient = '" + patient + "' and status>="+BaseDoorCoachOrderDO.Status.waitForCommnet.getType();
        count = jdbcTemplate.queryForObject(sql,Integer.class);
        String sql = "SELECT count(o.id) as count FROM base_door_coach_order o where  o.patient = '" + patient + "' and status>=" + BaseDoorCoachOrderDO.Status.waitForCommnet.getType();
        count = jdbcTemplate.queryForObject(sql, Integer.class);
        return count;
    }
    private String getRandomIntStr(){
    private String getRandomIntStr() {
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数
        i = rand.nextInt(100); //生成0-100以内的随机数
        i = (int)(Math.random() * 100000000); //0-100以内的随机数,用Matn.random()方式
        i = (int) (Math.random() * 100000000); //0-100以内的随机数,用Matn.random()方式
        return String.valueOf(i);
    }
}

+ 54 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/pay/PayService.java

@ -1,7 +1,6 @@
package com.yihu.jw.care.service.pay;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;
@ -9,12 +8,16 @@ import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachFeeDetailDao;
import com.yihu.jw.care.dao.doorCoach.BaseDoorCoachOrderDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareFeeDetailDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareOrderDao;
import com.yihu.jw.care.dao.sign.ServicePackageItemDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.service.doorCoach.PatientDoorCoachOrderService;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.WxpayUtil;
import com.yihu.jw.care.util.XMLUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.care.common.WxPayHttpLogDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachFeeDetailDO;
@ -22,13 +25,9 @@ import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.hospital.healthCare.YlzMedicalRelationDO;
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
import com.yihu.jw.entity.hospital.prescription.WlyyOutpatientDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionDO;
import com.yihu.jw.entity.hospital.prescription.WlyyPrescriptionInfoDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
@ -110,6 +109,14 @@ public class PayService {
    private LifeCareFeeDetailDao lifeCareFeeDetailDao;
    @Autowired
    private BaseDoorCoachFeeDetailDao doorCoachFeeDetailDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private ServicePackageSignRecordDao signRecordDao;
    @Autowired
    private ServicePackageItemDao servicePackageItemDao;
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    /**
     * 顶部状态栏订单各分类总条数
@ -231,6 +238,9 @@ public class PayService {
        }else if("4".equals(type)){
            List<LifeCareFeeDetailDO> feeDetailDOList = lifeCareFeeDetailDao.findByOrderId(businessOrderDO.getRelationCode());
            resJson.put("fees",feeDetailDOList);
        }else if("5".equals(type)){
            List<ServicePackageItemDO> feeDetailDOList = servicePackageItemDao.findByServicePackageId(businessOrderDO.getRelationCode());
            resJson.put("fees",feeDetailDOList);
        }
        //退款信息
        if(status>2){
@ -367,6 +377,13 @@ public class PayService {
                result.put(ResponseContant.resultMsg, "支付工单不存在");
                return result;
            }
        }else if("5".equals(category)){
            ServicePackageSignRecordDO orderDO = signRecordDao.findOne(orderId);
            if (orderDO==null){
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg, "支付工单不存在");
                return result;
            }
        }
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
        if (businessOrderDO==null){
@ -524,6 +541,10 @@ public class PayService {
                //desc = "生活照料服务";
                lifeCareOrderService.payOrderAfter(orderDO.getRelationCode());
                break;
            case "5":
                //签约服务包
                servicePackageService.payOrderAfter(orderDO.getRelationCode());
                break;
            default:
                break;
        }
@ -564,6 +585,10 @@ public class PayService {
                //desc = "生活照料服务";
                lifeCareOrderService.refundOrderAfter(businessOrderDO.getRelationCode());
                break;
            case "5":
                //签约服务包相关
                servicePackageService.refundOrderAfter(businessOrderDO.getRelationCode());
                break;
            default:
                break;
        }
@ -616,7 +641,12 @@ public class PayService {
        reqMap.put("mch_id", mchId);
        reqMap.put("nonce_str", noceStr);
        // 此路径是微信服务器调用支付结果通知路径
        reqMap.put("notify_url", "https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/wxPayNotify");
        String notifyUrl ="https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/wxPayNotify";
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("wxPayNotify");
        if(dictDO!=null){
            notifyUrl = dictDO.getDictValue();
        }
        reqMap.put("notify_url", notifyUrl);
        reqMap.put("out_trade_no", businessOrderDO.getOrderNo());
        reqMap.put("spbill_create_ip", IpUtil.getOneIpAddress(request));
        reqMap.put("product_id", businessOrderDO.getOrderNo());
@ -696,7 +726,12 @@ public class PayService {
        reqMap.put("mch_id", mchId);
        reqMap.put("nonce_str", noceStr);
        // 此路径是微信服务器调用支付结果通知路径
        reqMap.put("notify_url", "https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/wxPayNotify");
        String notifyUrl ="https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/wxPayNotify";
        WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("wxPayNotify");
        if(dictDO!=null){
            notifyUrl = dictDO.getDictValue();
        }
        reqMap.put("notify_url", notifyUrl);
        reqMap.put("out_trade_no", businessOrderDO.getOrderNo());
        reqMap.put("spbill_create_ip", IpUtil.getOneIpAddress(request));
        reqMap.put("product_id", businessOrderDO.getOrderNo());
@ -744,7 +779,7 @@ public class PayService {
    /**
     * 提交支付订单
     * 订单类型 1招生,2 课程,3 上门辅导托幼) 4 生活照料
     * 订单类型 1招生,2 课程,3 上门辅导托幼) 4 生活照料 5签约服务包
     * @return
     */
    public BusinessOrderDO submitOrder(String patientId,String type,String relationCode,Double price){
@ -776,6 +811,10 @@ public class PayService {
                desc = "生活照料服务项目费";
                relateName = "生活照料";
                break;
            case "5":
                desc = "签约服务包费";
                relateName = "签约服务包";
                break;
            default:
                desc = "服务费";
                relateName = "服务";
@ -868,7 +907,7 @@ public class PayService {
            }
            if (businessOrderDO!=null){
                if (businessOrderDO.getStatus()==1){
                    throw new Exception("该处方已支付过");
                    throw new Exception("该订单已支付过");
                }
                String openId = "";
                if (StringUtils.isNotBlank(appletCode)){
@ -886,6 +925,10 @@ public class PayService {
                businessOrderDO.setOrderNo(getOrderNo());
                businessOrderDO= businessOrderDao.save(businessOrderDO);
                String notifyUrl ="https://zhyzh.gongshu.gov.cn/cloudCare/pay/open/cloudPayNotify";
                WlyyHospitalSysDictDO dictDO = hospitalSysDictDao.findById("cloudPayNotify");
                if(dictDO!=null){
                    notifyUrl = dictDO.getDictValue();
                }
                String totalFee =businessOrderDO.getPayPrice().intValue()+"";
                map = businessOrderService.unifiedorder(wechatId,businessOrderDO.getDescription(),totalFee, depositType,openId,businessOrderDO.getOrderNo(),notifyUrl,businessOrderDO.getPatient());
            }

+ 480 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -1,13 +1,16 @@
package com.yihu.jw.care.service.sign;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.dao.sign.*;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.pay.PayService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
@ -16,24 +19,28 @@ import com.yihu.jw.entity.base.servicePackage.*;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
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.ServiceException;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
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.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@ -70,7 +77,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    @Autowired
    private BasePatientMedicardCardService basePatientMedicardCardService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private PayService payService;
    @Autowired
    private PatientBedApplyDao bedApplyDao;
    @Autowired
@ -83,7 +90,478 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    private DeviceService deviceService;
    @Autowired
    private BasePatientHelperDao patientHelperDao;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    //我的医养团队
    public List<Map<String,Object>> mySignDoctor(String patientId){
        String sql = "SELECT DISTINCT d.id,d.name,d.sex,d.mobile,d.idcard,d.photo,d.doctor_level level,di.dict_value levelName " +
                "from base_service_package_sign_record sr,base_service_package_record r,base_doctor d " +
                "LEFT JOIN wlyy_hospital_sys_dict di on di.dict_name='doctor_level' and di.dict_code=d.doctor_level " +
                "WHERE sr.patient = '"+patientId+"' and sr.`status`=1 and sr.id=r.sign_id and r.type='2' and r.doctor=d.id ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    //退款处理
    public JSONObject refundOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        ServicePackageSignRecordDO orderDO = servicePackageSignRecordDao.findOne(orderId);
        if (orderDO == null){
            String failMsg = "工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        orderDO.setPayStatus(2);//暂时只修改支付状态
        orderDO.setStatus(-5);//已退款
        servicePackageSignRecordDao.save(orderDO);
        String failMsg = "success";
        result.put(ResponseContant.resultFlag, ResponseContant.fail);
        result.put(ResponseContant.resultMsg, failMsg);
        return result;
    }
    //支付完成后开始订单
    public JSONObject payOrderAfter(String orderId) {
        JSONObject result = new JSONObject();
        BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(orderId);
        if (businessOrderDO==null){
            String failMsg = "未查询到该订单";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        ServicePackageSignRecordDO orderDO = servicePackageSignRecordDao.findOne(orderId);
        if (orderDO!=null) {
            orderDO.setPayStatus(1);
            orderDO.setPayWay(1);
            orderDO.setPaymentTime(new Date());
            orderDO.setStatus(1);
            servicePackageSignRecordDao.save(orderDO);
            //设置到期时间
            setSignDate(null,orderDO);
        }else {
            String failMsg = "工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "success");
        return result;
    }
    //分配服务者
    @Transactional(rollbackFor = Exception.class)
    public void allocationDoctor(String jsonData) throws Exception{
        List<ServicePackageRecordDO> recordDOList = new ArrayList<>();
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(jsonData, javaType);
        for (Map<String, String> map:list){
            ServicePackageRecordDO recordDO = new ServicePackageRecordDO();
            String signId = map.get("signId");
            String servicePackageId = map.get("servicePackageId");
            String patient = map.get("patient");
            String packageItemId = map.get("packageItemId");
            String type = map.get("serviceType");
            String doctor = map.get("doctor");
            String doctorName = map.get("doctorName");
            String id = map.get("recordId");
            if(StringUtils.isNotBlank(id)&&!"null".equals(id)){
                recordDO.setCreateTime(new Date());
                recordDO.setId(id);
            }
            recordDO.setPatient(patient);
            recordDO.setSignId(signId);
            recordDO.setServicePackageId(servicePackageId);
            recordDO.setPackageItemId(packageItemId);
            recordDO.setDoctor(doctor);
            recordDO.setDoctorName(doctorName);
            recordDO.setType(type);
            recordDOList.add(recordDO);
        }
        servicePackageRecordDao.save(recordDOList);
    }
    /**
     * 签约审核
     * @param id 申请记录id
     * @param uid
     * @param status 1同意 2拒绝
     * @param refuseType 拒绝原因
     * @param refuseReason 拒绝说明
     */
    @Transactional(rollbackFor = Exception.class)
    public void check(String id,String uid,String status,String refuseType,String refuseReason){
        ServicePackageSignRecordDO signRecordDO = servicePackageSignRecordDao.findOne(id);
        if(signRecordDO.getStatus()!=0){
            throw new ServiceException("只有待审核记录才能审核");
        }
        BaseDoctorDO doctorDO = doctorDao.findById(uid);
        signRecordDO.setCheckTime(DateUtil.getStringDate());
        if(doctorDO!=null){
            signRecordDO.setCheckDoctor(doctorDO.getId());
            signRecordDO.setCheckDoctorName(doctorDO.getName());
        }
        if("2".equals(status)){
            signRecordDO.setStatus(-4);
            signRecordDO.setRefuseType(refuseType);
            signRecordDO.setRefuseReason(refuseReason);
        }else {
            signRecordDO.setStatus(2);
            ServicePackageDO servicePackageDO = servicePackageDao.findOne(signRecordDO.getServicePackageId());
            //判断支付金额
            if(new BigDecimal(0).compareTo(servicePackageDO.getPrice())==0){
                //不需要支付
                signRecordDO.setStatus(1);//已签约
                //设置到期时间
                setSignDate(servicePackageDO,signRecordDO);
            }else{
                signRecordDO.setPayTime((3*24*60)+"");//3天 单位分钟
            }
        }
        servicePackageSignRecordDao.save(signRecordDO);
    }
    /**
     * 签约服务
     */
    public Map<String,Object> mySign(String patient){
        String sql = "SELECT DISTINCT ar.level_conclusion,di2.dict_value levelConclusionName,p.id" +
                ",p.`name`,p.sex,p.mobile,p.idcard,p.birthday,p.openid,p.photo ";
        String filter = " from base_patient p  " +
                " inner JOIN base_service_package_sign_record r on p.id = r.patient and r.status=1 " +
                " LEFT JOIN base_capacity_assessment_record ar on ar.patient = p.id and ar.assessment_time>= '" + DateUtil.getNowYear() + "-01-01' " +
                " LEFT JOIN wlyy_hospital_sys_dict di2 on di2.dict_name = 'level_conclusion' and di2.dict_code=ar.level_conclusion " +
                " where 1=1 ";
        filter += " and r.patient = '"+patient+"' ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter);
        String packageSql = "SELECT r.id,DATE_FORMAT(r.end_time,'%Y-%m-%d %H:%i:%S') endTime,r.type,p.`name`,p.num from base_service_package_sign_record r,base_service_package p " +
                "WHERE r.patient =? and r.`status`=1 and r.service_package_id=p.id ";
        for (Map<String,Object> map:list){
            String idcard = map.get("idcard")+"";
            String birthday = map.get("birthday")+"";
            map.put("age", IdCardUtil.getAgeByBirthdayStrOrIdcard(idcard,birthday));
            List<Map<String,Object>> packageList = jdbcTemplate.queryForList(packageSql,new Object[]{patient});
            map.put("packageList",packageList);
        }
        return list.get(0);
    }
    /**
     * 签约人数列表
     * status 状态 0待审核 1已签约 2待支付 3已拒绝 -1已过期 -2已失效 -3已撤销
     */
    public PageEnvelop signNumPage(String doctorId,String name,Integer page,Integer size){
        String sql = "SELECT DISTINCT ar.level_conclusion,di2.dict_value levelConclusionName,p.id" +
                ",p.`name`,p.sex,p.mobile,p.idcard,p.birthday,p.openid,p.photo ";
        String countSql = "select count(distinct p.id) ";
        String filter = " from base_patient p  " +
                " inner JOIN base_service_package_sign_record r on p.id = r.patient and r.status=1 " +
                " LEFT JOIN base_capacity_assessment_record ar on ar.patient = p.id and ar.assessment_time>= '" + DateUtil.getNowYear() + "-01-01' " +
                " LEFT JOIN wlyy_hospital_sys_dict di2 on di2.dict_name = 'level_conclusion' and di2.dict_code=ar.level_conclusion " +
                " where 1=1 ";
        if(StringUtils.isNotBlank(doctorId)){
            filter += " and r.check_doctor = '"+doctorId+"' ";
        }
        if(StringUtils.isNotBlank(name)){
            filter += " and p.name like '%"+name+"%' ";
        }
        String oderBy = " order by r.id desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+oderBy);
        String packageSql = "SELECT r.id,DATE_FORMAT(r.end_time,'%Y-%m-%d %H:%i:%S') endTime,r.type,p.`name`,p.num from base_service_package_sign_record r,base_service_package p " +
                "WHERE r.patient =? and r.`status`=1 and r.service_package_id=p.id ";
        for (Map<String,Object> map:list){
            String id = map.get("id")+"";
            String idcard = map.get("idcard")+"";
            String birthday = map.get("birthday")+"";
            map.put("age", IdCardUtil.getAgeByBirthdayStrOrIdcard(idcard,birthday));
            List<Map<String,Object>> packageList = jdbcTemplate.queryForList(packageSql,new Object[]{id});
            map.put("packageList",packageList);
        }
        long count = jdbcTemplate.queryForObject(countSql+filter+oderBy,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    /**
     * 获取签约总人数
     * @param doctorId
     * @return
     */
    public int doctorSignTotal(String doctorId){
        String sql = "SELECT COUNT(distinct sr.patient) from base_service_package_sign_record sr " +
                "WHERE sr.status=1 and sr.check_doctor = '"+doctorId+"' ";
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    //签约服务包数
    public int doctorSignServerPackageTotal(String doctorId){
        String sql = "SELECT COUNT(sr.service_package_id) from base_service_package_sign_record sr " +
                "WHERE sr.status=1 and sr.check_doctor = '"+doctorId+"' ";
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    /**
     * 签约详情
     * @param id
     * @param type 1返回分配情况  0不返回
     * @return
     * @throws Exception
     */
    public JSONObject signInfo(String id,String type){
        JSONObject json = new JSONObject();
        ServicePackageSignRecordDO signRecordDO = servicePackageSignRecordDao.findOne(id);
        ServicePackageDO servicePackageDO = servicePackageDao.findOne(signRecordDO.getServicePackageId());
        List<ServicePackageItemDO> itemDOList = null;
        if("1".equals(type)){
            String sql = "SELECT i.*,r.id recordId,r.doctor,r.doctor_name,r.type serviceType from base_service_package_item i " +
                    "LEFT JOIN base_service_package_record r on r.sign_id='"+id+"' and r.package_item_id=i.id " +
                    "WHERE i.service_package_id ='"+servicePackageDO.getId()+"' and i.del='1' ";
            itemDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(ServicePackageItemDO.class));
        }else {
            itemDOList = servicePackageItemDao.findByServicePackageId(signRecordDO.getServicePackageId());
        }
        servicePackageDO.setPackageItemDOList(itemDOList);
        json.put("signRecordDO",signRecordDO);
        json.put("servicePackageDO",servicePackageDO);
        return json;
    }
    //签约各状态数 状态新- 0待审核 1已签约 2待支付 -4已拒绝 -1已过期 -2已失效 -3已撤销
    public JSONObject signTopNum(String doctorId){
        JSONObject result = new JSONObject();
        int total = 0;
        int auditNum = 0;//待审核
        int payNum = 0;//待支付
        int signNum = 0;//已签约
        int expiredNum = 0;//已到期
        String sql = "SELECT COUNT(sr.id) num,status  from base_service_package_sign_record sr " +
                "WHERE sr.status=1 and sr.check_doctor = '"+doctorId+"' group by status";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map :list){
            String status = map.get("status")+"";
            int num = Integer.parseInt(map.get("num")+"");
            total += num;
            if("0".equals(status)){
                auditNum = num;
                continue;
            }
            if("2".equals(status)){
                payNum = num;
                continue;
            }
            if("1".equals(status)){
                signNum = num;
                continue;
            }
            if("-1".equals(status)){
                expiredNum = num;
            }
        }
        result.put("total",total);
        result.put("auditNum",auditNum);
        result.put("payNum",payNum);
        result.put("signNum",signNum);
        result.put("expiredNum",expiredNum);
        return result;
    }
    /**
     * 签约记录
     * status 状态 0待审核 1已签约 2待支付 3已拒绝 -1已过期 -2已失效 -3已撤销
     */
    public PageEnvelop signPage(String patientId,String doctorId,String name,String status,Integer page,Integer size){
        String sql = "SELECT DISTINCT ar.level_conclusion,di2.dict_value levelConclusionName,r.id,r.`status`,di.dict_value statusName" +
                ",r.patient,p.`name`,p.sex,p.mobile,p.idcard,p.birthday,p.openid " +
                ",p.photo,DATE_FORMAT(r.create_time,'%Y-%m-%d %H:%i:%S') createTime,r.type,sp.`name` packageName,sp.num,sp.org_name orgName";
        String countSql = "select count(distinct r.id) ";
        String filter = " from base_service_package_sign_record r " +
                " inner JOIN base_patient p on p.id = r.patient " +
                " LEFT JOIN base_service_package sp on r.service_package_id=sp.id " +
                " LEFT JOIN wlyy_hospital_sys_dict di on di.dict_name = 'sign_status' and di.dict_code=r.status " +
                " LEFT JOIN base_capacity_assessment_record ar on ar.patient = r.patient and ar.assessment_time>= '" + DateUtil.getNowYear() + "-01-01' " +
                " LEFT JOIN wlyy_hospital_sys_dict di2 on di2.dict_name = 'level_conclusion' and di2.dict_code=ar.level_conclusion " +
                " where 1=1 ";
        if(StringUtils.isNotBlank(patientId)){
            filter += " and r.patient = '"+patientId+"' ";
        }
        if(StringUtils.isNotBlank(doctorId)){
            filter += " and r.check_doctor = '"+doctorId+"' ";
        }
        if(StringUtils.isNotBlank(status)){
            filter += " and r.status = "+status+" ";
        }
        if(StringUtils.isNotBlank(name)){
            filter += " and p.name like '%"+name+"%' ";
        }
        String oderBy = " order by r.create_time desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+oderBy);
        for (Map<String,Object> map:list){
            String idcard = map.get("idcard")+"";
            String birthday = map.get("birthday")+"";
            map.put("age", IdCardUtil.getAgeByBirthdayStrOrIdcard(idcard,birthday));
        }
        long count = jdbcTemplate.queryForObject(countSql+filter+oderBy,Long.class);
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,size,count);
    }
    //是否签约服务包
    public boolean isSignPackage(String patientId,String servicePackageId) {
        String sql = "SELECT count(*) from base_service_package_sign_record WHERE patient='"+patientId+"' and service_package_id='"+servicePackageId+"' and `status`>0";
        int count = jdbcTemplate.queryForObject(sql,Integer.class);
        return count==0;
    }
    /**
     * 申请签约
     * @param jsonData
     * @param uid
     * @param type 1居民 2医生
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public ServicePackageSignRecordDO sign(String jsonData,String uid,String type) throws Exception{
        ServicePackageSignRecordDO signRecordDO = objectMapper.readValue(jsonData, ServicePackageSignRecordDO.class);
        String patientId = signRecordDO.getPatient();
        if(StringUtils.isBlank(patientId)){
            throw new ServiceException("参数错误");
        }
        synchronized (patientId.intern()){
            ServicePackageDO servicePackageDO = servicePackageDao.findOne(signRecordDO.getServicePackageId());
            if(servicePackageDO==null){
                throw new ServiceException("服务包不存在");
            }
            if(!isSignPackage(patientId,signRecordDO.getServicePackageId())){
                throw new ServiceException("您已经申请过该服务包,请勿重复申请");
            }
            signRecordDO.setPrice(servicePackageDO.getPrice());
            if("1".equals(servicePackageDO.getIsCheck())){
                //开启审核
                signRecordDO.setStatus(0);//待审核
                signRecordDO.setCheckDoctor(servicePackageDO.getCheckDoctor());
                signRecordDO.setCheckDoctorName(servicePackageDO.getCheckDoctorName());
            }else {
                signRecordDO.setStatus(2);//待支付
                //判断支付金额
                if(new BigDecimal(0).compareTo(signRecordDO.getPrice())==0){
                    //不需要支付
                    signRecordDO.setStatus(1);//已签约
                    //设置到期时间
                    setSignDate(servicePackageDO,signRecordDO);
                }else{
                    signRecordDO.setPayTime("10");//10分钟
                    signRecordDO.setPayStatus(0);
                    payService.submitOrder(signRecordDO.getPatient(),"4",signRecordDO.getId(),signRecordDO.getPrice().doubleValue());
                }
            }
            signRecordDO.setCreateTime(new Date());
            signRecordDO.setUpdateTime(new Date());
            if(patientId.equals(uid)){
                //本人
                signRecordDO.setType("1");
                signRecordDO.setProxyPatient(signRecordDO.getPatient());
                signRecordDO.setProxyPatientName(signRecordDO.getName());
            }else if("1".equals(type)){
                //家属
                BasePatientDO patientDO = patientDao.findById(uid);
                signRecordDO.setType("2");
                signRecordDO.setProxyPatient(patientDO.getId());
                signRecordDO.setProxyPatientName(patientDO.getName());
            }else {
                //医生
                BaseDoctorDO doctorDO = doctorDao.findById(uid);
                signRecordDO.setType("3");
                signRecordDO.setProxyPatient(doctorDO.getId());
                signRecordDO.setProxyPatientName(doctorDO.getName());
            }
            servicePackageSignRecordDao.save(signRecordDO);
            return signRecordDO;
        }
    }
    //设置签约的服务期限
    public void setSignDate(ServicePackageDO servicePackageDO,ServicePackageSignRecordDO signRecordDO){
        if(servicePackageDO == null){
            servicePackageDO = servicePackageDao.findOne(signRecordDO.getServicePackageId());
        }
        if("1".equals(servicePackageDO.getServerTimeType())){
            //固定期限
            String serverTime = servicePackageDO.getServerTime();
            if(StringUtils.isNotBlank(serverTime)&&!"*".equals(serverTime)){
                Calendar cal = Calendar.getInstance();
                int year = 0;
                int month = 0;
                String sTime[] = serverTime.split("\\*");
                if(sTime.length==1){
                    year = Integer.parseInt(sTime[0]);
                    cal.add(Calendar.YEAR,year);
                }else {
                    if(!"".equals(sTime[0])){
                        year = Integer.parseInt(sTime[0]);
                        cal.add(Calendar.YEAR,year);
                    }
                    month = Integer.parseInt(sTime[1]);
                    cal.add(Calendar.MONTH,month);
                }
                signRecordDO.setEndTime(cal.getTime());
            }
        }
        signRecordDO.setStartTime(new Date());
        sendMessage(servicePackageDO,signRecordDO);
    }
    //给分配者发送消息
    private void sendMessage(ServicePackageDO servicePackageDO,ServicePackageSignRecordDO signRecordDO){
        try {
            String sql = "SELECT DISTINCT d.id,d.name from base_doctor_role r,base_doctor_hospital h,base_doctor d " +
                    " WHERE r.role_code = 'dispatcher' and r.del='1' and r.doctor_code=h.doctor_code  " +
                    "and h.del='1' and r.doctor_code=d.id and h.org_code='"+servicePackageDO.getOrgCode()+"'";
            String content = "居民签约了服务包,请及时处理";
            List<Map<String,Object>> doctorList = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> map:doctorList){
                messageUtil.createMessage("服务项调度","980","system","服务项调度通知助手",signRecordDO.getId(),
                        map.get("id")+"",map.get("name")+"",signRecordDO.getName()+content);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    //服务包列表
    public PageEnvelop servicePackageList(Integer page,Integer size){
        String sql = "SELECT id,name,type,price,org_name orgName,server_time_type serverTimeType,server_time serverTime" +
                ",is_check isCheck,fee_after feeAfter";
        String countSql = "select count(*) ";
        String filter = " from base_service_package WHERE del='1' ";
        String orderBy = " ORDER BY create_time desc limit "+(page-1)*size+","+size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filter+orderBy);
        String itemSql = "SELECT i.name,c.server_count serverCount from base_service_package_item i " +
                "LEFT JOIN base_service_item_config c on i.id=c.server_item_id WHERE i.service_package_id=? ";
        for (Map<String,Object> map:list){
            String id = map.get("id")+"";
            List<Map<String,Object>> items = jdbcTemplate.queryForList(itemSql,new Object[]{id});
            map.put("items",items);
        }
        Long count = jdbcTemplate.queryForObject(countSql+filter,Long.class);
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,size,count);
    }
    //服务包详情
    public ServicePackageDO servicePackageInfo(String id){
        ServicePackageDO packageDO = servicePackageDao.findOne(id);
        String itemSql = "SELECT i.*,c.server_count serverCount from base_service_package_item i " +
                "LEFT JOIN base_service_item_config c on i.id=c.server_item_id WHERE i.service_package_id='"+id+"' ";
        List<ServicePackageItemDO> itemDOList = jdbcTemplate.query(itemSql,new BeanPropertyRowMapper<>(ServicePackageItemDO.class));
        packageDO.setPackageItemDOList(itemDOList);
        return packageDO;
    }
    public void addPatientSignList(){
        String lableCode = "0";
@ -436,9 +914,6 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        String signId = signRecordDO.getId();
        List<String> idList = new ArrayList<>();
        if(StringUtil.isEmpty(signId)){
//            List<ServicePackageSignRecordDO> signRecordDOs = servicePackageSignRecordDao.findByStatusAndPatient(1,signRecordDO.getPatient());
//            if(signRecordDOs.size()==0){
                BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
                //需要新增签约记录
                signRecordDO.setStatus(1);
@ -477,22 +952,6 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                    saveList.add(archiveDO);
                }
                archiveDao.save(saveList);
//            }else{
//                //不能重复签约
//                result.put(ResponseContant.resultFlag, ResponseContant.fail);
//                result.put(ResponseContant.resultMsg,"请勿重复签约");
//                return result;
////                ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
////                if(archiveDO!=null){
////                    archiveDO.setSignStatus(1);
////                    archiveDao.save(archiveDO);
////                }
////                signId = signRecordDOs.get(0).getId();
////                List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
////                idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
//            }
        }else{
            //不能重复签约
            result.put(ResponseContant.resultFlag, ResponseContant.fail);

+ 2 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java

@ -239,11 +239,11 @@ public class BaseVisitService {
    }
    /**
     * 新增随访计划(批量)
     * 新增走访计划(批量)
     */
    @Transactional
    public void addVistiPlan(String doctorCode, String patientCode, String data) throws Exception {
        //批量随访计划
        //批量走访计划
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
        if (list != null && list.size() > 0) {

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -388,7 +388,7 @@ public class MessageUtil {
        return messageDO;
    }
    public void createMessage(String title,String type,String sender,String senderName,String relationCode,String Receiver,String ReceiverName,String idCard,String msg){
    public void createMessage(String title,String type,String sender,String senderName,String relationCode,String Receiver,String ReceiverName,String msg){
        SystemMessageDO messageDO = new SystemMessageDO();
        messageDO.setTitle(title);
        messageDO.setType(type);//401为资质申请审核

+ 1 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/PostConstructUtil.java

@ -1,6 +1,5 @@
package com.yihu.jw.care.util;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,6 +29,6 @@ public class PostConstructUtil {
    @PostConstruct
    public void init(){
        logger.info("启动凯旋的设备的mqtt订阅====");
        mqttkxClientUtil.start();
//        mqttkxClientUtil.start();
    }
}

+ 217 - 68
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/controller/ConsultController.java

@ -9,17 +9,22 @@ import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.im.ConsultTeamLogDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.message.MessageNoticeSetting;
import com.yihu.jw.entity.util.SystemConfEntity;
import com.yihu.jw.hospital.module.consult.service.ConsultTeamService;
import com.yihu.jw.hospital.prescription.dao.PrescriptionDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.CommonUtil;
import com.yihu.jw.hospital.utils.HttpUtil;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.im.util.ImageCompress;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.hospital.utils.CommonUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -38,9 +43,14 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
/**
 * 患者端:三师咨询控制类
@ -52,12 +62,13 @@ import java.util.Map;
@Api(description = "患者端-患者咨询")
public class ConsultController extends EnvelopRestEndpoint {
    @Autowired
    protected HttpServletRequest request;
    @Autowired
    private ConsultTeamService consultTeamService;
    //    @Autowired
//    private DoctorCommentService doctorCommentService;
//    @Autowired
//    private DoctorStatisticsService doctorStatisticsService;
    @Autowired
    private BaseDoctorInfoService doctorService;
@ -69,29 +80,35 @@ public class ConsultController extends EnvelopRestEndpoint {
    @Autowired
    private CommonUtil CommonUtil;
    @Autowired
    private ImUtil imUtill;
    @Autowired
    private HttpUtil httpUtil;
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private PushMsgTask pushMsgTask;
    private HttpClientUtil httpClientUtil;
    @Autowired
    private ConsultTeamDao consultTeamDao;
    private MessageService messageService;
    @Autowired
    private PrescriptionDao prescriptionDao;
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ConsultDao consultDao;
    @Autowired
    WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @Value("${doctorAssistant.api}")
    private String doctorAssistant;
    @Value("${doctorAssistant.target_url}")
    private String targetUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private MessageService messageService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Value("${im.data_base_name}")
    private String im;
@ -100,8 +117,16 @@ public class ConsultController extends EnvelopRestEndpoint {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private HttpUtil httpUtil;
    @Autowired
    private PushMsgTask pushMsgTask;
    @Autowired
    private PrescriptionDao prescriptionDao;
//    @Autowired
//    private DoctorCommentService doctorCommentService;
//    @Autowired
//    private DoctorStatisticsService doctorStatisticsService;
//    @Autowired
//    private DoctorWorkTimeService doctorWorkTimeService;
//    @Autowired
@ -113,6 +138,7 @@ public class ConsultController extends EnvelopRestEndpoint {
//    @Autowired
//    private WlyyDynamicMessagesDao dynamicMessagesDao;
//    @ApiOperation("testRedis")
//    @RequestMapping(value = "testRedis",method = RequestMethod.POST)
//    public String testRedis(){
@ -1098,7 +1124,7 @@ public class ConsultController extends EnvelopRestEndpoint {
                                String doctorOpenID = doctor.getOpenid();
                                if (StringUtils.isNotEmpty(doctorOpenID)) {
                                    String title = "";
                                    ConsultDo consultSingle = consultDao.findByCode(log.getConsult());
                                    ConsultDo consultSingle = consultDao.findOne(log.getConsult());
                                    if (consultSingle != null) {
                                        Integer singleType = consultSingle.getType();
                                        if (singleType != null && singleType == 8) {
@ -1176,27 +1202,27 @@ public class ConsultController extends EnvelopRestEndpoint {
     * @param pagesize 每页显示数,默认为10
     * @return
     */
//    @RequestMapping(value = "loglist")
//    @ApiOperation("网络咨询咨询日志查询")
//    public String loglist(@RequestParam String consult, @RequestParam int page, @RequestParam int pagesize) {
//        try {
//            ConsultTeamDo consultModel = consultTeamService.findByCode(consult);
//            if (consultModel == null) {
//                return error(-1, "咨询记录不存在!");
//            }
//            JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, getRepUID());
//
//            //过滤续签
    @RequestMapping(value = "loglist")
    @ApiOperation("网络咨询咨询日志查询")
    public String loglist(
            @RequestParam String consult,
            @RequestParam String loginUser,
            @RequestParam int page, @RequestParam int pagesize) {
        try {
            ConsultTeamDo consultModel = consultTeamService.findByCode(consult);
            if (consultModel == null) {
                return error(-1, "咨询记录不存在!");
            }
            com.alibaba.fastjson.JSONObject messageObj = imUtill.getTopicMessage(consultModel.getConsult(), consultModel.getStartMsgId(), consultModel.getEndMsgId(), page, pagesize, loginUser);
            //过滤续签
//            consultTeamService.removeRenewPerson(messageObj, getRepUID());
//
//            return write(200, "查询成功", "list", messageObj);
//        } catch (ServiceException se) {
//            return write(-1, se.getMessage());
//        } catch (Exception e) {
//            error(e);
//            return invalidUserException(e, -1, "查询失败!");
//        }
//    }
            return write(200, "查询成功", "list", messageObj);
        } catch (Exception e) {
            error(e);
            return "查询失败!";
        }
    }
    /**
     * 网络咨询咨询日志查询
@ -1301,11 +1327,10 @@ public class ConsultController extends EnvelopRestEndpoint {
    /**
     * 三师咨询评论
     *
     * @param consult 咨询标识
     * @param content 评价内容
     * @param star    星级
     * @return 操作结果
     * consult 咨询标识
     * content 评价内容
     * star    星级
     *  操作结果
     */
//    @RequestMapping(value = "comment")
//    @ApiOperation("三师咨询评论")
@ -1337,17 +1362,14 @@ public class ConsultController extends EnvelopRestEndpoint {
//
//    }
//    @RequestMapping(value = "getTopic")
//    public String getTopic(String consult) {
//        try {
//            return success(imUtill.getTopic(consult).get("data").toString());
//        } catch (ServiceException se) {
//            return error(-1, se.getMessage());
//        } catch (Exception e) {
//            error(e);
//            return error(-1, e.getMessage());
//        }
//    }
    @RequestMapping(value = "getTopic")
    public Envelop getTopic(String consult) {
        try {
            return success(imUtill.getTopic(consult).get("data").toString());
        } catch (Exception e) {
            return failed( e.getMessage());
        }
    }
//    @RequestMapping(value = "getConsult")
//    public String getConsult(String consult) {
@ -1716,17 +1738,19 @@ public class ConsultController extends EnvelopRestEndpoint {
//    }
//    @RequestMapping(value = "queryByRelationCode", method = RequestMethod.GET)
//    @ApiOperation("根据关联业务code查询咨询记录")
//    public String queryByRelationCode(@ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code) {
//        try {
//            ConsultTeam consultTeam = consultTeamService.queryByRelationCode(code);
//            return write(200, "提交成功", "data", consultTeam);
//        } catch (Exception e) {
//            error(e);
//            return error(-1, "添加失败");
//        }
//    }
    @RequestMapping(value = "queryByRelationCode", method = RequestMethod.GET)
    @ApiOperation("根据关联业务code查询咨询记录")
    public String queryByRelationCode(
            @ApiParam(name = "code", value = "咨询关联业务code") @RequestParam(value = "code", required = true) String code
    ) {
        try {
            ConsultTeamDo consultTeam = consultTeamService.queryByRelationCode(code);
            return write(200, "提交成功", "data", consultTeam);
        } catch (Exception e) {
            error(e);
            return error(-1, "添加失败");
        }
    }
//    @RequestMapping(value = "queryByConsultCode", method = RequestMethod.GET)
//    @ApiOperation("根据咨询code查询关联业务项详情")
@ -1853,4 +1877,129 @@ public class ConsultController extends EnvelopRestEndpoint {
        }
    }
    /**
     * 获取微信服务器图片
     *
     * @return
     */
    public String fetchWxImages() {
        String photos = "";
        try {
            String images = request.getParameter("mediaIds");
            if (StringUtils.isEmpty(images)) {
                return photos;
            }
            String[] mediaIds = images.split(",");
            for (String mediaId : mediaIds) {
                if (StringUtils.isEmpty(mediaId)) {
                    continue;
                }
                String temp = saveImageToDisk(mediaId);
                if (StringUtils.isNotEmpty(temp)) {
                    if (photos.length() == 0) {
                        photos = temp;
                    } else {
                        photos += "," + temp;
                    }
                }
            }
        } catch (Exception e) {
            error(e);
        }
        return photos;
    }
    /**
     * 获取下载图片信息(jpg)
     *
     * @param mediaId 文件的id
     * @throws Exception
     */
    public String saveImageToDisk(String mediaId) throws Exception {
        // 文件保存的临时路径
        String tempPath = SystemConfEntity.getInstance().getTempPath() + File.separator;
        // 拼接年月日路径
        String datePath = DateUtil.getStringDate("yyyy") + File.separator + DateUtil.getStringDate("MM") + File.separator + DateUtil.getStringDate("dd") + File.separator;
        // 重命名文件
        String newFileName = DateUtil.dateToStr(new Date(), DateUtil.YYYYMMDDHHMMSS) + "_" + new Random().nextInt(1000) + ".png";
        // 保存路径
        File uploadFile = new File(tempPath + datePath + newFileName);
        InputStream inputStream = null;
        FileOutputStream fileOutputStream = null;
        try {
            if (!uploadFile.getParentFile().exists()) {
                uploadFile.getParentFile().mkdirs();
            }
            inputStream = getInputStream(mediaId);
            byte[] data = new byte[1024];
            int len = 0;
            fileOutputStream = new FileOutputStream(uploadFile);
            while ((len = inputStream.read(data)) != -1) {
                fileOutputStream.write(data, 0, len);
            }
            // 生成缩略图
            ImageCompress.compress(uploadFile.getAbsolutePath(), uploadFile.getAbsolutePath() + "_small", 300, 300);
            // 返回保存路径
            return datePath + newFileName;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
    /**
     * 下载多媒体文件(请注意,视频文件不支持下载,调用该接口需http协议)
     *
     * @return
     */
    public InputStream getInputStream(String mediaId) {
        String accessToken = getAccessToken();
        InputStream is = null;
        String url = "https://api.weixin.qq.com/cgi-bin/media/get?access_token=" + accessToken + "&media_id=" + mediaId;
        try {
            URL urlGet = new URL(url);
            HttpURLConnection http = (HttpURLConnection) urlGet.openConnection();
            http.setRequestMethod("GET"); // 必须是get方式请求
            http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            http.setDoOutput(true);
            http.setDoInput(true);
            System.setProperty("sun.net.client.defaultConnectTimeout", "30000");// 连接超时30秒
            System.setProperty("sun.net.client.defaultReadTimeout", "30000"); // 读取超时30秒
            http.connect();
            // 获取文件转化为byte流
            is = http.getInputStream();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return is;
    }
    /**
     * 获取微信的access_token
     *
     * @return
     */
    public String getAccessToken() {
        return weiXinAccessTokenUtils.getAccessToken();
    }
}

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultService.java

@ -71,7 +71,7 @@ public class ConsultService {
            String patient, String title, String symptoms, String images, int type
    ) throws Exception {
        ConsultDo consult = new ConsultDo();
        consult.setCode(UUID.randomUUID().toString().replaceAll("-", ""));//UUID
//        consult.setCode(UUID.randomUUID().toString().replaceAll("-", ""));//UUID
        consult.setCzrq(new Date());
        consult.setDel("1");
        consult.setPatient(patient);

+ 31 - 21
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/consult/service/ConsultTeamService.java

@ -217,25 +217,33 @@ public class ConsultTeamService extends ConsultService {
        consultTeam.setEvaluate(0);
        consultTeam.setDoctorRead(1); // 医生未读数量为1
        consult.setRelationCode(doorServiceOrderDO.getId());//关联业务code
        consultTeam.setConsult(consult.getCode()); // 设置咨询标识
        consultTeam.setConsult(consult.getId()); // 设置咨询标识
        //(im创建咨询) 上门服务咨询的sessionid为居民code+咨询code+工单编号+咨询类型
        String sessionId = patient + "_" + consult.getCode() + "_" + doorServiceOrderDO.getNumber() + "_" + consultTeam.getType();
        //原本:(im创建咨询) 上门服务咨询的sessionid为居民code+咨询code+工单编号+咨询类型
        String sessionId = patient + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consultTeam.getType();
        //4、 上门服务咨询-参与者
        JSONObject participants = new JSONObject();
        participants.put(patient, 0);
//        String content = signFamily.getHospitalName() + "为您服务";
        String content = doorServiceOrderDO.getDoctorName() + "为您服务";
        JSONObject messages = imUtill.getCreateTopicMessage(patient, patientDO.getName(), consult.getTitle(), content, consult.getImages(), "");
        //这边应该是要抛出异常比较合适
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getCode(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        String content;
        if (StringUtils.isNotBlank(doorServiceOrderDO.getDoctorName())) {
            content = doorServiceOrderDO.getDoctorName() + "-为您服务";
        } else {
            content = "调度员即将分配人员为您服务";
        }
//        if (imResponseJson == null || imResponseJson.getString("status").equals("-1")) {
//            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
//            throw new Exception(failMsg);
//        }
        //封装JSONObject的messages
        JSONObject messages = imUtill.getCreateTopicMessage(patient, patientDO.getName(), consult.getTitle(), content, consult.getImages(), "");
        /**
         * 创建议题
         */
        JSONObject imResponseJson = imUtill.createTopics(sessionId, consult.getId(), content, participants, messages, ImUtil.SESSION_TYPE_ONDOOR_NURSING);
        if (imResponseJson == null || imResponseJson.getString("status").equals("-1")) {
            String failMsg = "发起服务咨询时:IM" + imResponseJson.getString("message");
            throw new Exception(failMsg);
        }
        if (imResponseJson != null && imResponseJson.get("start_msg_id") != null) {
            consultTeam.setStartMsgId(imResponseJson.get("start_msg_id").toString());
        }
@ -2176,6 +2184,10 @@ public class ConsultTeamService extends ConsultService {
        return consultTeamDao.findByConsult(code);
    }
    public ConsultTeamDo findById(String id) {
        return consultTeamDao.findOne(id);
    }
    /**
     * 三师咨询转接医生
     *
@ -3324,13 +3336,13 @@ public class ConsultTeamService extends ConsultService {
    /**
     * 根据关联业务code查询咨询记录 wlyyDoorServiceOrderService.queryOneDetail(consult.getRelationCode());
     */
//    public ConsultTeamDo queryByRelationCode(String relationCode) {
//        if (StringUtils.isEmpty(relationCode)) {
//            return null;
//        }
//        ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(relationCode);
//        return consultTeam;
//    }
    public ConsultTeamDo queryByRelationCode(String relationCode) {
        if (StringUtils.isEmpty(relationCode)) {
            return null;
        }
        ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(relationCode);
        return consultTeam;
    }
    /**
     * 根据咨询查关联业务记录
@ -3356,7 +3368,6 @@ public class ConsultTeamService extends ConsultService {
//        result.putIfAbsent("data", consult);
//        return result;
//    }
    public org.json.JSONObject updateIMMsg(String sessionId, String sessionType, String msgId, String content) {
        org.json.JSONObject result = new org.json.JSONObject();
        if (StringUtils.isEmpty(sessionId) || StringUtils.isEmpty(sessionType) || StringUtils.isEmpty(msgId) || StringUtils.isEmpty(content)) {
@ -3480,5 +3491,4 @@ public class ConsultTeamService extends ConsultService {
//    }
}

+ 24 - 6
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/DoorOrderController.java

@ -97,6 +97,16 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    /**
     * 查询所有社区医生的机构
     */
    @GetMapping(value = "getDotorOrgList")
    @ApiOperation(value = "查询所有社区医生的机构")
    public Envelop getDotorOrgList() {
        List<Map<String, Object>> list = wlyyDoorServiceOrderService.getDotorOrgList();
        return success("查询成功", list);
    }
    @GetMapping(value = "queryDoctorList")
    @ApiOperation(value = "服务人员列表(医生列表)")
    public Envelop queryDoctorList(
@ -107,6 +117,11 @@ public class DoorOrderController extends EnvelopRestEndpoint {
            @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 {
            //初始化接单人员信息,社区医生的level=1
            wlyyDoorServiceOrderService.initDoorStatus(town);
            //查询医生信息
            JSONObject result = wlyyDoorServiceOrderService.queryDoctorList(patient, town, doctorName, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return failed(result.getString(ResponseContant.resultMsg));
@ -368,7 +383,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    @GetMapping("/topStatusBarNum")
    @ApiOperation(value = "顶部状态栏订单分类tab")
    public Envelop topStatusBarNum(
@ -463,14 +477,21 @@ public class DoorOrderController extends EnvelopRestEndpoint {
        }
    }
    /**
     * 参数:
     * orderId
     * reason
     * loginUserCode
     */
    @PostMapping("refuse")
    @ApiOperation(value = "拒单")
    public Envelop refuseOrder(
            @ApiParam(value = "工单id", name = "orderId", required = true) @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "拒绝原因", name = "reason", required = false) @RequestParam(value = "reason", required = false) String reason
            @ApiParam(value = "拒绝原因", name = "reason", required = false) @RequestParam(value = "reason", required = false) String reason,
            @ApiParam(value = "登录者", name = "loginUserCode", required = false) @RequestParam(value = "loginUserCode", required = false) String loginUserCode
    ) {
        try {
            doorOrderService.refuseOrder(getUID(), orderId, reason);
            doorOrderService.refuseOrder(loginUserCode, orderId, reason);
            return success("操作成功");
        } catch (Exception e) {
            return failed(e.getMessage());
@ -987,9 +1008,6 @@ public class DoorOrderController extends EnvelopRestEndpoint {
    }
    @PostMapping(value = "updateServiceStatus")
    @ApiOperation(value = "更新预约服务项目类型")

+ 24 - 3
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/controller/WlyyDoorServiceOrderController.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.hospital.module.door.service.DoorOrderService;
import com.yihu.jw.hospital.module.door.service.WlyyDoorPrescriptionService;
import com.yihu.jw.hospital.module.door.service.WlyyDoorServiceOrderService;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -31,7 +32,8 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    @Autowired
    private WlyyDoorServiceOrderService wlyyDoorServiceOrderService;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private DoorOrderService doorOrderService;
@ -49,6 +51,24 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
//    private String accId;
    @PostMapping(value = "testIm")
    @ApiOperation(value = "测试im")
    public Envelop testIm(
            @ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData
    ) {
        JSONObject participants = new JSONObject();
        participants.put("111", 0);
        String sessionId = "";
        String topicId = "";//consult.getId()
        String content = "";
        String messages = "";
//        JSONObject imResponseJson = imUtil.createTopics(sessionId,topicId, content, participants, messages, ImUtil.SESSION_TYPE_DOOR_COACH);
        return null;
    }
    /**
     * 居民创建上门服务
     * 参数:
@ -76,6 +96,7 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
    public Envelop queryInfoStatusCountList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient
    ) {
        System.out.println("统计上门服务工单各状态下的数量列表--参数" + patient);
        JSONObject result = wlyyDoorServiceOrderService.queryInfoStatusCountList(patient);
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return failed(result.getString(ResponseContant.resultMsg));
@ -262,6 +283,7 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
            @ApiParam(name = "reason", value = "取消理由") @RequestParam(value = "reason", required = true) String reason) {
        JSONObject result = new JSONObject();
        try {
            System.out.println("取消工单--参数orderId:" + orderId);
            result = wlyyDoorServiceOrderService.cancelOrder(orderId, 2, reason, null, null);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return failed(result.getString(ResponseContant.resultMsg));
@ -272,10 +294,9 @@ public class WlyyDoorServiceOrderController extends EnvelopRestEndpoint {
        }
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "queryDoctorList")
    @ApiOperation(value = "服务人员列表(医生列表)")
    public PageEnvelop queryDoctorList(

+ 74 - 92
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/DoorOrderService.java

@ -9,22 +9,23 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.system.SystemDictDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.wechat.WechatTemplateConfig;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.module.door.dao.*;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.order.dao.ConsultTeamOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import jxl.Workbook;
import jxl.write.*;
import org.apache.commons.collections.CollectionUtils;
@ -119,8 +120,8 @@ public class DoorOrderService {
    private ConsultDao consultDao;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
//    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    //    @Autowired
//    private HttpUtil httpUtil;
    @Autowired
    private WlyyDoorCommentDao doorCommentDao;
@ -130,6 +131,9 @@ public class DoorOrderService {
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
    @Autowired
    BasePatientDao basePatientDao;
//    @Autowired
//    private SignFamilyDao signFamilyDao;
//    @Autowired
@ -398,7 +402,7 @@ public class DoorOrderService {
            doorServiceOrder.setAge(age);
            doorServiceOrder.setPhoto(patient.getPhoto());
//            String typeValues = this.getTypeValueByPatientCode(patient.getCode());
           String typeValues = this.getTypeValueByPatientCode(patient.getId());
            String typeValues = this.getTypeValueByPatientCode(patient.getId());
            doorServiceOrder.setTypeValue(typeValues);
        }
        // 获取服务次数
@ -434,7 +438,7 @@ public class DoorOrderService {
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(id);
        if (null != consult) {
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
        }
        // 设置服务小结
@ -612,13 +616,13 @@ public class DoorOrderService {
        if (doorServiceOrder == null) {
            return;
        }
        
        // 发送微信模板消息通知患者医生已接单
        BasePatientDO patient = patientService.findPatientById(doorServiceOrder.getPatient());
        // 获取微信模板
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "smyyyjjd");
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "smyyyjjd");
            String first = templateConfig.getFirst();
            first = first.replace("key1", (patient.getName() == null ? "" : patient.getName()));
            first = first.replace("key2", null != doorServiceOrder.getDoctorName() ? doorServiceOrder.getDoctorName() : "");
@ -630,7 +634,7 @@ public class DoorOrderService {
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            if (consult != null) {
                json.put("consult", consult.getCode());
                json.put("consult", consult.getId());
            }
            logger.info("上门服务已接单推送前");
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
@ -664,10 +668,6 @@ public class DoorOrderService {
    /**
     * 拒单
     *
     * @param orderId
     * @param reason
     * @throws Exception
     */
    public void refuseOrder(String receiver, String orderId, String reason) throws Exception {
        WlyyDoorServiceOrderDO doorServiceOrder = doorServiceOrderDao.findOne(orderId);
@ -679,16 +679,18 @@ public class DoorOrderService {
//            this.createMessage(doorServiceOrder.getId(), "system", doorServiceOrder.getProxyPatient(), 403, "代预约服务工单重新派单", doorServiceOrder.getPatientName() + "的代预约服务工单需重新派单,请您前往处理");
            //2021-12-29 代预约医生拒单直接取消
            doorServiceOrder.setStatus(WlyyDoorServiceOrderDO.Status.cancel.getType());
            doorServiceOrder.setCancelReason(reason);   // 拒绝原因
            doorServiceOrder.setCancelReason(reason);// 拒绝原因
            doorServiceOrder.setCancelTime(new Date());
            doorServiceOrderDao.save(doorServiceOrder);
        } else {
            //删除消息
            this.systemMessageDao.orderMessageDel(doorServiceOrder.getDoctor(), orderId);
            //有调度员
            if (StringUtils.isNotBlank(doorServiceOrder.getDispatcher())) {
                // 派单消息
                this.createMessage(doorServiceOrder.getId(), "system", doorServiceOrder.getDispatcher(), 404, "服务工单拒单待重新派单", doorServiceOrder.getDoctorName() + "拒绝了" + doorServiceOrder.getProxyPatientName() + "的服务预约申请,请重新派单");
                //  调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
                // 调度员-派单-实时工单消息:435 医生拒单-- 王五拒绝了服务工单12345678
                List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId, new String[]{"431", "433"});
                if (CollectionUtils.isEmpty(messages)) {
                    logger.error("当前工单没有医生待接单消息!orderId:" + orderId);
@ -714,11 +716,6 @@ public class DoorOrderService {
    /**
     * 添加【工单派单,转单】等系统消息
     *
     * @param orderId
     * @param sender
     * @param receiver
     * @param Content
     */
    public void createMessage(String orderId, String sender, String receiver, int type, String title, String Content) {
        SystemMessageDO message = new SystemMessageDO();
@ -851,7 +848,7 @@ public class DoorOrderService {
            object.put("feeDetailResultList", feeDetailResultList);
            // 获取或者基本信息
            
            BasePatientDO patient = patientService.findPatientById(String.valueOf(one.get("patientCode")));
            if (patient != null) {
                String sex = IdCardUtil.getSexForIdcard(patient.getIdcard());
@ -868,7 +865,7 @@ public class DoorOrderService {
            //获取咨询
            ConsultDo consult = consultDao.queryByRelationCode(id);
            if (null != consult) {
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            }
            object.put("sessionId", doorServiceOrder.getSessionId());
@ -1068,7 +1065,7 @@ public class DoorOrderService {
            //获取咨询
            ConsultDo consult = consultDao.queryByRelationCode(id);
            if (null != consult) {
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
                doorServiceOrder.setSessionId(doorServiceOrder.getPatient() + "_" + consult.getId() + "_" + doorServiceOrder.getNumber() + "_" + consult.getType());
            }
            object.put("sessionId", doorServiceOrder.getSessionId());
@ -1354,41 +1351,29 @@ public class DoorOrderService {
        // 获取微信模板 smfwdwk-上门服务待付款
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        try {
            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "fwyspf");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first.replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "服务医生评分");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("id", orderId);
            //json.put("consult",consult.getCode());
            WlyyDoorCommentDO wlyyDoorCommentDO = this.doorCommentDao.selectCommentDoctor(patient.getId(), orderId);
            String finish = "";
            if (wlyyDoorCommentDO != null) {
                finish = "0";
                json.put("finish", finish);
            } else {
                finish = "1";
                json.put("finish", finish);
            }
            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
            /*WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback","smfwdwk");
            String first = templateConfig.getFirst();
            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
            first = first .replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
           // String keyword1 = templateConfig.getKeyword1();
            org.json.JSONObject json = new org.json.JSONObject();
            json.put("first", first);
            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
            json.put("keyword2", "上门服务待付款");
            json.put("url", templateConfig.getUrl());
            json.put("remark", templateConfig.getRemark());
            json.put("consult",consult.getCode());*/
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 30, patient.getOpenid(), patient.getName(), json);
//            //暂时没有微信模板消息的功能
//            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "fwyspf");
//            String first = templateConfig.getFirst();
//            first = first.replace("key1", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm"));
//            first = first.replace("key2", null != one.getDoctorName() ? one.getDoctorName() : "");
//            org.json.JSONObject json = new org.json.JSONObject();
//            json.put("first", first);
//            json.put("keyword1", DateUtil.dateToStrShort(new Date()));
//            json.put("keyword2", "服务医生评分");
//            json.put("url", templateConfig.getUrl());
//            json.put("remark", templateConfig.getRemark());
//            json.put("id", orderId);
//            //json.put("consult",consult.getCode());
//            WlyyDoorCommentDO wlyyDoorCommentDO = this.doorCommentDao.selectCommentDoctor(patient.getId(), orderId);
//            String finish = "";
//            if (wlyyDoorCommentDO != null) {
//                finish = "0";
//                json.put("finish", finish);
//            } else {
//                finish = "1";
//                json.put("finish", finish);
//            }
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 31, patient.getOpenid(), patient.getName(), json);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
@ -1494,10 +1479,8 @@ public class DoorOrderService {
    /**
     * 修改预计到达时间
     *
     * @param orderId
     * @param arrivingTime
     * @return
     * orderId
     * arrivingTime
     */
    public WlyyDoorServiceOrderDO updateArrivingTime(String orderId, String arrivingTime) {
        WlyyDoorServiceOrderDO one = doorServiceOrderDao.findOne(orderId);
@ -1776,27 +1759,26 @@ public class DoorOrderService {
        return typeValues;
    }
//    /**
//     * 修改保存服务项
//     *
//     * @param jsonData
//     */
//    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
//    public void updatePackageItemInfo(String jsonData) {
//        JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
//        String orderId = String.valueOf(jsonObjectParam.get("orderId"));
//        WlyyDoorServiceOrderDO order = doorServiceOrderDao.findById(orderId);
//        // 删除出诊医生或服务项
//        wlyyDoorServiceOrderService.orderWithFeeDelete(jsonObjectParam, order);
//        // 更新服务包信息
//        wlyyDoorServiceOrderService.orderWithPackageItemFeeAdd(new JSONObject(), jsonObjectParam, order);
//
//        // 发送微信模板消息,通知居民服务项目已经变更(smyyyjjd-服务项目变更通知)
//        BasePatientDO patient = patientService.findByCode(order.getProxyPatient());
//        ConsultDo consult = consultDao.queryByRelationCode(orderId);
//        Integer status = 0;
//        try {
//
    /**
     * 修改保存服务项
     *
     * @param jsonData
     */
    @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
    public void updatePackageItemInfo(String jsonData) throws Exception {
        JSONObject jsonObjectParam = JSONObject.parseObject(jsonData);
        String orderId = String.valueOf(jsonObjectParam.get("orderId"));
        WlyyDoorServiceOrderDO order = doorServiceOrderDao.findOne(orderId);
        // 删除出诊医生或服务项
        wlyyDoorServiceOrderService.orderWithFeeDelete(jsonObjectParam, order);
        // 更新服务包信息
        wlyyDoorServiceOrderService.orderWithPackageItemFeeAdd(new JSONObject(), jsonObjectParam, order);
        // 发送微信模板消息,通知居民服务项目已经变更(smyyyjjd-服务项目变更通知)
        BasePatientDO patient = basePatientDao.findOne(order.getProxyPatient());
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        Integer status = 0;
        try {
//            WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "fwxmbgtz");
//            String first = templateConfig.getFirst();
//            first = first.replace("key1", (patient.getName() == null ? "" : patient.getName()));
@ -1808,14 +1790,14 @@ public class DoorOrderService {
//            json.put("keyword2", "服务项目变更确认");
//            json.put("url", templateConfig.getUrl());
//            json.put("remark", templateConfig.getRemark());
//            json.put("consult", consult.getCode());
//            json.put("consult", consult.getId());
//            json.put("status", status);
////            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 32, patient.getOpenid(), patient.getName(), json);
//        } catch (Exception e) {
//            logger.error(e.getMessage());
//        }
//
//    }
//            pushMsgTask.putWxMsg(tokenUtils.getAccessToken(), 32, patient.getOpenid(), patient.getName(), json);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
    }
    /**
     * 获取管理员端上门服务菜单分类
@ -2018,9 +2000,9 @@ public class DoorOrderService {
        if (org.apache.commons.lang3.StringUtils.isBlank(sendId)) {
            wlyyDoorServiceOrder = wlyyDoorServiceOrderDao.findOne(orderId);
            response = imUtill.sendTopicIM(wlyyDoorServiceOrder.getDispatcher(), "智能助手", consult.getCode(), contentType, content, null);
            response = imUtill.sendTopicIM(wlyyDoorServiceOrder.getDispatcher(), "智能助手", consult.getId(), contentType, content, null);
        } else {
            response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
            response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
        }
        JSONObject resObj = JSONObject.parseObject(response);
        if (resObj.getIntValue("status") == -1) {

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorPrescriptionService.java

@ -231,7 +231,7 @@ public class WlyyDoorPrescriptionService {
            logger.error("当前工单未关联咨询,工单id:" + orderId);
            return result;
        }
        String response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
        String response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
        JSONObject resObj = JSONObject.parseObject(response);
        if (resObj.getIntValue("status") == -1) {
            logger.error("上门服务工单消息发送失败:" + resObj.getString("message"));

+ 252 - 81
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/door/service/WlyyDoorServiceOrderService.java

@ -9,18 +9,20 @@ import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.door.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.wechat.WechatTemplateConfig;
import com.yihu.jw.entity.order.BusinessOrderDO;
import com.yihu.jw.hospital.HospitalDao;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.hospital.module.consult.service.ConsultTeamService;
import com.yihu.jw.hospital.module.door.dao.*;
import com.yihu.jw.hospital.module.wx.dao.WechatTemplateConfigDao;
import com.yihu.jw.hospital.task.PushMsgTask;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.order.BusinessOrderService;
import com.yihu.jw.order.dao.BusinessOrderDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.restmodel.ResponseContant;
@ -30,6 +32,7 @@ import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.EntityUtils;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
@ -79,6 +82,11 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private BusinessOrderDao businessOrderDao;
    @Autowired
    private BusinessOrderService businessOrderService;
    @Autowired
    private WlyyDoorServiceOrderDao wlyyDoorServiceOrderDao;
@ -172,8 +180,11 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
    @Autowired
    private WeiXinAccessTokenUtils tokenUtils;
//    @Autowired
//    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    private WxTemplateConfigDao wxTemplateConfigDao;
//    @Autowired
//    private DmJobService dmJobService;
@ -402,10 +413,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            wlyyDoorFeeDetailDao.save(feeDetailDOList);
            doorOrderItemDao.save(orderItemDOList);
//          //更新总费用-这边没用到
//           order.setTotalFee(totalFee);
//           wlyyDoorServiceOrderDao.save(order);
            //更新总费用
            order.setTotalFee(totalFee);
            wlyyDoorServiceOrderDao.save(order);
        }
        return false;
    }
@ -539,7 +549,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            ConsultDo consult = consultDao.queryByRelationCode(orderDO.getId());
            String sessionId = null;
            if (consult != null) {
                sessionId = orderDO.getPatient() + "_" + consult.getCode() + "_" + orderDO.getNumber() + "_" + consult.getType();
                sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + orderDO.getNumber() + "_" + consult.getType();
            }
            for (Object one : doctorArray) {
                WlyyDoorDoctorDO doorDoctorDO = null;
@ -656,11 +666,32 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        WlyyDoorServiceOrderDO orderDO = EntityUtils.jsonToEntity(
                jsonObjectParam.get("order").toString(), WlyyDoorServiceOrderDO.class);
        orderDO.setNumber(getRandomIntStr());
        orderDO.setCreateTime(new Date());
        orderDO.setCreateUser(orderDO.getProxyPatient());
        orderDO.setCreateUserName(orderDO.getProxyPatientName());
        orderDO.setOrderInfo("0");
        orderDO.setOrderInfo("0");//工单详情 0-未推送 1-未确认 2-已确认
//        //服务后收费标识(1是0否)
//        if ("1".equals(orderDO.getFeeAfter())) {
//            //工单状态:-1-已取消,1-待(调度员)派单,2-待(医生)接单,3-待服务,4-待付款,5-待评价,6-已完成
//            if (StringUtils.isNotBlank(orderDO.getDoctor())) {
//                orderDO.setStatus(2);//待接单(医生)
//            } else {
//                orderDO.setStatus(1);//待派单(调度员)
//            }
//        } else {
//            orderDO.setStatus(4);//待付款
//        }
        if (StringUtils.isNotBlank(orderDO.getDoctor())) {
            orderDO.setStatus(2);//待接单(医生)
        } else {
            orderDO.setStatus(1);//待派单(调度员)
        }
        if (StringUtils.isEmpty(orderDO.getPatient())) {
            throw new Exception("当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient());
@ -680,7 +711,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                });
        if (bool) {
            String failMsg = "当前服务对象存在未完成的上门服务,请先完成该服务!";
            String failMsg = "当前服务对象存在未完成或未付款的上门服务,请先完成该服务!";
            throw new Exception(failMsg);
        }
@ -692,77 +723,172 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        } else if (!orderDO.getProxyPatient().equals(orderDO.getPatient())) {
            orderDO.setType(2);
        }
        orderDO.setServiceStatus("1");
        orderDO.setServiceStatus("1");//服务类型 1-预约项目 2-即时项目
        //保存服务订单
        wlyyDoorServiceOrderDao.save(orderDO);
        //创建咨询
        JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
        ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO)) {
            return result;
        }
        //判断其是否有分配执行人。如果有不用走调度平台
        if (StringUtils.isNotBlank(orderDO.getDoctor())) {
            orderDO.setStatus(2);
            //应该是康复模板的康复下转,才有签约--先注释
            orderDO.setDoctor(orderDO.getDoctor());
            orderDO.setDoctorName(orderDO.getDoctorName());
            this.save(orderDO);
            //新增工单医生关联关系
            if (orderWithDoctorAdd(result, jsonObjectParam, orderDO)) {
                return result;
            }
            // 给服务医生发接单消息--先注释
            this.createMessage(orderDO.getId(), orderDO.getProxyPatient(), orderDO.getDoctor(), 407, "服务工单待接单", "您有新的服务工单,请前往处理");
            //发送智能助手消息-微信消息先注释
            sendWeixinMessage(4, orderDO.getDoctor(), orderDO.getPatient());
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg, consultTeam);
            return result;
        }
        /**
         * 1、发起支付订单
         * 2、发送咨询消息
         */
        result = submitDoorOrderAndSendMsg(orderDO, "5", jsonObjectParam);
        //获取机构的调度员
        List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
        return result;
    }
    /**
     * 5表示上门服务
     * 情况
     * 1.直接付款走流程
     * 2.创建订单没付完款-待付款
     * 3.还要超时订单
     * -----
     * 这个上门服务是线下收费,不用在线支付
     */
    private JSONObject submitDoorOrderAndSendMsg(WlyyDoorServiceOrderDO orderDO, String type, JSONObject jsonObjectParam) throws Exception {
        boolean flag = true;
        JSONObject result = new JSONObject();
        //有调度员
        if (!dispatcherList.isEmpty()) {
            for (Map<String, Object> map : dispatcherList) {
                String dispatcher = map.get("code").toString();
                // 派单消息-首页
                this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
                this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
            }
        //创建订单信息
        BasePatientDO pateint = patientDao.findById(orderDO.getPatient());
        //查询是否存在订单信息
        BusinessOrderDO businessOrderDO = businessOrderDao.findByOrderId(orderDO.getId());
        if (businessOrderDO == null) {
            businessOrderDO = new BusinessOrderDO();
            businessOrderDO.setPatient(pateint.getId());
            //支付账号
            businessOrderDO.setYkOrderId(pateint.getMobile());
            businessOrderDO.setPatientName(pateint.getName());
            businessOrderDO.setOrderType(1);
            businessOrderDO.setOrderCategory(type);
            Date date = new Date();
            Long lastPayTime = date.getTime() + 1000 * 60 * 30;//订单截至支付日期
            businessOrderDO.setDescription("上门服务");
            businessOrderDO.setRelationCode(orderDO.getId());//订单id
            businessOrderDO.setRelationName("上门服务");
            businessOrderDO.setCreateTime(date);
            businessOrderDO.setUpdateTime(date);
            businessOrderDO.setStatus(0);
            businessOrderDO.setOrderNo(orderDO.getNumber());
            businessOrderDO.setUploadStatus(0);
            businessOrderDO.setPayType(1);
            businessOrderDO.setPayPrice(Double.valueOf(orderDO.getTotalFee().doubleValue()));
            businessOrderDO.setLastPayTime(lastPayTime);
        } else {
            /**
             * 暂时没用,线下付款的
             * 1、是否付款完成
             * 2、判断付款时间是否超过时长了--还需要定时任务监听订单修改状态,把未付款改成已取消
             */
//            if (businessOrderDO.getStatus() != 1) {
//                long nowTime = System.currentTimeMillis();
//                Long lastPayTime = businessOrderDO.getLastPayTime();
//                if (lastPayTime > nowTime) {
//                    //超时了 修改工单状态成已取消
//                    orderDO.setStatus(-1);//-已取消
//                    wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
//                    businessOrderDO.setStatus(2);//已取消
//                    businessOrderDao.save(businessOrderDO);//更新业务表
//                    flag = false;//不用创建咨询内容
//                }
//            }
        }
        //给机构调度员发送医生助手消息
        for (Map<String, Object> map : dispatcherList) {
            //这边还没有微信消息的功能呢。
            sendWeixinMessage(3, map.get("user_code") + "", orderDO.getPatient());
        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, consultTeam);
        /**
         *  1、费用0时无需支付
         *  2、调用微信支付 再来更新flag标识
         */
        //发送 预约卡片信息(2101类型)
        JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
        orderInfoContent.put("re_msg_type", 0);//居民预约
        //发送消息
        int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
//        if (i != 1) {
//            throw new Exception("上门服务工单消息发送失败");
//        if ("5".equals(type) && 0.0 == orderDO.getTotalFee().doubleValue()) {
//            businessOrderDO.setStatus(1);//1已支付
//            businessOrderDao.save(businessOrderDO);
//        } else {
//            /**
//             * 保存订单信息-这边要判断付款回调修改状态值-付款失败取消订单
//             * businessOrderService
//             */
//            businessOrderDO.setStatus(0);//0待支付
//            businessOrderDao.save(businessOrderDO);
//        }
        //保存业务表
        businessOrderDao.save(businessOrderDO);
        /**
         * 目前是线下付款的
         * 给出标识是否成功,往下面创建咨询信息发送内容
         */
        if (flag) {
            //获取机构的调度员
            List<Map<String, Object>> dispatcherList = queryDispatcherInfoByPatient(jsonObjectParam.getJSONObject("hospital").get("code").toString());
            //支付成功或者不用支付
            //创建咨询
            JSONObject successOrNot = consultTeamService.addDoorServiceConsult(orderDO.getId());
            ConsultTeamDo consultTeam = (ConsultTeamDo) successOrNot.get(ResponseContant.resultMsg);
            //判断其是否有分配执行人。如果有不用走调度平台
            if (StringUtils.isNotBlank(orderDO.getDoctor())) {
                orderDO.setStatus(2);//待接单
                orderDO.setDoctor(orderDO.getDoctor());
                orderDO.setDoctorName(orderDO.getDoctorName());
                this.save(orderDO);
                //新增工单医生关联关系
                if (orderWithDoctorAdd(result, jsonObjectParam, orderDO)) {
                    return result;
                }
                // 给服务医生发接单消息
                this.createMessage(orderDO.getId(), orderDO.getProxyPatient(), orderDO.getDoctor(), 407, "服务工单待接单", "您有新的服务工单,请前往处理");
                //发送智能助手消息-微信消息先注释
                sendWeixinMessage(4, orderDO.getDoctor(), orderDO.getPatient());
                result.put(ResponseContant.resultFlag, ResponseContant.success);
                result.put(ResponseContant.resultMsg, consultTeam);
                return result;
            }
        //后面这个要修改下,加个字段判断下是否转派
        if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
            //服务医生修改,直接转派
            BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
            sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
            //有调度员
            if (!dispatcherList.isEmpty()) {
                for (Map<String, Object> map : dispatcherList) {
                    String dispatcher = map.get("code").toString();
                    // 派单消息-首页
                    this.createMessage(orderDO.getId(), "system", dispatcher, 402, "新增居民预约服务申请", orderDO.getPatientName() + "提交了服务预约申请,请您前往处理");
                    // 派单-实时工单消息  430 居民提交工单申请-- 张三提交了服务工单12345678申请
                    this.createMessage(orderDO.getId(), "system", dispatcher, 430, "居民提交工单申请", orderDO.getPatientName() + "提交了服务工单" + orderDO.getNumber() + "申请");
                }
            }
            //给机构调度员发送医生助手消息
            for (Map<String, Object> map : dispatcherList) {
                //这边还没有微信消息的功能呢
                sendWeixinMessage(3, map.get("code") + "", orderDO.getPatient());
            }
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg, consultTeam);
            //发送 预约卡片信息(2101类型)
            JSONObject orderInfoContent = this.queryOrderCardInfo(orderDO);
            orderInfoContent.put("re_msg_type", 0);//居民预约
            //发送消息
            int i = qucikSendIM(orderDO.getId(), "system", "智能助手", "2101", orderInfoContent.toJSONString());
            if (i != 1) {
                throw new Exception("上门服务工单消息发送失败");
            }
            //后面这个要修改下,加个字段判断下是否转派
            if (StringUtils.isNoneBlank(orderDO.getDoctor())) {
                //服务医生修改,直接转派
                BaseDoctorDO transDoctor = doctorDao.findById(orderDO.getDoctor());
                sendOrderToDoctor(orderDO.getId(), null, "system", "系统", transDoctor.getId(), transDoctor.getName(), transDoctor.getJobTitleName());
            }
        } else {
            //取消订单
            orderDO.setStatus(-1);//-已取消
            wlyyDoorServiceOrderDao.save(orderDO);//更新上门工单
        }
        return result;
    }
@ -888,14 +1014,17 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            return result;
        }
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = orderDO.getPatient() + "_" + consult.getCode() + "_" + orderDO.getNumber() + "_" + consult.getType();
        String sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + orderDO.getNumber() + "_" + consult.getType();
//        String sessionId = orderDO.getPatient() + "_" + consult.getId() + "_" + orderDO.getNumber();
        // 把调度员拉入会话,作为其中一个成员,第一个进入会话的调度员,系统发送欢迎语和居民的预约卡片信息
        if (StringUtils.isEmpty(orderDO.getDispatcher())) {
            orderDO.setDispatcher(dispatcher);
            orderDO.setDispatcherName(dispatcherName);
            this.save(orderDO);
            // 先进入会话,再聊天
            imUtill.updateParticipant(sessionId, dispatcher, null);
//            String msg = imUtill.updateParticipant(sessionId, dispatcher, null);
            String msg = imUtill.updateParticipantNew(sessionId, dispatcher, null);
            System.out.println("进入会话,再聊天==>" + msg);
            String noticeContent = hospitalName + dispatcherName + "为您服务";
            this.qucikSendIM(orderId, dispatcher, "智能助手", "1", noticeContent);
//            imUtill.sendIntoTopicIM(dispatcher, sessionId, consult.getCode(), noticeContent, orderDO.getProxyPatient(), orderDO.getProxyPatientName());
@ -904,7 +1033,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        }
        // 把调度员拉入会话,作为其中一个成员
        imUtill.updateParticipant(sessionId, dispatcher, null);
//        String msg = imUtill.updateParticipant(sessionId, dispatcher, null);
        String msg = imUtill.updateParticipantNew(sessionId, dispatcher, null);
        System.out.println("把调度员拉入会话,作为其中一个成员==>" + msg);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "调度员[" + dispatcherName + "]进入会话成功");
        return result;
@ -1044,9 +1175,12 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            e.printStackTrace();
        }
        if (!CollectionUtils.isEmpty(feeDetailDOS)) {
            //2023-10-11 先注释 计算服务费用
            Map<String, Object> map = doorOrderService.countServerPackagePrice(jsonData, orderDO.getPatient());
            orderBriefInfo.put("packageFee", map.get("serverPackagePrice"));
            /**
             *  2023-10-11 先注释 计算服务费用
             *  这边需要改写用表base_service_package_record
             */
//            Map<String, Object> map = doorOrderService.countServerPackagePrice(jsonData, orderDO.getPatient());
//            orderBriefInfo.put("packageFee", map.get("serverPackagePrice"));
        }
        orderJson.put("order", orderBriefInfo);
@ -1538,7 +1672,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
        BasePatientDO patient = patientService.findPatientById(orderDO.getPatient());
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "smyyyqx");
        WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndScene("xm_test_ihealth_wx", "template_process_feedback", "smyyyqx");
        String first = templateConfig.getFirst().replace("key1", null != patient.getName() ? patient.getName() : "");
        org.json.JSONObject json = new org.json.JSONObject();
        json.put("first", first);
@ -1547,7 +1681,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        json.put("url", templateConfig.getUrl());
        json.put("remark", templateConfig.getRemark());
        if (consult != null) {
            json.put("consult", consult.getCode());
            json.put("consult", consult.getId());
        } else {
            json.put("id", orderDO.getId());
        }
@ -1572,7 +1706,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
        BasePatientDO patient = patientService.findPatientById(orderDO.getPatient());
        WechatTemplateConfig templateConfig = templateConfigDao.findByScene("template_process_feedback", "smyyyqx");
        WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByScene("template_process_feedback", "smyyyqx");
        String first = templateConfig.getFirst().replace("key1", null != patient.getName() ? patient.getName() : "");
        org.json.JSONObject json = new org.json.JSONObject();
        json.put("first", orderDO.getPatientName() + ",您好!您的上门服务知情同意书已送达");
@ -1583,7 +1717,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
//        appoint_service/html/appoint-serviceDetail.html?openid=ojsU-1XJVftkfdbP1F5bi8JVPtOo&consult=e0d17c67ab07477f8e96534bc610e51b
        json.put("remark", templateConfig.getRemark());
        if (consult != null) {
            json.put("consult", consult.getCode());
            json.put("consult", consult.getId());
        } else {
            json.put("id", orderDO.getId());
        }
@ -1969,6 +2103,8 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        }
        String serviceSql = "SELECT count(d.id) times FROM wlyy_door_doctor d where d.order_id in(SELECT id from wlyy_door_service_order WHERE DATE_FORMAT(doctor_sign_time, '%Y') = DATE_FORMAT(NOW(), '%Y') AND patient=?)";
//        final Set<String>  patientSet = doorServiceVoucherDao.queryByTypeIn(types);
        sqlResultlist.forEach(
                oneMap -> {
                    // 获取服务次数
@ -1985,7 +2121,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                    if (parArray != null) {
                        parArray.forEach(
                                oneParObj -> {
                                    org.json.JSONObject oneParJson = (org.json.JSONObject) oneParObj;
                                    com.alibaba.fastjson.JSONObject oneParJson = (com.alibaba.fastjson.JSONObject) oneParObj;
                                    if (StringUtils.equalsIgnoreCase(oneParJson.getString("id"), dispatcher)) {
                                        oneMap.put("isInSession", true);
                                    }
@ -2020,6 +2156,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        int end = 0 == size ? 15 : size;
        String sql = "SELECT " +
                "  a.dept_code 'deptCode',\ta.dept_name 'deptName',a.org_code 'orgCode',\ta.org_name 'orgName', " +
                "  d.id as doctor, " +
                "  d.photo as photo, " +
                "  d.name as name," +
@ -2028,7 +2165,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                "  when 1 then '男' " +
                "  when 2 then '女' " +
                "  end as sex, " +
                "  d.`job_title_name` AS jobName, " +
                "  d.job_title_code 'jobCode', d.`job_title_name` AS jobName, " +
                "  d.mobile as phone," +
                "  CONCAT(d.doctor_lat ,',',d.doctor_lon) 'position', " +
                "  IFNULL(ds.`status`,5) as status," +
@ -2090,7 +2227,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
            if (notFinish > 0 && StringUtils.isNotBlank(doctor)) {
                String notFinishSql = "select o.id,o.number,o.patient,o.patient_name,o.patient_phone,o.patient_expected_serve_time,o.`status`, CASE p.sex when 1 then '男' when 2 THEN '女' END as sex,p.idcard, " +
                        "year(now()) - ((CASE LENGTH(p.idcard) WHEN 18 THEN substring(p.idcard, 7, 4) WHEN 15 THEN CONCAT('19',substring(p.idcard, 7, 2)) END )) as age , p.photo,o.serve_lat AS lat,o.serve_lon AS lon,o.id AS orderId " +
                        "from wlyy_door_service_order o LEFT JOIN wlyy_patient p on o.patient = p.`code` and p.`status`=1 " +
                        "from wlyy_door_service_order o LEFT JOIN base_patient p on o.patient = p.`id` and p.`del`=1 " +
                        "where o.doctor ='" + doctor + "' and o.status in (2,3,4)";
                List<Map<String, Object>> notFinishList = jdbcTemplate.queryForList(notFinishSql);
                map.put("notFinishList", notFinishList);
@ -2248,7 +2385,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        imUtill.updateParticipant(sessionId, doctor, null);
        // 调度员处理完该单(新增预约的,或者是拒单重新派单的)
@ -2349,7 +2486,7 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        // 派单时,把医生拉入会话,作为其中一个成员,医生拒单时,退出会话
        ConsultDo consult = consultDao.queryByRelationCode(orderId);
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getCode() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        String sessionId = doorServiceOrderDO.getPatient() + "_" + consult.getId() + "_" + doorServiceOrderDO.getNumber() + "_" + consult.getType();
        imUtill.updateParticipant(sessionId, doctor, null);
        // 调度员处理完该单(新增预约的,或者是拒单重新派单的)
@ -2514,9 +2651,9 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
                if (StringUtils.isNoneBlank(wlyyDoorServiceOrder.getDispatcher())) {
                    sender = wlyyDoorServiceOrder.getDispatcher();
                }
                response = imUtill.sendTopicIM(sender, "智能助手", consult.getCode(), contentType, content, null);
                response = imUtill.sendTopicIM(sender, "智能助手", consult.getId(), contentType, content, null);
            } else {
                response = imUtill.sendTopicIM(sendId, sendName, consult.getCode(), contentType, content, null);
                response = imUtill.sendTopicIM(sendId, sendName, consult.getId(), contentType, content, null);
            }
            JSONObject resObj = JSONObject.parseObject(response);
            if (resObj.getIntValue("status") == -1) {
@ -2912,4 +3049,38 @@ public class WlyyDoorServiceOrderService extends BaseJpaService<WlyyDoorServiceO
        }
        return map;
    }
    /**
     * 初始化社区医生
     */
    public void initDoorStatus(String hospital) {
        String sql = "SELECT * from base_doctor doc WHERE doctor_level=1 and id not in ( " +
                "SELECT doctor from wlyy_door_doctor_status " +
                ")";
        if (org.apache.commons.lang.StringUtils.isNotBlank(hospital)) {
            sql += "and EXISTS (select id from base_doctor_hospital dh where doc.id = dh.doctor_code and dh.org_code='" + hospital + "' and dh.del=1 ) ";
        }
        List<BaseDoctorDO> doctorDOs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseDoctorDO.class));
        List<WlyyDoorDoctorStatusDO> doctorList = new ArrayList<>(doctorDOs.size());
        for (BaseDoctorDO baseDoctorDO : doctorDOs) {
            WlyyDoorDoctorStatusDO doctorDoor = new WlyyDoorDoctorStatusDO();
            doctorDoor.setDoctor(baseDoctorDO.getId());
            doctorDoor.setStatus(1);
            doctorDoor.setCreateTime(new Date());
            doctorDoor.setCreateUser("System");
            doctorDoor.setCreateUserName("System");
            doctorList.add(doctorDoor);
        }
        wlyyDoorDoctorStatusDao.save(doctorList);
    }
    public List<Map<String, Object>> getDotorOrgList() {
        String sql = "SELECT a.org_code 'hospitalCode',a.org_name 'hospitalName' \n" +
                "FROM base_doctor_hospital a INNER JOIN base_doctor b\n" +
                "WHERE b.doctor_level='1'\n";
        sql += " GROUP BY a.org_code,a.org_name ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

+ 12 - 0
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/module/pay/service/PayService.java

@ -0,0 +1,12 @@
package com.yihu.jw.hospital.module.pay.service;
import org.springframework.stereotype.Service;
/**
 * @author suqinyi
 * @Date 2023/10/26
 */
@Service
public class PayService {
}

+ 58 - 50
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/task/PushMsgTask.java

@ -2,14 +2,14 @@ package com.yihu.jw.hospital.task;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.wechat.WechatPushLog;
import com.yihu.jw.entity.base.wx.WxPushLogDO;
import com.yihu.jw.entity.wechat.WechatTemplate;
import com.yihu.jw.entity.wechat.WechatTemplateData;
import com.yihu.jw.hospital.module.wx.dao.WechatPushLogDao;
import com.yihu.jw.hospital.utils.HttpUtil;
import com.yihu.jw.hospital.utils.WeiXinAccessTokenUtils;
import com.yihu.jw.hospital.utils.WeiXinOpenIdUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.wechat.dao.WxPushLogDao;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONException;
@ -43,57 +43,62 @@ public class PushMsgTask {
    private String putMesMethod;
    @Value("${pushMes.redis_prescription_title}")
    private String redisQueue;
//    @Value("${putMesType.wechat}")
    //    @Value("${putMesType.wechat}")
    private String putMesType;
    //模板id
//    @Value("${wechat.message.template_sign_success}")
    private String template_sign_success;
//    @Value("${wechat.message.template_sign_failed}")
    //    @Value("${wechat.message.template_sign_failed}")
    private String template_sign_failed;
//    @Value("${wechat.message.template_consult_notice}")
    //    @Value("${wechat.message.template_consult_notice}")
    private String template_consult_notice;
//    @Value("${wechat.message.template_health_notice}")
    //    @Value("${wechat.message.template_health_notice}")
    private String template_health_notice;
//    @Value("${wechat.message.template_termination}")
    //    @Value("${wechat.message.template_termination}")
    private String template_termination;
//    @Value("${wechat.message.template_appoint_success}")
    //    @Value("${wechat.message.template_appoint_success}")
    private String template_appoint_success;
//    @Value("${wechat.message.template_appoint_failed}")
    //    @Value("${wechat.message.template_appoint_failed}")
    private String template_appoint_failed;
//    @Value("${wechat.message.template_expenses_remind}")
    //    @Value("${wechat.message.template_expenses_remind}")
    private String template_expenses_remind;
//    @Value("${wechat.message.template_healthy_article}")
    //    @Value("${wechat.message.template_healthy_article}")
    private String template_healthy_article;
//    @Value("${wechat.message.template_doctor_change}")
    //    @Value("${wechat.message.template_doctor_change}")
    private String template_doctor_change;
//    @Value("${wechat.message.template_doctor_survey}")
    //    @Value("${wechat.message.template_doctor_survey}")
    private String template_doctor_survey;
//    @Value("${wechat.message.template_doctor_audit}")
    //    @Value("${wechat.message.template_doctor_audit}")
    private String template_doctor_audit;//审核结果通知
//    @Value("${wechat.message.template_doctor_service}")
    //    @Value("${wechat.message.template_doctor_service}")
    private String template_doctor_service;//服务结果通知
//    @Value("${wechat.message.template_physical_examination}")
    //    @Value("${wechat.message.template_physical_examination}")
    private String template_physical_examination;//体检提醒
//    @Value("${wechat.message.doctor_invitel_template}")
    //    @Value("${wechat.message.doctor_invitel_template}")
    private String doctor_invitel_template;
//    @Value("${wechat.message.template_deal_with}")
    //    @Value("${wechat.message.template_deal_with}")
    private String template_deal_with;
//    @Value("${wechat.message.template_patient_bind_device}")
    //    @Value("${wechat.message.template_patient_bind_device}")
    private String template_patient_bind_device;
//    @Value("${wechat.message.template_healthbank_credit}")
    //    @Value("${wechat.message.template_healthbank_credit}")
    private String template_healthbank_credit;
//    @Value("${wechat.message.template_rehabilitation_plan}")
    //    @Value("${wechat.message.template_rehabilitation_plan}")
    private String template_rehabilitation_plan;
//    @Value("${wechat.message.template_process_feedback}")
    //    @Value("${wechat.message.template_process_feedback}")
    private String template_process_feedback;
//    @Value("${wechat.message.template_birthday_wishes}")
    //    @Value("${wechat.message.template_birthday_wishes}")
    private String template_birthday_wishes;//生日祝福
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private WechatPushLogDao wechatPushLogDao;
//    @Autowired
//    private WechatPushLogDao wechatPushLogDao;
    WxPushLogDao wxPushLogDao;
    @Autowired
    private WeiXinAccessTokenUtils accessTokenUtils;
    @Autowired
@ -293,6 +298,7 @@ public class PushMsgTask {
     * @return
     */
    public boolean sendWeixinMessage(String access_token, int type, String openid, String name, JSONObject json) {
        WxPushLogDO log = new WxPushLogDO();
        try {
            if (StringUtils.isEmpty(openid)) {
                logger.error("send wechat message failed:openid is empty");
@ -305,26 +311,26 @@ public class PushMsgTask {
                    logger.error("参数错误!error");
                    return false;
                }
                WechatPushLog log = new WechatPushLog();
                log.setType(type);
                log.setCreateTime(new Date());
                log.setName(name);
                log.setOpenid(openid);
                if (!json.isNull("toUser")) {
                    log.setPatient(json.getString("toUser"));
                }
                log.setCreateTime(new Date());
//                //这里没这些字段,后面看要不要补充
//                log.setName(name);
//                log.setType(type);
//                if (!json.isNull("toUser")) {
//                    log.setPatient(json.getString("toUser"));
//                }
                log.setRequest(json.toString());
                String result = HttpUtil.sendPost(token_url, params);
                JSONObject jsonResult = new JSONObject(result);
                log.setResponse(result);
                if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
                    logger.info("微信信息推送成功!success");
                    log.setStatus(1);
                    wechatPushLogDao.save(log);
                    log.setStatus("1");
                    wxPushLogDao.save(log);
                    return true;
                } else {
                    log.setStatus(0);
                    wechatPushLogDao.save(log);
                    log.setStatus("0");
                    wxPushLogDao.save(log);
                    logger.error("错误编码:" + jsonResult.get("errcode").toString() + "  错误提示:" + jsonResult.get("errmsg").toString());
                    return false;
                }
@ -361,27 +367,29 @@ public class PushMsgTask {
                    logger.error("参数错误!error");
                    return false;
                }
                WechatPushLog log = new WechatPushLog();
                log.setType(type);
                WxPushLogDO log = new WxPushLogDO();
                log.setScene(scene);
                log.setCreateTime(new Date());
                log.setName(name);
                log.setOpenid(openid);
                if (!json.isNull("toUser")) {
                    log.setPatient(json.getString("toUser"));
                }
//                //这里没这些字段,后面看要不要补充
//                log.setName(name);
//                log.setType(type);
//                if (!json.isNull("toUser")) {
//                    log.setPatient(json.getString("toUser"));
//                }
                log.setRequest(json.toString());
                String result = HttpUtil.sendPost(token_url, params);
                JSONObject jsonResult = new JSONObject(result);
                log.setResponse(result);
                if (Integer.parseInt(jsonResult.get("errcode").toString()) == 0) {
                    logger.info("微信信息推送成功!success");
                    log.setStatus(1);
                    wechatPushLogDao.save(log);
                    log.setStatus("1");
                    wxPushLogDao.save(log);
                    return true;
                } else {
                    log.setStatus(0);
                    wechatPushLogDao.save(log);
                    log.setStatus("0");
                    wxPushLogDao.save(log);
                    logger.error("错误编码:" + jsonResult.get("errcode").toString() + "  错误提示:" + jsonResult.get("errmsg").toString());
                    return false;
                }
@ -467,7 +475,7 @@ public class PushMsgTask {
                    } else if (json.has("agent") && ("0".equals(json.getString("agent")))) {
//                        发送给自己
                        temp.setUrl(url + "qygl/html/pay_flow.html?openid=" + openid + "&state=" + json.getString("doctor") + "&toUser=" + json.getString("toUser") + "&toName=" + name + "&isRenew=" + isRenew + "&signState=" + signState + "&represented=" + json.getString("represented") + "&signCode=" + json.getString("signCode"));
                    }else {
                    } else {
                        temp.setUrl((String) json.get("url"));
                    }
                }
@ -482,7 +490,7 @@ public class PushMsgTask {
                if (json.has("content")) {
                    keyword1.setValue(json.getString("content"));
                    keyword2.setValue(json.getString("doctorName"));
                }else {
                } else {
                    keyword1.setValue(json.getString("first"));
                    keyword2.setValue(json.getString("remark"));
                }
@ -584,7 +592,7 @@ public class PushMsgTask {
                if (json.has("doctorName")) {
                    keyword1.setValue(json.getString("doctorName"));
                    keyword4.setValue(json.getString("content"));
                }else {
                } else {
                    keyword1.setValue(json.getString("first"));
                    keyword4.setValue(json.getString("remark"));
                }
@ -1176,7 +1184,7 @@ public class PushMsgTask {
    /**
     * 根据type 匹配对应模板ID
     *
     * @param type 见WechatPushLog说明
     * @param type 见WxPushLogDO说明
     * @return
     */
    private String getTemplateId(int type) throws Exception {

+ 1 - 1
svr/svr-visit-behind/src/main/java/com/yihu/jw/hospital/utils/CommonUtil.java

@ -1,4 +1,4 @@
package com.yihu.jw.util.common;
package com.yihu.jw.hospital.utils;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.fastdfs.FastDFSUtil;

+ 1 - 1
svr/svr-visit-behind/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name:  svr-visit-behind
    name:  svr-visit-behind --
  cloud:
    config:
      failFast: true