Преглед на файлове

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

wangzhinan преди 2 години
родител
ревизия
805e9db065
променени са 54 файла, в които са добавени 2746 реда и са изтрити 101 реда
  1. 36 2
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java
  2. 68 0
      common/common-entity/sql记录
  3. 12 3
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/BasePatientWechatDo.java
  4. 10 1
      common/common-entity/src/main/java/com/yihu/jw/entity/child/BaseChildManage.java
  5. 72 0
      common/common-entity/src/main/java/com/yihu/jw/entity/child/BaseConsultWaresManageEntity.java
  6. 13 0
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  7. 79 0
      common/common-entity/src/main/java/com/yihu/jw/entity/log/BaseFamilyPushOnOffEntity.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/log/BasePushRecordLogEntity.java
  9. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/log/BasePushrecordLogInfoEntity.java
  10. 223 0
      common/common-entity/src/main/java/com/yihu/jw/entity/log/ZhaohuiDailyEntity.java
  11. 19 12
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  12. 18 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  13. 30 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/WxAppletsAccessTokenDao.java
  14. 30 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  15. 125 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/service/WechatService.java
  16. 11 0
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/childManage/BaseConsultWaresManageDao.java
  17. 7 3
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/ManageMessagePush/ManageSystemPushMessageController.java
  18. 74 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/PlatformArticleManage/PlatformArticleManageController.java
  19. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/childManage/ChildManageController.java
  20. 122 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/waresManage/WaresManageController.java
  21. 96 35
      svr/svr-base/src/main/java/com/yihu/jw/base/service/ManageMessagePush/ManageSystemPushMessageService.java
  22. 1 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java
  23. 2 1
      svr/svr-base/src/main/java/com/yihu/jw/base/service/child/ChildManageService.java
  24. 89 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/manage/PlatformArticleManageService.java
  25. 140 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/manage/WaresManageService.java
  26. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/log/BaseConsultWaresManageDao.java
  27. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/log/BaseFamilyPushOnOffDao.java
  28. 2 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java
  29. 4 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/child/ChildManageController.java
  30. 86 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/common/CommonController.java
  31. 35 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/WxPushEndpoint.java
  32. 69 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java
  33. 35 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/patient/PatientNoLoginEndPoint.java
  34. 8 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/child/ChildNewsListService.java
  35. 30 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/WxPushService.java
  36. 171 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/hzwulianganzhi/HzWuLianDeviceService.java
  37. 139 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java
  38. 13 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/wechat/WeiXinEventProcess.java
  39. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  40. 3 3
      svr/svr-cloud-care/src/main/resources/application.yml
  41. 45 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java
  42. 11 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/pushLog/ZhaohuiDailyDao.java
  43. 20 3
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  44. 41 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/FamilySystemWechatPushJob.java
  45. 39 1
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/PushRecordJob.java
  46. 39 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/PushZhaohuiRoundJob.java
  47. 20 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/zhaohuiDaily/zhaohuiDailyJob.java
  48. 1 1
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  49. 262 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/WechatPushService.java
  50. 216 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/message/ZhaohuiDailyService.java
  51. 109 15
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java
  52. 7 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/SystemPushMessageUtil.java
  53. 16 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/web/JobController.java
  54. 5 1
      svr/svr-cloud-job/src/main/resources/system.properties

+ 36 - 2
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatInfoService.java

@ -1,6 +1,5 @@
package com.yihu.jw.wechat.service;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.hospital.prescription.service.entrance.EntranceService;
@ -8,8 +7,10 @@ import com.yihu.jw.hospital.prescription.service.entrance.HcyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.TnyyEntranceService;
import com.yihu.jw.hospital.prescription.service.entrance.XzzxEntranceService;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.utils.network.HttpResponse;
import com.yihu.utils.network.HttpUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.LoggerFactory;
@ -17,6 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Map;
@Service
public class WechatInfoService {
    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(WechatInfoService.class);
@ -57,6 +60,37 @@ public class WechatInfoService {
        }
    }
    public JSONObject getXOpenidByCode(String code,String wxId) throws Exception {
        //通过wxId获取appId和appSecret
        WxWechatDO wxWechatDO = wechatDao.findById(wxId);
        return getXOpenidByCode(code,wxWechatDO.getApplets(),wxWechatDO.getAppletsSecret());
    }
    /**
     * 获取小程序openid
     * @param code
     * @param appid
     * @param appSecret
     * @return
     * @throws Exception
     */
    public JSONObject getXOpenidByCode(String code, String appid, String appSecret) throws Exception {
        HttpUtils httpUtils = new HttpUtils();
        Map<String, Object> param = new HashedMap();
        param.put("appid", appid);
        param.put("secret", appSecret);
        param.put("js_code", code);
        param.put("grant_type", "authorization_code");
        HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
        JSONObject json = new JSONObject(response.getContent());
        LOGGER.info("checkApplets:"+response.getContent());
        if (!json.has("unionid")) {
            json.put("unionid","123456");
        }
        return json;
    }
    /**
     * 通过code获取判断openid
     *

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

@ -2218,3 +2218,71 @@ INSERT INTO `base`.`wlyy_hospital_sys_dict`(`id`, `saas_id`, `dict_name`, `dict_
-- 20220926 lb
alter table base_daily_report_detail add column doubt_read tinyint(2) default null comment '异常效率是否已读0未读1已读';
alter table base_doctor_daily_report_upload add column nice_work_type tinyint(2) default null comment '点赞类型 字典nice_work_type';
-- 20221025 wsl
CREATE TABLE `base_zhaohui_daily` (
  `id` int(50) NOT NULL,
  `name` varchar(50) DEFAULT NULL COMMENT '家属',
  `patient` varchar(50) DEFAULT NULL COMMENT '家属code',
  `old_name` varchar(30) DEFAULT NULL COMMENT '老人',
  `old_patient` varchar(500) DEFAULT NULL COMMENT '老人code',
  `yg_total` varchar(30) DEFAULT NULL COMMENT '烟感',
  `qg_total` varchar(30) DEFAULT NULL COMMENT '气感',
  `sb_total` varchar(30) DEFAULT NULL COMMENT '手表',
  `gz_total` varchar(30) DEFAULT NULL COMMENT '拐杖',
  `smd_total` varchar(30) DEFAULT NULL COMMENT '睡眠带',
  `eme_total` varchar(30) DEFAULT NULL COMMENT '紧急',
  `sec_total` varchar(30) DEFAULT NULL COMMENT '安防',
  `lift_total` varchar(30) DEFAULT NULL COMMENT '生活',
  `create_time` datetime DEFAULT NULL COMMENT '统计时间',
  `device_code` varchar(20) DEFAULT NULL COMMENT '拥有设备',
  `total` varchar(20) DEFAULT NULL COMMENT '设备采集次数',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='朝晖日报';
ALTER table base_zhaohui_daily add COLUMN `device_code` VARCHAR(20) DEFAULT NULL COMMENT '拥有设备';
ALTER table base_zhaohui_daily add COLUMN `total` VARCHAR(20) DEFAULT NULL COMMENT '设备采集次数';
ALTER table base_system_message add COLUMN `user_type` Int(2) DEFAULT NULL COMMENT ' 3 为对送给家属的信息';
ALTER table base_pushrecord_log_info add COLUMN `patient_type` Int(2) DEFAULT NULL COMMENT ' 居民类型 1 老人  3 家属';
CREATE TABLE `base_consult_wares_manage` (
  `id` varchar(50) NOT NULL COMMENT '主键ID',
  `name` varchar(10) NOT NULL COMMENT '姓名',
  `mobile` varchar(12) NOT NULL COMMENT '手机号',
  `waresCode` varchar(20) DEFAULT NULL COMMENT '咨询服务',
  `send_time` datetime DEFAULT NULL COMMENT '发送时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品管理';
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 ('fddyj', NULL, 'consultService', '6', '防跌倒预警', NULL, 6, 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 ('fzsdw', NULL, 'consultService', '1', '防走失定位', NULL, 1, 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 ('hzyj', NULL, 'consultService', '2', '火灾预警', NULL, 2, 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 ('jjhj', NULL, 'consultService', '5', '紧急呼叫', NULL, 5, 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 ('qt', NULL, 'consultService', '8', '其他', NULL, 8, 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 ('rqxlyj', NULL, 'consultService', '3', '燃气泄漏预警', NULL, 3, 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 ('smzljc', NULL, 'consultService', '4', '睡眠质量监测', NULL, 4, 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 ('xyxdjc', NULL, 'consultService', '7', '血压/血糖监测', NULL, 7, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
CREATE TABLE `base_patient_family_pushonoff` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '居民code',
  `type` int(3) DEFAULT NULL COMMENT '推送类型 ',
  `type_name` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '推送类型名字 ',
  `on_off` int(1) DEFAULT NULL COMMENT '开关状态 0 关 1开',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=263 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='家属端推送开关';
-- 2022-10-31 ysj
alter table base_patient_wechat add column xopenid varchar(50) default null comment '微信小程序openid';

+ 12 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/BasePatientWechatDo.java

@ -1,7 +1,6 @@
package com.yihu.jw.entity.base.wx;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -19,7 +18,8 @@ public class BasePatientWechatDo extends UuidIdentityEntity {
	private String saasId;
	private String wechatId;
	private String patientId;
	private String openid;
	private String openid;//公众号openid
	private String xopenid;//小程序openid
	private String unionid;
	private Date createTime;
	
@ -65,7 +65,16 @@ public class BasePatientWechatDo extends UuidIdentityEntity {
	public void setUnionid(String unionid) {
		this.unionid = unionid;
	}
	
	public String getXopenid() {
		return xopenid;
	}
	@Column(name = "xopenid")
	public void setXopenid(String xopenid) {
		this.xopenid = xopenid;
	}
	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;

+ 10 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/child/BaseChildManage.java

@ -16,7 +16,7 @@ import java.util.Date;
@Table(name = "base_child_manage")
public class BaseChildManage extends UuidIdentityEntity {
    private Integer type;  //类型1图文辅导,2视频辅导,3喜讯详细
    private Integer type;  //类型1图文辅导,2视频辅导,3喜讯详细 4文章管理 5商品管理
    private String orgName;  //机构名字
    private String org;  //机构
    private String title;  //标题
@ -25,8 +25,17 @@ public class BaseChildManage extends UuidIdentityEntity {
    private Date createTime;  //创建时间
    private Integer del;  //1可用,0禁用
    private Integer click;//点击量
    private Integer sort; //排序
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getClick() {
        return click;
    }

+ 72 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/child/BaseConsultWaresManageEntity.java

@ -0,0 +1,72 @@
package com.yihu.jw.entity.child;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wsl on 2022/10/27
 */
@Entity
@Table(name = "base_consult_wares_manage")
public class BaseConsultWaresManageEntity extends UuidIdentityEntity {
    /**
     * 姓名
     */
    private String name;
    /**
     * 手机号
     */
    private String mobile;
    /**
     * 咨询服务
     */
    private String warescode;
    /**
     * 发送时间
     */
    private Date sendTime;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    public String getWarescode() {
        return warescode;
    }
    public void setWarescode(String warescode) {
        this.warescode = warescode;
    }
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    public Date getSendTime() {
        return sendTime;
    }
    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }
}

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

@ -28,6 +28,7 @@ public class SystemMessageDO extends UuidIdentityEntity {
     * 老人在线咨询 851
     * 老人健康咨询 852
     *
     * 体征设备测量系统消息 42  老人pad语音
     * 智能手表佩戴提示 991
     * 智能手表电量提示 992
     * 报警器电量提示 993
@ -74,6 +75,18 @@ public class SystemMessageDO extends UuidIdentityEntity {
     */
    private String del;
    private String over;//是否操作结束 是否操作结束 1否,0是
    private Integer userType;  //医养 家属端使用  1或null为家属  2为幼儿 3为家属信息
    @Column(name = "user_type")
    public Integer getUserType() {
        return userType;
    }
    public void setUserType(Integer userType) {
        this.userType = userType;
    }
    /**
     *已读时间
     */

+ 79 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/log/BaseFamilyPushOnOffEntity.java

@ -0,0 +1,79 @@
package com.yihu.jw.entity.log;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wsl on 2022/10/31
 */
@Entity
@Table(name = "base_patient_family_pushonoff")
public class BaseFamilyPushOnOffEntity extends IdEntity {
    private String patient;  //居民code
    private Integer type;  //推送类型
    //1	紧急预警
    //2	设备动态
    //3	体征动态
    //4	平台通知
    private String typeName;  //推送类型名字
    private Integer onOff;  //开关状态 0 关 1开
    private Date createTime;  //创建时间
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "type_name")
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    @Column(name = "on_off")
    public Integer getOnOff() {
        return onOff;
    }
    public void setOnOff(Integer onOff) {
        this.onOff = onOff;
    }
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/log/BasePushRecordLogEntity.java

@ -26,7 +26,7 @@ public class BasePushRecordLogEntity extends UuidIdentityEntity {
    private Date createTime;  //创建时间
    private String sendObject;  //发送对象
    private Integer messageType;//消息推送类型
    private Integer sendObjectType;//发送对象类型(1签约老人,2部分签约老人)
    private Integer sendObjectType;//发送对象类型(1签约老人,2部分签约老人,3家属)
    private List<String> patientList;

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/log/BasePushrecordLogInfoEntity.java

@ -24,7 +24,16 @@ public class BasePushrecordLogInfoEntity extends IdEntity {
    private Integer status; //发送状态
    private Date sendTime; //发送时间
    @Column(name = "patient_type")
    private Integer patientType; //居民类型 1 老人  3 家属
    public Integer getPatientType() {
        return patientType;
    }
    public void setPatientType(Integer patientType) {
        this.patientType = patientType;
    }
    @Column(name = "patient_name")
    public String getPatientName() {

+ 223 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/log/ZhaohuiDailyEntity.java

@ -0,0 +1,223 @@
package com.yihu.jw.entity.log;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by wsl on 2022/10/25
 */
@Entity
@Table(name = "base_zhaohui_daily")
public class ZhaohuiDailyEntity extends IdEntity {
    /**
     * name
     */
    private String name;
    /**
     * patient
     */
    private String patient;
    /**
     * 老人
     */
    private String oldName;
    /**
     * 老人code
     */
    private String oldPatient;
    /**
     * 烟感
     */
    private String ygTotal;
    /**
     * 气感
     */
    private String qgTotal;
    /**
     * 手表
     */
    private String sbTotal;
    /**
     * 拐杖
     */
    private String gzTotal;
    /**
     * 睡眠带
     */
    private String smdTotal;
    /**
     * 紧急
     */
    private String emeTotal;
    /**
     * 安防
     */
    private String secTotal;
    /**
     * 生活
     */
    private String liftTotal;
    private Date createTime;
    private String deviceCode;
    private String total;
    @Column(name = "total")
    public String getTotal() {
        return total;
    }
    public void setTotal(String total) {
        this.total = total;
    }
    @Column(name = "device_code")
    public String getDeviceCode() {
        return deviceCode;
    }
    public void setDeviceCode(String deviceCode) {
        this.deviceCode = deviceCode;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "old_name")
    public String getOldName() {
        return oldName;
    }
    public void setOldName(String oldName) {
        this.oldName = oldName;
    }
    @Column(name = "old_patient")
    public String getOldPatient() {
        return oldPatient;
    }
    public void setOldPatient(String oldPatient) {
        this.oldPatient = oldPatient;
    }
    @Column(name = "yg_total")
    public String getYgTotal() {
        return ygTotal;
    }
    public void setYgTotal(String ygTotal) {
        this.ygTotal = ygTotal;
    }
    @Column(name = "qg_total")
    public String getQgTotal() {
        return qgTotal;
    }
    public void setQgTotal(String qgTotal) {
        this.qgTotal = qgTotal;
    }
    @Column(name = "sb_total")
    public String getSbTotal() {
        return sbTotal;
    }
    public void setSbTotal(String sbTotal) {
        this.sbTotal = sbTotal;
    }
    @Column(name = "gz_total")
    public String getGzTotal() {
        return gzTotal;
    }
    public void setGzTotal(String gzTotal) {
        this.gzTotal = gzTotal;
    }
    @Column(name = "smd_total")
    public String getSmdTotal() {
        return smdTotal;
    }
    public void setSmdTotal(String smdTotal) {
        this.smdTotal = smdTotal;
    }
    @Column(name = "eme_total")
    public String getEmeTotal() {
        return emeTotal;
    }
    public void setEmeTotal(String emeTotal) {
        this.emeTotal = emeTotal;
    }
    @Column(name = "sec_total")
    public String getSecTotal() {
        return secTotal;
    }
    public void setSecTotal(String secTotal) {
        this.secTotal = secTotal;
    }
    @Column(name = "lift_total")
    public String getLiftTotal() {
        return liftTotal;
    }
    public void setLiftTotal(String liftTotal) {
        this.liftTotal = liftTotal;
    }
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Column(name = "create_time")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 19 - 12
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -84,21 +84,28 @@ public class BasicZuulFilter extends ZuulFilter {
    @Override
    public Object run() {
        RequestContext ctx = RequestContext.getCurrentContext();
        HttpServletRequest request = ctx.getRequest();
        String url = request.getRequestURI();
        RequestContext ctx = null;
        HttpServletRequest request = null;
        String url = null;
        try {
            ctx = RequestContext.getCurrentContext();
            request = ctx.getRequest();
            url = request.getRequestURI();
        //防止SQL注入过滤器
        if(doSqlFilter(request)){
            return this.forbidden(ctx, ResultStatus.ERROR_PARA, "Illegal parameter");
        }
            //防止SQL注入过滤器
            if(doSqlFilter(request)){
                return this.forbidden(ctx, ResultStatus.ERROR_PARA, "Illegal parameter");
            }
        //文件类型过滤器
        if(doFileFilter(request)){
            return this.forbidden(ctx, ResultStatus.ERROR_PARA, "Illegal file");
        }
            //文件类型过滤器
            if(doFileFilter(request)){
                return this.forbidden(ctx, ResultStatus.ERROR_PARA, "Illegal file");
            }
        logger.info("BasicZuulFilter:"+url);
            logger.info("BasicZuulFilter:"+url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (!(url.contains("/open/noLogin/notify")||
            url.contains("/open/noLogin/ylzReceiveNotify")||

+ 18 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -980,6 +980,24 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        }
    }
    public void updateXOpenIdAndWechatId(String openid,String unionid, String userId,String wechatId) {
        List<BasePatientWechatDo> patientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wechatId,userId);
        if (patientWechatDos!=null&&patientWechatDos.size()!=0){
            BasePatientWechatDo basePatientWechatDo = patientWechatDos.get(0);
            basePatientWechatDo.setXopenid(openid);
            basePatientWechatDo.setUnionid(unionid);
            basePatientWechatDao.save(basePatientWechatDo);
        }else {
            BasePatientWechatDo basePatientWechatDo=new BasePatientWechatDo();
            basePatientWechatDo.setCreateTime(new Date());
            basePatientWechatDo.setXopenid(openid);
            basePatientWechatDo.setUnionid(unionid);
            basePatientWechatDo.setPatientId(userId);
            basePatientWechatDo.setWechatId(wechatId);
            basePatientWechatDao.save(basePatientWechatDo);
        }
    }
    public String getSynPath(String wxId){
        String sql = "SELECT w.syn_path AS sysPath FROM wx_wechat w WHERE w.id ='"+wxId+"'";

+ 30 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/patient/WxAppletsAccessTokenDao.java

@ -0,0 +1,30 @@
package com.yihu.jw.security.dao.patient;
import com.yihu.jw.entity.base.wx.WxAppletsAccessTokenDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Administrator on 2017/5/18 0018.
 */
public interface WxAppletsAccessTokenDao extends PagingAndSortingRepository<WxAppletsAccessTokenDO, String>, JpaSpecificationExecutor<WxAppletsAccessTokenDO> {
    @Query("from WxAppletsAccessTokenDO w where w.wechatId =?1 order by w.addTimestamp desc")
    List<WxAppletsAccessTokenDO> getWxAccessTokenById(String wechatId);
    
    @Modifying
    @Query("delete from WxAppletsAccessTokenDO p where p.wechatId=?1 ")
    void deleteByWechatId(String wechatId);
    @Query("select p from WxAppletsAccessTokenDO p where p.code = ?1 order by p.addTimestamp desc")
    Iterable<WxAppletsAccessTokenDO> findAccessToken(String accId);
    @Modifying
    @Query("delete from WxAppletsAccessTokenDO p where p.code=?1 ")
    void deleteByAccId(String accId);
}

+ 30 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -79,6 +79,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import sun.misc.BASE64Encoder;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
@ -185,6 +186,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Resource
    private WechatService wechatService;
    @PostConstruct
    private void init() {
@ -379,6 +382,23 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                    Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("message"), -1, null);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if("wxApplets".equals(flag)){
                //微信小程序登录
                parameters.put("grant_type", "dingTalk");
                String authCode = parameters.get("authCode");
                if(org.apache.commons.lang3.StringUtils.isBlank(authCode)){
                    throw new InvalidRequestException("请求参数错误");
                }
                String userPhone = wechatService.getUserPhoneByApplets(authCode);
                if (!StringUtils.isEmpty(userPhone)){
                    parameters.put("username", userPhone);
                }else{
                    HttpHeaders headers = new HttpHeaders();
                    headers.set("Cache-Control", "no-store");
                    headers.set("Pragma", "no-cache");
                    Oauth2Envelop<WlyyUserSimple> oauth2Envelop = new Oauth2Envelop<>("获取用户手机号失败", -1, null);
                    return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
                }
            }else if (StringUtils.isEmpty(parameters.get("captcha"))) {
                parameters.put("grant_type", "password");
                //解密密码
@ -446,6 +466,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
            wlyyUserSimple.setState(parameters.get("state"));
            String loginType = parameters.get("login_type");
            String openid = parameters.get("openid");
            String xopenid = parameters.get("xopenid");
            String unionid = parameters.get("unionid");
            String wechatId = parameters.get("wechatId");
            logger.info("login:登录进入7");
            //更新患者openId
@ -468,6 +490,14 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
                    userDetailsService.updateDoctorOpenId(openid, wlyyUserSimple.getId());
                }
            }
        if (!StringUtils.isEmpty(xopenid) && !"undefined".equalsIgnoreCase(xopenid) && ("3".equals(loginType)||"4".equalsIgnoreCase(loginType))) {
            baseLoginLogDO.setOpenid(xopenid);
            logger.info("gengxin进入"+xopenid);
            if (!StringUtils.isEmpty(wechatId)&& !"undefined".equalsIgnoreCase(wechatId)){
                logger.info("gengxin进入"+wechatId);
                userDetailsService.updateXOpenIdAndWechatId(xopenid,unionid,wlyyUserSimple.getId(),wechatId);
            }
        }
            if (parameters.get("password") != null) {
                //使用密码登录成功后, 更新失败次数为 0

+ 125 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/WechatService.java

@ -0,0 +1,125 @@
package com.yihu.jw.security.service;
import com.yihu.jw.entity.base.wx.WxAppletsAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.security.dao.patient.WechatDao;
import com.yihu.jw.security.dao.patient.WxAppletsAccessTokenDao;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.utils.network.HttpUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*;
/**
 * Created by yeshijie on 2022/11/2.
 */
@Service
public class WechatService {
    private static Logger logger = LoggerFactory.getLogger(WechatService.class);
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private WxAppletsAccessTokenDao wxAppletsAccessTokenDao;
    /**
     * 根据小程序获取用户手机号
     *
     * @param code
     * @return
     * @throws Exception
     */
    public String getUserPhoneByApplets(String code) throws Exception {
        String token = getWxAppletsAccessTokenById(wxId).getAccessToken();
        if (org.apache.commons.lang3.StringUtils.isNoneBlank(code)){
            String token_url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + token;
            String params = "{\"code\": \""+code+"\"}";
            logger.info("参数:"+params);
            String result = HttpUtil.sendPost(token_url, params);
            logger.info("步骤1:"+result);
            if (org.apache.commons.lang3.StringUtils.isNoneBlank(result)){
                com.alibaba.fastjson.JSONObject object = com.alibaba.fastjson.JSONObject.parseObject(result);
                if (object.getString("errcode").equalsIgnoreCase("0")){
                    com.alibaba.fastjson.JSONObject jsonObject= object.getJSONObject("phone_info");
                    return jsonObject.getString("phoneNumber");
                }
            }
            return null;
        }else {
            return null;
        }
    }
    /**
     * 生成小程序token
     * @param wechatId
     * @return
     */
    public WxAppletsAccessTokenDO getWxAppletsAccessTokenById(String wechatId) {
        try {
            //根据wechatCode查找出appid和appSecret
            WxWechatDO wxWechat = wechatDao.findById(wechatId);
            List<WxAppletsAccessTokenDO> wxAccessTokens =  wxAppletsAccessTokenDao.getWxAccessTokenById(wechatId);
            if(wxWechat==null){
                throw new ApiException("wxWechat is not exist", ExceptionCode.common_error_params_code);
            }
            if(wxAccessTokens!=null&&wxAccessTokens.size()>0){
                for (WxAppletsAccessTokenDO accessToken : wxAccessTokens) {
                    if ((System.currentTimeMillis() - accessToken.getAddTimestamp()) < (accessToken.getExpiresIn() * 500)) {
                        return accessToken;
                    } else {
                        wxAppletsAccessTokenDao.delete(accessToken);
                        break;
                    }
                }
            }
            String token_url = "https://api.weixin.qq.com/cgi-bin/token";
            String appId="";
            String appSecret="";
            appId = wxWechat.getApplets();
            appSecret = wxWechat.getAppletsSecret();
            if (StringUtils.isEmpty(appId)){
                throw new ApiException("appId is null", ExceptionCode.common_error_params_code);
            }
            if (StringUtils.isEmpty(appSecret)){
                throw new ApiException("appSecret is null", ExceptionCode.common_error_params_code);
            }
            Map<String, Object> params = new HashMap<>();
            params.put("grant_type", "client_credential");
            params.put("appid", appId);
            params.put("secret", appSecret);
            String result = HttpUtils.doGet(token_url, params).getContent();
            logger.info("--------------wechat token return:"+result+"---------------");
            JSONObject json = new JSONObject(result);
            if (json.has("access_token")) {
                String token = json.get("access_token").toString();
                String expires_in = json.get("expires_in").toString();
                WxAppletsAccessTokenDO newaccessToken = new WxAppletsAccessTokenDO();
                newaccessToken.setAccessToken(token);
                newaccessToken.setExpiresIn(Long.parseLong(expires_in));
                newaccessToken.setAddTimestamp(System.currentTimeMillis());
                newaccessToken.setCzrq(new Date());
                newaccessToken.setCode(UUID.randomUUID().toString().replace("-",""));
                newaccessToken.setWechatId(wechatId);
                wxAppletsAccessTokenDao.save(newaccessToken);
                return newaccessToken;
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

+ 11 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/dao/childManage/BaseConsultWaresManageDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.base.dao.childManage;
import com.yihu.jw.entity.child.BaseConsultWaresManageEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wsl on 2022/10/27
 */
public interface BaseConsultWaresManageDao extends PagingAndSortingRepository<BaseConsultWaresManageEntity,String>, JpaSpecificationExecutor<BaseConsultWaresManageEntity> {
}

+ 7 - 3
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/ManageMessagePush/ManageSystemPushMessageController.java

@ -32,9 +32,11 @@ public class ManageSystemPushMessageController extends EnvelopRestEndpoint {
    @ApiOperation("获取所有签约老人")
    @GetMapping(value = "/signOlds")
    public ListEnvelop signOlds(@ApiParam(name = "name", value = "居民名字", required = false)
                                @RequestParam(value = "name", required = false) String name) {
                                @RequestParam(value = "name", required = false) String name,
                                @ApiParam(name = "type", value = "1签约老人  2 家属", required = false)
                                @RequestParam(value = "type", required = false) Integer type) {
        try {
            List<BasePatientDO> basePatientDOS = mspmservice.signOlds(name);
            List<BasePatientDO> basePatientDOS = mspmservice.signOlds(name,1);
            return success(basePatientDOS);
        } catch (Exception e) {
            e.printStackTrace();
@ -94,7 +96,7 @@ public class ManageSystemPushMessageController extends EnvelopRestEndpoint {
    @PostMapping(value = "/addPushMessage")
    public Envelop addPushMessage(@ApiParam(name = "content", value = "推送消息", required = true)
                                  @RequestParam(value = "content", required = true) String content,
                                  @ApiParam(name = "pushObjectType", value = "推送对象类型 1签约老人,2部分签约老人", required = true)
                                  @ApiParam(name = "pushObjectType", value = "推送对象类型 1签约老人,2部分签约老人 3家属", required = true)
                                  @RequestParam(value = "pushObjectType", required = true) Integer pushObjectType,
                                  @ApiParam(name = "pushObjectJson", value = "推送对象", required = false)
                                  @RequestParam(value = "pushObjectJson", required = false) String pushObjectJson,
@ -130,4 +132,6 @@ public class ManageSystemPushMessageController extends EnvelopRestEndpoint {
}

+ 74 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/PlatformArticleManage/PlatformArticleManageController.java

@ -0,0 +1,74 @@
package com.yihu.jw.base.endpoint.PlatformArticleManage;
import com.yihu.jw.base.service.manage.PlatformArticleManageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
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.*;
/**
 * Created by wsl on 2022/10/26
 */
@RestController
@RequestMapping("/PlatformArticleManage")
@Api(tags = "平台管理", description = "文章管理")
public class PlatformArticleManageController extends EnvelopRestEndpoint {
    @Autowired
    private PlatformArticleManageService platformArticleManageService;
    @ApiOperation(value = "获取列表")
    @GetMapping("/getArticle")
    public ObjEnvelop getArticle(
            @ApiParam(name = "title", value = "标题", required = false)
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "id", value = "id", required = false)
            @RequestParam(value = "id", required = false) String id,
            @RequestParam(value = "page", required = false) Integer page,
            @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return success(platformArticleManageService.getArticle(page, pageSize, title, id));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @ApiOperation(value = "保存修改")
    @PostMapping("/saveOrUpdate")
    public Envelop saveOrUpdate(@ApiParam(name = "jsonData", value = "实体转JSON", required = true)
                                @RequestParam(value = "jsonData", required = false) String jsonData) {
        try {
            platformArticleManageService.saveOrUpdate(jsonData);
            return success("保存成功!", 200);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("保存失败!");
        }
    }
    @ApiOperation(value = "删除")
    @PostMapping("/deletInfo")
    public Envelop deletinfo(@ApiParam(name = "id", value = "id", required = true)
                             @RequestParam(value = "id", required = true) String id) {
        try {
            platformArticleManageService.deleteinfo(id);
            return success("删除成功!", 200);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("删除失败!");
        }
    }
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/childManage/ChildManageController.java

@ -1,6 +1,6 @@
package com.yihu.jw.base.endpoint.childManage;
import com.yihu.jw.base.service.child.ChildManageService;
import com.yihu.jw.base.service.manage.ChildManageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;

+ 122 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/waresManage/WaresManageController.java

@ -0,0 +1,122 @@
package com.yihu.jw.base.endpoint.waresManage;
import com.yihu.jw.base.service.manage.WaresManageService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
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.http.MediaType;
import org.springframework.web.bind.annotation.*;
/**
 * Created by wsl on 2022/10/27
 */
@RestController
@RequestMapping(value = "/WaresManage", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(value = "推广管理", description = "推广管理", tags = {"wlyy推广管理 - 商品/咨询管理"})
public class WaresManageController extends EnvelopRestEndpoint {
    @Autowired
    private WaresManageService waresManageService;
    @ApiOperation(value = "获取商品列表")
    @GetMapping("/getWaresList")
    public ObjEnvelop getWaresList(
            @ApiParam(name = "title", value = "标题", required = false)
            @RequestParam(value = "title", required = false) String title,
            @ApiParam(name = "id", value = "id", required = false)
            @RequestParam(value = "id", required = false) String id,
            @RequestParam(value = "page", required = false) Integer page,
            @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return success(waresManageService.getWaresList(page, pageSize, title, id));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
    @ApiOperation(value = "保存修改")
    @PostMapping("/saveOrUpdate")
    public Envelop saveOrUpdate(@ApiParam(name = "jsonData", value = "实体转JSON", required = true)
                                @RequestParam(value = "jsonData", required = false) String jsonData) {
        try {
            waresManageService.saveOrUpdate(jsonData);
            return success("保存成功!", 200);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("保存失败!");
        }
    }
    @ApiOperation(value = "删除")
    @PostMapping("/deletInfo")
    public Envelop deletinfo(@ApiParam(name = "id", value = "id", required = true)
                             @RequestParam(value = "id", required = true) String id) {
        try {
            waresManageService.deleteinfo(id);
            return success("删除成功!", 200);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("删除失败!");
        }
    }
    @ApiOperation(value = "删除咨询")
    @PostMapping("/deleteConsultServer")
    public Envelop deleteConsultServer(@ApiParam(name = "id", value = "id", required = true)
                                       @RequestParam(value = "id", required = true) String id) {
        try {
            waresManageService.deleteConsultServer(id);
            return success("删除成功!", 200);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("删除失败!");
        }
    }
    @ApiOperation(value = "保存修改")
    @PostMapping("/saveConsultServer")
    public Envelop saveConsultServer(@ApiParam(name = "name", value = "name", required = true)
                                     @RequestParam(value = "name", required = true) String name,
                                     @ApiParam(name = "mobile", value = "mobile", required = true)
                                     @RequestParam(value = "mobile", required = true) String mobile,
                                     @ApiParam(name = "type", value = "type", required = true)
                                     @RequestParam(value = "type", required = true) String type) {
        try {
            waresManageService.saveConsultServer(name,mobile,type);
            return success("保存成功!", 200);
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError("保存失败!");
        }
    }
    @ApiOperation(value = "获取商品列表")
    @GetMapping("/getConsultWaresList")
    public ObjEnvelop getConsultWaresList(
            @ApiParam(name = "name", value = "标题", required = false)
            @RequestParam(value = "name", required = false) String name,
            @ApiParam(name = "mobile", value = "mobile", required = false)
            @RequestParam(value = "mobile", required = false) String mobile,
            @RequestParam(value = "page", required = false) Integer page,
            @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        try {
            return success(waresManageService.getConsultWaresList(page, pageSize, name, mobile));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");
        }
    }
}

+ 96 - 35
svr/svr-base/src/main/java/com/yihu/jw/base/service/ManageMessagePush/ManageSystemPushMessageService.java

@ -7,6 +7,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.base.dao.log.BasePatientPadPushOnOffDao;
import com.yihu.jw.base.dao.log.BasePushRecordLogDao;
import com.yihu.jw.base.dao.log.BasePushrecordLogInfoDao;
import com.yihu.jw.base.util.WxMessageUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.log.BasePatientPadPushOnOffEntity;
@ -18,17 +19,16 @@ import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;
/**
@ -54,6 +54,10 @@ public class ManageSystemPushMessageService {
    private RestTemplate restTemplate;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private WxMessageUtil putTemplateWxMessage;
    @Value("${wechat.id}")
    private String wxId;
    /*   SELECT p.id,p.name  FROM base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user`
    WHERE p.sign_status = 0 AND p.del = 1 AND d.del = 0 AND p.id NOT IN ( SELECT dict_code FROM `base`.`wlyy_hospital_sys_dict` WHERE `dict_name` = 'jkzl_older' OR dict_name = 'jkzl_child' )*/
@ -64,11 +68,15 @@ public class ManageSystemPushMessageService {
     * 获取签约老人
     * @param name
     */
    public List<BasePatientDO> signOlds(String name) {
    public List<BasePatientDO> signOlds(String name,Integer type) {
        String sql = "SELECT p.id,p.`name`,p.sex FROM  base_patient p " +
                " WHERE  p.sign_status = 1 AND p.del = 1  ";
                " WHERE  p.del = 1 and archive_type = "+type+"  ";
        if (3!=type){
            sql+=" and p.sign_status = 1 ";
        }
        if (StringUtils.isNotBlank(name)) {
            sql += "and p.name like '%" + name + "%'";
@ -78,11 +86,12 @@ public class ManageSystemPushMessageService {
        return basePatientDOS;
    }
    /**
     * 新增消息推送
     *
     * @param content  自定义内容
     * @param pushObjectType  推送对象类型 1签约老人 2部分签约老人
     * @param pushObjectType  推送对象类型 1签约老人 2部分签约老人 3家属
     * @param pushObjectJson 推送对象
     * @param pushDateType  推送时间 1立即推送 2定时推送
     * @param pushDate
@ -102,12 +111,16 @@ public class ManageSystemPushMessageService {
            }
        }
        //判断发送对象类型  1签约老人  2 部分签约老人
        //判断发送对象类型  1签约老人  2 部分签约老人  3 家属
        if (1 == pushObjectType) {
            basePatientDOS = signOlds("");
            basePatientDOS = signOlds("", 1);
            basePushRecordLogEntity.setSendObjectType(1);
            basePushRecordLogEntity.setSendObject("签约老人");
        }else {
        } else if (3 == pushObjectType) {
            basePatientDOS = signOlds("", 3);
            basePushRecordLogEntity.setSendObjectType(3);
            basePushRecordLogEntity.setSendObject("老人家属");
        } else {
            basePatientDOS = JSONObject.parseArray(pushObjectJson, BasePatientDO.class);
            basePushRecordLogEntity.setSendObjectType(2);
            String s = nameStringHandle(basePatientDOS);
@ -117,11 +130,16 @@ public class ManageSystemPushMessageService {
        Integer status ;
        //判断 1立即发送   2定时发送
        if (1==pushDateType) {
            SystemMessageDOListSave(basePatientDOS,content);
            SystemMessageDOListSave(basePatientDOS,content,pushObjectType);
            basePushRecordLogEntity.setStatus(1);
            basePushRecordLogEntity.setSendTime(new Date());
            basePushRecordLogEntity.setPushType("1");
            status = 1;
            if (pushObjectType==3) {
                familyWxPush(content);
            }
        }else{
            basePushRecordLogEntity.setSendTime(date);
            basePushRecordLogEntity.setStatus(0);
@ -133,8 +151,14 @@ public class ManageSystemPushMessageService {
        //创建定时任务记录
        for (BasePatientDO logInfoDO : basePatientDOS) {
            String data = content;
            if (StringUtils.containsIgnoreCase(content,"【姓名】"))data = data.replace("【姓名】",logInfoDO.getName());
            if (StringUtils.containsIgnoreCase(content,"【称谓】"))data = data.replace("【称谓】",logInfoDO.getSex()==1?"大爷":"大妈");
            if (StringUtils.containsIgnoreCase(content, "【姓名】")) data = data.replace("【姓名】", logInfoDO.getName());
            if (pushObjectType == 1 || pushObjectType == 2) {
                if (StringUtils.containsIgnoreCase(content, "【称谓】"))data = data.replace("【称谓】", logInfoDO.getSex() == 1 ? "爷爷" : "奶奶");
            }else {
                if (StringUtils.containsIgnoreCase(content, "【称谓】"))data = data.replace("【称谓】", "家属");
            }
            BasePushrecordLogInfoEntity basePushrecordLogInfoEntity = new BasePushrecordLogInfoEntity();
            basePushrecordLogInfoEntity.setPatient(logInfoDO.getId());
            basePushrecordLogInfoEntity.setPatientName(logInfoDO.getName());
@ -156,10 +180,30 @@ public class ManageSystemPushMessageService {
            basePushrecordLogInfoEntityList.forEach(basePushLogInfoEntity -> basePushLogInfoEntity.setPushId(basePushRecordLogEntity.getId()));
            basePushrecordLogInfoDao.save(basePushrecordLogInfoEntityList);
        }
    }
    @Async
    public void familyWxPush(String content){
        String sql ="select name,openid from base_patient where archive_type = 3 and openid is not null";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list.size()>0) {
            for (Map<String, Object> map : list) {
                String newContent = content;
                if (StringUtils.containsIgnoreCase(content, "【姓名】")) newContent = newContent.replace("【姓名】", map.get("name").toString());
                if (StringUtils.containsIgnoreCase(content, "【称谓】")) newContent  = newContent.replace("【称谓】","");
                String first  = "您好,朝晖云朝晖向您发送一条通知";
                putTemplateWxMessage.putTemplateWxMessage(wxId,"template_system_family","jsxtxx",map.get("openid").toString(),first,null,null,1,null,newContent,"【推送完成】",DateUtil.getStringDate());
                return;
                //putTemplateWxMessage.putTemplateWxMessage(wxId,"template_fwlx","fwlx",map.get("openid").toString(),null,null,null,1,null,"",newContent,"【推送完成】",DateUtil.getStringDate());
            }
        }
    }
    //获取列表
    public JSONObject pushMessageList(Integer messageType,Integer status,String name,Integer page,Integer pageSize){
@ -278,30 +322,47 @@ public class ManageSystemPushMessageService {
    private void SystemMessageDOListSave(List<BasePatientDO> basePatientDOS,String content){
    private void SystemMessageDOListSave(List<BasePatientDO> basePatientDOS,String content,Integer pushObjectType){
        List<SystemMessageDO> messageDOS = new ArrayList<>();
        for (BasePatientDO basePatientDO : basePatientDOS) {
            String data = content;
            if (StringUtils.containsIgnoreCase(content,"【姓名】"))data = data.replace("【姓名】",basePatientDO.getName());
            if (StringUtils.containsIgnoreCase(content,"【称谓】"))data = data.replace("【称谓】",basePatientDO.getSex()==1?"大爷":"大妈");
            SystemMessageDO systemMessageDO = new SystemMessageDO();
            systemMessageDO.setId(UUID.randomUUID().toString().replace("-", ""));
            systemMessageDO.setTitle("系统消息推送");
            systemMessageDO.setType("999");
            systemMessageDO.setIsRead("0");
            systemMessageDO.setSender("system");
            systemMessageDO.setSenderName("系统推送助手");
            systemMessageDO.setReceiver(basePatientDO.getId());
            systemMessageDO.setReceiverName(basePatientDO.getName());
            systemMessageDO.setContent(data);
            systemMessageDO.setOver("1");
            systemMessageDO.setDel("1");
            systemMessageDO.setCreateTime(new Date());
            systemMessageDO.setAudioUrl(audioUrl(data));
            messageDOS.add(systemMessageDO);
            patientMessageSocket(systemMessageDO);
            Boolean flag = true;
            if (3==pushObjectType){
                String sql = "select on_off from base_patient_family_pushonoff where patient = '"+basePatientDO.getId()+"' and  type = 4  ";
                List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
                if (list.size()>0) {
                     flag = list.get(0).get("on_off").toString().equals("1")?true:false;
                }
            }
            if (flag) {
                String data = content;
                if (StringUtils.containsIgnoreCase(content, "【姓名】"))
                    data = data.replace("【姓名】", basePatientDO.getName());
                if (StringUtils.containsIgnoreCase(content, "【称谓】") && pushObjectType != 3){
                    data = data.replace("【称谓】", basePatientDO.getSex() == 1 ? "爷爷" : "奶奶");
                }else {
                    data = data.replace("【称谓】","");
                }
                SystemMessageDO systemMessageDO = new SystemMessageDO();
                systemMessageDO.setId(UUID.randomUUID().toString().replace("-", ""));
                systemMessageDO.setTitle("系统消息推送");
                systemMessageDO.setType("999");
                systemMessageDO.setIsRead("0");
                systemMessageDO.setSender("system");
                systemMessageDO.setSenderName("系统推送助手");
                systemMessageDO.setReceiver(basePatientDO.getId());
                systemMessageDO.setReceiverName(basePatientDO.getName());
                systemMessageDO.setContent(data);
                systemMessageDO.setOver("1");
                systemMessageDO.setDel("1");
                systemMessageDO.setCreateTime(new Date());
                systemMessageDO.setAudioUrl(audioUrl(data));
                systemMessageDO.setUserType(pushObjectType);
                messageDOS.add(systemMessageDO);
                patientMessageSocket(systemMessageDO);
            }
        }
        systemMessageDao.save(messageDOS);
    }

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/doctor/BaseDoctorService.java

@ -1314,7 +1314,7 @@ public class BaseDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
                salt = randomString(5);
                baseDoctorDO.setSalt(salt);
            }
            baseDoctorDO.setPassword(MD5.md5Hex(baseDoctorDO.getIdcard().substring(12, 18) + "{" + salt + "}"));
            baseDoctorDO.setPassword(MD5.md5Hex("a123456*" + "{" + salt + "}"));
            baseDoctorDao.save(baseDoctorDO);
            if ("xm_ykyy_wx".equalsIgnoreCase(wxId)){
                String res = ykyyService.getResetCode("4",baseDoctorDO.getMobile());

+ 2 - 1
svr/svr-base/src/main/java/com/yihu/jw/base/service/child/ChildManageService.java

@ -1,4 +1,4 @@
package com.yihu.jw.base.service.child;
package com.yihu.jw.base.service.manage;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.childManage.BaseChildManageDao;
@ -16,6 +16,7 @@ import java.util.Map;
/**
 * Created by wsl on 2022/7/20
 * 幼儿咨询 管理
 */
@Service

+ 89 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/manage/PlatformArticleManageService.java

@ -0,0 +1,89 @@
package com.yihu.jw.base.service.manage;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.childManage.BaseChildManageDao;
import com.yihu.jw.entity.child.BaseChildManage;
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 org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
 * Created by wsl on 2022/10/24
 * 平台咨询-文章管理
 */
@Service
public class PlatformArticleManageService {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseChildManageDao baseChildManageDao;
    //列表 获取详细
    public JSONObject getArticle(Integer page,Integer pageSize,String title,String id){
        JSONObject result = new JSONObject();
        String sql = "select * from base_child_manage where type = 4 ";
        String totalSql = "select count(id) from base_child_manage where type = 4  ";
        StringBuffer commonSql = new StringBuffer();
        if(page==null){
            page = 1;
        }
        if(pageSize==null){
            pageSize = 10;
        }
        if (StringUtils.isNotBlank(id)) {
            commonSql.append("and id = '"+id+"' ");
        }
        if (StringUtils.isNotBlank(title)){
            commonSql.append(" and title like '%"+title+"%' ");
        }
        commonSql.append(" ORDER BY create_time DESC LIMIT  " + (page - 1) * pageSize + "," + pageSize + "");
        List<BaseChildManage> articleManage = jdbcTemplate.query(sql+commonSql, new BeanPropertyRowMapper<>(BaseChildManage.class));
        Integer total = jdbcTemplate.queryForObject(totalSql + commonSql, Integer.class);
        result.put("obj",articleManage);
        result.put("total",total);
        return result;
    }
    //新增修改
    @Transactional(rollbackFor = Exception.class)
    public void saveOrUpdate(String jsonData) {
        BaseChildManage baseChildManage = JSONObject.parseObject(jsonData, BaseChildManage.class);
        if (null == baseChildManage.getId()) {
            baseChildManage.setCreateTime(new Date());
            baseChildManage.setType(4);
            baseChildManage.setClick(0);
        }
        baseChildManageDao.save(baseChildManage);
    }
    //删除
    @Transactional(rollbackFor = Exception.class)
    public void deleteinfo(String id){
            baseChildManageDao.delete(id);
    }
}

+ 140 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/manage/WaresManageService.java

@ -0,0 +1,140 @@
package com.yihu.jw.base.service.manage;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.base.dao.childManage.BaseChildManageDao;
import com.yihu.jw.base.dao.childManage.BaseConsultWaresManageDao;
import com.yihu.jw.entity.child.BaseChildManage;
import com.yihu.jw.entity.child.BaseConsultWaresManageEntity;
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 org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
 * Created by wsl on 2022/10/25
 *
 * 推广管理-商品管理-商品咨询
 */
@Service
public class WaresManageService {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private BaseChildManageDao baseChildManageDao;
    @Autowired
    private BaseConsultWaresManageDao baseConsultWaresManageDao;
    //新增修改
    @Transactional(rollbackFor = Exception.class)
    public void saveOrUpdate(String jsonData) {
        BaseChildManage baseChildManage = JSONObject.parseObject(jsonData, BaseChildManage.class);
        if (null == baseChildManage.getId()) {
            baseChildManage.setCreateTime(new Date());
            baseChildManage.setType(5);
            baseChildManage.setClick(0);
        }
        baseChildManageDao.save(baseChildManage);
    }
    public JSONObject getWaresList(Integer page,Integer pageSize,String title,String id){
        JSONObject result = new JSONObject();
        String sql = "select * from base_child_manage where type = 5 ";
        String totalSql = "select count(id) from base_child_manage where type = 5  ";
        StringBuffer commonSql = new StringBuffer();
        if(page==null){
            page = 1;
        }
        if(pageSize==null){
            pageSize = 10;
        }
        if (StringUtils.isNotBlank(id)) {
            commonSql.append("and id = '"+id+"' ");
        }
        if (StringUtils.isNotBlank(title)){
            commonSql.append(" and title like '%"+title+"%' ");
        }
        commonSql.append(" ORDER BY sort ASC,create_time DESC  LIMIT  " + (page - 1) * pageSize + "," + pageSize + "");
        List<BaseChildManage> articleManage = jdbcTemplate.query(sql+commonSql, new BeanPropertyRowMapper<>(BaseChildManage.class));
        Integer total = jdbcTemplate.queryForObject(totalSql + commonSql, Integer.class);
        result.put("obj",articleManage);
        result.put("total",total);
        return result;
    }
    //删除
    @Transactional(rollbackFor = Exception.class)
    public void deleteinfo(String id){
        baseChildManageDao.delete(id);
    }
    /*---------------------------------服务咨询---------------------------*/
    @Transactional(rollbackFor = Exception.class)
    public void saveConsultServer(String name,String mobile,String type){
        BaseConsultWaresManageEntity baseConsultWaresManageEntity = new BaseConsultWaresManageEntity();
        baseConsultWaresManageEntity.setWarescode(type);
        baseConsultWaresManageEntity.setName(name);
        baseConsultWaresManageEntity.setMobile(mobile);
        baseConsultWaresManageEntity.setSendTime(new Date());
        baseConsultWaresManageDao.save(baseConsultWaresManageEntity);
    }
    @Transactional(rollbackFor = Exception.class)
    public void deleteConsultServer(String id){
        baseConsultWaresManageDao.delete(id);
    }
    public JSONObject getConsultWaresList(Integer page,Integer pageSize,String name,String mobile){
        JSONObject jsonObject = new JSONObject();
        StringBuffer sql = new StringBuffer("select * from base_consult_wares_manage where 1=1 ");
        StringBuffer sqlTotal = new StringBuffer("select count(id) from base_consult_wares_manage where 1=1 ");
        if (StringUtils.isNotBlank(name)){
            sql.append(" and name like '%"+name+"%' ");
            sqlTotal.append(" and name like '%"+name+"%' ");
        }
        if (StringUtils.isNotBlank(mobile)){
            sql.append(" and mobile like '%"+mobile+"%' ");
            sqlTotal.append(" and mobile like '%"+mobile+"%' ");
        }
        sql.append(" order by send_time DESC LIMIT  " + (page - 1) * pageSize + "," + pageSize + "");
        List<BaseConsultWaresManageEntity> result = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper<>(BaseConsultWaresManageEntity.class));
        Integer total =jdbcTemplate.queryForObject(sqlTotal.toString(), Integer.class);
        jsonObject.put("obj",result);
        jsonObject.put("total",total);
        return jsonObject;
    }
}

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/log/BaseConsultWaresManageDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.log;
import com.yihu.jw.entity.child.BaseConsultWaresManageEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
 * Created by wsl on 2022/10/28
 */
public interface BaseConsultWaresManageDao extends JpaRepository<BaseConsultWaresManageEntity, String>, JpaSpecificationExecutor<BaseConsultWaresManageEntity> {
}

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/log/BaseFamilyPushOnOffDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.care.dao.log;
import com.yihu.jw.entity.log.BaseFamilyPushOnOffEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wsl on 2022/10/31
 */
public interface BaseFamilyPushOnOffDao extends PagingAndSortingRepository<BaseFamilyPushOnOffEntity, String>, JpaSpecificationExecutor<BaseFamilyPushOnOffEntity> {
    @Modifying
    @Query("update BaseFamilyPushOnOffEntity a set a.onOff =?3 where a.patient=?1 and a.type = ?2")
    void updPushOnOff(String patient,Integer type,Integer onOff);
}

+ 2 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/admin/CommonEndpoint.java

@ -5,10 +5,7 @@ import com.yihu.jw.care.dao.label.BaseCapacityLabelDao;
import com.yihu.jw.care.service.common.CommomService;
import com.yihu.jw.care.service.device.DevicePatientFaceService;
import com.yihu.jw.care.service.patient.CarePatientService;
import com.yihu.jw.care.util.DingdingUtil;
import com.yihu.jw.care.util.HongLingJinUtil;
import com.yihu.jw.care.util.PatientPushOnOffUtil;
import com.yihu.jw.care.util.SpeechTtsUtil;
import com.yihu.jw.care.util.*;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.label.BaseCapacityLabelDO;
import com.yihu.jw.patient.dao.BasePatientDao;
@ -66,6 +63,7 @@ public class CommonEndpoint extends EnvelopRestEndpoint {
    private PatientPushOnOffUtil patientPushOnOffUtil;
    @GetMapping(value = "open/getToken")
    @ApiOperation(value = "红领巾平台获取token")
    public Envelop getToken() {

+ 4 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/child/ChildManageController.java

@ -25,16 +25,18 @@ public class ChildManageController extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取列表")
    @PostMapping("/getChildManageList")
    public ObjEnvelop getChildManageList(@ApiParam(name = "type" ,value = "类型 1图文辅导,2视频辅导,3喜讯详细",required = true)
    public ObjEnvelop getChildManageList(@ApiParam(name = "type" ,value = "类型 1图文辅导,2视频辅导,3喜讯详细 4文章管理 5商品管理",required = true)
                                         @RequestParam(value = "type",required = true)Integer type,
                                         @ApiParam(name = "id" ,value = "id",required = false)
                                         @RequestParam(value = "id",required = false)String id,
                                         @ApiParam(name = "title" ,value = "标题",required = false)
                                         @RequestParam(value = "title",required = false)String title,
                                         @RequestParam(value = "page",required = false)Integer page,
                                         @RequestParam(value = "pageSize",required = false)Integer pageSize){
        try {
            return success(childNewsListService.getChildManageList(type,page,pageSize,id));
            return success(childNewsListService.getChildManageList(type,page,pageSize,id,title));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("获取失败");

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

@ -1,20 +1,24 @@
package com.yihu.jw.care.endpoint.common;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.message.PatientMessageService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.care.util.WeatherUtil;
import com.yihu.jw.entity.care.weather.BaseWeatherDayDO;
import com.yihu.jw.entity.care.weather.BaseWeatherWeekDO;
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.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -30,6 +34,8 @@ public class CommonController extends EnvelopRestEndpoint {
    @Autowired
    private WeatherUtil weatherUtil;
    @Autowired
    private PatientMessageService patientMessageService;
    @GetMapping(value = "weather")
@ -47,4 +53,81 @@ public class CommonController extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "open/saveRegisterInfo")
    @ApiOperation(value = "保存登记信息")
    public Envelop saveRegisterInfo( @RequestParam(value = "name",required = true)String name,
                                     @RequestParam(value = "phone",required = true)String phone,
                                     @RequestParam(value = "type",required = true)String type){
        try {
            //String zzz = "0\\d{2,3}[-]?\\d{7,8}|0\\d{2,3}\\s?\\d{7,8}|13[0-9]\\d{8}|15[1089]\\d{8}";
            //phone.matches(zz);
            patientMessageService.saveRegisterInfo(name, phone, type);
            return success("保存成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException2(e);
        }
    }
    @GetMapping(value = "open/getDeviceArticleList")
    @ApiOperation(value = "获取商品文章")
    public ListEnvelop getDeviceArticleList(@RequestParam(value = "id",required = false)String id){
        try {
            return success(patientMessageService.getDeviceArticleList(id));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "open/getDeviceArticleDict")
    @ApiOperation(value = "免登录字典")
    public ListEnvelop getDeviceArticleDict(){
        try {
            return success(patientMessageService.getDeviceArticleDict());
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @PostMapping(value = "open/cshOnOff")
    @ApiOperation(value = "初始化家属开关")
    public Envelop cshOnOff(){
        try {
            patientMessageService.cshOnOff();
            return success("成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException2(e);
        }
    }
    @Autowired
    private MessageUtil messageUtil;
    @Value("${wechat.id}")
    private String wxId;
    @GetMapping(value = "wxtxmob")
    @ApiOperation(value = "推送微信模板")
    public Envelop wxtxmob(){
        try {
            StringBuffer content = new StringBuffer(" 紧急预警:0次 \r\n 生活照料:0次  ");
            boolean b = messageUtil.putTemplateWxMessage(wxId, "template_zhrb", "zhrb", "o_DJs59V7MKJ5ea-YW__LoccEn50", null, null, null, 1, null, content.toString(),"推送完成", DateUtil.getStringDate());
            return success(b);
        } catch (Exception e) {
            e.printStackTrace();
            return failedException2(e);
        }
    }
}

+ 35 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/consult/WxPushEndpoint.java

@ -58,4 +58,39 @@ public class WxPushEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "sendFamilyWxTemplate")
    @ApiOperation(value = "发送微信模板消息")
    @ObserverRequired
    public Envelop sendFamilyWxTemplate(@ApiParam(name = "openid", value = "openid")
                                        @RequestParam(value = "openid", required = false) String openid,
                                        @ApiParam(name = "content", value = "发送内容")
                                        @RequestParam(value = "content", required = false) String content,
                                        @ApiParam(name = "contentString", value = "发送类型")
                                        @RequestParam(value = "contentString", required = false) String contentString,
                                        @ApiParam(name = "sessionId", value = "会话id")
                                        @RequestParam(value = "sessionId", required = false) String sessionId,
                                        @ApiParam(name = "title", value = "会话id")
                                        @RequestParam(value = "title", required = false) String title,
                                        @ApiParam(name = "id", value = "居民id")
                                        @RequestParam(value = "id", required = false) String id) {
        try {
            int i = wxPushService.sendFamilyWxTemplate(openid, content, contentString, title, sessionId);
            switch (i){
                case 1:
                    return success("微信模板--发送成功");
                case -1:
                    return success("微信模板--openid 不存在");
                default:
                    return success("微信模板--发送异常");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failedException2(e);
        }
    }
}

+ 69 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/PatientMessageEndpoint.java

@ -192,6 +192,23 @@ public class PatientMessageEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "/familyPushOnOffUpd")
    @ApiOperation("修改家属推送开关")
    public Envelop familyPushOnOffUpd(@ApiParam(name = "patient",required = true)
                                          @RequestParam(value = "patient")String patient,
                                          @ApiParam(name = "type",value = "以数据库为主 base_patient_family_pushonoff ",required = true)
                                          @RequestParam(value = "type")Integer type,
                                          @ApiParam(name = "onOff",required = true)
                                          @RequestParam(value = "onOff")Integer onOff){
        try {
            patientMessageService.familyPushOnOffUpd(patient,type,onOff);
            return Envelop.getSuccess("修改成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return failedException2(e);
        }
    }
    @GetMapping(value = "/patientPadPushOnOff")
    @ApiOperation(value = "获取居民推送开关")
    public ListEnvelop patientPadPushOnOff(@ApiParam(name ="patient",required =true)
@ -206,4 +223,56 @@ public class PatientMessageEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "/familyPushOnOff")
    @ApiOperation(value = "获取家属推送开关")
    public ListEnvelop familyPushOnOff(@ApiParam(name ="patient",required =true)
                                           @RequestParam(value = "patient")String patient){
        try {
            List<Map<String, Object>> list = patientMessageService.familyPushOnOff(patient);
            return success("获取成功",200,list);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "/getZhaoHuiRiBaoList")
    @ApiOperation(value = "获取朝晖日报")
    public ListEnvelop getZhaoHuiRiBaoList(@ApiParam(name = "startTime", required = false)
                                           @RequestParam(value = "startTime") String startTime,
                                           @ApiParam(name = "endTime", required = false)
                                           @RequestParam(value = "endTime") String endTime,
                                           @ApiParam(name = "patient", required = true)
                                           @RequestParam(value = "patient") String patient
    ) {
        try {
            return success("获取成功",200,patientMessageService.getZhaoHuiRiBaoList(startTime, endTime, patient));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "/getSystemMessageListNew")
    @ApiOperation(value = "获取系统消息")
    public ListEnvelop getSystemMessageListNew(@ApiParam(name = "type", required = false)
                                               @RequestParam(value = "type") String type,
                                               @ApiParam(name = "patient", required = false)
                                               @RequestParam(value = "patient") String patient,
                                               @ApiParam(name = "startTime", required = false)
                                               @RequestParam(value = "startTime",required = false) String startTime,
                                               @ApiParam(name = "endTime", required = false)
                                               @RequestParam(value = "endTime",required = false) String endTime) {
        try {
            return success("获取成功!", 200, patientMessageService.getFamilySystemMessageList(type, patient, startTime, endTime));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
}

+ 35 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/patient/PatientNoLoginEndPoint.java

@ -17,7 +17,7 @@ import com.yihu.jw.wechat.service.WechatInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.axis.utils.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -54,6 +54,40 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
    @Autowired
    private ConsultService consultService;
    /**
     * 获取微信小程序openid
     *
     * @param code
     * @return
     */
    @RequestMapping(value = "/getXOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET})
    public Envelop getXOpenidByCode(String code){
        try {
            //通过redis获取openid, 获取不到,则调用微信接口去取
            String key = wxId+":code";
            String openid = redisTemplate.opsForValue().get(key);
            if(!StringUtils.isEmpty(openid)){
                return success(PatientRequestMapping.Wechat.api_success,openid);
            }
            org.json.JSONObject json = wechatInfoService.getXOpenidByCode(code, wxId);
            if(json.has("openid")){
                openid = json.getString("openid");
                JSONObject res = new JSONObject();
                res.put("openid",openid);
                res.put("unionid",json.getString("unionid"));
                res.put("session_key",json.getString("session_key"));
                redisTemplate.opsForValue().set(key,openid);
                redisTemplate.expire(key,10, TimeUnit.SECONDS);
                return success(PatientRequestMapping.Wechat.api_success,res);
            }else {
                return Envelop.getError("获取失败");
            }
        } catch (Exception e){
            return  failedException2(e);
        }
    }
    /**
     * 获取微信openid
     *
@ -61,7 +95,6 @@ public class PatientNoLoginEndPoint extends EnvelopRestEndpoint {
     * @return
     */
    @RequestMapping(value = "/getOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public Envelop getOpenidByCode(String code, @RequestParam(value = "patientId", required = false)String patientId) throws Exception {
        try {

+ 8 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/child/ChildNewsListService.java

@ -26,7 +26,7 @@ public class ChildNewsListService {
    //获取
    @Transactional(rollbackFor = Exception.class)
    public JSONObject getChildManageList(Integer type, Integer page, Integer pageSize,String id){
    public JSONObject getChildManageList(Integer type, Integer page, Integer pageSize,String id,String title){
        JSONObject jsonObject = new JSONObject();
@ -49,6 +49,13 @@ public class ChildNewsListService {
            if(pageSize==null){
                pageSize = 10;
            }
            if (StringUtils.isNotBlank(title)) {
                sql+=" and title ='"+title+"'";
                totalSql+=" and title ='"+title+"'";
            }
            limitSql +=" LIMIT  " + (page - 1) * pageSize + "," + pageSize + "";
        }

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

@ -11,6 +11,7 @@ import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -83,4 +84,33 @@ public class WxPushService {
        }
    }
    /**
     *居民 p2p
     */
    public int sendFamilyWxTemplate(String openid,String content,String contentString,String first,String sessionId){
        String url = "https://zhyzh.gongshu.gov.cn/medical-care-patient/message/index";
        if (StringUtils.isBlank(openid)) {
            return -1;
        }
        switch (contentString){
            case "[图片]":
                content = "【图片】";
                break;
            case "[语音]":
                content = "【语音】";
                break;
            default:
                break;
        }
        messageUtil.putTemplateWxMessage(wxId, "template_system_family", "jsxtxx", openid, first, url, null, 1, null, content, "推送完成", DateUtil.getStringDate());
        return 1;
    }
}

+ 171 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/hzwulianganzhi/HzWuLianDeviceService.java

@ -0,0 +1,171 @@
package com.yihu.jw.care.service.device.hzwulianganzhi;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.tomcat.util.codec.binary.Base64;
import org.bouncycastle.asn1.pkcs.RSAPublicKey;
import org.springframework.stereotype.Service;
import javax.crypto.Cipher;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.security.Key;
import java.security.KeyFactory;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by wsl on 2022/10/20
 */
@Service
public class HzWuLianDeviceService {
    /*200 成功
    401 token 错误
    402 token 失效
    403 appkey 错误
    405 请求参数错误
    420 报文校验不合格
    421 请求内容错误
    422 传输数据验证不正确
    500 服务器内部错误*/
    private final String tokenUrl = "/api/sp/token";  //token 获取
    private final String deviceSyncUrl = "/api/device/deviceSync";  //设备基础信息同步
    private final String dataBatchSyncUrl = "/api/device/dataBatchSync";  //设备运行数据上报
    private final String alarmDealSyncUrl = "/api/alarm/alarmDealSync";  // 事件处置同步
    private final String searchAddrUrl = "/api/zfw/searchAddr";  // 政法委统一地址库编码查询
    private final String appkey = "";
    //获取Token
    public String getToken(){
        String url = ""+tokenUrl;
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appkey","10"));    //设备名称
        Map<String,Object> headerMap=new HashMap<>();
        headerMap.put("token","xxx");
        headerPost(url,params,"UTF-8",headerMap);
        return null;
    }
    public void deviceSync(){
        String url = ""+deviceSyncUrl;
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("deviceName","10"));    //设备名称
        params.add(new BasicNameValuePair("deviceCode","10"));    //设备唯一编号
        params.add(new BasicNameValuePair("deviceTypeCode","10"));  //设备类型编码
        params.add(new BasicNameValuePair("deviceTypeName","10"));  //设备类型名称
        params.add(new BasicNameValuePair("manufacturer","10"));   //设备制造商
        params.add(new BasicNameValuePair("linkType","10"));   //通讯方式
        params.add(new BasicNameValuePair("provinceCode","10"));  //省编码
        params.add(new BasicNameValuePair("provinceName","10"));  //省
        params.add(new BasicNameValuePair("cityCode","10"));    //市编码
        params.add(new BasicNameValuePair("cityName","10"));   //市
        params.add(new BasicNameValuePair("districtCode","10"));  //区编码
        params.add(new BasicNameValuePair("districtName","10")); //区
        params.add(new BasicNameValuePair("address","10")); //位置信息
        params.add(new BasicNameValuePair("lng","10")); //地图经度
        params.add(new BasicNameValuePair("lat","10")); //地图纬度
        params.add(new BasicNameValuePair("state","10")); //数据状态
        params.add(new BasicNameValuePair("status","10")); //设备状态
        params.add(new BasicNameValuePair("transmissionIntercal","10")); //传输间隔
        params.add(new BasicNameValuePair("dept","10"));  //部门/单位
        params.add(new BasicNameValuePair("scene1","10"));  //一级场景编码
        params.add(new BasicNameValuePair("scene2","10"));  //二级场景编码
        params.add(new BasicNameValuePair("scene3","10"));  //三级场景编码
        params.add(new BasicNameValuePair("unifiedAddressCode","10")); //政法委统一地址库编码
        Map<String,Object> headerMap=new HashMap<>();
        headerMap.put("appkey","appkey");
        headerMap.put("token","xxx");
        headerPost(url,params,"UTF-8",headerMap);
    }
    /**
     * RSA公钥解密
     * @param str       解密字符串
     * @param publicKey 私钥
     * @return 明文
     * @throws Exception 解密过程中的异常信息
     */
    public static String rsaPublicDecrypt(String str, String publicKey)
            throws Exception {
        byte[] inputByte = Base64.decodeBase64(str.getBytes("UTF-8"));
        byte[] decoded = Base64.decodeBase64(publicKey);
        RSAPublicKey pubKey = (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(decoded));
        Cipher cipher = Cipher.getInstance("RSA");
        cipher.init(Cipher.DECRYPT_MODE, (Key) pubKey);
        String outStr = new String(cipher.doFinal(inputByte));
        return outStr;
    }
    private   String headerPost(String url, List<NameValuePair> params, String chatSet, Map<String,Object> headerMap) {
        // 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost(url);
        UrlEncodedFormEntity uefEntity;
        try {
            uefEntity = new UrlEncodedFormEntity(params, chatSet);
            httppost.setEntity(uefEntity);
            if (headerMap.size() > 0) {
                for (String str : headerMap.keySet()) {
                    httppost.addHeader(str, headerMap.get(str).toString());
                }
            }
            CloseableHttpResponse response = httpclient.execute(httppost);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

+ 139 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -1,8 +1,13 @@
package com.yihu.jw.care.service.message;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.child.BaseChildManageDao;
import com.yihu.jw.care.dao.device.PatientSafeAreaConfirmDao;
import com.yihu.jw.care.dao.device.PatientSafeAreaDao;
import com.yihu.jw.care.dao.log.BaseConsultWaresManageDao;
import com.yihu.jw.care.dao.log.BaseFamilyPushOnOffDao;
import com.yihu.jw.care.dao.log.BasePatientPadPushOnOffDao;
import com.yihu.jw.care.dao.message.OrgNoticeDao;
import com.yihu.jw.care.dao.message.UserNoticeDao;
@ -14,7 +19,11 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.PatientSafeAreaDO;
import com.yihu.jw.entity.care.message.OrgNoticeDO;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.child.BaseChildManage;
import com.yihu.jw.entity.child.BaseConsultWaresManageEntity;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.log.BaseFamilyPushOnOffEntity;
import com.yihu.jw.entity.log.ZhaohuiDailyEntity;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
@ -22,10 +31,12 @@ import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
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 org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -57,6 +68,11 @@ public class PatientMessageService {
    private EmergencyAssistanceService emergencyAssistanceService;
    @Autowired
    private BasePatientPadPushOnOffDao basePatientPadPushOnOffDao;
    @Autowired
    BaseConsultWaresManageDao baseConsultWaresManageDao;
    @Autowired
    private BaseFamilyPushOnOffDao baseFamilyPushOnOffDao;
    public PageEnvelop getNoticeList(String patient,String beginTime, String endTime, int page, int size){
        page = page>0?page-1:0;
@ -244,6 +260,58 @@ public class PatientMessageService {
        return list;
    }
    //家属端 获取家属开关
    public List<Map<String, Object>> familyPushOnOff(String patient){
        String sql = "select patient,type,type_name,on_off from base_patient_family_pushonoff where patient ='"+patient+"'";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    //家属端 修改推送开关
    @Transactional(rollbackFor = Exception.class)
    public void familyPushOnOffUpd(String patient, Integer type, Integer onOff) {
        baseFamilyPushOnOffDao.updPushOnOff(patient, type, onOff);
    }
    @Transactional(rollbackFor = Exception.class)
    public void cshOnOff(){
        JSONObject jsonObject = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        List<BaseFamilyPushOnOffEntity> onOffEntityList = new ArrayList<>();
        jsonObject.put("1","紧急预警");
        jsonArray.add(jsonObject);
        jsonObject.put("2","设备动态");
        jsonArray.add(jsonObject);
        jsonObject.put("3","体征动态");
        jsonArray.add(jsonObject);
        jsonObject.put("4","平台通知");
        jsonArray.add(jsonObject);
        //base_patient_pad_pushonoff
        String sql = "select * from base_patient where archive_type = 3 and del = 1";
        List<BasePatientDO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientDO.class));
        for (BasePatientDO basePatientDO : query) {
            for (int i = 1; i <= jsonArray.size(); i++) {
                BaseFamilyPushOnOffEntity ent = new BaseFamilyPushOnOffEntity();
                ent.setPatient(basePatientDO.getId());
                ent.setType(i);
                ent.setTypeName(jsonArray.getJSONObject(0).getString(i+""));
                ent.setOnOff(1);
                ent.setCreateTime(new Date());
                onOffEntityList.add(ent);
            }
        }
        Iterable<BaseFamilyPushOnOffEntity> save = baseFamilyPushOnOffDao.save(onOffEntityList);
        System.out.println(save.toString());
    }
    //pad端 修改居民推送开关
    @Transactional(rollbackFor = Exception.class)
    public void patientPadPushOnOffUpd(String patient, Integer type, Integer onOff) {
@ -251,6 +319,77 @@ public class PatientMessageService {
    }
    public List<ZhaohuiDailyEntity> getZhaoHuiRiBaoList(String start,String end,String patient) {
        StringBuffer sql  =new StringBuffer("select * from base_zhaohui_daily where patient = '"+patient+"'  ") ;
        if (StringUtils.isNotBlank(start)) {
            sql.append(" and create_time >='"+start+"' ");
        }
        if (StringUtils.isNotBlank(end)) {
            sql.append(" and create_time <= '"+end+"' ");
        }
        List<ZhaohuiDailyEntity> zhaohuiDailyEntities = jdbcTemplate.queryForList(sql.toString(), ZhaohuiDailyEntity.class);
        return  zhaohuiDailyEntities;
    }
    public List<Map<String, Object>> getFamilySystemMessageList(String type,String patient,String startTime,String endTime){
        StringBuffer sql = new StringBuffer("select id,code,type,title,sender,sender_name,receiver,receiver_name,data,is_read,del,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%s') as create_time ,content,user_type from base_system_message where user_type = 3 and type in ("+type+") and receiver = '"+patient+"' ");
        if (StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime)){
            startTime = startTime+" 00:00:00";
            endTime = endTime+" 23:59:59";
            sql.append(" and create_time >= '"+startTime+"' and  create_time<='"+endTime+"' ");
        }
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql.toString());
        return list;
    }
    //落地页-保存登记信息
    @Transactional(rollbackFor = Exception.class)
    public void saveRegisterInfo(String name,String phone,String type){
        BaseConsultWaresManageEntity entity = new BaseConsultWaresManageEntity();
        entity.setName(name);
        entity.setMobile(phone);
        entity.setWarescode(type);
        entity.setSendTime(new Date());
        baseConsultWaresManageDao.save(entity);
    }
    @Autowired
    private BaseChildManageDao baseChildManageDao;
    //落地页-获取商品文章
    public List<Map<String, Object>> getDeviceArticleList(String id){
        List<Map<String, Object>> list = new ArrayList<>();
        String sql = "";
        if (StringUtils.isNotBlank(id)) {
            sql = "select id,type,org_name,title,url,img,click,sort,del*1 as del,DATE_FORMAT(create_time,'%Y-%m-%d') as create_time from base_child_manage where type = 5 and del = 1 and id='"+id+"' order by sort";
            list = jdbcTemplate.queryForList(sql);
            if (list.size()>0) {
                BaseChildManage baseChildManage = JSONObject.parseObject(JSON.toJSON(list.get(0)).toString(), BaseChildManage.class);
                baseChildManage.setClick(baseChildManage.getClick()+1);
                baseChildManageDao.save(baseChildManage);
            }
        }else {
            sql = "select *  from base_child_manage where type = 5 and del = 1 order by sort";
            list = jdbcTemplate.queryForList(sql);
        }
        return list;
    }
    public List<Map<String, Object>>  getDeviceArticleDict(){
        String sql = "select id,dict_name,dict_code,dict_value from wlyy_hospital_sys_dict where dict_name = 'consultService' order by sort  ";
        return jdbcTemplate.queryForList(sql);
    }
}

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

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

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

@ -178,7 +178,7 @@ public class MessageUtil {
                taskDescription = "您好,"+assistanceDO.getPatientName()+"居民发起紧急呼叫,请及时处理。";
                eventLocation = assistanceDO.getServeAddress();
            }
            hongLingJinUtil.zzdcommon(doctorDO.getMobile(),doctorDO.getName(),eventHappenTime,eventName,taskDescription,eventLocation,taskId);
            //hongLingJinUtil.zzdcommon(doctorDO.getMobile(),doctorDO.getName(),eventHappenTime,eventName,taskDescription,eventLocation,taskId);
        }catch (Exception e){
            e.printStackTrace();
        }

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

@ -258,9 +258,9 @@ es:
  host:  http://172.26.0.112:9000
  tHost: 172.26.0.112:9300
  clusterName: jkzl
  securityUser: lion:jkzlehr
  user: lion
  password: jkzlehr
  securityUser: zjxl:6Dbq&fHg
  user: zjxl
  password: 6Dbq&fHg
# 上传文件临时路径配置
FileTempPath:

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

@ -152,16 +152,20 @@ public class DeviceUploadService {
            BasePatientDO patientDO = patientDao.findById(result.getUser());
            if (null != patientDO){
                SystemMessageDO messageDO = new SystemMessageDO();
                SystemMessageDO messageFamilyDO = new SystemMessageDO();
                String familyMessageName = "";
                String typeName = null;
                String typeName2 = null;
                switch (type){
                    case "1":
                        typeName = "您有新的血糖测量记录:血糖浓度:"+result.getValue1()+"mmol/L";
                        familyMessageName = "{\"name\":\""+patientDO.getName()+"\",\"patient\":\""+patientDO.getId()+"\",\"type\": 1,\"value1\":"+result.getValue1()+"}";
                        typeName2 = "您刚刚测量了一次血糖";
                        break;
                    case "2":
                        typeName = "您有新的血压测量记录:收缩压:"+result.getValue1()+"mmHg,舒张压:"
                                +result.getValue2()+"mmHg,脉搏:"+result.getValue3()+"次/min";
                        familyMessageName = "{\"name\":\""+patientDO.getName()+"\",\"patient\":\""+patientDO.getId()+"\",\"type\": 1,\"value1\":"+result.getValue1()+",\"value2\":"+result.getValue2()+",\"value3\":"+result.getValue3()+"}";
                        typeName2 = "您刚刚测量了一次血压";
                        break;
                }
@ -180,7 +184,48 @@ public class DeviceUploadService {
                        messageDO.setRelationCode(result.getId() + "");
                        messageDO.setReceiver(patientDO.getId());
                        messageDO.setReceiverName(patientDO.getName());
                        messageDO.setUserType(1);
                        messageDO.setOver("1");
                        //发送 家属端
                        List<Map<String,Object>> families = patientFamilyService.getPatientFamilyList(patientDO.getId(),"3");
                        for (Map<String, Object> family : families) {
                            messageFamilyDO.setTitle("体征动态");
                            messageFamilyDO.setData(familyMessageName);
                            messageFamilyDO.setType("42");//42体征设备测量
                            messageFamilyDO.setSender("system");
                            messageFamilyDO.setSenderName("养护助手");
                            messageFamilyDO.setRelationCode(result.getId() + "");
                            messageFamilyDO.setReceiver(family.get("id").toString());
                            messageFamilyDO.setReceiverName(family.get("name").toString());
                            messageFamilyDO.setUserType(3);
                            messageFamilyDO.setIsRead("0");
                            messageFamilyDO.setOver("1");
                            messageFamilyDO.setCode(type);//与体征类型对应
                            messageFamilyDO.setDel("1");
                            messageFamilyDO.setCreateTime(new Date());
                            if (StringUtils.isNotBlank(family.get("openid").toString())){
                                String first = "您好,您的亲属"+patientDO.getName()+"新增一条体征记录";
                                String content = "";
                                switch (type){
                                    case "1":
                                        content = ("收缩压:"+result.getValue1()+"mmHg\r\n舒张压:"+result.getValue2()+"mmHg");
                                        break;
                                    case "2":
                                        content = ("血糖浓度:"+result.getValue1()+"mmol/L");
                                        break;
                                    default:
                                        break;
                                }
                                //o_DJs59V7MKJ5ea-YW__LoccEn50
                                String url = "https://zhyzh.gongshu.gov.cn/medical-care-patient/healthRecords/detail?patientId="+patientDO.getId()+"&type="+type+"";
                                messageUtil.putTemplateWxMessage(wxId, "template_system_family", "jsxtxx", family.get("openid").toString(), first, url, null, 1, null, content,"推送完成", DateUtil.getStringDate());
                            }
                        }
                        String url = "";
                        ResponseEntity<String> forEntity = restTemplate.getForEntity("http://127.0.0.1:10301/common/open/wordToVoice?text={1}", String.class, typeName);
                        com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(forEntity.getBody());

+ 11 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/pushLog/ZhaohuiDailyDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.pushLog;
import com.yihu.jw.entity.log.ZhaohuiDailyEntity;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by wsl on 2022/10/25
 */
public interface ZhaohuiDailyDao extends PagingAndSortingRepository<ZhaohuiDailyEntity, String>, JpaSpecificationExecutor<ZhaohuiDailyEntity> {
}

+ 20 - 3
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java

@ -12,6 +12,7 @@ import com.yihu.jw.care.job.order.CancelPayOrderJob;
import com.yihu.jw.care.job.order.DailyWaterJob;
import com.yihu.jw.care.job.order.EmeWarnOrderDayJob;
import com.yihu.jw.care.job.order.EmeWarnOrderJob;
import com.yihu.jw.care.job.pushRecord.FamilySystemWechatPushJob;
import com.yihu.jw.care.job.pushRecord.PushRecordJob;
import com.yihu.jw.care.job.pushRecord.PushTimeIntegerPointJob;
import com.yihu.jw.care.job.pushRecord.PushWeatherForecastJob;
@ -263,7 +264,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("PUSH_MASSAGE_TIME_INTEGER_POINT_JOB success");
            }else {
                logger.info("PUSH_MASSAGE_TIME_INTEGER_POINT_JOB success");
                logger.info("PUSH_MASSAGE_TIME_INTEGER_POINT_JOB exist");
            }
            //天气预报:每天早上11点播报
            if (!quartzHelper.isExistJob("PUSH_MESSAGE_WEATHER_FORECAST_JOB")){
@ -271,7 +272,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                quartzHelper.addJob(PushWeatherForecastJob.class,trigger,"PUSH_MESSAGE_WEATHER_FORECAST_JOB",new HashMap<String,Object>());
                logger.info("PUSH_MESSAGE_WEATHER_FORECAST_JOB success");
            }else {
                logger.info("PUSH_MESSAGE_WEATHER_FORECAST_JOB success");
                logger.info("PUSH_MESSAGE_WEATHER_FORECAST_JOB exist");
            }
            //删除天气预报:每天晚上12点删除
            if (!quartzHelper.isExistJob("DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB")){
@ -279,7 +280,23 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                quartzHelper.addJob(PushWeatherForecastJob.class,trigger,"DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB",new HashMap<String,Object>());
                logger.info("DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB success");
            }else {
                logger.info("DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB success");
                logger.info("DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB exist");
            }
          /*  //朝晖日报:每天晚上8点发送
            if (!quartzHelper.isExistJob("PUSH_ZHAO_HUI_RI_BAO_JOB")){
                String trigger =  SystemConf.getInstance().getSystemProperties().getProperty("PUSH_ZHAO_HUI_RI_BAO_JOB");
                quartzHelper.addJob(PushZhaohuiRoundJob.class,trigger,"PUSH_ZHAO_HUI_RI_BAO_JOB",new HashMap<String,Object>());
                logger.info("PUSH_ZHAO_HUI_RI_BAO_JOB success");
            }else {
                logger.info("PUSH_ZHAO_HUI_RI_BAO_JOB exist");
            }*/
            //家属设备微信推送
            if (!quartzHelper.isExistJob("FAMILY_WECHAT_PUSH_DEVICE_JOB")){
                String trigger =  SystemConf.getInstance().getSystemProperties().getProperty("FAMILY_WECHAT_PUSH_DEVICE_JOB");
                quartzHelper.addJob(FamilySystemWechatPushJob.class,trigger,"FAMILY_WECHAT_PUSH_DEVICE_JOB",new HashMap<String,Object>());
                logger.info("FAMILY_WECHAT_PUSH_DEVICE_JOB success");
            }else {
                logger.info("FAMILY_WECHAT_PUSH_DEVICE_JOB exist");
            }
        } catch (Exception e) {

+ 41 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/FamilySystemWechatPushJob.java

@ -0,0 +1,41 @@
package com.yihu.jw.care.job.pushRecord;
import com.yihu.jw.care.service.device.WechatPushService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Created by wsl on 2022/11/1
 */
public class FamilySystemWechatPushJob implements Job{
    private static Logger logger = LoggerFactory.getLogger(FamilySystemWechatPushJob.class);
    @Autowired
    private WechatPushService wechatPushService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            System.out.println("====================家属设备微信start==================");
            logger.info("FamilySystemWechatPushJob start");
            wechatPushService.familyWeChatPush();
            logger.info("FamilySystemWechatPushJob end");
            System.out.println("====================家属设备微信end==================");
        } catch (Exception e) {
            logger.info("FamilySystemWechatPushJob --ERROR MSG:" + e.getMessage());
            e.printStackTrace();
        }
    }
}

+ 39 - 1
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/PushRecordJob.java

@ -4,6 +4,7 @@ import com.yihu.jw.care.dao.pushLog.BasePushRecordLogDao;
import com.yihu.jw.care.dao.pushLog.BasePushrecordLogInfoDao;
import com.yihu.jw.care.util.DateUtil;
import com.yihu.jw.care.util.DeviceLostMessageUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.entity.log.BasePushRecordLogEntity;
import com.yihu.jw.entity.log.BasePushrecordLogInfoEntity;
@ -15,8 +16,10 @@ import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import java.util.*;
@ -38,6 +41,10 @@ public class PushRecordJob implements Job {
    private SystemMessageDao systemMessageDao;
    @Autowired
    private DeviceLostMessageUtil devicelostMessageUtil;
    @Autowired
    private MessageUtil messageUtil;
    @Value("${wechat.id}")
    private String wxId;
    @Override
@ -48,12 +55,30 @@ public class PushRecordJob implements Job {
            List<BasePushrecordLogInfoEntity> logInfoEntityList = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePushrecordLogInfoEntity.class));
            List<SystemMessageDO> messageDOS = new ArrayList<>();
            Set<String> pushIdSet = new HashSet<>();
            String pushId = "";
            if (logInfoEntityList.size()>0) {
                for (BasePushrecordLogInfoEntity basePushrecordLogInfoEntity : logInfoEntityList) {
                    SystemMessageDO systemMessageDO = new SystemMessageDO();
                    systemMessageDO.setUserType(1);
                    //记录表设置已发送
                    basePushrecordLogInfoEntity.setStatus(1);
                    //是否发送给家属
                    if (!pushId.equals(basePushrecordLogInfoEntity.getPushId())){
                        pushId=basePushrecordLogInfoEntity.getPushId();
                        String basePushLogSatusSql = "select * from base_pushrecord_log where id = '" + pushId + "' ";
                        List<BasePushRecordLogEntity> logEntityList = jdbcTemplate.query(basePushLogSatusSql, new BeanPropertyRowMapper<>(BasePushRecordLogEntity.class));
                        if (logEntityList.size() > 0) {
                            for (BasePushRecordLogEntity logEntity : logEntityList) {
                                if (logEntity.getSendObjectType() == 3) {
                                    systemMessageDO.setUserType(3);
                                    wxPush(basePushrecordLogInfoEntity.getContent());
                                }
                            }
                        }
                    }
                    //新增推送记录
                    SystemMessageDO systemMessageDO = new SystemMessageDO();
                    systemMessageDO.setId(UUID.randomUUID().toString().replace("-", ""));
                    systemMessageDO.setTitle("系统消息推送");
                    systemMessageDO.setType("999");
@ -95,4 +120,17 @@ public class PushRecordJob implements Job {
    }
    @Async
    public void wxPush(String content){
        String sql ="select name,opeind from base_patient where archive_type = 3 and opeind is not null";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        String first = "您好,朝晖云朝晖向您发送一条通知";
        if (list.size()>0) {
            for (Map<String, Object> map : list) {
                messageUtil.putTemplateWxMessage(wxId,"template_system_family","jsxtxx",map.get("opined").toString(),first,null,null,1,null,content,"【推送完成】", com.yihu.jw.util.date.DateUtil.getStringDate());
            }
        }
    }
}

+ 39 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/pushRecord/PushZhaohuiRoundJob.java

@ -0,0 +1,39 @@
package com.yihu.jw.care.job.pushRecord;
import com.yihu.jw.care.service.message.ZhaohuiDailyService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
 * Created by wsl on 2022/10/27
 */
public class PushZhaohuiRoundJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(PushZhaohuiRoundJob.class);
    @Autowired
    private ZhaohuiDailyService zhaohuiDailyService;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            System.out.println("====================朝晖日报start==================");
            logger.info("PushZhaohuiRoundJob start");
            zhaohuiDailyService.allRound();
            logger.info("PushZhaohuiRoundJob end");
            System.out.println("====================朝晖日报end==================");
        } catch (Exception e) {
            logger.info("PushZhaohuiRoundJob --ERROR MSG:" + e.getMessage());
            e.printStackTrace();
        }
    }
}

+ 20 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/zhaohuiDaily/zhaohuiDailyJob.java

@ -0,0 +1,20 @@
package com.yihu.jw.care.job.zhaohuiDaily;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * Created by wsl on 2022/10/24
 */
public class zhaohuiDailyJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(zhaohuiDailyJob.class);
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
    }
}

+ 1 - 1
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -330,7 +330,6 @@ public class PatientDeviceService {
                }
                Thread.sleep(1000);
            }
            if (rslist.size()>0) {
                deviceLostMessageUtil.watchOffWear(rslist);
            }
@ -363,6 +362,7 @@ public class PatientDeviceService {
                }
                Thread.sleep(1000);
            }
            System.out.println("电量低数量:"+rslist.size());
            if (rslist.size()>0) {
                deviceLostMessageUtil.watchRemainingPower(rslist);
            }

+ 262 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/WechatPushService.java

@ -0,0 +1,262 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.util.DateUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
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.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by wsl on 2022/10/31
 */
@Service
public class WechatPushService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Value("${wechat.id}")
    private String wxId;
    public void familyWeChatPush() {
        List<BasePatientDO> familyOpeindList = faminlyPatientList();
        familyOpeindList.forEach(familyOpeind -> {
            String sql = "select p.* from  base_patient p INNER JOIN  base_patient_family_member m  ON p.id = m.family_member where m.patient = '" + familyOpeind.getId() + "' AND archive_type = 1 ";
            List<BasePatientDO> query = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientDO.class));
            for (BasePatientDO patient : query) {
                String online = oldPatientDeviceList(familyOpeind, patient);
                online = online.replace("<device>,", "");
                if (StringUtils.isBlank(online)) {
                    online = "暂无设备离线!";
                }
                JSONObject watch = oldPatientWatch(patient.getId());
                wxPush(familyOpeind.getOpenid(),watch,online,patient.getName());
            }
        });
    }
    private void wxPush(String openid,JSONObject watch,String online,String name){
        if (name.equals("姜云")){
        String first = "您好,您的亲属【"+name+"】当前设备状态如下";
        String content = "智能手表:"+watch.get("WatchWear")+"\r\n智能手表:"+watch.get("pwoer")+"\r\n离线设备:"+online;
        String url = "https://zhyzh.gongshu.gov.cn/medical-care-patient/healthRecords/index?active=1";
        //o_DJs59V7MKJ5ea-YW__LoccEn50
           messageUtil.putTemplateWxMessage(wxId,"template_system_family","jsxtxx",openid,first,url,null,1,null,content,"【推送完成】", com.yihu.jw.util.date.DateUtil.getStringDate());
        }
    }
    //查找有openid 的家属
    private List<BasePatientDO> faminlyPatientList() {
        String faminlySql = "SELECT * FROM base_patient where archive_type = 3 and openid is not null ";
        /*List <BasePatientDO> entity = new ArrayList<>();
        BasePatientDO basePatientDO = new BasePatientDO();
        basePatientDO.setId("8a92aba97d329802017d32a6edfe000a");
        basePatientDO.setIdcard("110101199001230123");
        basePatientDO.setName("张静");
        basePatientDO.setSex(2);
        basePatientDO.setMobile("16600000001");
        basePatientDO.setPhoto("group1/M00/00/04/ChIrKGIxs1GAWIcPAAAqrjvtn6Q615.png");
        basePatientDO.setDel("1");
        basePatientDO.setArchiveType(3);
        basePatientDO.setOpenid("o_DJs59V7MKJ5ea-YW__LoccEn50");
        entity.add(basePatientDO);*/
        return jdbcTemplate.query(faminlySql, new BeanPropertyRowMapper<>(BasePatientDO.class));
        //return entity;
    }
    //设备离线
    private String oldPatientDeviceList(BasePatientDO family, BasePatientDO patient) {
        String deviceNames = "<device>";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String endTime = sdf.format(new Date());
        Calendar device1 = Calendar.getInstance();
        device1.setTime(new Date());
        device1.add(device1.DATE, -30);
        Date nowDate = device1.getTime();
        String startTimeDevice1 = sdf.format(nowDate);
        List<String> lostSN = new ArrayList<>();
        List<SystemMessageDO> familyMessageList = new ArrayList();
        String startTimeDevice2 = DateUtil.getPreTime(endTime, -60 * 2 + "");
        //血糖仪、血压**/
        String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd   where pd.user = '" + patient.getId() + "' and pd.del=0 and pd.category_code in (1,2) and not EXISTS ( " +
                "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.device_sn is not null and dp.create_time " +
                " BETWEEN '" + startTimeDevice1 + "' AND '" + endTime + "') ";
        List<String> devices = jdbcTemplate.queryForList(sql, String.class);
        if (devices.size() > 0) {
            lostSN.addAll(devices);
        }
        //智能拐杖、手表 睡眠带
        sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.user = '" + patient.getId() + "' and pd.del=0 and pd.category_code in (4,13,16) and not EXISTS ( " +
                "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.device_sn is not null and dp.create_time " +
                " BETWEEN '" + startTimeDevice2 + "' AND '" + endTime + "') ";
        devices = jdbcTemplate.queryForList(sql, String.class);
        if (devices.size() > 0) {
            lostSN.addAll(devices);
        }
        if (lostSN.size() > 0) {
            for (String deviceSn : devices) {
                List<DevicePatientDevice> pds = patientDeviceDao.findByDeviceSn(deviceSn);
                if (pds.size() > 0) {
                    DevicePatientDevice deviceDO = pds.get(0);
                    String deviceName = "";
                    switch (deviceDO.getCategoryCode()) {
                        case "1":
                            deviceNames += ",血糖仪";
                            deviceName=",血糖仪";
                            break;
                        case "2":
                            deviceNames += ",血压计";
                            deviceName="血压计";
                            break;
                        case "4":
                            deviceNames += ",智能手表";
                            deviceName = "智能手表";
                            break;
                        case "7":
                            deviceNames += ",居家安全报警器";
                            deviceName = "居家安全报警器";
                            break;
                        case "12":
                            deviceNames += ",监控器";
                            deviceName = "监控器";
                            break;
                        case "13":
                            deviceNames += ",睡眠带";
                            deviceName = "睡眠带";
                            break;
                        case "14":
                            deviceNames += ",气感报警器";
                            deviceName = "气感报警器";
                            break;
                        case "15":
                            deviceNames += ",烟感报警器";
                            deviceName = "烟感报警器";
                            break;
                        case "16":
                            deviceNames += ",智能拐杖";
                            deviceName = "智能拐杖";
                            break;
                    }
                    String onOffsql = "select on_off from base_patient_family_pushonoff where patient = '" + family.getId() + "' and type = 2 ";
                    List<Map<String, Object>> onOffList = jdbcTemplate.queryForList(onOffsql);
                    if (onOffList.size() > 0) {
                        if (Integer.parseInt(onOffList.get(0).get("on_off").toString()) == 1 ? true : false) {
                            SystemMessageDO familyMessageDO = new SystemMessageDO();
                            String familyMessageName = "{ \"name\":\"" + patient.getName() + "\"," +
                                    "  \"deviceCode\": \"" + deviceDO.getCategoryCode() + "\"," +
                                    "  \"patient\": \"" + patient.getId() + "\"," +
                                    "  \"deviceName\":\"" + deviceName + "\"," +
                                    "  \"deviceSn\":\"" + deviceSn + "\" " +
                                    "}\n";
                            //家属推送消息
                            familyMessageDO.setUserType(3);
                            familyMessageDO.setContent("您亲属绑定的【" + deviceName + "】处于离线状态,为保证老人安全,请确保设备正确连接。");
                            familyMessageDO.setDel("1");
                            familyMessageDO.setOver("1");
                            familyMessageDO.setType("994");
                            familyMessageDO.setIsRead("0");
                            familyMessageDO.setTitle("设备离线通知");
                            familyMessageDO.setSender("system");
                            familyMessageDO.setSenderName("设备离线通知助手");
                            familyMessageDO.setReceiver(family.getId());
                            familyMessageDO.setReceiverName(family.getName());
                            familyMessageDO.setData(familyMessageName);
                            familyMessageDO.setCreateTime(new Date());
                            familyMessageList.add(familyMessageDO);
                            delDeviceMessage(family.getId(), "994");
                        }
                    }
                }
            }
        }
        if (familyMessageList.size()>0) {
            systemMessageDao.save(familyMessageList);
        }
        return deviceNames;
    }
    @Transactional(rollbackFor = Exception.class)
    public void delDeviceMessage(String patientId,String type){
        String sql =  "delete from base_system_message where user_type = 3 and receiver = '"+patientId+"' and type ='"+type+"'  ";
        jdbcTemplate.update(sql);
    }
    //手表佩戴
    private JSONObject oldPatientWatch(String patient) {
        JSONObject result = new JSONObject();
        String sql = "SELECT p.id,p.`name`,p.sex,d.device_sn,p.photo FROM base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user` WHERE p.id = '" + patient + "' and category_code = 4 AND p.del = 1 ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        if (list.size() > 0) {
            for (Map<String, Object> deviceInfo : list) {
                JSONObject response = patientDeviceService.getAqgDeviceInfo2(deviceInfo.get("device_sn").toString());
                if (response.containsKey("wear_flag") && response.get("wear_flag") != null || 1 == response.getInteger("wear_flag")) {
                    result.put("WatchWear", "未佩戴");
                } else {
                    result.put("WatchWear", "已佩戴");
                }
                if (response.containsKey("remaining_power") && response.get("remaining_power") != null && response.getInteger("remaining_power") <= 20) {
                    result.put("pwoer", "电量低");
                } else {
                    result.put("pwoer", "正常");
                }
            }
        } else {
            result.put("WatchWear", "无手表");
            result.put("pwoer", "无手表");
        }
        return result;
    }
    //
}

+ 216 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/message/ZhaohuiDailyService.java

@ -0,0 +1,216 @@
package com.yihu.jw.care.service.message;
import com.yihu.jw.care.dao.pushLog.ZhaohuiDailyDao;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.log.ZhaohuiDailyEntity;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * Created by wsl on 2022/10/24
 */
@Component
public class ZhaohuiDailyService {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private ZhaohuiDailyDao zhaohuiDailyDao;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private MessageUtil messageUtil;
    @Value("${wechat.id}")
    private String wxId;
    public void allRound() {
        List<Map<String, Object>> familyAll = getFamily();
        familyAll.stream().forEach(family -> {
            String familyId = family.get("id").toString();
            String openid = family.get("openid").toString();
            getFamilyOld(familyId,openid);
        });
    }
    //获取所有家属
    private List<Map<String, Object>> getFamily() {
        StringBuffer stringBuffer = new StringBuffer("select id,openid from base_patient where archive_type = 3 ");
        List<Map<String, Object>> list = jdbcTemplate.queryForList(stringBuffer.toString());
        return list;
    }
    private void getFamilyOld(String id,String openid) {
        String sql = "select family_member from base_patient_family_member where patient ='" + id + "' and del = 1 ";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List result = new ArrayList<>();
        for (Map<String, Object> map : list) {
            ZhaohuiDailyEntity family_member = getFamilyOldInfo(map.get("family_member").toString(), id,openid);
            result.add(family_member);
        }
        zhaohuiDailyDao.save(result);
    }
    private List<Map<String, Object>> getDeviceSn(String id){
        String sql = " SELECT device_sn,category_code  FROM wlyy_patient_device WHERE user ='"+id+"'";
         return jdbcTemplate.queryForList(sql);
    }
    private ZhaohuiDailyEntity getFamilyOldInfo(String oldId,String faminlyId,String openid) {
        String deviceCode = "0";
        String gzDeviceSn ="";
        String ygDeviceSn ="";
        String qgDeviceSn ="";
        String sbDeviceSn ="";
        String smdDeviceSn ="";
        String bjqDeviceSn ="";
        List<Map<String, Object>> deviceSnS = getDeviceSn(oldId);
        for (Map<String, Object> deviceSn : deviceSnS) {
            switch (Integer.parseInt(deviceSn.get("category_code").toString())) {
                case 7: //居家报警器
                    bjqDeviceSn = deviceSn.get("device_sn").toString();
                    deviceCode+=",7";
                    break;
                case 4: //智能手表
                    sbDeviceSn = deviceSn.get("device_sn").toString();
                    deviceCode+=",4";
                    break;
                case 13: //睡眠带
                    smdDeviceSn = deviceSn.get("device_sn").toString();
                    deviceCode+=",13";
                    break;
                case 14: //气感报警器
                    qgDeviceSn = deviceSn.get("device_sn").toString();
                    deviceCode+=",14";
                    break;
                case 15: //烟感报警器
                    ygDeviceSn = deviceSn.get("device_sn").toString();
                    deviceCode+=",15";
                    break;
                case 16: //智能拐杖
                    gzDeviceSn = deviceSn.get("device_sn").toString();
                    deviceCode+=",16";
                    break;
                default:
                    break;
            }
        }
        //生活照料总数
        Integer liftOlderTotal = 0;
        //紧急总数
        Integer emeOlderTotal = 0;
        //安防总数
        Integer secOlderTotal = 0;
        //睡眠带总数
        Integer smdDeviceTotal = 0;
        //拐杖总数
        Integer gzDeviceTotal = 0;
        //烟感
        Integer ygDeviceTotal = 0;
        //气感
        Integer qgDeviceTotal = 0;
        //手表
        Integer sbDeviceTotal = 0;
        String date = DateUtil.getStringDateShort();
        String stateDate = date + " 00:00:00";
        String endDate = date + " 23:59:59";
        //生活照料
        StringBuffer liftSql = new StringBuffer("select count(id) total from base_life_care_order where patient = '" + oldId + "' and create_time >= '" + stateDate + "' and create_time<= '" + endDate + "' ");
        liftOlderTotal = jdbcTemplate.queryForObject(liftSql.toString(), Integer.class);
        //紧急
        StringBuffer emeSql = new StringBuffer("select count(id) total from base_emergency_assistance_order where patient = '" + oldId + "' and create_time >= '" + stateDate + "' and create_time<= '" + endDate + "'  ");
        emeOlderTotal = jdbcTemplate.queryForObject(emeSql.toString(), Integer.class);
        //安防
        StringBuffer secSql = new StringBuffer("select count(id) total from base_security_monitoring_order where patient = '" + oldId + "' and create_time >= '" + stateDate + "' and create_time<= '" + endDate + "' ");
        secOlderTotal = jdbcTemplate.queryForObject(secSql.toString(), Integer.class);
        //睡眠带
        StringBuffer smdDeviceSql = new StringBuffer("select count(id) total from base_sleep_device where patient = '" + oldId + "' and create_time >= '" + stateDate + "' and create_time<= '" + endDate + "'");
        smdDeviceTotal = jdbcTemplate.queryForObject(smdDeviceSql.toString(), Integer.class);
        //拐杖
        if (StringUtils.isNotBlank(gzDeviceSn)){
            StringBuffer gzDeviceSql = new StringBuffer("select count(id) total from base_yxdevice_index where sn ='"+gzDeviceSn+"' and create_time >= '" + stateDate + "' and create_time<= '" + endDate + "' ");
            gzDeviceTotal = jdbcTemplate.queryForObject(gzDeviceSql.toString(),Integer.class);
        }
        StringBuffer qgDeviceSql = new StringBuffer("SELECT  count(id) as total FROM base_device_health_index WHERE device_sn = '" + qgDeviceSn + "' AND create_time >='" + stateDate + "'  AND create_time <= '" + endDate + "'");
        StringBuffer ygDeviceSql = new StringBuffer("SELECT  count(id) as total FROM base_device_health_index WHERE device_sn = '" + ygDeviceSn + "' AND create_time >='" + stateDate + "'  AND create_time <= '" + endDate + "'");
        ygDeviceTotal = jdbcTemplate.queryForObject(ygDeviceSql.toString(),Integer.class);
        qgDeviceTotal = jdbcTemplate.queryForObject(qgDeviceSql.toString(),Integer.class);
        //手表
        StringBuffer sbDeviceSql = new StringBuffer("select count(id) total from base_sleep_x1device where patient ='" + oldId + "' and create_time >= '" + stateDate + "' and create_time<='" + endDate + "' ");
        sbDeviceTotal = jdbcTemplate.queryForObject(sbDeviceSql.toString(), Integer.class);
        Integer total = smdDeviceTotal+gzDeviceTotal+ygDeviceTotal+qgDeviceTotal+sbDeviceTotal;
        BasePatientDO oldPatient = basePatientDao.findById(oldId);
        BasePatientDO familyPatient = basePatientDao.findById(faminlyId);
        ZhaohuiDailyEntity zhaohuiDailyEntity = new ZhaohuiDailyEntity();
        zhaohuiDailyEntity.setDeviceCode(deviceCode);
        zhaohuiDailyEntity.setGzTotal(gzDeviceTotal.toString());
        zhaohuiDailyEntity.setLiftTotal(liftOlderTotal.toString());
        zhaohuiDailyEntity.setSbTotal(sbDeviceTotal.toString());
        zhaohuiDailyEntity.setSmdTotal(smdDeviceTotal.toString());
        zhaohuiDailyEntity.setYgTotal(ygDeviceTotal.toString());
        zhaohuiDailyEntity.setQgTotal(qgDeviceTotal.toString());
        zhaohuiDailyEntity.setEmeTotal(emeOlderTotal.toString());
        zhaohuiDailyEntity.setSecTotal(secOlderTotal.toString());
        zhaohuiDailyEntity.setCreateTime(new Date());
        zhaohuiDailyEntity.setOldPatient(oldPatient.getId());
        zhaohuiDailyEntity.setOldName(oldPatient.getName());
        zhaohuiDailyEntity.setPatient(familyPatient.getId());
        zhaohuiDailyEntity.setName(familyPatient.getName());
        zhaohuiDailyEntity.setTotal(total.toString());
        String first = "您好,您的亲属"+oldPatient.getName()+"今日照护日报已生成";
        Integer key2 = secOlderTotal+emeOlderTotal;
        messageUtil.putTemplateWxMessage(wxId,"template_zhrb","zhrb",openid,first,null,null,1,null,"",key2+"",liftOlderTotal+"","【推送完成】",DateUtil.getStringDate());
        return zhaohuiDailyEntity;
    }
}

+ 109 - 15
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java

@ -36,6 +36,8 @@ public class DeviceLostMessageUtil {
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private SystemPushMessageUtil systemPushMessageUtil;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
@ -164,6 +166,7 @@ public class DeviceLostMessageUtil {
    @Transactional(rollbackFor = Exception.class)
    public void deviceLostMessagePatient(List<String> devices){
        List<SystemMessageDO> messageDOS = new ArrayList<>();
        String content = "{name}{sex}您好,您的{device}设备已离线,请保持设备连接通畅。";
@ -201,11 +204,11 @@ public class DeviceLostMessageUtil {
                    }
                }
            }
            if (StringUtils.isNotBlank(deivceName)){
            if (StringUtils.isNotBlank(deivceName)) {
                String sContent = content;
                sContent = sContent.replace("{name}",patient.get("name").toString());
                sContent = sContent.replace("{sex}",Integer.parseInt(patient.get("sex").toString())==1?"大爷":"大妈");
                sContent = sContent.replace("{device}",deivceName);
                sContent = sContent.replace("{name}", patient.get("name").toString());
                sContent = sContent.replace("{sex}", Integer.parseInt(patient.get("sex").toString()) == 1 ? "爷爷" : "奶奶");
                sContent = sContent.replace("{device}", deivceName);
                SystemMessageDO messageDO = new SystemMessageDO();
                messageDO.setTitle("设备离线通知");
                messageDO.setContent(sContent);
@ -216,17 +219,18 @@ public class DeviceLostMessageUtil {
                messageDO.setReceiver(patient.get("id").toString());
                messageDO.setReceiverName(patient.get("name").toString());
                messageDO.setOver("1");
               // messageDO.setData(deviceName+"离线");
                // messageDO.setData(deviceName+"离线");
                messageDO.setDel("1");
                messageDO.setUserType(1);
                messageDO.setCreateTime(new Date());
                messageDO.setSenderPhoto(patient.get("photo").toString());
                messageDO.setAudioUrl(audioUrl(sContent));
                messageDOS.add(messageDO);
                //socket推送
                patientMessageSocket(messageDO,deviceSnS);
            }
                patientMessageSocket(messageDO, deviceSnS);
        }
    }
        if (messageDOS.size()>0){
            BasePushRecordLogEntity logEntity = new BasePushRecordLogEntity();
            logEntity.setContent(content);
@ -244,6 +248,12 @@ public class DeviceLostMessageUtil {
    }
    private List<Map<String, Object>> faminlyPatientList(String patientId){
        String faminlySql = "SELECT p.id,p.name,p.openid FROM base_patient p INNER JOIN base_patient_family_member m ON p.id = m.patient WHERE m.patient = '"+patientId+"' AND m.del AND p.archive_type = 3 ";
        return jdbcTemplate.queryForList(faminlySql);
    }
    /**
     * 手表未佩戴居民通知
     * @param patientList
@ -251,15 +261,17 @@ public class DeviceLostMessageUtil {
    @Transactional(rollbackFor = Exception.class)
    public void watchOffWear(List<JSONObject> patientList){
        List<SystemMessageDO> messageDOS = new ArrayList<>();
        List<SystemMessageDO> familyMessageDOS = new ArrayList<>();
        String contentOne = "{name}{sex} 监测到您没有佩戴手表,建议正确佩戴手表,方便我们对您进行照护。";
        String faminlyContent = "您的亲属未正确佩戴手表,为防止失联,请正确佩戴手表。";
        for (JSONObject jsonObject : patientList) {
            SystemMessageDO messageDO = new SystemMessageDO();
            String contentTwo = contentOne;
            contentTwo = contentTwo.replace("{name}",jsonObject.getString("name"));
            contentTwo = contentTwo.replace("{sex}",1==jsonObject.getInteger("sex")?"大爷":"大妈");
            contentTwo = contentTwo.replace("{sex}",1==jsonObject.getInteger("sex")?"爷爷":"奶奶");
            String s = audioUrl(contentTwo);
            messageDO.setTitle("设备未佩戴通知");
@ -278,6 +290,42 @@ public class DeviceLostMessageUtil {
            messageDO.setAudioUrl(s);
            messageDOS.add(messageDO);
            //家属
            List<Map<String, Object>> familyListMap = faminlyPatientList(jsonObject.getString("patient"));
            System.out.println("家属数量:" + familyListMap.size());
            if (familyListMap.size() > 0) {
                for (Map<String, Object> familys : familyListMap) {
                    if (systemPushMessageUtil.familyMessagePushOnOff(familys.get("patient").toString(), 2)) {
                        String familyMessageName = "{ \"name\":\""+jsonObject.getString("name")+"\"," +
                                "  \"deviceName\":\"智能手表\"," +
                                "  \"patient\":\""+jsonObject.getString("patient")+"\"," +
                                "  \"deviceSn\":\""+jsonObject.getString("device_sn")+"\" " +
                                "}\n";
                        SystemMessageDO messageFamily = new SystemMessageDO();
                        messageFamily.setTitle("智能手表");
                        messageFamily.setContent(faminlyContent);
                        messageFamily.setType("991");
                        messageFamily.setIsRead("0");
                        messageFamily.setSender("system");
                        messageFamily.setUserType(3);
                        messageFamily.setSenderName("设备未佩戴通知助手");
                        messageFamily.setCreateTime(new Date());
                        messageFamily.setReceiver(familys.get("patient").toString());
                        messageFamily.setReceiverName(familys.get("name").toString());
                        messageFamily.setData(familyMessageName);
                        messageFamily.setOver("1");
                        messageFamily.setDel("1");
                        familyMessageDOS.add(messageFamily);
                        delDeviceMessage(familys.get("patient").toString(), "991");
                    }
                }
            }
            JSONObject message = new JSONObject();
            message.put("title","设备未佩戴通知");
            message.put("type","991");
@ -300,9 +348,14 @@ public class DeviceLostMessageUtil {
            logEntity.setMessageType(3);
            systemMessageDao.save(messageDOS);
            basePushRecordLogDao.save(logEntity);
            systemMessageDao.save(familyMessageDOS);
        }
    }
    @Transactional(rollbackFor = Exception.class)
    public void delDeviceMessage(String patientId,String type){
        String sql =  "delete from base_system_message where user_type = 3 and receiver = '"+patientId+"' and type ='"+type+"'  ";
        jdbcTemplate.update(sql);
    }
@ -331,10 +384,14 @@ public class DeviceLostMessageUtil {
     */
    public void watchRemainingPower(List<JSONObject> patientList){
        List<SystemMessageDO> messageDOSWatch = new ArrayList<>();
        List<SystemMessageDO> messageDOSWatchFamily = new ArrayList<>();
        List<SystemMessageDO> messageDOSSOS = new ArrayList<>();
        String watchContent = "手表电量低,请充电";
        String watchContent = "<patientName><sex> 您的手表电量低,请充电";
        String SosContent = "报警器电量低,请充电";
        StringBuffer watchFamilyContent = new StringBuffer("您的亲属智能手表电量低,为防止失联,请及时充电");
        Integer watchSize = 0;
        String watchName = "";
        Integer SOSSize = 0;
@ -345,13 +402,14 @@ public class DeviceLostMessageUtil {
            switch (jsonObject.getInteger("category_code")){
                case 4:
                    if (messageOnOff(3)){
                        String newContent = watchContent.replace("<patientName>",jsonObject.getString("name"));
                        newContent = newContent.replace("<sex>",1==jsonObject.getInteger("sex")?"爷爷":"奶奶");
                        //文字转语音
                        String url = audioUrl(watchContent);
                        String url = audioUrl(newContent);
                        SystemMessageDO messageDOWatch = new SystemMessageDO();
                        messageDOWatch.setTitle("设备电量低通知");
                        messageDOWatch.setContent(watchContent);
                        messageDOWatch.setContent(newContent);
                        messageDOWatch.setType("992");
                        messageDOWatch.setIsRead("0");
                        messageDOWatch.setSender("system");
@ -371,8 +429,41 @@ public class DeviceLostMessageUtil {
                        }else {
                            watchName+=jsonObject.getString("name");
                        }
                        List<Map<String, Object>> familyList = faminlyPatientList(jsonObject.getString("patient"));
                        if (familyList.size() > 0) {
                            for (Map<String, Object> map : familyList) {
                                if (systemPushMessageUtil.familyMessagePushOnOff(map.get("id").toString(), 2)) {
                                    String familyMessageName = "{ \"name\":\""+map.get("name").toString()+"\"," +
                                            "  \"deviceName\":\"智能手表\"," +
                                            "  \"patient\":\""+map.get("id").toString()+"\"," +
                                            "  \"deviceSn\":\""+jsonObject.getString("device_sn")+"\" " +
                                            "}\n";
                                    SystemMessageDO messageDOWatchFamily = new SystemMessageDO();
                                    messageDOWatchFamily.setCreateTime(new Date());
                                    messageDOWatchFamily.setIsRead("0");
                                    messageDOWatchFamily.setUserType(3);
                                    messageDOWatchFamily.setType("992");
                                    messageDOWatchFamily.setOver("1");
                                    messageDOWatchFamily.setDel("1");
                                    messageDOWatchFamily.setSender("system");
                                    messageDOWatchFamily.setSenderName("设备电量通知助手");
                                    messageDOWatchFamily.setTitle("智能手表");
                                    messageDOWatchFamily.setReceiver(map.get("patient").toString());
                                    messageDOWatchFamily.setReceiverName(map.get("name").toString());
                                    messageDOWatchFamily.setData(familyMessageName);
                                    messageDOWatchFamily.setContent(watchFamilyContent.toString());
                                    messageDOSWatchFamily.add(messageDOWatchFamily);
                                    delDeviceMessage(map.get("patient").toString(), "992");
                                }
                            }
                        }
                        /*socket 推送*/
                        patientMessageSocket(messageDOWatch, jsonObject.getString("deviceSn"));
                    }
                    break;
                case 7:
@ -420,6 +511,7 @@ public class DeviceLostMessageUtil {
            logEntity.setMessageType(4);
            systemMessageDao.save(messageDOSWatch);
            basePushRecordLogDao.save(logEntity);
            systemMessageDao.save(messageDOSWatchFamily);
        }
        if (messageDOSSOS.size() > 0) {
@ -515,6 +607,8 @@ public class DeviceLostMessageUtil {
        return kg;
    }
    public String audioUrl(String content){
        ResponseEntity<String> forEntity = restTemplate.getForEntity("http://127.0.0.1:10301/common/open/wordToVoice?text={1}", String.class, content);
        JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody());

+ 7 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/SystemPushMessageUtil.java

@ -40,6 +40,13 @@ public class SystemPushMessageUtil {
    }
    public Boolean familyMessagePushOnOff(String patient, Integer type){
        String sql = "select on_off from base_patient_family_pushonoff where patient = '" + patient + "' and type ='" + type + "'";
        Integer integer = jdbcTemplate.queryForObject(sql,Integer.class);
        return integer == 0 ? false : true;
    }
    //basePushRecordLogEntity

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

@ -11,6 +11,7 @@ import com.yihu.jw.care.service.BirthdayReminderService;
import com.yihu.jw.care.service.JobService;
import com.yihu.jw.care.service.WlyysimFlowVoiceService;
import com.yihu.jw.care.service.device.InitializeDataJobService;
import com.yihu.jw.care.service.device.WechatPushService;
import com.yihu.jw.care.service.hz.HzInterfaceService;
import com.yihu.jw.care.util.SystemConf;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -273,6 +274,21 @@ public class JobController extends BaseController {
        }
    }
    @Autowired
    private WechatPushService wechatPushService;
    @RequestMapping(value = "familyWeChatPush", method = RequestMethod.POST)
    public String familyWeChatPush() {
        try {
            wechatPushService.familyWeChatPush();
            return success("启动成功!");
        } catch (Exception e) {
            error(e);
            return invalidUserException(e, -1, "启动失败:" + e.getMessage());
        }
    }
    /**
     * 停止任务
     *

+ 5 - 1
svr/svr-cloud-job/src/main/resources/system.properties

@ -51,4 +51,8 @@ PUSH_MASSAGE_TIME_INTEGER_POINT_JOB= 0 0 10,11,12,13,14,15,16,17,18 * * ?
#\u5929\u6C14\u9884\u62A5\uFF1A\u6BCF\u5929\u65E9\u4E0A11\u70B9\u64AD\u62A5
PUSH_MESSAGE_WEATHER_FORECAST_JOB= 0 0 11 * * ?
#\u665A\u4E0A12\u70B9\u5220\u9664\u4E4B\u524D\u7684\u5929\u6C14\u9884\u62A5
DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB = 0 5 0 * * ?
DEL_PUSH_MESSAGE_WEATHER_FORECAST_JOB = 0 5 0 * * ?
#\u6BCF\u5929\u665A\u4E0A8\u70B9\u9644\u9001\u671D\u6656\u65E5\u62A5
PUSH_ZHAO_HUI_RI_BAO_JOB = 0 0 20 * * ?
#\u5BB6\u5C5E\u5FAE\u4FE1\u63A8\u9001 \u6BCF\u5929\u65E9\u4E0A\u5341\u70B9
FAMILY_WECHAT_PUSH_DEVICE_JOB = 0 0 10 * * ?