mj-li 2 months ago
commit
7239268ee9
29 changed files with 1750 additions and 0 deletions
  1. 84 0
      .gitignore
  2. 29 0
      health-behavior-application-api/pom.xml
  3. 51 0
      health-behavior-application-api/src/main/java/com/xxh/cloud/healthy/behavior/application/controller/PatientBehaviorApplicationController.java
  4. 23 0
      health-behavior-client/pom.xml
  5. 19 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/PatientBehaviorClientService.java
  6. 71 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/bo/PatientBehaviorBO.java
  7. 159 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/bo/PatientBehaviorSecureBO.java
  8. 86 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/dto/PatientBehaviorSaveClientDTO.java
  9. 71 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/dto/PatientBehaviorUploadClientDTO.java
  10. 95 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/constant/BehaviorSourceTypeConstant.java
  11. 34 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/constant/PatientOperatedTypeEnum.java
  12. 54 0
      health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/util/BehaviorSecureUtil.java
  13. 41 0
      health-behavior-framework/pom.xml
  14. 96 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/entity/PatientBehaviorInfo.java
  15. 16 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/mapper/PatientBehaviorInfoMapper.java
  16. 16 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/service/PatientBehaviorInfoService.java
  17. 18 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/service/impl/PatientBehaviorInfoServiceImpl.java
  18. 87 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/dto/PatientBehaviorAddDTO.java
  19. 32 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/dto/PatientBehaviorQueryDTO.java
  20. 48 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/dto/PatientBehaviorUploadDTO.java
  21. 15 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/vo/PatientBehaviorBaseVO.java
  22. 86 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/vo/PatientBehaviorVO.java
  23. 23 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/helper/PatientBehaviorHelper.java
  24. 22 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/PatientBehaviorBizService.java
  25. 13 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/PatientBehaviorQueryBizService.java
  26. 250 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/impl/PatientBehaviorBizServiceImpl.java
  27. 40 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/impl/PatientBehaviorQueryBizServiceImpl.java
  28. 133 0
      health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/client/service/PatientBehaviorClientServiceImpl.java
  29. 38 0
      pom.xml

+ 84 - 0
.gitignore

@@ -0,0 +1,84 @@
+# maven output files
+/target/
+*/target/
+**/target/
+
+# virtual machine crash logs
+hs_err_pid*
+/bin/
+/build/
+*/bin/
+*/gen/
+*/out/
+
+# Java class files
+*.class
+
+# Files for the Dalvik VM
+*.dex
+
+#Built application files
+*.apk
+*.ap_
+proguard/
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+# *.jar
+*.war
+*.ear
+
+# Eclipse Project files
+.classpath
+*/.classpath
+**/.classpath
+.project
+*/.project
+**/.project
+.factorypath
+*/.factorypath
+**/.factorypath
+.settings/
+/.settings/
+*/.settings/
+**/.settings/
+*/.apt_generated/
+**/.apt_generated/
+*/.apt_generated_tests/
+**/.apt_generated_tests/
+
+# IntelliJ IDEA Project files
+.idea
+*.iml
+*/*.iml
+**/*.iml
+*.ipr
+*.iws
+out
+*/.DS_Store
+**/.DS_Store
+.DS_Store
+Thumbs.db
+/.idea/
+*/.idea/
+**/.idea/
+.idea/
+
+#gradle wrapper
+gradle/
+/.gradle/
+# Gradle files
+.gradle/
+build/
+*/build/
+**/build/
+gradlew
+gradlew.bat
+
+# Log Files
+*.log
+
+# VSCode
+.vscode

+ 29 - 0
health-behavior-application-api/pom.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>health-behavior-java</artifactId>
+        <groupId>com.xxh.cloud</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <artifactId>health-behavior-application-api</artifactId>
+    <version>1.0.0</version>
+
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>xx-config-web</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>health-behavior-framework</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

+ 51 - 0
health-behavior-application-api/src/main/java/com/xxh/cloud/healthy/behavior/application/controller/PatientBehaviorApplicationController.java

@@ -0,0 +1,51 @@
+package com.xxh.cloud.healthy.behavior.application.controller;
+
+import cn.dev33.satoken.annotation.SaCheckLogin;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.alibaba.fastjson2.JSON;
+import com.xxh.cloud.framework.common.entity.Result;
+import com.xxh.cloud.framework.common.user.AuthContextUtils;
+import com.xxh.cloud.framework.common.user.LoginUser;
+import com.xxh.cloud.framework.common.utils.IpUtils;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorUploadDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorBaseVO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.service.PatientBehaviorBizService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.log4j.Log4j2;
+
+@Log4j2
+@RestController
+@RequestMapping("/app/healthy/patient/behavior")
+@Api(tags = "用户行为管理")
+public class PatientBehaviorApplicationController {
+    
+    @Autowired
+    private PatientBehaviorBizService patientBehaviorBizService;
+    
+    /**
+     * 添加用户行为
+     */
+    @SaCheckLogin
+    @PostMapping("/add")
+    @ApiOperation(value = "用户行为上传", response = PatientBehaviorBaseVO.class)
+    public Result<PatientBehaviorBaseVO> add(HttpServletRequest request, @RequestBody PatientBehaviorUploadDTO params) {
+        log.info("/app/healthy/patient/behavior/add >>> {}", JSON.toJSONString(params));
+        LoginUser user = AuthContextUtils.getCurrentLoginUser();
+
+        params.setIp(IpUtils.getIpAddr());
+        params.setUa(request.getHeader("User-Agent"));
+        PatientBehaviorBaseVO vo = patientBehaviorBizService.upload(params, user);
+        return new Result<PatientBehaviorBaseVO>().ok(vo);
+    }
+
+}

+ 23 - 0
health-behavior-client/pom.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>health-behavior-java</artifactId>
+        <groupId>com.xxh.cloud</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <artifactId>health-behavior-client</artifactId>
+    <version>1.0.0</version>
+
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>xx-config-framework</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

+ 19 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/PatientBehaviorClientService.java

@@ -0,0 +1,19 @@
+package com.xxh.cloud.healthy.behavior.client.api;
+
+import java.util.List;
+
+import com.xxh.cloud.healthy.behavior.client.api.bean.dto.PatientBehaviorSaveClientDTO;
+import com.xxh.cloud.healthy.behavior.client.api.bean.dto.PatientBehaviorUploadClientDTO;
+
+public interface PatientBehaviorClientService {
+    
+    // 保存
+    void add(PatientBehaviorUploadClientDTO params);
+
+    // 批量保存
+    void addBatch(List<PatientBehaviorUploadClientDTO> params);
+
+    // 批量保存
+    void simpleSaveBatch(List<PatientBehaviorSaveClientDTO> params);
+
+}

+ 71 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/bo/PatientBehaviorBO.java

@@ -0,0 +1,71 @@
+package com.xxh.cloud.healthy.behavior.client.api.bean.bo;
+
+public class PatientBehaviorBO {
+
+    // "加密数据"
+    private String secureData;
+
+    // "操作类型[阅读、阅读时长、感兴趣、已知晓、挂号、在线问诊、就诊]"
+    private String operatedType;
+
+    // "操作时长")
+    private Integer operatedDuration;
+
+    // 自定义操作内容
+    private String operatedContent;
+
+    // "ip")
+    private String ip;
+    
+    // "ua")
+    private String ua;
+
+    public String getSecureData() {
+        return secureData;
+    }
+
+    public void setSecureData(String secureData) {
+        this.secureData = secureData;
+    }
+
+    public String getOperatedType() {
+        return operatedType;
+    }
+
+    public void setOperatedType(String operatedType) {
+        this.operatedType = operatedType;
+    }
+
+    public Integer getOperatedDuration() {
+        return operatedDuration;
+    }
+
+    public void setOperatedDuration(Integer operatedDuration) {
+        this.operatedDuration = operatedDuration;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    public String getUa() {
+        return ua;
+    }
+
+    public void setUa(String ua) {
+        this.ua = ua;
+    }
+
+    public String getOperatedContent() {
+        return operatedContent;
+    }
+
+    public void setOperatedContent(String operatedContent) {
+        this.operatedContent = operatedContent;
+    }
+    
+}

+ 159 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/bo/PatientBehaviorSecureBO.java

@@ -0,0 +1,159 @@
+package com.xxh.cloud.healthy.behavior.client.api.bean.bo;
+
+public class PatientBehaviorSecureBO {
+
+    // "患者id"
+    private String patientId;
+
+    // "用户id"
+    private String userId;
+
+    // "内容类型[BehaviorSourceTypeConstant.ContentTypeEnum]"
+    private String contentType;
+
+    // "内容ID"
+    private String contentId;
+
+    // "数据来源一级类型[BehaviorSourceTypeConstant.SourceOneTypeEnum]"
+    private String sourceOneType;
+
+    // "数据来源一级id"
+    private String sourceOneId;
+
+    // "数据来源二级类型[BehaviorSourceTypeConstant.SourceTwoTypeEnum]"
+    private String sourceTwoType;
+
+    // "数据来源二级id"
+    private String sourceTwoId;
+
+    // "数据来源三级类型[BehaviorSourceTypeConstant.SourceThreeTypeEnum]"
+    private String sourceThreeType;
+
+    // "数据来源三级id"
+    private String sourceThreeId;
+
+    // "数据来源四级类型[BehaviorSourceTypeConstant.SourceFourTypeEnum]"
+    private String sourceFourType;
+
+    // "数据来源四级id"
+    private String sourceFourId;
+
+    // "数据来源五级类型[BehaviorSourceTypeConstant.SourceFiveTypeEnum]"
+    private String sourceFiveType;
+
+    // "数据来源五级id"
+    private String sourceFiveId;
+
+    public String getPatientId() {
+        return patientId;
+    }
+
+    public void setPatientId(String patientId) {
+        this.patientId = patientId;
+    }
+
+    public String getUserId() {
+        return userId;
+    }
+
+    public void setUserId(String userId) {
+        this.userId = userId;
+    }
+
+    public String getContentType() {
+        return contentType;
+    }
+
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    public String getContentId() {
+        return contentId;
+    }
+
+    public void setContentId(String contentId) {
+        this.contentId = contentId;
+    }
+
+    public String getSourceOneType() {
+        return sourceOneType;
+    }
+
+    public void setSourceOneType(String sourceOneType) {
+        this.sourceOneType = sourceOneType;
+    }
+
+    public String getSourceOneId() {
+        return sourceOneId;
+    }
+
+    public void setSourceOneId(String sourceOneId) {
+        this.sourceOneId = sourceOneId;
+    }
+
+    public String getSourceTwoType() {
+        return sourceTwoType;
+    }
+
+    public void setSourceTwoType(String sourceTwoType) {
+        this.sourceTwoType = sourceTwoType;
+    }
+
+    public String getSourceTwoId() {
+        return sourceTwoId;
+    }
+
+    public void setSourceTwoId(String sourceTwoId) {
+        this.sourceTwoId = sourceTwoId;
+    }
+
+    public String getSourceThreeType() {
+        return sourceThreeType;
+    }
+
+    public void setSourceThreeType(String sourceThreeType) {
+        this.sourceThreeType = sourceThreeType;
+    }
+
+    public String getSourceThreeId() {
+        return sourceThreeId;
+    }
+
+    public void setSourceThreeId(String sourceThreeId) {
+        this.sourceThreeId = sourceThreeId;
+    }
+
+    public String getSourceFourType() {
+        return sourceFourType;
+    }
+
+    public void setSourceFourType(String sourceFourType) {
+        this.sourceFourType = sourceFourType;
+    }
+
+    public String getSourceFourId() {
+        return sourceFourId;
+    }
+
+    public void setSourceFourId(String sourceFourId) {
+        this.sourceFourId = sourceFourId;
+    }
+
+    public String getSourceFiveType() {
+        return sourceFiveType;
+    }
+
+    public void setSourceFiveType(String sourceFiveType) {
+        this.sourceFiveType = sourceFiveType;
+    }
+
+    public String getSourceFiveId() {
+        return sourceFiveId;
+    }
+
+    public void setSourceFiveId(String sourceFiveId) {
+        this.sourceFiveId = sourceFiveId;
+    }
+
+}

+ 86 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/dto/PatientBehaviorSaveClientDTO.java

@@ -0,0 +1,86 @@
+package com.xxh.cloud.healthy.behavior.client.api.bean.dto;
+
+import java.util.Date;
+
+import javax.validation.constraints.NotEmpty;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class PatientBehaviorSaveClientDTO {
+
+    @ApiModelProperty(value = "id")
+    private String id;
+
+    @ApiModelProperty(value = "患者id", required = true)
+    @NotEmpty(message = "患者id[patientId]不能为空")
+    private String patientId;
+
+    @ApiModelProperty(value = "用户id", required = true)
+    @NotEmpty(message = "用户id[userId]不能为空")
+    private String userId;
+
+    @ApiModelProperty(value = "内容类型[BehaviorSourceTypeConstant.ContentTypeEnum]", required = true)
+    @NotEmpty(message = "内容类型[contentType]不能为空")
+    private String contentType;
+
+    @ApiModelProperty(value = "内容ID", required = true)
+    @NotEmpty(message = "内容ID[contentId]不能为空")
+    private String contentId;
+
+    @ApiModelProperty(value = "数据来源一级类型[BehaviorSourceTypeConstant.SourceOneTypeEnum]")
+    private String sourceOneType;
+
+    @ApiModelProperty(value = "数据来源一级id")
+    private String sourceOneId;
+
+    @ApiModelProperty(value = "数据来源二级类型[BehaviorSourceTypeConstant.SourceTwoTypeEnum]")
+    private String sourceTwoType;
+
+    @ApiModelProperty(value = "数据来源二级id")
+    private String sourceTwoId;
+
+    @ApiModelProperty(value = "数据来源三级类型")
+    private String sourceThreeType;
+
+    @ApiModelProperty(value = "数据来源三级id")
+    private String sourceThreeId;
+
+    @ApiModelProperty(value = "数据来源四级类型")
+    private String sourceFourType;
+
+    @ApiModelProperty(value = "数据来源四级id")
+    private String sourceFourId;
+
+    @ApiModelProperty(value = "数据来源五级类型")
+    private String sourceFiveType;
+
+    @ApiModelProperty(value = "数据来源五级id")
+    private String sourceFiveId;
+
+    @ApiModelProperty(value = "操作类型[阅读、阅读时长、感兴趣、已知晓、挂号、在线问诊、就诊]", required = true)
+    @NotEmpty(message = "操作类型[operatedType]不能为空")
+    private String operatedType;
+
+    @ApiModelProperty(value = "操作时长")
+    private Integer operatedDuration;
+
+    @ApiModelProperty(value = "自定义操作内容")
+    private String operatedContent;
+
+    @ApiModelProperty("创建者")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+
+    @ApiModelProperty("ip")
+    private String ip;
+    
+    @ApiModelProperty("ua")
+    private String ua;
+    
+}

+ 71 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/bean/dto/PatientBehaviorUploadClientDTO.java

@@ -0,0 +1,71 @@
+package com.xxh.cloud.healthy.behavior.client.api.bean.dto;
+
+public class PatientBehaviorUploadClientDTO {
+
+    // "加密数据"
+    private String secureData;
+
+    // "操作类型[阅读、阅读时长、感兴趣、已知晓、挂号、在线问诊、就诊]"
+    private String operatedType;
+
+    // "操作时长")
+    private Integer operatedDuration;
+
+    // 自定义操作内容
+    private String operatedContent;
+
+    // "ip")
+    private String ip;
+    
+    // "ua")
+    private String ua;
+
+    public String getSecureData() {
+        return secureData;
+    }
+
+    public void setSecureData(String secureData) {
+        this.secureData = secureData;
+    }
+
+    public String getOperatedType() {
+        return operatedType;
+    }
+
+    public void setOperatedType(String operatedType) {
+        this.operatedType = operatedType;
+    }
+
+    public Integer getOperatedDuration() {
+        return operatedDuration;
+    }
+
+    public void setOperatedDuration(Integer operatedDuration) {
+        this.operatedDuration = operatedDuration;
+    }
+
+    public String getIp() {
+        return ip;
+    }
+
+    public void setIp(String ip) {
+        this.ip = ip;
+    }
+
+    public String getUa() {
+        return ua;
+    }
+
+    public void setUa(String ua) {
+        this.ua = ua;
+    }
+
+    public String getOperatedContent() {
+        return operatedContent;
+    }
+
+    public void setOperatedContent(String operatedContent) {
+        this.operatedContent = operatedContent;
+    }
+    
+}

+ 95 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/constant/BehaviorSourceTypeConstant.java

@@ -0,0 +1,95 @@
+package com.xxh.cloud.healthy.behavior.client.api.constant;
+
+/**
+ * 用户行为数据来源类型枚举
+ */
+public class BehaviorSourceTypeConstant {
+
+    public enum ContentTypeEnum {
+
+        Article("article","文章"),
+        Scale("scale","量表"),
+
+        ;
+
+        private String code;
+        private String msg;
+        private ContentTypeEnum(String code, String msg) {
+            this.code = code;
+            this.msg = msg;
+        }
+        public String getCode() {
+            return code;
+        }
+        public String getMsg() {
+            return msg;
+        }
+
+    }
+
+    public enum SourceOneTypeEnum {
+
+        Schedule("schedule","日程"),
+        Remind("remind","提醒"),
+
+        ;
+
+        private String code;
+        private String msg;
+        private SourceOneTypeEnum(String code, String msg) {
+            this.code = code;
+            this.msg = msg;
+        }
+        public String getCode() {
+            return code;
+        }
+        public String getMsg() {
+            return msg;
+        }
+
+    }
+
+    public enum SourceTwoTypeEnum {
+
+        PatientPushServe("patient_push_serve","患者推送服务"),
+
+        ;
+
+        private String code;
+        private String msg;
+        private SourceTwoTypeEnum(String code, String msg) {
+            this.code = code;
+            this.msg = msg;
+        }
+        public String getCode() {
+            return code;
+        }
+        public String getMsg() {
+            return msg;
+        }
+
+    }
+
+    public enum SourceThreeTypeEnum {
+
+        PushServeConfig("push_serve_config","推送服务配置"),
+
+        ;
+
+        private String code;
+        private String msg;
+        private SourceThreeTypeEnum(String code, String msg) {
+            this.code = code;
+            this.msg = msg;
+        }
+        public String getCode() {
+            return code;
+        }
+        public String getMsg() {
+            return msg;
+        }
+
+    }
+
+}
+

+ 34 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/constant/PatientOperatedTypeEnum.java

@@ -0,0 +1,34 @@
+package com.xxh.cloud.healthy.behavior.client.api.constant;
+
+/**
+ * 用户行为枚举
+ */
+public enum PatientOperatedTypeEnum {
+
+    Browse("browse","浏览"),
+    Browse_Duration("browse_duration","浏览时长"),
+    Interested("interested","感兴趣"),
+    Knew("knew","已知晓"),
+    Further_Reading("further_reading", "衍生阅读"),
+
+    Register("register","挂号"),
+    Consultation_Online("consultation_online","在线问诊"),
+    Consultation("consultation","就诊"),
+
+    ;
+
+    private String code;
+    private String msg;
+    private PatientOperatedTypeEnum(String code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+    public String getCode() {
+        return code;
+    }
+    public String getMsg() {
+        return msg;
+    }
+
+}
+

+ 54 - 0
health-behavior-client/src/main/java/com/xxh/cloud/healthy/behavior/client/api/util/BehaviorSecureUtil.java

@@ -0,0 +1,54 @@
+package com.xxh.cloud.healthy.behavior.client.api.util;
+
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONObject;
+import com.xxh.cloud.healthy.behavior.client.api.bean.bo.PatientBehaviorSecureBO;
+
+import cn.hutool.core.codec.Base64;
+import cn.hutool.crypto.SecureUtil;
+
+public class BehaviorSecureUtil {
+
+    private static String secureKey = "ug7EJYvHbJZwpv9a";
+    
+    public static String encryptData(String data) {
+        return SecureUtil.aes(secureKey.getBytes()).encryptBase64(JSON.toJSONString(data));
+    }
+
+    public static String decryptDataStr(String secureData) {
+        return SecureUtil.aes(secureKey.getBytes()).decryptStr(secureData);
+    }
+
+    public static String encryptData(PatientBehaviorSecureBO data) {
+        return SecureUtil.aes(secureKey.getBytes()).encryptBase64(JSON.toJSONString(data));
+    }
+
+    public static PatientBehaviorSecureBO decryptData(String secureData) {
+        String data = SecureUtil.aes(secureKey.getBytes()).decryptStr(secureData);
+        return JSONObject.parseObject(data, PatientBehaviorSecureBO.class);
+    }
+
+    // 媒体id与类型整合成一个字符串
+    public static String mergeSourceData(String sourceType, String sourceId) {
+        return sourceType + "-" + sourceId;
+    }
+
+    // 把媒体数据拆分为媒体类型和媒体id
+    public static String[] decomposeSourceData(String sourceData) {
+        return sourceData.split("-");
+    }
+
+    public static void main(String[] args) {
+        String str = "a_PPS1721180801649627136-r_PPS1721180801649627136";
+
+        String data = encryptData(str);
+        System.out.println(data);
+
+        String base64 = Base64.encode(data);
+        System.out.println(base64);
+
+        System.out.println(Base64.decodeStr(base64, "utf-8"));
+
+        System.out.println(decryptDataStr(data));
+    }
+}

+ 41 - 0
health-behavior-framework/pom.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>health-behavior-java</artifactId>
+        <groupId>com.xxh.cloud</groupId>
+        <version>1.0.0</version>
+    </parent>
+    <artifactId>health-behavior-framework</artifactId>
+    <version>1.0.0</version>
+
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>xx-config-framework</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>xx-config-mybatisplus</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>health-behavior-client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.xxh.cloud</groupId>
+            <artifactId>healthy-serve-pushServe-client</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+    </dependencies>
+
+</project>

+ 96 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/entity/PatientBehaviorInfo.java

@@ -0,0 +1,96 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.bean.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * <p>
+ * 患者行为信息表
+ * </p>
+ */
+@Data
+@TableName("hb_patient_behavior_info")
+public class PatientBehaviorInfo {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "编号")
+    @TableId(value = "id", type = IdType.INPUT)
+    private String id;
+
+    @ApiModelProperty(value = "患者id")
+    private String patientId;
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "内容类型")
+    private String contentType;
+
+    @ApiModelProperty(value = "内容ID")
+    private String contentId;
+
+    @ApiModelProperty(value = "数据来源一级类型")
+    private String sourceOneType;
+
+    @ApiModelProperty(value = "数据来源一级id")
+    private String sourceOneId;
+
+    @ApiModelProperty(value = "数据来源二级类型")
+    private String sourceTwoType;
+
+    @ApiModelProperty(value = "数据来源二级id")
+    private String sourceTwoId;
+
+    @ApiModelProperty(value = "数据来源三级类型")
+    private String sourceThreeType;
+
+    @ApiModelProperty(value = "数据来源三级id")
+    private String sourceThreeId;
+
+    @ApiModelProperty(value = "数据来源四级类型")
+    private String sourceFourType;
+
+    @ApiModelProperty(value = "数据来源四级id")
+    private String sourceFourId;
+
+    @ApiModelProperty(value = "数据来源五级类型")
+    private String sourceFiveType;
+
+    @ApiModelProperty(value = "数据来源五级id")
+    private String sourceFiveId;
+
+    @ApiModelProperty(value = "操作类型")
+    private String operatedType;
+
+    @ApiModelProperty(value = "操作开始时间")
+    private Date operatedStartDate;
+
+    @ApiModelProperty(value = "操作结束时间")
+    private Date operatedEndDate;
+
+    @ApiModelProperty(value = "操作时长")
+    private Integer operatedDuration;
+
+    @ApiModelProperty(value = "自定义操作内容")
+    private String operatedContent;
+
+    @ApiModelProperty("创建者")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+
+    @ApiModelProperty("ip")
+    private String ip;
+    
+    @ApiModelProperty("ua")
+    private String ua;
+    
+}

+ 16 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/mapper/PatientBehaviorInfoMapper.java

@@ -0,0 +1,16 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.bean.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+
+/**
+ * <p>
+ * 患者行为信息表 Mapper 接口
+ * </p>
+ *
+ * @author wing
+ * @since 2023-10-13
+ */
+public interface PatientBehaviorInfoMapper extends BaseMapper<PatientBehaviorInfo> {
+
+}

+ 16 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/service/PatientBehaviorInfoService.java

@@ -0,0 +1,16 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.bean.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+
+/**
+ * <p>
+ * 患者行为信息表 服务类
+ * </p>
+ *
+ * @author wing
+ * @since 2023-10-13
+ */
+public interface PatientBehaviorInfoService extends IService<PatientBehaviorInfo> {
+
+}

+ 18 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/bean/service/impl/PatientBehaviorInfoServiceImpl.java

@@ -0,0 +1,18 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.bean.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.mapper.PatientBehaviorInfoMapper;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.service.PatientBehaviorInfoService;
+
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 患者行为信息表 服务实现类
+ * </p>
+ */
+@Service
+public class PatientBehaviorInfoServiceImpl extends ServiceImpl<PatientBehaviorInfoMapper, PatientBehaviorInfo> implements PatientBehaviorInfoService {
+
+}

+ 87 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/dto/PatientBehaviorAddDTO.java

@@ -0,0 +1,87 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+import javax.validation.constraints.NotEmpty;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@Getter
+@Setter
+public class PatientBehaviorAddDTO {
+
+    @ApiModelProperty(value = "id")
+    private String id;
+
+    @ApiModelProperty(value = "患者id", required = true)
+    @NotEmpty(message = "患者id[patientId]不能为空")
+    private String patientId;
+
+    @ApiModelProperty(value = "用户id", required = true)
+    @NotEmpty(message = "用户id[userId]不能为空")
+    private String userId;
+
+    @ApiModelProperty(value = "内容类型[BehaviorSourceTypeConstant.ContentTypeEnum]", required = true)
+    @NotEmpty(message = "内容类型[contentType]不能为空")
+    private String contentType;
+
+    @ApiModelProperty(value = "内容ID", required = true)
+    @NotEmpty(message = "内容ID[contentId]不能为空")
+    private String contentId;
+
+    @ApiModelProperty(value = "数据来源一级类型[BehaviorSourceTypeConstant.SourceOneTypeEnum]")
+    private String sourceOneType;
+
+    @ApiModelProperty(value = "数据来源一级id")
+    private String sourceOneId;
+
+    @ApiModelProperty(value = "数据来源二级类型[BehaviorSourceTypeConstant.SourceTwoTypeEnum]")
+    private String sourceTwoType;
+
+    @ApiModelProperty(value = "数据来源二级id")
+    private String sourceTwoId;
+
+    @ApiModelProperty(value = "数据来源三级类型")
+    private String sourceThreeType;
+
+    @ApiModelProperty(value = "数据来源三级id")
+    private String sourceThreeId;
+
+    @ApiModelProperty(value = "数据来源四级类型")
+    private String sourceFourType;
+
+    @ApiModelProperty(value = "数据来源四级id")
+    private String sourceFourId;
+
+    @ApiModelProperty(value = "数据来源五级类型")
+    private String sourceFiveType;
+
+    @ApiModelProperty(value = "数据来源五级id")
+    private String sourceFiveId;
+
+    @ApiModelProperty(value = "操作类型[阅读、阅读时长、感兴趣、已知晓、挂号、在线问诊、就诊]", required = true)
+    @NotEmpty(message = "操作类型[operatedType]不能为空")
+    private String operatedType;
+
+    @ApiModelProperty(value = "操作时长")
+    private Integer operatedDuration;
+
+    @ApiModelProperty(value = "自定义操作内容")
+    private String operatedContent;
+
+    @ApiModelProperty("创建者")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+
+    @ApiModelProperty("ip")
+    private String ip;
+    
+    @ApiModelProperty("ua")
+    private String ua;
+    
+}

+ 32 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/dto/PatientBehaviorQueryDTO.java

@@ -0,0 +1,32 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@Getter
+@Setter
+public class PatientBehaviorQueryDTO {
+
+    @ApiModelProperty(value = "编号")
+    private String id;
+
+    @ApiModelProperty(value = "患者id")
+    private String patientId;
+
+    @ApiModelProperty(value = "患者ids")
+    private List<String> patientIds;
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "用户ids")
+    private List<String> userIds;
+
+    @ApiModelProperty(value = "操作类型[阅读、阅读时长、感兴趣、已知晓、挂号、在线问诊、就诊]")
+    private String operatedType;
+
+}

+ 48 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/dto/PatientBehaviorUploadDTO.java

@@ -0,0 +1,48 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotEmpty;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@Getter
+@Setter
+public class PatientBehaviorUploadDTO {
+
+    // @ApiModelProperty(value = "加密数据")
+    // private String secureData;
+
+    @ApiModelProperty(value = "id")
+    private String id;
+
+    @ApiModelProperty(value = "媒体数类型D", required = true)
+    @NotEmpty(message = "媒体数类型D[mediaType]不能为空")
+    private String mediaType;
+
+    @ApiModelProperty(value = "媒体数据ID", required = true)
+    @NotEmpty(message = "媒体数据ID[mediaId]不能为空")
+    private String mediaId;
+
+    @ApiModelProperty(value = "数据来源", required = true)
+    @NotEmpty(message = "数据来源[sourceData]不能为空")
+    private String sourceData;
+
+    @ApiModelProperty(value = "操作类型[PatientOperatedTypeEnum]", required = true)
+    @NotEmpty(message = "操作类型[operatedType]不能为空")
+    private String operatedType;
+
+    @ApiModelProperty(value = "操作时长")
+    private Integer operatedDuration;
+
+    @ApiModelProperty(value = "自定义操作内容")
+    private String operatedContent;
+
+    @ApiModelProperty("ip")
+    private String ip;
+    
+    @ApiModelProperty("ua")
+    private String ua;
+    
+}

+ 15 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/vo/PatientBehaviorBaseVO.java

@@ -0,0 +1,15 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@Getter
+@Setter
+public class PatientBehaviorBaseVO {
+
+    @ApiModelProperty(value = "id")
+    private String id;
+
+}

+ 86 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/bean/vo/PatientBehaviorVO.java

@@ -0,0 +1,86 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+import io.swagger.annotations.ApiModelProperty;
+
+@Getter
+@Setter
+public class PatientBehaviorVO {
+
+    @ApiModelProperty(value = "编号")
+    private String id;
+
+    @ApiModelProperty(value = "患者id")
+    private String patientId;
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "内容类型[BehaviorSourceTypeConstant.ContentTypeEnum]")
+    private String contentType;
+
+    @ApiModelProperty(value = "内容ID")
+    private String contentId;
+
+    @ApiModelProperty(value = "数据来源一级类型[BehaviorSourceTypeConstant.SourceOneTypeEnum]")
+    private String sourceOneType;
+
+    @ApiModelProperty(value = "数据来源一级id")
+    private String sourceOneId;
+
+    @ApiModelProperty(value = "数据来源二级类型[BehaviorSourceTypeConstant.SourceTwoTypeEnum]")
+    private String sourceTwoType;
+
+    @ApiModelProperty(value = "数据来源二级id")
+    private String sourceTwoId;
+
+    @ApiModelProperty(value = "数据来源三级类型")
+    private String sourceThreeType;
+
+    @ApiModelProperty(value = "数据来源三级id")
+    private String sourceThreeId;
+
+    @ApiModelProperty(value = "数据来源四级类型")
+    private String sourceFourType;
+
+    @ApiModelProperty(value = "数据来源四级id")
+    private String sourceFourId;
+
+    @ApiModelProperty(value = "数据来源五级类型")
+    private String sourceFiveType;
+
+    @ApiModelProperty(value = "数据来源五级id")
+    private String sourceFiveId;
+
+    @ApiModelProperty(value = "操作类型[阅读、浏览时长、感兴趣、已知晓、衍生阅读、挂号、在线问诊、就诊]")
+    private String operatedType;
+
+    @ApiModelProperty(value = "操作开始时间")
+    private Date operatedStartDate;
+
+    @ApiModelProperty(value = "操作结束时间")
+    private Date operatedEndDate;
+
+    @ApiModelProperty(value = "操作时长")
+    private Integer operatedDuration;
+
+    @ApiModelProperty(value = "自定义操作内容")
+    private String operatedContent;
+
+    @ApiModelProperty("创建者")
+    private String creator;
+
+    @ApiModelProperty("创建时间")
+    private Date createDate;
+
+    @ApiModelProperty("ip")
+    private String ip;
+    
+    @ApiModelProperty("ua")
+    private String ua;
+    
+}

+ 23 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/helper/PatientBehaviorHelper.java

@@ -0,0 +1,23 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.helper;
+
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorVO;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
+
+// zs:20231023
+public class PatientBehaviorHelper {
+
+    public static String getPatientBehaviorInfoId(){
+        return StrUtil.format("PB{}", IdUtil.getSnowflake(5,6).nextIdStr());
+    }
+
+    public static PatientBehaviorVO getPatientBehaviorVO(PatientBehaviorInfo entity) {
+        PatientBehaviorVO vo = new PatientBehaviorVO();
+        BeanUtil.copyProperties(entity, vo);
+        return vo;
+    }
+
+}

+ 22 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/PatientBehaviorBizService.java

@@ -0,0 +1,22 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.service;
+
+import java.util.List;
+
+import com.xxh.cloud.framework.common.user.LoginUser;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorAddDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorUploadDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorBaseVO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorVO;
+
+public interface PatientBehaviorBizService {
+    
+    // 上报
+    PatientBehaviorBaseVO upload(PatientBehaviorUploadDTO params, LoginUser user);
+
+    // 保存
+    PatientBehaviorVO add(PatientBehaviorAddDTO params);
+
+    // 批量保存
+    void addBatch(List<PatientBehaviorAddDTO> params);
+
+}

+ 13 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/PatientBehaviorQueryBizService.java

@@ -0,0 +1,13 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.service;
+
+import java.util.List;
+
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorQueryDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorVO;
+
+public interface PatientBehaviorQueryBizService {
+    
+    // 列表
+    List<PatientBehaviorVO> list(PatientBehaviorQueryDTO params);
+
+}

+ 250 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/impl/PatientBehaviorBizServiceImpl.java

@@ -0,0 +1,250 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxh.cloud.framework.common.exception.BusinessException;
+import com.xxh.cloud.framework.common.user.LoginUser;
+import com.xxh.cloud.framework.common.validator.ValidatorUtils;
+import com.xxh.cloud.healthy.behavior.client.api.constant.BehaviorSourceTypeConstant;
+import com.xxh.cloud.healthy.behavior.client.api.constant.PatientOperatedTypeEnum;
+import com.xxh.cloud.healthy.behavior.client.api.util.BehaviorSecureUtil;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.service.PatientBehaviorInfoService;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorAddDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorUploadDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorBaseVO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorVO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.helper.PatientBehaviorHelper;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.service.PatientBehaviorBizService;
+import com.xxh.cloud.healthy.serve.pushServe.client.api.PatientPushServeClientService;
+import com.xxh.cloud.healthy.serve.pushServe.client.api.bean.bo.PatientRemindBO;
+import com.xxh.cloud.healthy.serve.pushServe.client.api.bean.bo.PatientScheduleBO;
+import com.xxh.cloud.healthy.serve.pushServe.client.api.constant.PatientPushServeConstant;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.util.StrUtil;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@Service
+public class PatientBehaviorBizServiceImpl implements PatientBehaviorBizService {
+
+    @Autowired
+    private PatientBehaviorInfoService patientBehaviorInfoService;
+    @Autowired
+    private PatientPushServeClientService patientPushServeClientService;
+    
+    // 感兴趣的浏览时长
+    @Value("${behavior.interestedTime:30}")
+    private String interestedTime;
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public PatientBehaviorBaseVO upload(PatientBehaviorUploadDTO params, LoginUser user) {
+        log.info("用户行为上报>>>>>>PatientBehaviorUploadDTO={}; LoginUser={}", JSON.toJSONString(params), JSON.toJSONString(user));
+        ValidatorUtils.validateEntity(params);
+
+        // 根据媒体ID查询各种数据来源id及类型
+        String[] sourceData = BehaviorSecureUtil.decomposeSourceData(params.getSourceData());
+        
+        PatientBehaviorBaseVO vo = new PatientBehaviorBaseVO();
+        
+        PatientBehaviorAddDTO patientBehaviorAddDTO = new PatientBehaviorAddDTO();
+        patientBehaviorAddDTO.setId(params.getId());
+        patientBehaviorAddDTO.setOperatedType(params.getOperatedType());
+        patientBehaviorAddDTO.setOperatedDuration(params.getOperatedDuration());
+        patientBehaviorAddDTO.setContentType(params.getMediaType());
+        patientBehaviorAddDTO.setContentId(params.getMediaId());
+        patientBehaviorAddDTO.setCreator(user.getUserName());
+        patientBehaviorAddDTO.setIp(params.getIp());
+        patientBehaviorAddDTO.setUa(params.getUa());
+        patientBehaviorAddDTO.setOperatedContent(params.getOperatedContent());
+
+        patientBehaviorAddDTO.setSourceOneType(sourceData[0]);
+        patientBehaviorAddDTO.setSourceOneId(sourceData[1]);
+
+        if (BehaviorSourceTypeConstant.SourceOneTypeEnum.Schedule.getCode().equals(sourceData[0])) {
+            PatientScheduleBO patientScheduleBO = patientPushServeClientService.updatePatientScheduleStatus(sourceData[1], PatientPushServeConstant.ScheduleStatus.DONE.getCode()); // 查询并更新日程状态
+            if (null != patientScheduleBO) {
+                if (!patientScheduleBO.getUserId().equals(user.getId())) {
+                    throw new BusinessException("没有权限");
+                }
+                patientBehaviorAddDTO.setPatientId(patientScheduleBO.getPatientId());
+                patientBehaviorAddDTO.setUserId(patientScheduleBO.getUserId());
+                patientBehaviorAddDTO.setSourceTwoType(BehaviorSourceTypeConstant.SourceTwoTypeEnum.PatientPushServe.getCode());
+                patientBehaviorAddDTO.setSourceTwoId(patientScheduleBO.getBizId());
+                patientBehaviorAddDTO.setSourceThreeType(BehaviorSourceTypeConstant.SourceThreeTypeEnum.PushServeConfig.getCode());
+                patientBehaviorAddDTO.setSourceThreeId(patientScheduleBO.getPatientPushServeBO().getPushServeId());
+            }
+        } else if (BehaviorSourceTypeConstant.SourceOneTypeEnum.Remind.getCode().equals(sourceData[0])) {
+            PatientRemindBO patientRemindBO = patientPushServeClientService.getPatientRemindBO(sourceData[1]);
+            if (null != patientRemindBO) {
+                if (!patientRemindBO.getUserId().equals(user.getId())) {
+                    throw new BusinessException("没有权限");
+                }
+                patientBehaviorAddDTO.setPatientId(patientRemindBO.getPatientId());
+                patientBehaviorAddDTO.setUserId(patientRemindBO.getUserId());
+                patientBehaviorAddDTO.setSourceTwoType(BehaviorSourceTypeConstant.SourceTwoTypeEnum.PatientPushServe.getCode());
+                patientBehaviorAddDTO.setSourceTwoId(patientRemindBO.getBizId());
+                patientBehaviorAddDTO.setSourceThreeType(BehaviorSourceTypeConstant.SourceThreeTypeEnum.PushServeConfig.getCode());
+                patientBehaviorAddDTO.setSourceThreeId(patientRemindBO.getPatientPushServeBO().getPushServeId());
+            }
+        } else {
+            throw new BusinessException("不支持的上报");
+        }
+
+        PatientBehaviorVO patientBehaviorVO = this.add(patientBehaviorAddDTO);
+        if (null != patientBehaviorAddDTO) {
+            vo.setId(patientBehaviorVO.getId());
+        }
+
+        return vo;
+    }
+    
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public PatientBehaviorVO add(PatientBehaviorAddDTO params) {
+        ValidatorUtils.validateEntity(params);
+
+        DateTime now = DateTime.now();
+        // zs20231026 根据浏览时长判断是否感兴趣
+        if (PatientOperatedTypeEnum.Browse_Duration.getCode().equals(params.getOperatedType()) && params.getOperatedDuration() >= Integer.valueOf(interestedTime)) {
+            PatientBehaviorInfo entity = patientBehaviorInfoService.getOne(new QueryWrapper<PatientBehaviorInfo>()
+                    .eq(StrUtil.isNotBlank(params.getPatientId()), "patient_id", params.getPatientId())
+                    .eq(StrUtil.isNotBlank(params.getUserId()), "user_id", params.getUserId())
+                    .eq(StrUtil.isNotBlank(params.getContentType()), "content_type", params.getContentType())
+                    .eq(StrUtil.isNotBlank(params.getContentId()), "content_id", params.getContentId())
+                    .eq(StrUtil.isNotBlank(params.getSourceOneType()), "source_one_type", params.getSourceOneType())
+                    .eq(StrUtil.isNotBlank(params.getSourceOneId()), "source_one_id", params.getSourceOneId())
+                    .eq(StrUtil.isNotBlank(params.getSourceTwoType()), "source_two_type", params.getSourceTwoType())
+                    .eq(StrUtil.isNotBlank(params.getSourceTwoId()), "source_two_id", params.getSourceTwoId())
+                    .eq(StrUtil.isNotBlank(params.getSourceThreeType()), "source_three_type", params.getSourceThreeType())
+                    .eq(StrUtil.isNotBlank(params.getSourceThreeId()), "source_three_id", params.getSourceThreeId())
+                    .eq(StrUtil.isNotBlank(params.getSourceFourType()), "source_four_type", params.getSourceFourType())
+                    .eq(StrUtil.isNotBlank(params.getSourceFourId()), "source_four_id", params.getSourceFourId())
+                    .eq(StrUtil.isNotBlank(params.getSourceFiveType()), "source_five_type", params.getSourceFiveType())
+                    .eq(StrUtil.isNotBlank(params.getSourceFiveId()), "source_five_id", params.getSourceFiveId())
+                    .eq(StrUtil.isNotBlank(params.getOperatedType()), "operated_type", PatientOperatedTypeEnum.Interested.getCode())
+            );
+            if (null == entity) {
+                PatientBehaviorAddDTO patientBehaviorAddDTO = new PatientBehaviorAddDTO();
+                patientBehaviorAddDTO.setPatientId(params.getPatientId());
+                patientBehaviorAddDTO.setUserId(params.getUserId());
+                patientBehaviorAddDTO.setContentType(params.getContentType());
+                patientBehaviorAddDTO.setContentId(params.getContentId());
+                patientBehaviorAddDTO.setSourceOneType(params.getSourceOneType());
+                patientBehaviorAddDTO.setSourceOneId(params.getSourceOneId());
+                patientBehaviorAddDTO.setSourceTwoType(params.getSourceTwoType());
+                patientBehaviorAddDTO.setSourceTwoId(params.getSourceTwoId());
+                patientBehaviorAddDTO.setSourceThreeType(params.getSourceThreeType());
+                patientBehaviorAddDTO.setSourceThreeId(params.getSourceThreeId());
+                patientBehaviorAddDTO.setSourceFourType(params.getSourceFourType());
+                patientBehaviorAddDTO.setSourceFourId(params.getSourceFourId());
+                patientBehaviorAddDTO.setSourceFiveType(params.getSourceFiveType());
+                patientBehaviorAddDTO.setSourceFiveId(params.getSourceFiveId());
+                patientBehaviorAddDTO.setOperatedType(PatientOperatedTypeEnum.Interested.getCode());
+                patientBehaviorAddDTO.setCreator(params.getCreator());
+                patientBehaviorAddDTO.setIp(params.getIp());
+                patientBehaviorAddDTO.setUa(params.getUa());
+                this.add(patientBehaviorAddDTO);
+            }
+        }
+
+        // zs20231026 在上报时间时,每次浏览都会上报多次浏览时长,所以第一次上报返回id,之后上报用id更新浏览时长,上报的浏览时长直接更新不做增量更新
+        // TODO 可以通过nginx配置,一直让某个请求在padding状态(一直保持http连接),之后如果离开页面则连接断开,这样可以用nginx判断连接了多长时间,从而间接得出浏览时长
+        if (StrUtil.isNotBlank(params.getId()) && PatientOperatedTypeEnum.Browse_Duration.getCode().equals(params.getOperatedType())) {
+            PatientBehaviorInfo entity = patientBehaviorInfoService.getById(params.getId());
+            if (null != entity && PatientOperatedTypeEnum.Browse_Duration.getCode().equals(entity.getOperatedType())) {
+                if (params.getOperatedDuration() > entity.getOperatedDuration()) {
+                    entity.setOperatedDuration(params.getOperatedDuration());
+                    entity.setOperatedEndDate(now);
+                    patientBehaviorInfoService.updateById(entity);
+                }
+                return PatientBehaviorHelper.getPatientBehaviorVO(entity);
+            }
+        }
+
+        PatientBehaviorInfo entity = new PatientBehaviorInfo();
+        entity.setId(PatientBehaviorHelper.getPatientBehaviorInfoId());
+        entity.setPatientId(params.getPatientId());
+        entity.setUserId(params.getUserId());
+        entity.setContentType(params.getContentType());
+        entity.setContentId(params.getContentId());
+        entity.setSourceOneType(params.getSourceOneType());
+        entity.setSourceOneId(params.getSourceOneId());
+        entity.setSourceTwoType(params.getSourceTwoType());
+        entity.setSourceTwoId(params.getSourceTwoId());
+        entity.setSourceThreeType(params.getSourceThreeType());
+        entity.setSourceThreeId(params.getSourceThreeId());
+        entity.setSourceFourType(params.getSourceFourType());
+        entity.setSourceFourId(params.getSourceFourId());
+        entity.setSourceFiveType(params.getSourceFiveType());
+        entity.setSourceFiveId(params.getSourceFiveId());
+        entity.setOperatedType(params.getOperatedType());
+        entity.setOperatedStartDate(now);
+        entity.setOperatedDuration(params.getOperatedDuration());
+
+        entity.setCreateDate(now);
+        entity.setCreator(params.getCreator());
+        entity.setIp(params.getIp());
+        entity.setUa(params.getUa());
+
+        entity.setOperatedContent(params.getOperatedContent());
+        
+        patientBehaviorInfoService.save(entity);
+
+        return PatientBehaviorHelper.getPatientBehaviorVO(entity);
+    }
+
+    @Override
+    public void addBatch(List<PatientBehaviorAddDTO> params) {
+        List<PatientBehaviorInfo> list = new ArrayList<>();
+        DateTime now = DateTime.now();
+        params.forEach(i -> {
+            PatientBehaviorInfo entity = new PatientBehaviorInfo();
+            entity.setId(PatientBehaviorHelper.getPatientBehaviorInfoId());
+            entity.setPatientId(i.getPatientId());
+            entity.setUserId(i.getUserId());
+            entity.setContentType(i.getContentType());
+            entity.setContentId(i.getContentId());
+            entity.setSourceOneType(i.getSourceOneType());
+            entity.setSourceOneId(i.getSourceOneId());
+            entity.setSourceTwoType(i.getSourceTwoType());
+            entity.setSourceTwoId(i.getSourceTwoId());
+            entity.setSourceThreeType(i.getSourceThreeType());
+            entity.setSourceThreeId(i.getSourceThreeId());
+            entity.setSourceFourType(i.getSourceFourType());
+            entity.setSourceFourId(i.getSourceFourId());
+            entity.setSourceFiveType(i.getSourceFiveType());
+            entity.setSourceFiveId(i.getSourceFiveId());
+            entity.setOperatedType(i.getOperatedType());
+            entity.setOperatedDuration(i.getOperatedDuration());
+
+            entity.setOperatedStartDate(now);
+            entity.setCreateDate(now);
+
+            if (null != i.getCreateDate()) {
+                entity.setOperatedStartDate(i.getCreateDate());
+                entity.setCreateDate(i.getCreateDate());
+            }
+
+            entity.setCreator(i.getCreator());
+            entity.setIp(i.getIp());
+            entity.setUa(i.getUa());
+
+            entity.setOperatedContent(i.getOperatedContent());
+        
+            list.add(entity);
+        });
+        patientBehaviorInfoService.saveBatch(list);
+    }
+
+}

+ 40 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/biz/service/impl/PatientBehaviorQueryBizServiceImpl.java

@@ -0,0 +1,40 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.biz.service.impl;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.service.PatientBehaviorInfoService;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorQueryDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.vo.PatientBehaviorVO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.helper.PatientBehaviorHelper;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.service.PatientBehaviorQueryBizService;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+
+@Service
+public class PatientBehaviorQueryBizServiceImpl implements PatientBehaviorQueryBizService {
+
+    @Autowired
+    private PatientBehaviorInfoService patientBehaviorInfoService;
+
+    @Override
+    public List<PatientBehaviorVO> list(PatientBehaviorQueryDTO params) {
+        List<PatientBehaviorInfo> list = patientBehaviorInfoService.list(new QueryWrapper<PatientBehaviorInfo>()
+                .eq(StrUtil.isNotBlank(params.getId()), "id", params.getId())
+                .eq(StrUtil.isNotBlank(params.getPatientId()), "patient_id", params.getPatientId())
+                .in(CollectionUtil.isNotEmpty(params.getPatientIds()), "patient_id", params.getPatientIds())
+                .eq(StrUtil.isNotBlank(params.getUserId()), "user_id", params.getUserId())
+                .in(CollectionUtil.isNotEmpty(params.getUserIds()), "user_id", params.getUserIds())
+                .eq(StrUtil.isNotBlank(params.getOperatedType()), "operated_type", params.getOperatedType())
+        );
+
+        return list.stream().map(PatientBehaviorHelper::getPatientBehaviorVO).collect(Collectors.toList());
+    }
+    
+}

+ 133 - 0
health-behavior-framework/src/main/java/com/xxh/cloud/healthy/behavior/framework/modules/client/service/PatientBehaviorClientServiceImpl.java

@@ -0,0 +1,133 @@
+package com.xxh.cloud.healthy.behavior.framework.modules.client.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.xxh.cloud.healthy.behavior.client.api.PatientBehaviorClientService;
+import com.xxh.cloud.healthy.behavior.client.api.bean.bo.PatientBehaviorSecureBO;
+import com.xxh.cloud.healthy.behavior.client.api.bean.dto.PatientBehaviorSaveClientDTO;
+import com.xxh.cloud.healthy.behavior.client.api.bean.dto.PatientBehaviorUploadClientDTO;
+import com.xxh.cloud.healthy.behavior.client.api.util.BehaviorSecureUtil;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.entity.PatientBehaviorInfo;
+import com.xxh.cloud.healthy.behavior.framework.modules.bean.service.PatientBehaviorInfoService;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.bean.dto.PatientBehaviorAddDTO;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.helper.PatientBehaviorHelper;
+import com.xxh.cloud.healthy.behavior.framework.modules.biz.service.PatientBehaviorBizService;
+
+import cn.hutool.core.util.StrUtil;
+
+@Service
+public class PatientBehaviorClientServiceImpl implements PatientBehaviorClientService {
+
+    @Autowired
+    private PatientBehaviorBizService patientBehaviorBizService;
+    @Autowired
+    private PatientBehaviorInfoService patientBehaviorInfoService;
+
+    @Override
+    public void add(PatientBehaviorUploadClientDTO params) {
+        if (StrUtil.isBlank(params.getSecureData())) {
+            return;
+        }
+        // 解析加密数据
+        PatientBehaviorSecureBO patientBehaviorSecureBO = BehaviorSecureUtil.decryptData(params.getSecureData());
+
+        PatientBehaviorAddDTO entity = new PatientBehaviorAddDTO();
+        entity.setPatientId(patientBehaviorSecureBO.getPatientId());
+        entity.setUserId(patientBehaviorSecureBO.getUserId());
+        entity.setContentType(patientBehaviorSecureBO.getContentType());
+        entity.setContentId(patientBehaviorSecureBO.getContentId());
+        entity.setSourceOneType(patientBehaviorSecureBO.getSourceOneType());
+        entity.setSourceOneId(patientBehaviorSecureBO.getSourceOneId());
+        entity.setSourceTwoType(patientBehaviorSecureBO.getSourceTwoType());
+        entity.setSourceTwoId(patientBehaviorSecureBO.getSourceTwoId());
+        entity.setSourceThreeType(patientBehaviorSecureBO.getSourceThreeType());
+        entity.setSourceThreeId(patientBehaviorSecureBO.getSourceThreeId());
+        entity.setSourceFourType(patientBehaviorSecureBO.getSourceFourType());
+        entity.setSourceFourId(patientBehaviorSecureBO.getSourceFourId());
+        entity.setSourceFiveType(patientBehaviorSecureBO.getSourceFiveType());
+        entity.setSourceFiveId(patientBehaviorSecureBO.getSourceFiveId());
+        entity.setOperatedType(params.getOperatedType());
+        entity.setOperatedDuration(params.getOperatedDuration());
+        entity.setIp(params.getIp());
+        entity.setUa(params.getUa());
+
+        entity.setOperatedContent(params.getOperatedContent());
+
+        patientBehaviorBizService.add(entity);
+    }
+
+    @Override
+    public void addBatch(List<PatientBehaviorUploadClientDTO> params) {
+        List<PatientBehaviorAddDTO> list = new ArrayList<>();
+        params.forEach(i -> {
+
+            // 解析加密数据
+            PatientBehaviorSecureBO patientBehaviorSecureBO = BehaviorSecureUtil.decryptData(i.getSecureData());
+
+            PatientBehaviorAddDTO addDTO = new PatientBehaviorAddDTO();
+            addDTO.setPatientId(patientBehaviorSecureBO.getPatientId());
+            addDTO.setUserId(patientBehaviorSecureBO.getUserId());
+            addDTO.setContentType(patientBehaviorSecureBO.getContentType());
+            addDTO.setContentId(patientBehaviorSecureBO.getContentId());
+            addDTO.setSourceOneType(patientBehaviorSecureBO.getSourceOneType());
+            addDTO.setSourceOneId(patientBehaviorSecureBO.getSourceOneId());
+            addDTO.setSourceTwoType(patientBehaviorSecureBO.getSourceTwoType());
+            addDTO.setSourceTwoId(patientBehaviorSecureBO.getSourceTwoId());
+            addDTO.setSourceThreeType(patientBehaviorSecureBO.getSourceThreeType());
+            addDTO.setSourceThreeId(patientBehaviorSecureBO.getSourceThreeId());
+            addDTO.setSourceFourType(patientBehaviorSecureBO.getSourceFourType());
+            addDTO.setSourceFourId(patientBehaviorSecureBO.getSourceFourId());
+            addDTO.setSourceFiveType(patientBehaviorSecureBO.getSourceFiveType());
+            addDTO.setSourceFiveId(patientBehaviorSecureBO.getSourceFiveId());
+            addDTO.setOperatedType(i.getOperatedType());
+            addDTO.setOperatedDuration(i.getOperatedDuration());
+            addDTO.setIp(i.getIp());
+            addDTO.setUa(i.getUa());
+
+            addDTO.setOperatedContent(i.getOperatedContent());
+            
+            list.add(addDTO);
+        });
+        patientBehaviorBizService.addBatch(list);
+    }
+
+    @Override
+    public void simpleSaveBatch(List<PatientBehaviorSaveClientDTO> params) {
+        List<PatientBehaviorInfo> list = new ArrayList<>();
+        params.forEach(i -> {
+            PatientBehaviorInfo entity = new PatientBehaviorInfo();
+            entity.setId(i.getId());
+            entity.setPatientId(i.getPatientId());
+            entity.setUserId(i.getUserId());
+            entity.setContentType(i.getContentType());
+            entity.setContentId(i.getContentId());
+            entity.setSourceOneType(i.getSourceOneType());
+            entity.setSourceOneId(i.getSourceOneId());
+            entity.setSourceTwoType(i.getSourceTwoType());
+            entity.setSourceTwoId(i.getSourceTwoId());
+            entity.setSourceThreeType(i.getSourceThreeType());
+            entity.setSourceThreeId(i.getSourceThreeId());
+            entity.setSourceFourType(i.getSourceFourType());
+            entity.setSourceFourId(i.getSourceFourId());
+            entity.setSourceFiveType(i.getSourceFiveType());
+            entity.setSourceFiveId(i.getSourceFiveId());
+            entity.setOperatedType(i.getOperatedType());
+            entity.setOperatedDuration(i.getOperatedDuration());
+            entity.setIp(i.getIp());
+            entity.setUa(i.getUa());
+
+            entity.setOperatedContent(i.getOperatedContent());
+
+            entity.setOperatedStartDate(i.getCreateDate());
+            entity.setCreateDate(i.getCreateDate());
+            
+            list.add(entity);
+        });
+        patientBehaviorInfoService.saveBatch(list);
+    }
+
+}

+ 38 - 0
pom.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>com.xxh.cloud</groupId>
+    <artifactId>health-behavior-java</artifactId>
+    <version>1.0.0</version>
+
+    <packaging>pom</packaging>
+    <description>用户行为分析服务</description>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <xx.framework.version>1.0.0</xx.framework.version>
+    </properties>
+
+    <modules>
+        <module>health-behavior-client</module>
+        <module>health-behavior-framework</module>
+        <module>health-behavior-application-api</module>
+    </modules>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>com.xxh.cloud</groupId>
+                <artifactId>xx-framework-dependencies</artifactId>
+                <version>${xx.framework.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+</project>