diff --git a/smart-health-modules/cloud-upms/cloud-upms-api/src/main/java/cn/sh/stc/sict/cloud/upms/model/SysUserBase.java b/smart-health-modules/cloud-upms/cloud-upms-api/src/main/java/cn/sh/stc/sict/cloud/upms/model/SysUserBase.java index ecd66e229b3f74b5f42dd519717c7a5e6c7d3064..e04e345a8f4a3afd251600908eb8ec59a75269ef 100644 --- a/smart-health-modules/cloud-upms/cloud-upms-api/src/main/java/cn/sh/stc/sict/cloud/upms/model/SysUserBase.java +++ b/smart-health-modules/cloud-upms/cloud-upms-api/src/main/java/cn/sh/stc/sict/cloud/upms/model/SysUserBase.java @@ -32,6 +32,11 @@ public class SysUserBase extends Model<SysUserBase> { @ApiModelProperty(value = "用户id") private Long id; + /** + * 公众å·appId + */ + private String appId; + private String openId; /** diff --git a/smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/service/impl/SysUserBaseServiceImpl.java b/smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/service/impl/SysUserBaseServiceImpl.java index e7c8ddf62e9582f442f9d7a7972a83fa203faef7..056f84a3e022634a15a4d24f28f91a40066c0d6a 100644 --- a/smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/service/impl/SysUserBaseServiceImpl.java +++ b/smart-health-modules/cloud-upms/cloud-upms-biz/src/main/java/cn/sh/stc/sict/cloud/upms/service/impl/SysUserBaseServiceImpl.java @@ -108,6 +108,7 @@ public class SysUserBaseServiceImpl extends ServiceImpl<SysUserBaseMapper, SysUs */ private UserInfo getByXszyWoa(String[] infoArray) { String source = infoArray[0]; + String appId = infoArray[1]; String token = infoArray[2]; String hospitalCode = infoArray[3]; @@ -143,6 +144,7 @@ public class SysUserBaseServiceImpl extends ServiceImpl<SysUserBaseMapper, SysUs user.setStatus(Constant.BYTE_NO); user.setPasswd(ENCODER.encode(Constant.DEFAULT_PASSWORD)); user.setPhone(xszyUserInfo.getMobile()); + user.setAppId(appId); this.save(user); } diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java new file mode 100644 index 0000000000000000000000000000000000000000..b57fc362d80aefc328b16ae1cb70e6e75c24c3cf --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/controller/web/HpStatisticsController.java @@ -0,0 +1,51 @@ +package cn.sh.stc.sict.theme.hphy.controller.web; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; +import cn.sh.stc.sict.cloud.common.core.constant.enums.LoginTypeEnum; +import cn.sh.stc.sict.cloud.common.core.dto.WDUserCardInfo; +import cn.sh.stc.sict.cloud.common.core.dto.WDUserInfo; +import cn.sh.stc.sict.cloud.common.core.dto.XSZYUserInfo; +import cn.sh.stc.sict.cloud.common.core.util.NumberUtil; +import cn.sh.stc.sict.cloud.common.core.util.R; +import cn.sh.stc.sict.cloud.common.core.util.SsbUtil; +import cn.sh.stc.sict.cloud.common.security.util.SecurityUtils; +import cn.sh.stc.sict.theme.hphy.constant.PatientConstant; +import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase; +import cn.sh.stc.sict.theme.hphy.service.HpStatisticsService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 黄埔医导统计 + * + * @author gao + * @date 2023/01/06 10:43 + */ +@Api(value = "[黄浦]统计使用情况", tags = "[黄浦]统计使用情况") +@RestController +@RequestMapping("hpStatistics") +@AllArgsConstructor +@Slf4j +public class HpStatisticsController { + + private final HpStatisticsService hpStatisticsService; + + @ApiOperation("统计用户使用情况") + @GetMapping("/usage-overview") + public R statisticsUsage(@RequestParam("startTime") String startTime, + @RequestParam("endTime") String endTime) { + log.error("统计用户使用情况:startTime = {}, token = {}", startTime, endTime); + return new R(hpStatisticsService.getUsageOverviewStatistics(startTime, endTime)); + } + +} diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/dao/HpStatisticsMapper.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/dao/HpStatisticsMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..5f398216e5880e69534971e151188723a28759e5 --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/dao/HpStatisticsMapper.java @@ -0,0 +1,47 @@ +package cn.sh.stc.sict.theme.hphy.dao; + +import cn.sh.stc.sict.theme.hphy.vo.StatisticsUsageVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author gao + * @date 2023/01/06 11:09 + */ +@Mapper +public interface HpStatisticsMapper { + + /** + * 按时间统计å„医院预约人数 + * + * @param startTime 开始时间 + * @param endTime ç»“æŸæ—¶é—´ + * @return + */ + List<StatisticsUsageVO.HosUsageStatistics> queryAppointmentUserGroupByHos(@Param("startTime") String startTime, + @Param("endTime") String endTime); + + /** + * 统计新增用户 + * + * @param startTime + * @param endTime + * @return + */ + Long countNewUser(@Param("startTime") String startTime, + @Param("endTime") String endTime); + + + /** + * 统计登录用户 + * + * @param startTime + * @param endTime + * @return + */ + Long countLoginUser(@Param("startTime") String startTime, + @Param("endTime") String endTime); + +} diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpStatisticsService.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpStatisticsService.java new file mode 100644 index 0000000000000000000000000000000000000000..111ce17b9885c095f86b7eb6fac3c21ce1cd724e --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/HpStatisticsService.java @@ -0,0 +1,22 @@ +package cn.sh.stc.sict.theme.hphy.service; + +import cn.sh.stc.sict.theme.hphy.vo.StatisticsUsageVO; + +/** + * @author gao + * @date 2023/01/06 11:03 + */ +public interface HpStatisticsService { + + /** + * 获å–ä½¿ç”¨æƒ…å†µæ¦‚è§ˆç»Ÿè®¡ä¿¡æ¯ + * + * @param startTime 开始时间 + * @param endTime ç»“æŸæ—¶é—´ + * @return + */ + StatisticsUsageVO getUsageOverviewStatistics(String startTime, + String endTime); + + +} diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpStatisticsServiceImpl.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpStatisticsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..da4e1ae3180960afba8eba4ca27a8c8e6ab73d90 --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/service/impl/HpStatisticsServiceImpl.java @@ -0,0 +1,48 @@ +package cn.sh.stc.sict.theme.hphy.service.impl; + +import cn.sh.stc.sict.theme.hphy.dao.HpAppointmentMapper; +import cn.sh.stc.sict.theme.hphy.dao.HpStatisticsMapper; +import cn.sh.stc.sict.theme.hphy.dao.HphyPatientBaseMapper; +import cn.sh.stc.sict.theme.hphy.model.HphyPatientBase; +import cn.sh.stc.sict.theme.hphy.service.HpStatisticsService; +import cn.sh.stc.sict.theme.hphy.vo.StatisticsUsageVO; +import lombok.AllArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 黄埔医导用户使用情况查询 + * + * @author gao + * @date 2023/01/06 11:04 + */ +@Service("hpStatisticsService") +@AllArgsConstructor +public class HpStatisticsServiceImpl implements HpStatisticsService { + + @Autowired + private final HpStatisticsMapper hpStatisticsMapper; + + @Autowired + private final HpAppointmentMapper hpAppointmentMapper; + + /** + * 获å–ä½¿ç”¨æƒ…å†µæ¦‚è§ˆç»Ÿè®¡ä¿¡æ¯ + * + * @param startTime 开始时间 + * @param endTime ç»“æŸæ—¶é—´ + * @return + */ + @Override + public StatisticsUsageVO getUsageOverviewStatistics(String startTime, String endTime) { + + Long loginUserCount = hpStatisticsMapper.countLoginUser(startTime, endTime); + Long newUserCount = hpStatisticsMapper.countNewUser(startTime, endTime); + List<StatisticsUsageVO.HosUsageStatistics> hosUsageStatisticsList = hpStatisticsMapper.queryAppointmentUserGroupByHos(startTime, endTime); + + return StatisticsUsageVO.builder().newUserCount(newUserCount).loginUserCount(loginUserCount).hosAppointmentStatistics(hosUsageStatisticsList).build(); + } +} diff --git a/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/StatisticsUsageVO.java b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/StatisticsUsageVO.java new file mode 100644 index 0000000000000000000000000000000000000000..b34152c69d8f1320e3d5aa603baccbb91b4734d1 --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/vo/StatisticsUsageVO.java @@ -0,0 +1,45 @@ +package cn.sh.stc.sict.theme.hphy.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.*; + +import java.io.Serializable; +import java.util.List; + +/** + * 统计用户使用详情 + * + * @author gao + * @date 2023/01/06 10:58 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class StatisticsUsageVO implements Serializable { + + private static final long serialVersionUID = -279866011612238581L; + + @ApiModelProperty(value = "登录总人数") + private Long loginUserCount; + + @ApiModelProperty(value = "新增用户总人数") + private Long newUserCount; + + @ApiModelProperty(value = "医院预约人数") + private List<HosUsageStatistics> hosAppointmentStatistics; + + @Data + public static class HosUsageStatistics implements Serializable { + private static final long serialVersionUID = -1088663393589514198L; + + @ApiModelProperty(value = "医院编ç ") + private String hospitalCode; + + @ApiModelProperty(value = "医院åç§°") + private String hospitalName; + + @ApiModelProperty(value = "医院预约人数") + private Long appointmentUserCount; + } +} diff --git a/smart-health-modules/theme-schema/src/main/resources/mapper/hphy/HpStatisticsMapper.xml b/smart-health-modules/theme-schema/src/main/resources/mapper/hphy/HpStatisticsMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..f64b341d9eb6b36d484188e527158c0aeab4d32d --- /dev/null +++ b/smart-health-modules/theme-schema/src/main/resources/mapper/hphy/HpStatisticsMapper.xml @@ -0,0 +1,62 @@ +<?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="cn.sh.stc.sict.theme.hphy.dao.HpStatisticsMapper"> + + <resultMap type="cn.sh.stc.sict.theme.hphy.vo.StatisticsUsageVO$HosUsageStatistics" id="AppointmentHosCountMap"> + <result property="appointmentUserCount" column="appointment_count" jdbcType="INTEGER"/> + <result property="hospitalCode" column="hos_org_code" jdbcType="VARCHAR"/> + <result property="hospitalName" column="hos_name" jdbcType="VARCHAR"/> + </resultMap> + + <select id="queryAppointmentUserGroupByHos" resultMap="AppointmentHosCountMap"> + SELECT + c.appointment_count, + c.hos_org_code, + h.hos_name + FROM ( + SELECT count(1) AS appointment_count, hos_org_code + FROM `hp_appointment` + <where> + <if test="startTime != null and startTime != '' "> + AND create_time >= #{startTime} + </if> + <if test="endTime != null and endTime != '' "> + AND create_time <= #{endTime} + </if> + </where> + GROUP BY hos_org_code + ) c + LEFT JOIN hp_hos_info h ON c.hos_org_code = h.hos_org_code + </select> + + <select id="countNewUser" resultType="java.lang.Long"> + SELECT count(1) + FROM hp_user_base + <where> + <if test="startTime != null and startTime != '' "> + AND create_time >= #{startTime} + </if> + <if test="endTime != null and endTime != '' "> + AND create_time <= #{endTime} + </if> + </where> + </select> + + <select id="countLoginUser" resultType="java.lang.Long"> + SELECT + count( DISTINCT create_by ) + FROM + `sys_log` + <where> + <if test="startTime != null and startTime != '' "> + AND create_time >= #{startTime} + </if> + <if test="endTime != null and endTime != '' "> + AND create_time <= #{endTime} + </if> + AND `title` LIKE '%用户登录%' + AND `exception` = '' + </where> + </select> + +</mapper> \ No newline at end of file