Browse Source

标签埋点数据统计

wangfeng 5 years atrás
parent
commit
d79b474c61

+ 7 - 1
config-server/src/main/resources/shared/prec-service-dev.yml

@@ -58,7 +58,13 @@ spring:
   #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
         outputBiLog:
           destination: myBiLog
-
+        #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        outputPoint:
+          destination: myPoint
+          #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        inputPoint:
+          destination: myPoint
+          group: pointReceiveGroup
   #mq
   rabbitmq:
     host: 192.168.2.236

+ 7 - 0
config-server/src/main/resources/shared/prec-service-local.yml

@@ -58,6 +58,13 @@ spring:
   #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
         outputBiLog:
           destination: myBiLog
+          #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        outputPoint:
+          destination: myPoint
+          #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        inputPoint:
+          destination: myPoint
+          group: pointReceiveGroup
 
   #mq
   rabbitmq:

+ 7 - 1
config-server/src/main/resources/shared/prec-service-pre.yml

@@ -58,7 +58,13 @@ spring:
   #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
         outputBiLog:
           destination: myBiLog
-
+        #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        outputPoint:
+          destination: myPoint
+          #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        inputPoint:
+          destination: myPoint
+          group: pointReceiveGroup
   #mq
   rabbitmq:
     host: 192.168.2.121

+ 7 - 1
config-server/src/main/resources/shared/prec-service-pro.yml

@@ -58,7 +58,13 @@ spring:
   #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
         outputBiLog:
           destination: myBiLog
-
+        #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        outputPoint:
+          destination: myPoint
+          #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        inputPoint:
+          destination: myPoint
+          group: pointReceiveGroup
   #mq
   rabbitmq:
     host: 192.168.2.122

+ 7 - 1
config-server/src/main/resources/shared/prec-service-test.yml

@@ -58,7 +58,13 @@ spring:
   #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
         outputBiLog:
           destination: myBiLog
-
+        #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        outputPoint:
+          destination: myPoint
+          #          contentType: text/plain      # 实体 json string 在传递的类型装换 查看 http://docs.spring
+        inputPoint:
+          destination: myPoint
+          group: pointReceiveGroup
   #mq
   rabbitmq:
     host: 192.168.2.241

+ 234 - 0
prec-service/src/main/java/com/diagbot/entity/Statistical.java

@@ -0,0 +1,234 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableId;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 数据埋点统计表
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2020-02-24
+ */
+@TableName("prec_statistical")
+public class Statistical implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+    /**
+     * 医院id
+     */
+    private Long hospitalId;
+
+    /**
+     * 部门id
+     */
+    private Long hospitalDeptId;
+
+    /**
+     * 医生id
+     */
+    private Long doctorId;
+
+    /**
+     * 病人id
+     */
+    private Long patientId;
+
+    /**
+     * 就诊号
+     */
+    private String inquiryCode;
+
+    /**
+     * 标签ID
+     */
+    private Integer labelId;
+
+    /**
+     * 标签名
+     */
+    private String labelName;
+
+    /**
+     * 操作类型
+     */
+    private String operationType;
+
+    /**
+     * 操作次数
+     */
+    private Integer operationNum;
+
+    /**
+     * 是否存在标签库(0:默认有,1:无)
+     */
+    private Integer status;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+    public String getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(String isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+    public Date getGmtCreate() {
+        return gmtCreate;
+    }
+
+    public void setGmtCreate(Date gmtCreate) {
+        this.gmtCreate = gmtCreate;
+    }
+    public Date getGmtModified() {
+        return gmtModified;
+    }
+
+    public void setGmtModified(Date gmtModified) {
+        this.gmtModified = gmtModified;
+    }
+    public String getCreator() {
+        return creator;
+    }
+
+    public void setCreator(String creator) {
+        this.creator = creator;
+    }
+    public String getModifier() {
+        return modifier;
+    }
+
+    public void setModifier(String modifier) {
+        this.modifier = modifier;
+    }
+    public Long getHospitalId() {
+        return hospitalId;
+    }
+
+    public void setHospitalId(Long hospitalId) {
+        this.hospitalId = hospitalId;
+    }
+    public Long getHospitalDeptId() {
+        return hospitalDeptId;
+    }
+
+    public void setHospitalDeptId(Long hospitalDeptId) {
+        this.hospitalDeptId = hospitalDeptId;
+    }
+    public Long getDoctorId() {
+        return doctorId;
+    }
+
+    public void setDoctorId(Long doctorId) {
+        this.doctorId = doctorId;
+    }
+    public Long getPatientId() {
+        return patientId;
+    }
+
+    public void setPatientId(Long patientId) {
+        this.patientId = patientId;
+    }
+    public String getInquiryCode() {
+        return inquiryCode;
+    }
+
+    public void setInquiryCode(String inquiryCode) {
+        this.inquiryCode = inquiryCode;
+    }
+    public Integer getLabelId() {
+        return labelId;
+    }
+
+    public void setLabelId(Integer labelId) {
+        this.labelId = labelId;
+    }
+    public String getLabelName() {
+        return labelName;
+    }
+
+    public void setLabelName(String labelName) {
+        this.labelName = labelName;
+    }
+    public String getOperationType() {
+        return operationType;
+    }
+
+    public void setOperationType(String operationType) {
+        this.operationType = operationType;
+    }
+    public Integer getOperationNum() {
+        return operationNum;
+    }
+
+    public void setOperationNum(Integer operationNum) {
+        this.operationNum = operationNum;
+    }
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    @Override
+    public String toString() {
+        return "Statistical{" +
+            "id=" + id +
+            ", isDeleted=" + isDeleted +
+            ", gmtCreate=" + gmtCreate +
+            ", gmtModified=" + gmtModified +
+            ", creator=" + creator +
+            ", modifier=" + modifier +
+            ", hospitalId=" + hospitalId +
+            ", hospitalDeptId=" + hospitalDeptId +
+            ", doctorId=" + doctorId +
+            ", patientId=" + patientId +
+            ", inquiryCode=" + inquiryCode +
+            ", labelId=" + labelId +
+            ", labelName=" + labelName +
+            ", operationType=" + operationType +
+            ", operationNum=" + operationNum +
+            ", status=" + status +
+        "}";
+    }
+}

+ 61 - 0
prec-service/src/main/java/com/diagbot/facade/StatisticalFacade.java

@@ -0,0 +1,61 @@
+package com.diagbot.facade;
+
+import com.diagbot.entity.Statistical;
+import com.diagbot.service.StatisticalService;
+import com.diagbot.service.impl.StatisticalServiceImpl;
+import com.diagbot.util.DateUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.vo.StatisticalVO;
+import com.diagbot.vo.Taggeds;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2020-02-24 14:34
+ */
+@Component
+public class StatisticalFacade extends StatisticalServiceImpl {
+
+    @Autowired
+    private StatisticalService statisticalService;
+
+    /**
+     * 批量保存
+     *
+     * @param statisticalVO
+     * @return
+     */
+    public boolean saveStatistical(StatisticalVO statisticalVO) {
+        boolean res = false;
+        if (null != statisticalVO
+                && ListUtil.isNotEmpty(statisticalVO.getTaggeds())) {
+            List<Statistical> buriedList = new ArrayList<Statistical>();
+            for (Taggeds taggedsNew : statisticalVO.getTaggeds()) {
+                Statistical buriedData = new Statistical();
+                buriedData.setCreator(statisticalVO.getDoctorId().toString());
+                buriedData.setDoctorId(statisticalVO.getDoctorId());
+                buriedData.setGmtCreate(DateUtil.now());
+                buriedData.setHospitalDeptId(statisticalVO.getHospitalDeptId());
+                buriedData.setHospitalId(statisticalVO.getHospitalId());
+                buriedData.setInquiryCode(statisticalVO.getInquiryCode());
+                buriedData.setPatientId(statisticalVO.getPatientId());
+                buriedData.setLabelId(taggedsNew.getLabelId());
+                buriedData.setLabelName(taggedsNew.getLabelName());
+                buriedData.setOperationNum(taggedsNew.getOperationNum());
+                buriedData.setOperationType(taggedsNew.getOperationType());
+                buriedData.setStatus(taggedsNew.getStatus());
+                buriedList.add(buriedData);
+            }
+
+            res = statisticalService.saveBatch(buriedList);
+        }
+        return res;
+    }
+
+}

+ 16 - 0
prec-service/src/main/java/com/diagbot/mapper/StatisticalMapper.java

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.Statistical;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 数据埋点统计表 Mapper 接口
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2020-02-24
+ */
+public interface StatisticalMapper extends BaseMapper<Statistical> {
+
+}

+ 9 - 0
prec-service/src/main/java/com/diagbot/rabbit/MyProcessor.java

@@ -29,4 +29,13 @@ public interface MyProcessor {
 
     @Output(OUTPUT_BI_LOG)
     MessageChannel outputBiLog();
+
+    String INPUT_POINT = "inputPoint";
+    String OUTPUT_POINT = "outputPoint";
+
+    @Input(INPUT_POINT)
+    SubscribableChannel inputPoint();
+
+    @Output(OUTPUT_POINT)
+    MessageChannel outputPoint();
 }

+ 26 - 0
prec-service/src/main/java/com/diagbot/rabbit/MyReceiver.java

@@ -0,0 +1,26 @@
+package com.diagbot.rabbit;
+
+import com.diagbot.facade.StatisticalFacade;
+import com.diagbot.util.GsonUtil;
+import com.diagbot.vo.StatisticalVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.stream.annotation.EnableBinding;
+import org.springframework.cloud.stream.annotation.StreamListener;
+
+/**
+ * @Description: 消费者
+ * @author: gaodm
+ * @time: 2018/8/29 14:02
+ */
+@EnableBinding({ MyProcessor.class })
+public class MyReceiver {
+    @Autowired
+    StatisticalFacade statisticalFacade;
+
+    @StreamListener(MyProcessor.INPUT_POINT)
+    public void inputPoint(String message) {
+        System.out.println("Received <" + "数据埋点数据" + ">");
+        StatisticalVO statisticalVO = GsonUtil.toObject(message, StatisticalVO.class);
+        statisticalFacade.saveStatistical(statisticalVO);
+    }
+}

+ 9 - 0
prec-service/src/main/java/com/diagbot/rabbit/MySender.java

@@ -3,6 +3,7 @@ package com.diagbot.rabbit;
 import com.diagbot.biz.log.entity.BiRecord;
 import com.diagbot.biz.log.entity.SysLog;
 import com.diagbot.util.GsonUtil;
+import com.diagbot.vo.StatisticalVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.cloud.stream.annotation.EnableBinding;
@@ -33,4 +34,12 @@ public class MySender {
     public void outputBiLogSend(BiRecord biRecord) {
         outputBiLog.send(MessageBuilder.withPayload(GsonUtil.toJson(biRecord)).build());
     }
+
+    @Autowired
+    @Qualifier("outputPoint")
+    MessageChannel outputPoint;
+
+    public void outputPointSend(StatisticalVO statisticalVO) {
+        outputPoint.send(MessageBuilder.withPayload(GsonUtil.toJson(statisticalVO)).build());
+    }
 }

+ 16 - 0
prec-service/src/main/java/com/diagbot/service/StatisticalService.java

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.Statistical;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 数据埋点统计表 服务类
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2020-02-24
+ */
+public interface StatisticalService extends IService<Statistical> {
+
+}

+ 20 - 0
prec-service/src/main/java/com/diagbot/service/impl/StatisticalServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.Statistical;
+import com.diagbot.mapper.StatisticalMapper;
+import com.diagbot.service.StatisticalService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 数据埋点统计表 服务实现类
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2020-02-24
+ */
+@Service
+public class StatisticalServiceImpl extends ServiceImpl<StatisticalMapper, Statistical> implements StatisticalService {
+
+}

+ 49 - 0
prec-service/src/main/java/com/diagbot/vo/StatisticalVO.java

@@ -0,0 +1,49 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+/**
+ * @author wangfeng
+ * @Description:
+ * @date 2020-02-24 14:30
+ */
+@Getter
+@Setter
+public class StatisticalVO {
+    /**
+     * 医院id
+     */
+    @NotNull(message = "请输入医院id")
+    private Long hospitalId;
+
+    /**
+     * 部门id
+     */
+    //@NotNull(message = "请输入部门id")
+    private Long hospitalDeptId;
+
+    /**
+     * 医生id
+     */
+    //@NotNull(message = "请输入医生id")
+    private Long doctorId;
+
+    /**
+     * 病人id
+     */
+    @NotNull(message = "请输入病人id")
+    private Long patientId;
+
+    /**
+     * 就诊号
+     */
+    //@NotBlank(message = "请输入就诊号")
+    private String inquiryCode;
+
+    private List<Taggeds> taggeds;
+}

+ 46 - 0
prec-service/src/main/java/com/diagbot/vo/Taggeds.java

@@ -0,0 +1,46 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+/**
+ * 
+ * @author wangfeng
+ * @Description: TODO
+ * @date 2018年11月23日 上午10:35:30
+ */
+@Getter
+@Setter
+public class Taggeds {
+
+	/**
+     * 标签ID
+     */
+	//@NotNull(message = "请输入标签ID")
+    private Integer labelId;
+
+    /**
+     * 标签名
+     */
+    @NotBlank(message = "请输入标签名")
+    private String labelName;
+
+    /**
+     * 操作类型(1:常见标签点击, 2:搜索标签点击)
+     */
+    @NotBlank(message = "请输入操作类型")
+    private String operationType;
+
+    /**
+     * 操作次数
+     */
+    private Integer operationNum;
+    
+    /**
+     * 是否存在标签库
+     */
+    private Integer status;
+}

+ 49 - 0
prec-service/src/main/java/com/diagbot/web/StatisticalController.java

@@ -0,0 +1,49 @@
+package com.diagbot.web;
+
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.StatisticalFacade;
+import com.diagbot.rabbit.MySender;
+import com.diagbot.vo.StatisticalVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
+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 javax.validation.Valid;
+
+/**
+ * <p>
+ * 数据埋点统计表 前端控制器
+ * </p>
+ *
+ * @author wangfeng
+ * @since 2020-02-24
+ */
+@RestController
+@RequestMapping("/statistical")
+@Api(value = "标签数据埋点统计API[by:wangfeng]", tags = { "WF——标签数据埋点统计API" })
+@SuppressWarnings("unchecked")
+public class StatisticalController {
+    @Autowired
+    MySender mySender;
+    @Autowired
+    StatisticalFacade statisticalFacade;
+
+
+    @ApiOperation(value = "标签数据埋点统计保存[by:wangfeng]", notes = "标签数据埋点统计保存")
+    @PostMapping("/saveStatisticals")
+    @SysLogger("saveStatisticals")
+    @Transactional
+    public RespDTO<Boolean> saveBuriedSomeStatisticals(@Valid @RequestBody StatisticalVO statisticalVO) {
+        mySender.outputPointSend(statisticalVO);
+        //boolean res =  statisticalFacade.saveStatistical(statisticalVO);
+        return RespDTO.onSuc(true);
+    }
+
+}

+ 25 - 0
prec-service/src/main/resources/mapper/StatisticalMapper.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.StatisticalMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.Statistical">
+        <id column="id" property="id" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="hospital_dept_id" property="hospitalDeptId" />
+        <result column="doctor_id" property="doctorId" />
+        <result column="patient_id" property="patientId" />
+        <result column="inquiry_code" property="inquiryCode" />
+        <result column="label_id" property="labelId" />
+        <result column="label_name" property="labelName" />
+        <result column="operation_type" property="operationType" />
+        <result column="operation_num" property="operationNum" />
+        <result column="status" property="status" />
+    </resultMap>
+
+</mapper>