Compare commits

...

7 Commits

Author SHA1 Message Date
tianyongbao
ddaaec2401 fix: token有效期修改为,90天。 2026-07-12 10:05:51 +08:00
tianyongbao
c85a29eded feat: 药品基础信息,就医记录,活动记录,新增附件上传功能。 2026-06-25 15:54:26 +08:00
tianyongbao
09719cbc46 feat: 健康档案功能大屏新增。 2026-06-20 22:06:25 +08:00
tianyongbao
55d55f70a6 feat: 消费地图大屏功能, 新增。 2026-06-18 13:51:43 +08:00
tianyongbao
050c844508 fix: 交易记录,新增定位字段。 2026-06-17 20:58:29 +08:00
bot5
846cd3141e feat(medication): 实现用药提醒短信和电话提醒功能
- 新增 intc-common-message 消息服务模块
- 阿里云短信服务 SmsService(用药提醒、漏服提醒、家属通知)
- 阿里云语音服务 VoiceService(用药提醒、漏服提醒电话)
- HealthPerson 添加 phone 手机号字段
- MedicationPlan 添加 remind_type 提醒方式字段(1-短信 2-电话 3-短信+电话)
- MedicationRemindJob 完善提醒逻辑:
  - 定时扫描待服药任务发送提醒
  - 超时30分钟未服药发送加强提醒
  - 配置家属通知功能
- 新增数据库更新SQL和Nacos配置示例文件
2026-03-29 18:26:53 +08:00
tianyongbao
f0a61a5314 fix: 慢性病管理,用药任务生成修改。 2026-03-29 09:41:17 +08:00
61 changed files with 4533 additions and 126 deletions

View File

@@ -8,14 +8,14 @@ package com.intc.common.core.constant;
public class CacheConstants
{
/**
* 缓存有效期,默认720分钟
* 缓存有效期,默认129600分钟90天
*/
public final static long EXPIRATION = 720;
public final static long EXPIRATION = 129600;
/**
* 缓存刷新时间默认120分钟
* 缓存刷新时间默认10080分钟7天
*/
public final static long REFRESH_TIME = 120;
public final static long REFRESH_TIME = 10080;
/**
* 密码最大错误次数

View File

@@ -0,0 +1,65 @@
<?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">
<parent>
<groupId>com.intc</groupId>
<artifactId>intc-common</artifactId>
<version>3.6.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>intc-common-message</artifactId>
<description>
intc-common-message 消息通知服务(短信、语音等)
</description>
<dependencies>
<!-- 阿里云短信 SDK -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>2.0.24</version>
</dependency>
<!-- 阿里云语音 SDK -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dyvmsapi20170525</artifactId>
<version>3.2.2</version>
</dependency>
<!-- 阿里云核心 SDK -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>tea-openapi</artifactId>
<version>0.3.4</version>
</dependency>
<!-- Spring Boot Starter -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!-- Fastjson -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
<!-- intc-common-core -->
<dependency>
<groupId>com.intc</groupId>
<artifactId>intc-common-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,17 @@
package com.intc.common.message.config;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* 阿里云消息服务自动配置
*
* @author bot5
* @date 2026-03-29
*/
@Configuration
@EnableConfigurationProperties(AliyunMessageProperties.class)
@ComponentScan(basePackages = "com.intc.common.message")
public class AliyunMessageAutoConfiguration {
}

View File

@@ -0,0 +1,77 @@
package com.intc.common.message.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* 阿里云消息服务配置
*
* @author bot5
* @date 2026-03-29
*/
@Data
@ConfigurationProperties(prefix = "aliyun.message")
public class AliyunMessageProperties {
/**
* 阿里云 AccessKey ID
*/
private String accessKeyId;
/**
* 阿里云 AccessKey Secret
*/
private String accessKeySecret;
/**
* 短信服务配置
*/
private SmsConfig sms = new SmsConfig();
/**
* 语音服务配置
*/
private VoiceConfig voice = new VoiceConfig();
@Data
public static class SmsConfig {
/**
* 短信签名名称
*/
private String signName;
/**
* 短信模板CODE用药提醒
*/
private String medicationRemindTemplateCode;
/**
* 短信模板CODE漏服提醒
*/
private String missedRemindTemplateCode;
/**
* 短信模板CODE家属通知
*/
private String familyNotifyTemplateCode;
}
@Data
public static class VoiceConfig {
/**
* 语音通知模板CODE用药提醒
*/
private String medicationRemindTtsCode;
/**
* 语音通知模板CODE漏服提醒
*/
private String missedRemindTtsCode;
/**
* 被叫号码显示的呼入号码
*/
private String calledShowNumber;
}
}

View File

@@ -0,0 +1,129 @@
package com.intc.common.message.service;
import com.alibaba.fastjson2.JSON;
import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.dysmsapi20170525.models.SendSmsRequest;
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
import com.aliyun.teaopenapi.models.Config;
import com.intc.common.message.config.AliyunMessageProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* 阿里云短信服务
*
* @author bot5
* @date 2026-03-29
*/
@Service
public class SmsService {
private static final Logger log = LoggerFactory.getLogger(SmsService.class);
@Resource
private AliyunMessageProperties properties;
private Client smsClient;
@PostConstruct
public void init() throws Exception {
Config config = new Config()
.setAccessKeyId(properties.getAccessKeyId())
.setAccessKeySecret(properties.getAccessKeySecret())
.setEndpoint("dysmsapi.aliyuncs.com");
this.smsClient = new Client(config);
}
/**
* 发送用药提醒短信
*
* @param phoneNumber 手机号
* @param personName 成员姓名
* @param medicineName 药品名称
* @param plannedTime 计划服药时间
* @return 是否成功
*/
public boolean sendMedicationRemind(String phoneNumber, String personName, String medicineName, String plannedTime) {
Map<String, String> templateParams = new HashMap<>();
templateParams.put("name", personName);
templateParams.put("medicine", medicineName);
templateParams.put("time", plannedTime);
return sendSms(phoneNumber, properties.getSms().getMedicationRemindTemplateCode(), templateParams);
}
/**
* 发送漏服提醒短信
*
* @param phoneNumber 手机号
* @param personName 成员姓名
* @param medicineName 药品名称
* @param plannedTime 计划服药时间
* @return 是否成功
*/
public boolean sendMissedRemind(String phoneNumber, String personName, String medicineName, String plannedTime) {
Map<String, String> templateParams = new HashMap<>();
templateParams.put("name", personName);
templateParams.put("medicine", medicineName);
templateParams.put("time", plannedTime);
return sendSms(phoneNumber, properties.getSms().getMissedRemindTemplateCode(), templateParams);
}
/**
* 发送家属通知短信
*
* @param phoneNumber 手机号
* @param personName 成员姓名
* @param medicineName 药品名称
* @param plannedTime 计划服药时间
* @return 是否成功
*/
public boolean sendFamilyNotify(String phoneNumber, String personName, String medicineName, String plannedTime) {
Map<String, String> templateParams = new HashMap<>();
templateParams.put("name", personName);
templateParams.put("medicine", medicineName);
templateParams.put("time", plannedTime);
return sendSms(phoneNumber, properties.getSms().getFamilyNotifyTemplateCode(), templateParams);
}
/**
* 发送短信
*
* @param phoneNumber 手机号
* @param templateCode 模板CODE
* @param templateParams 模板参数
* @return 是否成功
*/
public boolean sendSms(String phoneNumber, String templateCode, Map<String, String> templateParams) {
try {
SendSmsRequest request = new SendSmsRequest()
.setPhoneNumbers(phoneNumber)
.setSignName(properties.getSms().getSignName())
.setTemplateCode(templateCode)
.setTemplateParam(JSON.toJSONString(templateParams));
SendSmsResponse response = smsClient.sendSms(request);
if ("OK".equals(response.getBody().getCode())) {
log.info("短信发送成功: phone={}, templateCode={}, bizId={}",
phoneNumber, templateCode, response.getBody().getBizId());
return true;
} else {
log.error("短信发送失败: phone={}, code={}, message={}",
phoneNumber, response.getBody().getCode(), response.getBody().getMessage());
return false;
}
} catch (Exception e) {
log.error("短信发送异常: phone={}, templateCode={}", phoneNumber, templateCode, e);
return false;
}
}
}

View File

@@ -0,0 +1,111 @@
package com.intc.common.message.service;
import com.alibaba.fastjson2.JSON;
import com.aliyun.dyvmsapi20170525.Client;
import com.aliyun.dyvmsapi20170525.models.SingleCallByTtsRequest;
import com.aliyun.dyvmsapi20170525.models.SingleCallByTtsResponse;
import com.aliyun.teaopenapi.models.Config;
import com.intc.common.message.config.AliyunMessageProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* 阿里云语音通知服务
*
* @author bot5
* @date 2026-03-29
*/
@Service
public class VoiceService {
private static final Logger log = LoggerFactory.getLogger(VoiceService.class);
@Resource
private AliyunMessageProperties properties;
private Client voiceClient;
@PostConstruct
public void init() throws Exception {
Config config = new Config()
.setAccessKeyId(properties.getAccessKeyId())
.setAccessKeySecret(properties.getAccessKeySecret())
.setEndpoint("dyvmsapi.aliyuncs.com");
this.voiceClient = new Client(config);
}
/**
* 发送用药提醒语音电话
*
* @param phoneNumber 手机号
* @param personName 成员姓名
* @param medicineName 药品名称
* @param plannedTime 计划服药时间
* @return 是否成功
*/
public boolean callMedicationRemind(String phoneNumber, String personName, String medicineName, String plannedTime) {
Map<String, String> ttsParams = new HashMap<>();
ttsParams.put("name", personName);
ttsParams.put("medicine", medicineName);
ttsParams.put("time", plannedTime);
return callByTts(phoneNumber, properties.getVoice().getMedicationRemindTtsCode(), ttsParams);
}
/**
* 发送漏服提醒语音电话
*
* @param phoneNumber 手机号
* @param personName 成员姓名
* @param medicineName 药品名称
* @param plannedTime 计划服药时间
* @return 是否成功
*/
public boolean callMissedRemind(String phoneNumber, String personName, String medicineName, String plannedTime) {
Map<String, String> ttsParams = new HashMap<>();
ttsParams.put("name", personName);
ttsParams.put("medicine", medicineName);
ttsParams.put("time", plannedTime);
return callByTts(phoneNumber, properties.getVoice().getMissedRemindTtsCode(), ttsParams);
}
/**
* 发送语音通知电话
*
* @param phoneNumber 手机号
* @param ttsCode 语音模板CODE
* @param ttsParams 模板参数
* @return 是否成功
*/
public boolean callByTts(String phoneNumber, String ttsCode, Map<String, String> ttsParams) {
try {
SingleCallByTtsRequest request = new SingleCallByTtsRequest()
.setCalledNumber(phoneNumber)
.setCalledShowNumber(properties.getVoice().getCalledShowNumber())
.setTtsCode(ttsCode)
.setTtsParam(JSON.toJSONString(ttsParams));
SingleCallByTtsResponse response = voiceClient.singleCallByTts(request);
if ("OK".equals(response.getBody().getCode())) {
log.info("语音电话发送成功: phone={}, ttsCode={}, callId={}",
phoneNumber, ttsCode, response.getBody().getCallId());
return true;
} else {
log.error("语音电话发送失败: phone={}, code={}, message={}",
phoneNumber, response.getBody().getCode(), response.getBody().getMessage());
return false;
}
} catch (Exception e) {
log.error("语音电话发送异常: phone={}, ttsCode={}", phoneNumber, ttsCode, e);
return false;
}
}
}

View File

@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=
com.intc.common.message.config.AliyunMessageAutoConfiguration

View File

@@ -94,7 +94,7 @@ public class AuthLogic
}
/**
* 验证当前用户有效期, 如果相差不足120分钟,自动刷新缓存
* 验证当前用户有效期, 如果相差不足配置的刷新时间,自动刷新缓存
*
* @param loginUser 当前用户信息
*/

View File

@@ -36,7 +36,7 @@ public class TokenService
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
private final static Long MILLIS_REFRESH_TIME = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
/**
* 创建令牌
@@ -134,7 +134,7 @@ public class TokenService
}
/**
* 验证令牌有效期,相差不足120分钟,自动刷新缓存
* 验证令牌有效期,相差不足配置的刷新时间,自动刷新缓存
*
* @param loginUser
*/
@@ -142,7 +142,7 @@ public class TokenService
{
long expireTime = loginUser.getExpireTime();
long currentTime = System.currentTimeMillis();
if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
if (expireTime - currentTime <= MILLIS_REFRESH_TIME)
{
refreshToken(loginUser);
}

View File

@@ -17,6 +17,7 @@
<module>intc-common-security</module>
<module>intc-common-datascope</module>
<module>intc-common-datasource</module>
<module>intc-common-message</module>
</modules>
<artifactId>intc-common</artifactId>

View File

@@ -100,6 +100,13 @@
<groupId>com.intc</groupId>
<artifactId>intc-common-swagger</artifactId>
</dependency>
<!-- intc-common-message 消息服务 -->
<dependency>
<groupId>com.intc</groupId>
<artifactId>intc-common-message</artifactId>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>

View File

@@ -0,0 +1,116 @@
package com.intc.health.controller;
import com.intc.common.core.web.controller.BaseController;
import com.intc.common.core.web.domain.AjaxResult;
import com.intc.common.core.web.page.TableDataInfo;
import com.intc.common.log.annotation.Log;
import com.intc.common.log.enums.BusinessType;
import com.intc.common.security.annotation.RequiresPermissions;
import com.intc.health.domain.ChronicDiseaseFollowUpRecord;
import com.intc.health.domain.ChronicDiseaseIndicatorRecord;
import com.intc.health.domain.ChronicDiseaseStatusHistory;
import com.intc.health.service.IChronicDiseaseManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Api(tags = "慢性疾病管理扩展")
@RestController
@RequestMapping("/chronicDiseaseManage")
public class ChronicDiseaseManageController extends BaseController {
@Resource
private IChronicDiseaseManageService chronicDiseaseManageService;
@ApiOperation("查询慢病指标记录")
@RequiresPermissions("health:chronicDisease:list")
@GetMapping("/indicator/list")
public TableDataInfo indicatorList(ChronicDiseaseIndicatorRecord query) {
startPage();
List<ChronicDiseaseIndicatorRecord> list = chronicDiseaseManageService.selectIndicatorList(query);
return getDataTable(list);
}
@ApiOperation("查询慢病指标详情")
@RequiresPermissions("health:chronicDisease:query")
@GetMapping("/indicator/{id}")
public AjaxResult indicatorInfo(@PathVariable Long id) {
return success(chronicDiseaseManageService.selectIndicatorById(id));
}
@ApiOperation("新增慢病指标记录")
@RequiresPermissions("health:chronicDisease:add")
@Log(title = "慢性疾病指标记录", businessType = BusinessType.INSERT)
@PostMapping("/indicator")
public AjaxResult indicatorAdd(@RequestBody ChronicDiseaseIndicatorRecord record) {
return toAjax(chronicDiseaseManageService.insertIndicator(record));
}
@ApiOperation("修改慢病指标记录")
@RequiresPermissions("health:chronicDisease:edit")
@Log(title = "慢性疾病指标记录", businessType = BusinessType.UPDATE)
@PutMapping("/indicator")
public AjaxResult indicatorEdit(@RequestBody ChronicDiseaseIndicatorRecord record) {
return toAjax(chronicDiseaseManageService.updateIndicator(record));
}
@ApiOperation("删除慢病指标记录")
@RequiresPermissions("health:chronicDisease:remove")
@Log(title = "慢性疾病指标记录", businessType = BusinessType.DELETE)
@DeleteMapping("/indicator/{ids}")
public AjaxResult indicatorRemove(@PathVariable Long[] ids) {
return toAjax(chronicDiseaseManageService.deleteIndicatorByIds(ids));
}
@ApiOperation("查询复诊随访记录")
@RequiresPermissions("health:chronicDisease:list")
@GetMapping("/followUp/list")
public TableDataInfo followUpList(ChronicDiseaseFollowUpRecord query) {
startPage();
List<ChronicDiseaseFollowUpRecord> list = chronicDiseaseManageService.selectFollowUpList(query);
return getDataTable(list);
}
@ApiOperation("新增复诊随访记录")
@RequiresPermissions("health:chronicDisease:add")
@Log(title = "慢性疾病复诊随访", businessType = BusinessType.INSERT)
@PostMapping("/followUp")
public AjaxResult followUpAdd(@RequestBody ChronicDiseaseFollowUpRecord record) {
return toAjax(chronicDiseaseManageService.insertFollowUp(record));
}
@ApiOperation("修改复诊随访记录")
@RequiresPermissions("health:chronicDisease:edit")
@Log(title = "慢性疾病复诊随访", businessType = BusinessType.UPDATE)
@PutMapping("/followUp")
public AjaxResult followUpEdit(@RequestBody ChronicDiseaseFollowUpRecord record) {
return toAjax(chronicDiseaseManageService.updateFollowUp(record));
}
@ApiOperation("删除复诊随访记录")
@RequiresPermissions("health:chronicDisease:remove")
@Log(title = "慢性疾病复诊随访", businessType = BusinessType.DELETE)
@DeleteMapping("/followUp/{ids}")
public AjaxResult followUpRemove(@PathVariable Long[] ids) {
return toAjax(chronicDiseaseManageService.deleteFollowUpByIds(ids));
}
@ApiOperation("查询状态变更历史")
@RequiresPermissions("health:chronicDisease:list")
@GetMapping("/statusHistory/list")
public TableDataInfo statusHistoryList(ChronicDiseaseStatusHistory query) {
startPage();
List<ChronicDiseaseStatusHistory> list = chronicDiseaseManageService.selectStatusHistoryList(query);
return getDataTable(list);
}
@ApiOperation("新增状态变更历史")
@RequiresPermissions("health:chronicDisease:edit")
@Log(title = "慢性疾病状态变更", businessType = BusinessType.INSERT)
@PostMapping("/statusHistory")
public AjaxResult statusHistoryAdd(@RequestBody ChronicDiseaseStatusHistory record) {
return toAjax(chronicDiseaseManageService.insertStatusHistory(record));
}
}

View File

@@ -8,9 +8,12 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
/**
@@ -46,6 +49,20 @@ public class StatisticAnalysisController extends BaseController {
return AjaxResult.success(resultMap);
}
@ApiOperation("活动统计分析")
@GetMapping("/activityAnalysis")
public Map<String,Object> getActivityAnalysis(AnalysisDto analysisDto){
Map<String, Object> resultMap = iStatisticAnalysisService.getActivityAnalysis(analysisDto);
return AjaxResult.success(resultMap);
}
@ApiOperation("健康总览大屏")
@GetMapping("/healthScreen")
public Map<String,Object> getHealthScreen(AnalysisDto analysisDto){
Map<String, Object> resultMap = iStatisticAnalysisService.getHealthScreen(analysisDto);
return AjaxResult.success(resultMap);
}
@ApiOperation("档案统计分析")
@GetMapping("/recordAnalysis")
public Map<String,Object> getRecordAnalysis(AnalysisDto analysisDto){
@@ -53,6 +70,19 @@ public class StatisticAnalysisController extends BaseController {
return AjaxResult.success(resultMap);
}
@ApiOperation("健康档案大屏")
@GetMapping("/recordScreen")
public Map<String,Object> getRecordScreen(AnalysisDto analysisDto){
Map<String, Object> resultMap = iStatisticAnalysisService.getRecordScreen(analysisDto);
return AjaxResult.success(resultMap);
}
@ApiOperation("导出健康档案完整信息")
@PostMapping("/recordFullExport")
public void exportRecordFull(HttpServletResponse response, AnalysisDto analysisDto) throws IOException {
iStatisticAnalysisService.exportRecordFull(response, analysisDto);
}
@ApiOperation("就医统计分析")
@GetMapping("/doctorAnalysis")
public Map<String,Object> getDoctorAnalysis(AnalysisDto analysisDto){

View File

@@ -0,0 +1,58 @@
package com.intc.health.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("慢性疾病复诊随访记录")
public class ChronicDiseaseFollowUpRecord extends BaseEntity {
private Long id;
@ApiModelProperty("慢性疾病档案ID")
private Long chronicDiseaseId;
@ApiModelProperty("成员ID")
private Long personId;
@ApiModelProperty("类型1-复诊 2-复查 3-随访")
private Integer followUpType;
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("复诊/随访日期")
private Date followUpDate;
private String hospital;
private String department;
private String doctor;
@ApiModelProperty("复查项目")
private String checkItems;
@ApiModelProperty("结果")
private String result;
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("下次复诊日期")
private Date nextFollowUpDate;
@ApiModelProperty("状态1-待完成 2-已完成 3-已过期")
private Integer status;
@ApiModelProperty("说明")
private String notes;
private Integer delFlag;
private String startTime;
private String endTime;
}

View File

@@ -0,0 +1,58 @@
package com.intc.health.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("慢性疾病指标记录")
public class ChronicDiseaseIndicatorRecord extends BaseEntity {
private Long id;
@ApiModelProperty("慢性疾病档案ID")
private Long chronicDiseaseId;
@ApiModelProperty("成员ID")
private Long personId;
@ApiModelProperty("指标类型")
private String indicatorType;
@ApiModelProperty("指标名称")
private String indicatorName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("测量时间")
private Date measureTime;
@ApiModelProperty("指标值")
private BigDecimal indicatorValue;
@ApiModelProperty("指标单位")
private String indicatorUnit;
@ApiModelProperty("目标下限")
private BigDecimal targetMin;
@ApiModelProperty("目标上限")
private BigDecimal targetMax;
@ApiModelProperty("状态1-正常 2-偏高 3-偏低 4-需关注")
private Integer status;
@ApiModelProperty("记录说明")
private String notes;
private Integer delFlag;
private String startTime;
private String endTime;
}

View File

@@ -0,0 +1,41 @@
package com.intc.health.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("慢性疾病状态变更历史")
public class ChronicDiseaseStatusHistory extends BaseEntity {
private Long id;
@ApiModelProperty("慢性疾病档案ID")
private Long chronicDiseaseId;
@ApiModelProperty("成员ID")
private Long personId;
@ApiModelProperty("原状态")
private Integer oldStatus;
@ApiModelProperty("新状态")
private Integer newStatus;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("变更时间")
private Date changeTime;
@ApiModelProperty("变更原因")
private String reason;
@ApiModelProperty("处理建议")
private String treatmentAdvice;
private Integer delFlag;
}

View File

@@ -80,6 +80,11 @@ public class HealthActivity extends BaseEntity
/** 费用明细 */
private String costDetail;
/** 附件 */
@ApiModelProperty(value="附件")
@Excel(name = "附件")
private String attachment;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -102,6 +107,7 @@ public class HealthActivity extends BaseEntity
.append("totalCost", getTotalCost())
.append("partner", getPartner())
.append("costDetail", getCostDetail())
.append("attachment", getAttachment())
.toString();
}
}

View File

@@ -92,6 +92,11 @@ public class HealthDoctorRecord extends BaseEntity
@Excel(name = "就诊类型")
private String type;
/** 附件 */
@ApiModelProperty(value="附件")
@Excel(name = "附件")
private String attachment;
@Override
public String toString() {
@@ -114,6 +119,7 @@ public class HealthDoctorRecord extends BaseEntity
.append("partner", getPartner())
.append("costDetail", getCostDetail())
.append("type", getType())
.append("attachment", getAttachment())
.append("diagnosis", getDiagnosis())
.toString();
}

View File

@@ -129,6 +129,11 @@ public class HealthMedicineBasic extends BaseEntity
@Excel(name = "包装单位")
private String packageUnit;
/** 附件 */
@ApiModelProperty(value="附件")
@Excel(name = "附件")
private String attachment;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -162,6 +167,7 @@ public class HealthMedicineBasic extends BaseEntity
.append("indications", getIndications())
.append("shortName", getShortName())
.append("packageUnit", getPackageUnit())
.append("attachment", getAttachment())
.toString();
}
}

View File

@@ -81,6 +81,11 @@ public class HealthPerson extends BaseEntity
@Excel(name = "身份证")
private String identityCard;
/** 手机号 */
@ApiModelProperty(value="手机号")
@Excel(name = "手机号")
private String phone;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -100,6 +105,7 @@ public class HealthPerson extends BaseEntity
.append("ranking", getRanking())
.append("sex", getSex())
.append("identityCard", getIdentityCard())
.append("phone", getPhone())
.toString();
}
}

View File

@@ -66,6 +66,9 @@ public class MedicationPlan extends BaseEntity {
@ApiModelProperty("是否开启提醒1-是 0-否")
private Integer remindEnabled;
@ApiModelProperty("提醒方式1-短信 2-电话 3-短信+电话")
private Integer remindType;
@ApiModelProperty("提前提醒分钟数")
private Integer remindAdvanceMin;

View File

@@ -43,5 +43,20 @@ public class AnalysisDto extends BaseEntity implements Serializable
@ApiModelProperty(value="档案id")
private Long recordId;
/** 活动名称 */
@ApiModelProperty(value="活动名称")
private String name;
/** 活动类型 */
@ApiModelProperty(value="活动类型")
private String activityType;
/** 活动地点 */
@ApiModelProperty(value="活动地点")
private String place;
/** 活动量 */
@ApiModelProperty(value="活动量")
private String activityVolume;
}

View File

@@ -72,6 +72,9 @@ public class MedicationPlanVo {
@ApiModelProperty("是否开启提醒1-是 0-否")
private Integer remindEnabled;
@ApiModelProperty("提醒方式1-短信 2-电话 3-短信+电话")
private Integer remindType;
@ApiModelProperty("提前提醒分钟数")
private Integer remindAdvanceMin;
@@ -90,6 +93,9 @@ public class MedicationPlanVo {
@ApiModelProperty("今日已完成")
private Integer todayCompleted;
@ApiModelProperty("创建人")
private String createBy;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;

View File

@@ -33,6 +33,9 @@ public class MedicationTaskVo {
@ApiModelProperty("成员名称")
private String personName;
@ApiModelProperty("成员手机号")
private String personPhone;
@ApiModelProperty("药品名称")
private String medicineName;

View File

@@ -0,0 +1,37 @@
package com.intc.health.mapper;
import com.intc.common.datascope.annotation.DataScope;
import com.intc.health.domain.ChronicDiseaseFollowUpRecord;
import com.intc.health.domain.ChronicDiseaseIndicatorRecord;
import com.intc.health.domain.ChronicDiseaseStatusHistory;
import java.util.List;
public interface ChronicDiseaseManageMapper {
@DataScope(businessAlias = "a")
List<ChronicDiseaseIndicatorRecord> selectIndicatorList(ChronicDiseaseIndicatorRecord query);
ChronicDiseaseIndicatorRecord selectIndicatorById(Long id);
int insertIndicator(ChronicDiseaseIndicatorRecord record);
int updateIndicator(ChronicDiseaseIndicatorRecord record);
int removeIndicatorByIds(Long[] ids);
@DataScope(businessAlias = "a")
List<ChronicDiseaseFollowUpRecord> selectFollowUpList(ChronicDiseaseFollowUpRecord query);
ChronicDiseaseFollowUpRecord selectFollowUpById(Long id);
int insertFollowUp(ChronicDiseaseFollowUpRecord record);
int updateFollowUp(ChronicDiseaseFollowUpRecord record);
int removeFollowUpByIds(Long[] ids);
@DataScope(businessAlias = "a")
List<ChronicDiseaseStatusHistory> selectStatusHistoryList(ChronicDiseaseStatusHistory query);
int insertStatusHistory(ChronicDiseaseStatusHistory record);
}

View File

@@ -2,13 +2,16 @@ package com.intc.health.mapper;
import com.intc.common.datascope.annotation.DataScope;
import com.intc.health.domain.dto.HealthDoctorRecordDto;
import com.intc.health.domain.dto.HealthActivityDto;
import com.intc.health.domain.dto.HealthMarRecordDto;
import com.intc.health.domain.dto.HealthMilkPowderRecordDto;
import com.intc.health.domain.dto.HealthRecordDto;
import com.intc.health.domain.dto.HealthTemperatureRecordDto;
import com.intc.health.domain.vo.*;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface StatisticAnalysisMapper {
@@ -98,6 +101,60 @@ public interface StatisticAnalysisMapper {
@DataScope(businessAlias = "hp")
public List<HealthStaticPersonVo> selectStaticPersonList (HealthRecordDto dto);
/**
* 查询健康总览大屏成员风险排行
*/
@DataScope(businessAlias = "hp")
public List<HealthStaticPersonVo> selectHealthScreenPersonRankList(HealthRecordDto dto);
/**
* 查询健康总览大屏就医汇总
*/
@DataScope(businessAlias = "a")
public Map<String, Object> selectHealthScreenDoctorSummary(HealthDoctorRecordDto dto);
/**
* 查询健康总览大屏用药汇总
*/
@DataScope(businessAlias = "a")
public Map<String, Object> selectHealthScreenMedicineSummary(HealthMarRecordDto dto);
/**
* 查询健康总览大屏体温汇总
*/
@DataScope(businessAlias = "a")
public Map<String, Object> selectHealthScreenTemperatureSummary(HealthTemperatureRecordDto dto);
/**
* 查询健康总览大屏活动汇总
*/
@DataScope(businessAlias = "a")
public Map<String, Object> selectHealthScreenActivitySummary(HealthActivityDto dto);
/**
* 查询健康总览大屏近期活动明细
*/
@DataScope(businessAlias = "a")
public List<HealthActivityVo> selectHealthScreenActivityList(HealthActivityDto dto);
/**
* 查询健康总览大屏近期就医明细
*/
@DataScope(businessAlias = "a")
public List<HealthDoctorRecordVo> selectHealthScreenDoctorList(HealthDoctorRecordDto dto);
/**
* 查询健康总览大屏近期用药明细
*/
@DataScope(businessAlias = "a")
public List<HealthMarRecordVo> selectHealthScreenMedicineList(HealthMarRecordDto dto);
/**
* 查询健康总览大屏近期体温明细
*/
@DataScope(businessAlias = "a")
public List<HealthTemperatureRecordVo> selectHealthScreenTemperatureList(HealthTemperatureRecordDto dto);
/**
* 查询用药记录

View File

@@ -0,0 +1,33 @@
package com.intc.health.service;
import com.intc.health.domain.ChronicDiseaseFollowUpRecord;
import com.intc.health.domain.ChronicDiseaseIndicatorRecord;
import com.intc.health.domain.ChronicDiseaseStatusHistory;
import java.util.List;
public interface IChronicDiseaseManageService {
List<ChronicDiseaseIndicatorRecord> selectIndicatorList(ChronicDiseaseIndicatorRecord query);
ChronicDiseaseIndicatorRecord selectIndicatorById(Long id);
int insertIndicator(ChronicDiseaseIndicatorRecord record);
int updateIndicator(ChronicDiseaseIndicatorRecord record);
int deleteIndicatorByIds(Long[] ids);
List<ChronicDiseaseFollowUpRecord> selectFollowUpList(ChronicDiseaseFollowUpRecord query);
ChronicDiseaseFollowUpRecord selectFollowUpById(Long id);
int insertFollowUp(ChronicDiseaseFollowUpRecord record);
int updateFollowUp(ChronicDiseaseFollowUpRecord record);
int deleteFollowUpByIds(Long[] ids);
List<ChronicDiseaseStatusHistory> selectStatusHistoryList(ChronicDiseaseStatusHistory query);
int insertStatusHistory(ChronicDiseaseStatusHistory record);
}

View File

@@ -2,6 +2,8 @@ package com.intc.health.service;
import com.intc.health.domain.dto.AnalysisDto;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
/**
@@ -17,9 +19,17 @@ public interface IStatisticAnalysisService {
public Map<String, Object> getHealthAnalysisInfo();
public Map<String, Object> getActivityAnalysis(AnalysisDto analysisDto);
public Map<String, Object> getHealthScreen(AnalysisDto analysisDto);
public Map<String, Object> getRecordAnalysis(AnalysisDto analysisDto);
public Map<String, Object> getRecordScreen(AnalysisDto analysisDto);
public void exportRecordFull(HttpServletResponse response, AnalysisDto analysisDto) throws IOException;
public Map<String, Object> getDoctorAnalysis(AnalysisDto analysisDto);

View File

@@ -0,0 +1,109 @@
package com.intc.health.service.impl;
import com.intc.common.core.utils.DateUtils;
import com.intc.common.core.utils.IdWorker;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.health.domain.ChronicDiseaseFollowUpRecord;
import com.intc.health.domain.ChronicDiseaseIndicatorRecord;
import com.intc.health.domain.ChronicDiseaseStatusHistory;
import com.intc.health.mapper.ChronicDiseaseManageMapper;
import com.intc.health.service.IChronicDiseaseManageService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class ChronicDiseaseManageServiceImpl implements IChronicDiseaseManageService {
@Resource
private ChronicDiseaseManageMapper chronicDiseaseManageMapper;
@Override
public List<ChronicDiseaseIndicatorRecord> selectIndicatorList(ChronicDiseaseIndicatorRecord query) {
return chronicDiseaseManageMapper.selectIndicatorList(query);
}
@Override
public ChronicDiseaseIndicatorRecord selectIndicatorById(Long id) {
return chronicDiseaseManageMapper.selectIndicatorById(id);
}
@Override
public int insertIndicator(ChronicDiseaseIndicatorRecord record) {
record.setId(IdWorker.getId());
record.setCreateBy(SecurityUtils.getUsername());
record.setCreateTime(DateUtils.getNowDate());
if (record.getMeasureTime() == null) {
record.setMeasureTime(new Date());
}
if (record.getStatus() == null) {
record.setStatus(1);
}
return chronicDiseaseManageMapper.insertIndicator(record);
}
@Override
public int updateIndicator(ChronicDiseaseIndicatorRecord record) {
record.setUpdateBy(SecurityUtils.getUsername());
record.setUpdateTime(DateUtils.getNowDate());
return chronicDiseaseManageMapper.updateIndicator(record);
}
@Override
public int deleteIndicatorByIds(Long[] ids) {
return chronicDiseaseManageMapper.removeIndicatorByIds(ids);
}
@Override
public List<ChronicDiseaseFollowUpRecord> selectFollowUpList(ChronicDiseaseFollowUpRecord query) {
return chronicDiseaseManageMapper.selectFollowUpList(query);
}
@Override
public ChronicDiseaseFollowUpRecord selectFollowUpById(Long id) {
return chronicDiseaseManageMapper.selectFollowUpById(id);
}
@Override
public int insertFollowUp(ChronicDiseaseFollowUpRecord record) {
record.setId(IdWorker.getId());
record.setCreateBy(SecurityUtils.getUsername());
record.setCreateTime(DateUtils.getNowDate());
if (record.getFollowUpType() == null) {
record.setFollowUpType(1);
}
if (record.getStatus() == null) {
record.setStatus(1);
}
return chronicDiseaseManageMapper.insertFollowUp(record);
}
@Override
public int updateFollowUp(ChronicDiseaseFollowUpRecord record) {
record.setUpdateBy(SecurityUtils.getUsername());
record.setUpdateTime(DateUtils.getNowDate());
return chronicDiseaseManageMapper.updateFollowUp(record);
}
@Override
public int deleteFollowUpByIds(Long[] ids) {
return chronicDiseaseManageMapper.removeFollowUpByIds(ids);
}
@Override
public List<ChronicDiseaseStatusHistory> selectStatusHistoryList(ChronicDiseaseStatusHistory query) {
return chronicDiseaseManageMapper.selectStatusHistoryList(query);
}
@Override
public int insertStatusHistory(ChronicDiseaseStatusHistory record) {
record.setId(IdWorker.getId());
record.setCreateBy(SecurityUtils.getUsername());
record.setCreateTime(DateUtils.getNowDate());
if (record.getChangeTime() == null) {
record.setChangeTime(new Date());
}
return chronicDiseaseManageMapper.insertStatusHistory(record);
}
}

View File

@@ -4,8 +4,10 @@ import com.intc.common.core.utils.DateUtils;
import com.intc.common.core.utils.IdWorker;
import com.intc.common.security.utils.SecurityUtils;
import com.intc.health.domain.ChronicDiseaseRecord;
import com.intc.health.domain.ChronicDiseaseStatusHistory;
import com.intc.health.domain.dto.ChronicDiseaseRecordDto;
import com.intc.health.domain.vo.ChronicDiseaseRecordVo;
import com.intc.health.mapper.ChronicDiseaseManageMapper;
import com.intc.health.mapper.ChronicDiseaseRecordMapper;
import com.intc.health.service.IChronicDiseaseRecordService;
import org.springframework.stereotype.Service;
@@ -25,6 +27,9 @@ public class ChronicDiseaseRecordServiceImpl implements IChronicDiseaseRecordSer
@Resource
private ChronicDiseaseRecordMapper chronicDiseaseRecordMapper;
@Resource
private ChronicDiseaseManageMapper chronicDiseaseManageMapper;
/**
* 查询慢性疾病档案
*
@@ -93,9 +98,29 @@ public class ChronicDiseaseRecordServiceImpl implements IChronicDiseaseRecordSer
@Override
public int updateChronicDiseaseRecord(ChronicDiseaseRecord chronicDiseaseRecord)
{
ChronicDiseaseRecordVo oldRecord = null;
if (chronicDiseaseRecord.getId() != null && chronicDiseaseRecord.getDiseaseStatus() != null) {
oldRecord = chronicDiseaseRecordMapper.selectChronicDiseaseRecordById(chronicDiseaseRecord.getId());
}
chronicDiseaseRecord.setUpdateBy(SecurityUtils.getUsername());
chronicDiseaseRecord.setUpdateTime(DateUtils.getNowDate());
return chronicDiseaseRecordMapper.updateChronicDiseaseRecord(chronicDiseaseRecord);
int rows = chronicDiseaseRecordMapper.updateChronicDiseaseRecord(chronicDiseaseRecord);
if (rows > 0 && oldRecord != null && oldRecord.getDiseaseStatus() != null
&& !oldRecord.getDiseaseStatus().equals(chronicDiseaseRecord.getDiseaseStatus())) {
ChronicDiseaseStatusHistory history = new ChronicDiseaseStatusHistory();
history.setId(IdWorker.getId());
history.setChronicDiseaseId(chronicDiseaseRecord.getId());
history.setPersonId(oldRecord.getPersonId());
history.setOldStatus(oldRecord.getDiseaseStatus());
history.setNewStatus(chronicDiseaseRecord.getDiseaseStatus());
history.setChangeTime(DateUtils.getNowDate());
history.setReason(chronicDiseaseRecord.getRemark() != null ? chronicDiseaseRecord.getRemark() : "档案状态调整");
history.setTreatmentAdvice(chronicDiseaseRecord.getNotes());
history.setCreateBy(SecurityUtils.getUsername());
history.setCreateTime(DateUtils.getNowDate());
chronicDiseaseManageMapper.insertStatusHistory(history);
}
return rows;
}
/**
@@ -121,4 +146,4 @@ public class ChronicDiseaseRecordServiceImpl implements IChronicDiseaseRecordSer
{
return chronicDiseaseRecordMapper.removeChronicDiseaseRecordById(id);
}
}
}

View File

@@ -1,15 +1,24 @@
package com.intc.health.task;
import com.fasterxml.jackson.databind.JsonNode;
import com.intc.common.message.service.SmsService;
import com.intc.common.message.service.VoiceService;
import com.intc.health.domain.MedicationTask;
import com.intc.health.domain.vo.HealthPersonVo;
import com.intc.health.domain.vo.MedicationPlanVo;
import com.intc.health.domain.vo.MedicationTaskVo;
import com.intc.health.mapper.HealthPersonMapper;
import com.intc.health.mapper.MedicationPlanMapper;
import com.intc.health.mapper.MedicationTaskMapper;
import com.intc.health.service.IHealthPersonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
@@ -26,6 +35,20 @@ public class MedicationRemindJob {
@Resource
private MedicationTaskMapper taskMapper;
@Resource
private MedicationPlanMapper planMapper;
@Resource
private HealthPersonMapper personMapper;
@Resource
private SmsService smsService;
@Resource
private VoiceService voiceService;
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm");
/**
* 扫描并发送提醒
* 定时任务配置:每分钟执行
@@ -63,11 +86,59 @@ public class MedicationRemindJob {
task.getPersonName(), task.getMedicineName(),
task.getPlannedDate(), task.getPlannedTime());
// TODO: 实现消息推送
// 1. 查询用户的提醒设置
// 2. 根据设置选择推送渠道
// 3. 发送推送消息
// 4. 记录提醒日志
// 获取用药计划配置
MedicationPlanVo plan = planMapper.selectById(task.getPlanId());
if (plan == null) {
log.warn("用药计划不存在: planId={}", task.getPlanId());
return;
}
// 检查是否开启提醒
if (plan.getRemindEnabled() == null || plan.getRemindEnabled() == 0) {
log.debug("用药计划未开启提醒: planId={}", task.getPlanId());
return;
}
// 获取成员手机号
String phone = task.getPersonPhone();
if (phone == null || phone.isEmpty()) {
log.warn("成员手机号为空: personId={}", task.getPersonId());
return;
}
// 格式化计划时间
String plannedTimeStr = formatPlannedTime(task);
// 提醒方式1-短信 2-电话 3-短信+电话
Integer remindType = plan.getRemindType();
if (remindType == null) {
remindType = 1; // 默认短信
}
boolean smsSuccess = false;
boolean voiceSuccess = false;
// 发送短信提醒
if (remindType == 1 || remindType == 3) {
smsSuccess = smsService.sendMedicationRemind(phone, task.getPersonName(), task.getMedicineName(), plannedTimeStr);
log.info("短信提醒发送结果: phone={}, success={}", phone, smsSuccess);
}
// 发送电话提醒
if (remindType == 2 || remindType == 3) {
voiceSuccess = voiceService.callMedicationRemind(phone, task.getPersonName(), task.getMedicineName(), plannedTimeStr);
log.info("电话提醒发送结果: phone={}, success={}", phone, voiceSuccess);
}
// 更新任务提醒状态
MedicationTask updateTask = new MedicationTask();
updateTask.setId(task.getId());
updateTask.setRemindStatus(1); // 已提醒
updateTask.setRemindTime(LocalDateTime.now());
taskMapper.update(updateTask);
log.info("提醒发送完成: taskId={}, person={}, sms={}, voice={}",
task.getId(), task.getPersonName(), smsSuccess, voiceSuccess);
}
/**
@@ -109,8 +180,98 @@ public class MedicationRemindJob {
task.getPersonName(), task.getMedicineName(),
task.getPlannedDate(), task.getPlannedTime());
// TODO: 实现超时提醒逻辑
// 1. 发送二次提醒
// 2. 如果配置了家属通知,通知家属
// 获取用药计划配置
MedicationPlanVo plan = planMapper.selectById(task.getPlanId());
if (plan == null) {
log.warn("用药计划不存在: planId={}", task.getPlanId());
return;
}
// 获取成员手机号
String phone = task.getPersonPhone();
if (phone == null || phone.isEmpty()) {
log.warn("成员手机号为空: personId={}", task.getPersonId());
return;
}
// 格式化计划时间
String plannedTimeStr = formatPlannedTime(task);
// 提醒方式:超时提醒默认短信+电话
Integer remindType = plan.getRemindType();
if (remindType == null) {
remindType = 3; // 默认短信+电话
} else if (remindType == 1) {
remindType = 3; // 短信改为短信+电话加强提醒
}
// 发送超时短信提醒
boolean smsSuccess = smsService.sendMissedRemind(phone, task.getPersonName(), task.getMedicineName(), plannedTimeStr);
log.info("超时短信提醒发送结果: phone={}, success={}", phone, smsSuccess);
// 发送超时电话提醒
if (remindType == 2 || remindType == 3) {
boolean voiceSuccess = voiceService.callMissedRemind(phone, task.getPersonName(), task.getMedicineName(), plannedTimeStr);
log.info("超时电话提醒发送结果: phone={}, success={}", phone, voiceSuccess);
}
// 更新任务提醒状态为已超时提醒
MedicationTask updateTask = new MedicationTask();
updateTask.setId(task.getId());
updateTask.setRemindStatus(2); // 已超时提醒
updateTask.setRemindTime(LocalDateTime.now());
taskMapper.update(updateTask);
// 如果配置了家属通知,通知家属
if (plan.getNotifyFamily() != null && plan.getNotifyFamily() == 1) {
notifyFamily(task, plan);
}
log.info("超时提醒发送完成: taskId={}, person={}", task.getId(), task.getPersonName());
}
/**
* 通知家属
*/
private void notifyFamily(MedicationTaskVo task, MedicationPlanVo plan) {
JsonNode familyMemberIds = plan.getFamilyMemberIds();
if (familyMemberIds == null || !familyMemberIds.isArray()) {
log.debug("未配置家属成员");
return;
}
String plannedTimeStr = formatPlannedTime(task);
for (JsonNode memberIdNode : familyMemberIds) {
Long memberId = memberIdNode.asLong();
HealthPersonVo familyMember = personMapper.selectHealthPersonById(memberId);
if (familyMember == null) {
log.warn("家属成员不存在: memberId={}", memberId);
continue;
}
// 获取家属手机号需要在HealthPersonVo中添加phone字段
String familyPhone = familyMember.getPhone();
if (familyPhone == null || familyPhone.isEmpty()) {
log.warn("家属手机号为空: memberId={}", memberId);
continue;
}
// 发送家属通知短信
boolean success = smsService.sendFamilyNotify(familyPhone, task.getPersonName(), task.getMedicineName(), plannedTimeStr);
log.info("家属通知发送结果: familyPhone={}, familyMember={}, success={}",
familyPhone, familyMember.getName(), success);
}
}
/**
* 格式化计划时间
*/
private String formatPlannedTime(MedicationTaskVo task) {
if (task.getPlannedTime() != null) {
// plannedTime是Date类型需要转换
return new java.text.SimpleDateFormat("HH:mm").format(task.getPlannedTime());
}
return "未知时间";
}
}

View File

@@ -220,6 +220,7 @@ public class MedicationTaskJob {
task.setPlannedDosage(dosage);
task.setStatus(0); // 待服药
task.setRemindStatus(0); // 未提醒
task.setCreateBy(plan.getCreateBy());
task.setCreateTime(DateUtils.getNowDate());
tasks.add(task);

View File

@@ -0,0 +1,314 @@
<?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.intc.health.mapper.ChronicDiseaseManageMapper">
<resultMap type="ChronicDiseaseIndicatorRecord" id="ChronicDiseaseIndicatorResult">
<id property="id" column="id"/>
<result property="chronicDiseaseId" column="chronic_disease_id"/>
<result property="personId" column="person_id"/>
<result property="indicatorType" column="indicator_type"/>
<result property="indicatorName" column="indicator_name"/>
<result property="measureTime" column="measure_time"/>
<result property="indicatorValue" column="indicator_value"/>
<result property="indicatorUnit" column="indicator_unit"/>
<result property="targetMin" column="target_min"/>
<result property="targetMax" column="target_max"/>
<result property="status" column="status"/>
<result property="notes" column="notes"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<resultMap type="ChronicDiseaseFollowUpRecord" id="ChronicDiseaseFollowUpResult">
<id property="id" column="id"/>
<result property="chronicDiseaseId" column="chronic_disease_id"/>
<result property="personId" column="person_id"/>
<result property="followUpType" column="follow_up_type"/>
<result property="followUpDate" column="follow_up_date"/>
<result property="hospital" column="hospital"/>
<result property="department" column="department"/>
<result property="doctor" column="doctor"/>
<result property="checkItems" column="check_items"/>
<result property="result" column="result"/>
<result property="nextFollowUpDate" column="next_follow_up_date"/>
<result property="status" column="status"/>
<result property="notes" column="notes"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<resultMap type="ChronicDiseaseStatusHistory" id="ChronicDiseaseStatusHistoryResult">
<id property="id" column="id"/>
<result property="chronicDiseaseId" column="chronic_disease_id"/>
<result property="personId" column="person_id"/>
<result property="oldStatus" column="old_status"/>
<result property="newStatus" column="new_status"/>
<result property="changeTime" column="change_time"/>
<result property="reason" column="reason"/>
<result property="treatmentAdvice" column="treatment_advice"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="selectIndicatorVo">
select a.id, a.chronic_disease_id, a.person_id, a.indicator_type, a.indicator_name,
a.measure_time, a.indicator_value, a.indicator_unit, a.target_min, a.target_max,
a.status, a.notes, a.create_by, a.create_time, a.update_by, a.update_time,
a.remark, a.del_flag
from chronic_disease_indicator_record a
inner join health_person p on a.person_id = p.id and p.del_flag = '0'
</sql>
<select id="selectIndicatorList" parameterType="ChronicDiseaseIndicatorRecord" resultMap="ChronicDiseaseIndicatorResult">
<include refid="selectIndicatorVo"/>
<where>
a.del_flag = 0
<if test="chronicDiseaseId != null">and a.chronic_disease_id = #{chronicDiseaseId}</if>
<if test="personId != null">and a.person_id = #{personId}</if>
<if test="indicatorType != null and indicatorType != ''">and a.indicator_type = #{indicatorType}</if>
<if test="indicatorName != null and indicatorName != ''">and a.indicator_name like '%' || #{indicatorName} || '%'</if>
<if test="status != null">and a.status = #{status}</if>
<if test="startTime != null and startTime != ''">and a.measure_time &gt;= to_timestamp(#{startTime}, 'YYYY-MM-DD HH24:MI:SS')</if>
<if test="endTime != null and endTime != ''">and a.measure_time &lt;= to_timestamp(#{endTime}, 'YYYY-MM-DD HH24:MI:SS')</if>
</where>
${params.dataScope}
order by a.measure_time desc, a.create_time desc
</select>
<select id="selectIndicatorById" parameterType="Long" resultMap="ChronicDiseaseIndicatorResult">
<include refid="selectIndicatorVo"/>
where a.id = #{id} and a.del_flag = 0
</select>
<insert id="insertIndicator" parameterType="ChronicDiseaseIndicatorRecord">
insert into chronic_disease_indicator_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="chronicDiseaseId != null">chronic_disease_id,</if>
<if test="personId != null">person_id,</if>
<if test="indicatorType != null">indicator_type,</if>
<if test="indicatorName != null">indicator_name,</if>
<if test="measureTime != null">measure_time,</if>
<if test="indicatorValue != null">indicator_value,</if>
<if test="indicatorUnit != null">indicator_unit,</if>
<if test="targetMin != null">target_min,</if>
<if test="targetMax != null">target_max,</if>
<if test="status != null">status,</if>
<if test="notes != null">notes,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remark != null">remark,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="chronicDiseaseId != null">#{chronicDiseaseId},</if>
<if test="personId != null">#{personId},</if>
<if test="indicatorType != null">#{indicatorType},</if>
<if test="indicatorName != null">#{indicatorName},</if>
<if test="measureTime != null">#{measureTime},</if>
<if test="indicatorValue != null">#{indicatorValue},</if>
<if test="indicatorUnit != null">#{indicatorUnit},</if>
<if test="targetMin != null">#{targetMin},</if>
<if test="targetMax != null">#{targetMax},</if>
<if test="status != null">#{status},</if>
<if test="notes != null">#{notes},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remark != null">#{remark},</if>
0,
</trim>
</insert>
<update id="updateIndicator" parameterType="ChronicDiseaseIndicatorRecord">
update chronic_disease_indicator_record
<set>
<if test="chronicDiseaseId != null">chronic_disease_id = #{chronicDiseaseId},</if>
<if test="personId != null">person_id = #{personId},</if>
<if test="indicatorType != null">indicator_type = #{indicatorType},</if>
<if test="indicatorName != null">indicator_name = #{indicatorName},</if>
<if test="measureTime != null">measure_time = #{measureTime},</if>
<if test="indicatorValue != null">indicator_value = #{indicatorValue},</if>
<if test="indicatorUnit != null">indicator_unit = #{indicatorUnit},</if>
<if test="targetMin != null">target_min = #{targetMin},</if>
<if test="targetMax != null">target_max = #{targetMax},</if>
<if test="status != null">status = #{status},</if>
<if test="notes != null">notes = #{notes},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</set>
where id = #{id}
</update>
<update id="removeIndicatorByIds" parameterType="Long">
update chronic_disease_indicator_record set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
</update>
<sql id="selectFollowUpVo">
select a.id, a.chronic_disease_id, a.person_id, a.follow_up_type, a.follow_up_date,
a.hospital, a.department, a.doctor, a.check_items, a.result, a.next_follow_up_date,
a.status, a.notes, a.create_by, a.create_time, a.update_by, a.update_time,
a.remark, a.del_flag
from chronic_disease_follow_up_record a
inner join health_person p on a.person_id = p.id and p.del_flag = '0'
</sql>
<select id="selectFollowUpList" parameterType="ChronicDiseaseFollowUpRecord" resultMap="ChronicDiseaseFollowUpResult">
<include refid="selectFollowUpVo"/>
<where>
a.del_flag = 0
<if test="chronicDiseaseId != null">and a.chronic_disease_id = #{chronicDiseaseId}</if>
<if test="personId != null">and a.person_id = #{personId}</if>
<if test="followUpType != null">and a.follow_up_type = #{followUpType}</if>
<if test="status != null">and a.status = #{status}</if>
<if test="hospital != null and hospital != ''">and a.hospital like '%' || #{hospital} || '%'</if>
<if test="startTime != null and startTime != ''">and a.follow_up_date &gt;= to_date(#{startTime}, 'YYYY-MM-DD')</if>
<if test="endTime != null and endTime != ''">and a.follow_up_date &lt;= to_date(#{endTime}, 'YYYY-MM-DD')</if>
</where>
${params.dataScope}
order by a.follow_up_date desc, a.create_time desc
</select>
<select id="selectFollowUpById" parameterType="Long" resultMap="ChronicDiseaseFollowUpResult">
<include refid="selectFollowUpVo"/>
where a.id = #{id} and a.del_flag = 0
</select>
<insert id="insertFollowUp" parameterType="ChronicDiseaseFollowUpRecord">
insert into chronic_disease_follow_up_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="chronicDiseaseId != null">chronic_disease_id,</if>
<if test="personId != null">person_id,</if>
<if test="followUpType != null">follow_up_type,</if>
<if test="followUpDate != null">follow_up_date,</if>
<if test="hospital != null">hospital,</if>
<if test="department != null">department,</if>
<if test="doctor != null">doctor,</if>
<if test="checkItems != null">check_items,</if>
<if test="result != null">result,</if>
<if test="nextFollowUpDate != null">next_follow_up_date,</if>
<if test="status != null">status,</if>
<if test="notes != null">notes,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remark != null">remark,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="chronicDiseaseId != null">#{chronicDiseaseId},</if>
<if test="personId != null">#{personId},</if>
<if test="followUpType != null">#{followUpType},</if>
<if test="followUpDate != null">#{followUpDate},</if>
<if test="hospital != null">#{hospital},</if>
<if test="department != null">#{department},</if>
<if test="doctor != null">#{doctor},</if>
<if test="checkItems != null">#{checkItems},</if>
<if test="result != null">#{result},</if>
<if test="nextFollowUpDate != null">#{nextFollowUpDate},</if>
<if test="status != null">#{status},</if>
<if test="notes != null">#{notes},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remark != null">#{remark},</if>
0,
</trim>
</insert>
<update id="updateFollowUp" parameterType="ChronicDiseaseFollowUpRecord">
update chronic_disease_follow_up_record
<set>
<if test="chronicDiseaseId != null">chronic_disease_id = #{chronicDiseaseId},</if>
<if test="personId != null">person_id = #{personId},</if>
<if test="followUpType != null">follow_up_type = #{followUpType},</if>
<if test="followUpDate != null">follow_up_date = #{followUpDate},</if>
<if test="hospital != null">hospital = #{hospital},</if>
<if test="department != null">department = #{department},</if>
<if test="doctor != null">doctor = #{doctor},</if>
<if test="checkItems != null">check_items = #{checkItems},</if>
<if test="result != null">result = #{result},</if>
<if test="nextFollowUpDate != null">next_follow_up_date = #{nextFollowUpDate},</if>
<if test="status != null">status = #{status},</if>
<if test="notes != null">notes = #{notes},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</set>
where id = #{id}
</update>
<update id="removeFollowUpByIds" parameterType="Long">
update chronic_disease_follow_up_record set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
</update>
<sql id="selectStatusHistoryVo">
select a.id, a.chronic_disease_id, a.person_id, a.old_status, a.new_status,
a.change_time, a.reason, a.treatment_advice, a.create_by, a.create_time,
a.update_by, a.update_time, a.remark, a.del_flag
from chronic_disease_status_history a
inner join health_person p on a.person_id = p.id and p.del_flag = '0'
</sql>
<select id="selectStatusHistoryList" parameterType="ChronicDiseaseStatusHistory" resultMap="ChronicDiseaseStatusHistoryResult">
<include refid="selectStatusHistoryVo"/>
<where>
a.del_flag = 0
<if test="chronicDiseaseId != null">and a.chronic_disease_id = #{chronicDiseaseId}</if>
<if test="personId != null">and a.person_id = #{personId}</if>
<if test="oldStatus != null">and a.old_status = #{oldStatus}</if>
<if test="newStatus != null">and a.new_status = #{newStatus}</if>
</where>
${params.dataScope}
order by a.change_time desc, a.create_time desc
</select>
<insert id="insertStatusHistory" parameterType="ChronicDiseaseStatusHistory">
insert into chronic_disease_status_history
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="chronicDiseaseId != null">chronic_disease_id,</if>
<if test="personId != null">person_id,</if>
<if test="oldStatus != null">old_status,</if>
<if test="newStatus != null">new_status,</if>
<if test="changeTime != null">change_time,</if>
<if test="reason != null">reason,</if>
<if test="treatmentAdvice != null">treatment_advice,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="remark != null">remark,</if>
del_flag,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="chronicDiseaseId != null">#{chronicDiseaseId},</if>
<if test="personId != null">#{personId},</if>
<if test="oldStatus != null">#{oldStatus},</if>
<if test="newStatus != null">#{newStatus},</if>
<if test="changeTime != null">#{changeTime},</if>
<if test="reason != null">#{reason},</if>
<if test="treatmentAdvice != null">#{treatmentAdvice},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="remark != null">#{remark},</if>
0,
</trim>
</insert>
</mapper>

View File

@@ -33,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark,
p.name as person_name
from chronic_disease_record a
left join health_person p on a.person_id = p.id
inner join health_person p on a.person_id = p.id and p.del_flag = '0'
</sql>
<select id="selectChronicDiseaseRecordList" parameterType="ChronicDiseaseRecordDto" resultMap="ChronicDiseaseRecordResult">
@@ -164,4 +164,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</update>
</mapper>
</mapper>

View File

@@ -24,10 +24,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="totalCost" column="total_cost" />
<result property="partner" column="partner" />
<result property="costDetail" column="cost_detail" />
<result property="attachment" column="attachment" />
</resultMap>
<sql id="selectHealthActivityVo">
select a.id, a.name, a.type, a.place, a.activity_volume, a.exercise_time, a.start_time, a.end_time, a.harvest, a.foods, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark, a.total_cost, a.partner, a.cost_detail from health_activity a
select a.id, a.name, a.type, a.place, a.activity_volume, a.exercise_time, a.start_time, a.end_time, a.harvest, a.foods, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark, a.total_cost, a.partner, a.cost_detail, a.attachment from health_activity a
</sql>
<select id="selectHealthActivityList" parameterType="HealthActivityDto" resultMap="HealthActivityResult">
@@ -73,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="totalCost != null">total_cost,</if>
<if test="partner != null">partner,</if>
<if test="costDetail != null">cost_detail,</if>
<if test="attachment != null">attachment,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -94,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="totalCost != null">#{totalCost},</if>
<if test="partner != null">#{partner},</if>
<if test="costDetail != null">#{costDetail},</if>
<if test="attachment != null">#{attachment},</if>
</trim>
</insert>
@@ -118,6 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="totalCost != null">total_cost = #{totalCost},</if>
<if test="partner != null">partner = #{partner},</if>
<if test="costDetail != null">cost_detail = #{costDetail},</if>
<if test="attachment != null">attachment = #{attachment},</if>
</trim>
where id = #{id}
</update>

View File

@@ -34,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectHealthDoctorRecordCostVo"/>
<where>
a.del_flag='0'
and exists (select 1 from health_person hp where hp.id = a.person_id and hp.del_flag = '0')
<if test="doctorRecordId != null "> and a.doctor_record_id = #{doctorRecordId}</if>
<if test="type != null and type != ''"> and a.type = #{type}</if>
<if test="healthRecordId != null "> and a.health_record_id = #{healthRecordId}</if>
@@ -47,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHealthDoctorRecordCostById" parameterType="Long" resultMap="HealthDoctorRecordCostResult">
<include refid="selectHealthDoctorRecordCostVo"/>
where a.id = #{id}
and exists (select 1 from health_person hp where hp.id = a.person_id and hp.del_flag = '0')
</select>
<insert id="insertHealthDoctorRecordCost" parameterType="HealthDoctorRecordCost">

View File

@@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="partner" column="partner" />
<result property="costDetail" column="cost_detail" />
<result property="type" column="type" />
<result property="attachment" column="attachment" />
<result property="diagnosis" column="diagnosis" />
</resultMap>
@@ -48,13 +49,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.total_cost,
a.partner,
a.cost_detail,
a.attachment,
a.diagnosis,
hp."name" as person_name ,
hr."name" as health_record_name
from
health_doctor_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on
hr.id = a.health_record_id
</sql>
@@ -108,6 +110,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="partner != null">partner,</if>
<if test="costDetail != null">cost_detail,</if>
<if test="type != null and type != ''">type,</if>
<if test="attachment != null">attachment,</if>
<if test="diagnosis != null and diagnosis != ''">diagnosis,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -129,6 +132,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="partner != null">#{partner},</if>
<if test="costDetail != null">#{costDetail},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="attachment != null">#{attachment},</if>
<if test="diagnosis != null and diagnosis != ''">#{diagnosis},</if>
</trim>
</insert>
@@ -153,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="partner != null">partner = #{partner},</if>
<if test="costDetail != null">cost_detail = #{costDetail},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="attachment != null">attachment = #{attachment},</if>
<if test="diagnosis != null and diagnosis != ''">diagnosis = #{diagnosis},</if>
</trim>
where id = #{id}

View File

@@ -35,8 +35,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hp."name" as person_name
from
health_height_weight_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
</sql>
<select id="selectHealthHeightWeightRecordList" parameterType="HealthHeightWeightRecordDto" resultMap="HealthHeightWeightRecordResult">

View File

@@ -56,8 +56,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hmb.short_name || '-' || hmb.brand || '(' || hmb.packaging || ')' as name
from
health_mar_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on
hr.id = a.health_record_id
left join health_medicine_basic hmb on

View File

@@ -35,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="indications" column="indications" />
<result property="shortName" column="short_name" />
<result property="packageUnit" column="package_unit" />
<result property="attachment" column="attachment" />
</resultMap>
<sql id="selectHealthMedicineBasicVo">
@@ -68,7 +69,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.storage,
a.indications,
a.short_name,
a.package_unit
a.package_unit,
a.attachment
from
health_medicine_basic a
@@ -134,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="indications != null">indications,</if>
<if test="shortName != null">short_name,</if>
<if test="packageUnit != null">package_unit,</if>
<if test="attachment != null">attachment,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -166,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="indications != null">#{indications},</if>
<if test="shortName != null">#{shortName},</if>
<if test="packageUnit != null">#{packageUnit},</if>
<if test="attachment != null">#{attachment},</if>
</trim>
</insert>
@@ -201,6 +205,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="indications != null">indications = #{indications},</if>
<if test="shortName != null">short_name = #{shortName},</if>
<if test="packageUnit != null">package_unit = #{packageUnit},</if>
<if test="attachment != null">attachment = #{attachment},</if>
</trim>
where id = #{id}
</update>

View File

@@ -37,8 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hp."name" as person_name
from
health_milk_powder_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
</sql>

View File

@@ -21,10 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="ranking" column="ranking" />
<result property="sex" column="sex" />
<result property="identityCard" column="identity_card" />
<result property="phone" column="phone" />
</resultMap>
<sql id="selectHealthPersonVo">
select a.id, a.name,a.sex,a.identity_card, a.type, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark, a.birthday, a.nick_name, a.height, a.weight, a.ranking from health_person a
select a.id, a.name, a.sex, a.identity_card, a.phone, a.type, a.create_by, a.create_time, a.update_by, a.update_time, a.del_flag, a.remark, a.birthday, a.nick_name, a.height, a.weight, a.ranking from health_person a
</sql>
<select id="selectHealthPersonList" parameterType="HealthPersonDto" resultMap="HealthPersonResult">
@@ -42,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectHealthPersonById" parameterType="Long" resultMap="HealthPersonResult">
<include refid="selectHealthPersonVo"/>
where a.id = #{id}
where a.id = #{id} and a.del_flag = '0'
</select>
<insert id="insertHealthPerson" parameterType="HealthPerson">
@@ -64,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ranking != null">ranking,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="identityCard != null and identityCard != ''">identity_card,</if>
<if test="phone != null and phone != ''">phone,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -82,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ranking != null">#{ranking},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="identityCard != null and identityCard != ''">#{identityCard},</if>
<if test="phone != null and phone != ''">#{phone},</if>
</trim>
</insert>
@@ -103,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ranking != null">ranking = #{ranking},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="identityCard != null and identityCard != ''">identity_card = #{identityCard},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
</trim>
where id = #{id}
</update>

View File

@@ -38,8 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hr."name" as health_record_name
from
health_process_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on
hr.id = a.health_record_id</sql>

View File

@@ -47,8 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hp."name" as person_name
from
health_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
</sql>
<select id="selectHealthRecordList" parameterType="HealthRecordDto" resultMap="HealthRecordResult">

View File

@@ -37,8 +37,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
hr."name" as health_record_name
from
health_temperature_record a
left join health_person hp on
hp.id = a.person_id
inner join health_person hp on
hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on
hr.id = a.health_record_id
</sql>

View File

@@ -20,12 +20,14 @@
<result property="startDate" column="start_date"/>
<result property="endDate" column="end_date"/>
<result property="remindEnabled" column="remind_enabled"/>
<result property="remindType" column="remind_type"/>
<result property="remindAdvanceMin" column="remind_advance_min"/>
<result property="notifyFamily" column="notify_family"/>
<result property="familyMemberIds" column="family_member_ids" typeHandler="com.intc.common.core.handler.JsonNodeTypeHandler"/>
<result property="status" column="status"/>
<result property="todayTotal" column="today_total"/>
<result property="todayCompleted" column="today_completed"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
</resultMap>
@@ -34,12 +36,12 @@
c.disease_name as chronic_disease_name, a.plan_name, a.medicine_id,
a.medicine_name, a.specification, a.dosage_per_time, a.dosage_unit,
a.frequency_type, a.frequency_config, a.time_slots, a.start_date, a.end_date,
a.remind_enabled, a.remind_advance_min, a.notify_family, a.family_member_ids,
a.status, a.create_time,
a.remind_enabled, a.remind_type, a.remind_advance_min, a.notify_family, a.family_member_ids,
a.status, a.create_by, a.create_time,
(select count(1) from medication_task t where t.plan_id = a.id and t.del_flag = 0 and t.planned_date = current_date) as today_total,
(select count(1) from medication_task t where t.plan_id = a.id and t.del_flag = 0 and t.planned_date = current_date and t.status = 1) as today_completed
from medication_plan a
left join health_person p on a.person_id = p.id
inner join health_person p on a.person_id = p.id and p.del_flag = '0'
left join chronic_disease_record c on a.chronic_disease_id = c.id
</sql>
@@ -93,6 +95,7 @@
<if test="startDate != null">start_date,</if>
<if test="endDate != null">end_date,</if>
<if test="remindEnabled != null">remind_enabled,</if>
<if test="remindType != null">remind_type,</if>
<if test="remindAdvanceMin != null">remind_advance_min,</if>
<if test="notifyFamily != null">notify_family,</if>
<if test="familyMemberIds != null">family_member_ids,</if>
@@ -117,6 +120,7 @@
<if test="startDate != null">#{startDate},</if>
<if test="endDate != null">#{endDate},</if>
<if test="remindEnabled != null">#{remindEnabled},</if>
<if test="remindType != null">#{remindType},</if>
<if test="remindAdvanceMin != null">#{remindAdvanceMin},</if>
<if test="notifyFamily != null">#{notifyFamily},</if>
<if test="familyMemberIds != null">#{familyMemberIds, typeHandler=com.intc.common.core.handler.JsonNodeTypeHandler},</if>
@@ -145,6 +149,7 @@
<if test="startDate != null">start_date = #{startDate},</if>
<if test="endDate != null">end_date = #{endDate},</if>
<if test="remindEnabled != null">remind_enabled = #{remindEnabled},</if>
<if test="remindType != null">remind_type = #{remindType},</if>
<if test="remindAdvanceMin != null">remind_advance_min = #{remindAdvanceMin},</if>
<if test="notifyFamily != null">notify_family = #{notifyFamily},</if>
<if test="familyMemberIds != null">family_member_ids = #{familyMemberIds, typeHandler=com.intc.common.core.handler.JsonNodeTypeHandler},</if>
@@ -173,4 +178,4 @@
update medication_plan set del_flag = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
</update>
</mapper>
</mapper>

View File

@@ -8,6 +8,7 @@
<result property="planName" column="plan_name"/>
<result property="personId" column="person_id"/>
<result property="personName" column="person_name"/>
<result property="personPhone" column="person_phone"/>
<result property="medicineName" column="medicine_name"/>
<result property="plannedDate" column="planned_date"/>
<result property="plannedTime" column="planned_time"/>
@@ -23,13 +24,13 @@
</resultMap>
<sql id="selectVo">
select a.id, a.plan_id, p.plan_name, a.person_id, m.name as person_name,
select a.id, a.plan_id, p.plan_name, a.person_id, m.name as person_name, m.phone as person_phone,
a.medicine_name, a.planned_date, a.planned_time, a.planned_dosage,
a.actual_time, a.actual_dosage, a.status, a.confirm_type, a.notes,
a.remind_status, a.remind_time, a.create_time
from medication_task a
left join medication_plan p on a.plan_id = p.id
left join health_person m on a.person_id = m.id
inner join health_person m on a.person_id = m.id and m.del_flag = '0'
</sql>
<select id="selectById" parameterType="Long" resultMap="MedicationTaskResult">
@@ -118,6 +119,7 @@
<select id="countByPlanAndDate" resultType="int">
select count(1) from medication_task
where del_flag = 0 and plan_id = #{planId} and planned_date = #{date}
and exists (select 1 from health_person hp where hp.id = person_id and hp.del_flag = '0')
</select>
<delete id="deleteByPlanAndDate">
@@ -128,12 +130,14 @@
<select id="countCompletedByPlanAndDate" resultType="int">
select count(1) from medication_task
where del_flag = 0 and plan_id = #{planId} and planned_date = #{date} and status = 1
and exists (select 1 from health_person hp where hp.id = person_id and hp.del_flag = '0')
</select>
<update id="markExpired">
update medication_task
set status = 2, update_time = current_timestamp
where del_flag = 0 and status = 0
and exists (select 1 from health_person hp where hp.id = person_id and hp.del_flag = '0')
and (planned_date || ' ' || planned_time)::timestamp &lt; #{expireThreshold}
</update>
@@ -159,6 +163,7 @@
then 1 else 0 end) as ontime_tasks
from medication_task
where del_flag = 0
and exists (select 1 from health_person hp where hp.id = person_id and hp.del_flag = '0')
<if test="personId != null"> and person_id = #{personId}</if>
<if test="startDate != null"> and planned_date &gt;= #{startDate}</if>
<if test="endDate != null"> and planned_date &lt;= #{endDate}</if>
@@ -176,6 +181,7 @@
then 1 else 0 end) as ontime_tasks
from medication_task
where del_flag = 0
and exists (select 1 from health_person hp where hp.id = person_id and hp.del_flag = '0')
<if test="personId != null"> and person_id = #{personId}</if>
<if test="startDate != null"> and planned_date &gt;= #{startDate}</if>
<if test="endDate != null"> and planned_date &lt;= #{endDate}</if>
@@ -194,10 +200,11 @@
then 1 else 0 end) as ontime_tasks
from medication_task
where del_flag = 0
and exists (select 1 from health_person hp where hp.id = person_id and hp.del_flag = '0')
<if test="personId != null"> and person_id = #{personId}</if>
<if test="startDate != null"> and planned_date &gt;= #{startDate}</if>
<if test="endDate != null"> and planned_date &lt;= #{endDate}</if>
group by extract(hour from planned_time)
order by hour
</select>
</mapper>
</mapper>

View File

@@ -54,12 +54,13 @@
health_mar_record hmr
left join health_medicine_basic hmb on
hmb.id = hmr.medicine_id
left join health_person hp on
hp.id = hmr.person_id
inner join health_person hp on
hp.id = hmr.person_id and hp.del_flag = '0'
left join health_record hr on
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.dosing_time, 'yyyy-MM-dd')
</if>
@@ -92,6 +93,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -112,6 +114,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -133,6 +136,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -155,6 +159,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -180,6 +185,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -204,6 +210,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -225,6 +232,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0' and hmr.temperature>=37
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -241,89 +249,340 @@
<select id="selectStaticPersonList" parameterType="HealthRecordDto" resultType="com.intc.health.domain.vo.HealthStaticPersonVo">
select
hp."name" as personName,
(
select
count(*)
from
health_record hr
where
hr.person_id = hp.id
and hr.del_flag = '0') as healthRecordCount,
(
select
count(distinct hdr.hospital_name)
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as hospitalCount,
(
select
count(distinct hdr.doctor)
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as doctorTotalCount,
(
select
count(*)
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as doctorCount,
(
select
case when sum(hdr.total_cost) is null then 0
else sum(hdr.total_cost)
end
from
health_doctor_record hdr
where
hdr.person_id = hp.id
and hdr.del_flag = '0') as doctorCost,
(
select
count(distinct to_char(hmr.dosing_time, 'yyyy-MM-dd') )
from
health_mar_record hmr
where
hmr.person_id = hp.id
and hmr.del_flag = '0') as marDayCount,
(
select
count(*)
from
health_mar_record hmr
where
hmr.person_id = hp.id
and hmr.del_flag = '0') as marCount,
(
select
count(distinct hmr."medicine_id")
from
health_mar_record hmr
where
hmr.person_id = hp.id
and hmr.del_flag = '0') as marTypeCount,
(
select
count(distinct to_char(hmr.measure_time, 'yyyy-MM-dd') )
from
health_temperature_record hmr
where
hmr.person_id = hp.id
and hmr.temperature >= 37) as feverDayCount
coalesce(hr.healthRecordCount, 0) as healthRecordCount,
coalesce(hdr.hospitalCount, 0) as hospitalCount,
coalesce(hdr.doctorTotalCount, 0) as doctorTotalCount,
coalesce(hdr.doctorCount, 0) as doctorCount,
coalesce(hdr.doctorCost, 0) as doctorCost,
coalesce(hmr.marDayCount, 0) as marDayCount,
coalesce(hmr.marCount, 0) as marCount,
coalesce(hmr.marTypeCount, 0) as marTypeCount,
coalesce(htr.feverDayCount, 0) as feverDayCount
from
health_person hp
where 1=1
left join (
select
person_id,
count(*) as healthRecordCount
from health_record
where del_flag = '0'
group by person_id
) hr on hr.person_id = hp.id
left join (
select
person_id,
count(distinct hospital_name) as hospitalCount,
count(distinct doctor) as doctorTotalCount,
count(*) as doctorCount,
coalesce(sum(total_cost), 0) as doctorCost
from health_doctor_record
where del_flag = '0'
group by person_id
) hdr on hdr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(dosing_time, 'yyyy-MM-dd')) as marDayCount,
count(*) as marCount,
count(distinct medicine_id) as marTypeCount
from health_mar_record
where del_flag = '0'
group by person_id
) hmr on hmr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(measure_time, 'yyyy-MM-dd')) as feverDayCount
from health_temperature_record
where del_flag = '0'
and temperature >= 37
group by person_id
) htr on htr.person_id = hp.id
where hp.del_flag = '0'
<if test="personId != null "> and hp.id = #{personId}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by hp.ranking
</select>
<select id="selectHealthScreenDoctorSummary" parameterType="HealthDoctorRecordDto" resultType="java.util.HashMap">
select
count(*) as "doctorCount",
coalesce(sum(a.total_cost), 0) as "doctorCost",
count(distinct a.hospital_name) as "hospitalCount",
count(distinct a.doctor) as "doctorTotalCount"
from health_doctor_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.visiting_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.visiting_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenPersonRankList" parameterType="HealthRecordDto" resultType="com.intc.health.domain.vo.HealthStaticPersonVo">
select
hp."name" as personName,
coalesce(hr.healthRecordCount, 0) as healthRecordCount,
coalesce(hdr.hospitalCount, 0) as hospitalCount,
coalesce(hdr.doctorTotalCount, 0) as doctorTotalCount,
coalesce(hdr.doctorCount, 0) as doctorCount,
coalesce(hdr.doctorCost, 0) as doctorCost,
coalesce(hmr.marDayCount, 0) as marDayCount,
coalesce(hmr.marCount, 0) as marCount,
coalesce(hmr.marTypeCount, 0) as marTypeCount,
coalesce(htr.feverDayCount, 0) as feverDayCount
from health_person hp
left join (
select person_id, count(*) as healthRecordCount
from health_record
where del_flag = '0'
group by person_id
) hr on hr.person_id = hp.id
left join (
select
person_id,
count(distinct hospital_name) as hospitalCount,
count(distinct doctor) as doctorTotalCount,
count(*) as doctorCount,
coalesce(sum(total_cost), 0) as doctorCost
from health_doctor_record
where del_flag = '0'
group by person_id
) hdr on hdr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(dosing_time, 'yyyy-MM-dd')) as marDayCount,
count(*) as marCount,
count(distinct medicine_id) as marTypeCount
from health_mar_record
where del_flag = '0'
group by person_id
) hmr on hmr.person_id = hp.id
left join (
select
person_id,
count(distinct to_char(measure_time, 'yyyy-MM-dd')) as feverDayCount
from health_temperature_record
where del_flag = '0'
and temperature >= 37
group by person_id
) htr on htr.person_id = hp.id
where hp.del_flag = '0'
<if test="personId != null "> and hp.id = #{personId}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by
(
least(round(coalesce(htr.feverDayCount, 0) * 1.2), 35)
+ least(round(coalesce(hdr.doctorCount, 0) * 2.5), 30)
+ least(round(coalesce(hmr.marCount, 0) * 0.15), 12)
+ least(coalesce(hr.healthRecordCount, 0) * 2, 10)
+ least(round(coalesce(hdr.doctorCost, 0) / 1000), 13)
) desc,
hp.ranking
limit 12
</select>
<select id="selectHealthScreenMedicineSummary" parameterType="HealthMarRecordDto" resultType="java.util.HashMap">
select
count(*) as "marCount",
count(distinct a.medicine_id) as "medicalTypeCount",
count(distinct to_char(a.dosing_time, 'yyyy-MM-dd')) as "marDayCount"
from health_mar_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.dosing_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.dosing_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null and healthRecordId != ''"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenTemperatureSummary" parameterType="HealthTemperatureRecordDto" resultType="java.util.HashMap">
select
count(*) as "temperatureTotalCount",
count(case when a.temperature &lt; 36.9 then 1 end) as "normalTempCount",
count(case when a.temperature &gt;= 36.9 and a.temperature &lt;= 37.5 then 1 end) as "lowerTempCount",
count(case when a.temperature &gt; 37.5 and a.temperature &lt; 38.5 then 1 end) as "middleTempCount",
count(case when a.temperature &gt;= 38.5 then 1 end) as "higherTempCount",
count(distinct case when a.temperature &gt;= 37 then to_char(a.measure_time, 'yyyy-MM-dd') end) as "feverDayCount"
from health_temperature_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.measure_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.measure_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null "> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenActivitySummary" parameterType="HealthActivityDto" resultType="java.util.HashMap">
select
count(*) as "activityCount",
coalesce(sum(a.total_cost), 0) as "activityCost"
from health_activity a
<where>
a.del_flag = '0'
<if test="endTime != null "> and a.start_time &lt;= #{endTime}</if>
<if test="startTime != null "> and a.start_time &gt;= #{startTime}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
</select>
<select id="selectHealthScreenActivityList" parameterType="HealthActivityDto" resultType="com.intc.health.domain.vo.HealthActivityVo">
select
a.id,
a.name,
a.type,
a.place,
a.activity_volume as activityVolume,
a.exercise_time as exerciseTime,
a.start_time as startTime,
a.end_time as endTime,
a.harvest,
a.foods,
a.total_cost as totalCost,
a.partner,
a.cost_detail as costDetail
from health_activity a
<where>
a.del_flag = '0'
<if test="endTime != null "> and a.start_time &lt;= #{endTime}</if>
<if test="startTime != null "> and a.start_time &gt;= #{startTime}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.start_time desc
limit 50
</select>
<select id="selectHealthScreenDoctorList" parameterType="HealthDoctorRecordDto" resultType="com.intc.health.domain.vo.HealthDoctorRecordVo">
select
a.id,
a.hospital_name as hospitalName,
a.departments,
a.doctor,
a.type,
a.health_record_id as healthRecordId,
a.visiting_time as visitingTime,
a.prescribe,
a.diagnosis,
a.person_id as personId,
a.total_cost as totalCost,
hp."name" as personName,
hr."name" as healthRecordName
from health_doctor_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on hr.id = a.health_record_id
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.visiting_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.visiting_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.visiting_time desc
limit 50
</select>
<select id="selectHealthScreenMedicineList" parameterType="HealthMarRecordDto" resultType="com.intc.health.domain.vo.HealthMarRecordVo">
select
a.id,
a.type,
a.health_record_id as healthRecordId,
a.dosing_time as dosingTime,
a.dosage,
a.person_id as personId,
a.resource,
a.place,
a.medicine_id as medicineId,
a.unit,
a.content,
a.content_unit as contentUnit,
hp."name" as personName,
hr."name" as healthRecordName,
hmb.short_name || '-' || hmb.brand || '(' || hmb.packaging || ')' as name
from health_mar_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on hr.id = a.health_record_id
left join health_medicine_basic hmb on hmb.id = a.medicine_id
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.dosing_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.dosing_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null and healthRecordId != ''"> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.dosing_time desc
limit 50
</select>
<select id="selectHealthScreenTemperatureList" parameterType="HealthTemperatureRecordDto" resultType="com.intc.health.domain.vo.HealthTemperatureRecordVo">
select
a.id,
a.health_record_id as healthRecordId,
a.measure_time as measureTime,
a.temperature,
a.person_id as personId,
hp."name" as personName,
hr."name" as healthRecordName
from health_temperature_record a
inner join health_person hp on hp.id = a.person_id and hp.del_flag = '0'
left join health_record hr on hr.id = a.health_record_id
<where>
a.del_flag = '0'
<if test="endTime!=null and endTime !=''">
and a.measure_time &lt;= to_date(#{endTime}, 'yyyy-MM-dd') + interval '1 day' - interval '1 second'
</if>
<if test="startTime!=null and startTime !=''">
and a.measure_time &gt;= to_date(#{startTime}, 'yyyy-MM-dd')
</if>
<if test="healthRecordId != null "> and a.health_record_id = #{healthRecordId}</if>
<if test="personId != null "> and a.person_id = #{personId}</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by a.measure_time desc
limit 1000
</select>
<select id="selectHealthRecordCostList" parameterType="HealthRecordDto" resultType="com.intc.health.domain.vo.HealthRecordVo">
select
(
@@ -344,6 +603,7 @@
health_record hr
<where>
hr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -445,6 +705,7 @@
<where>
hr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -469,6 +730,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -490,6 +752,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -511,6 +774,7 @@
left join health_record hr on hr.id=hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hr.occur_time, 'yyyy-MM-dd')
</if>
@@ -534,6 +798,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.visiting_time, 'yyyy-MM-dd')
</if>
@@ -560,6 +825,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.visiting_time, 'yyyy-MM-dd')
</if>
@@ -585,6 +851,7 @@
hr.id = hmr.health_record_id
<where>
hmr.del_flag = '0'
and exists (select 1 from health_person hp where hp.id = hmr.person_id and hp.del_flag = '0')
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmr.visiting_time, 'yyyy-MM-dd')
</if>
@@ -804,6 +1071,7 @@
from
health_milk_powder_record hmpr
where hmpr.del_flag ='0'
and exists (select 1 from health_person hp where hp.id = hmpr.person_id and hp.del_flag = '0')
<if test="personId != null "> and hmpr.person_id = #{personId}</if>
<if test="endTime!=null and endTime !=''">
and #{endTime}>=to_char(hmpr.suckles_time, 'yyyy-MM-dd')
@@ -820,4 +1088,4 @@
to_char(hmpr.suckles_time,
'yyyy-MM-dd') desc
</select>
</mapper>
</mapper>

View File

@@ -3,9 +3,12 @@ package com.intc.invest.controller;
import com.intc.common.core.web.controller.BaseController;
import com.intc.common.core.web.domain.AjaxResult;
import com.intc.common.core.web.page.TableDataInfo;
import com.intc.invest.domain.dto.AccountDealLocationDto;
import com.intc.invest.domain.dto.AccountsDto;
import com.intc.invest.domain.dto.AnalysisDto;
import com.intc.invest.domain.vo.AccountCalendarVo;
import com.intc.invest.domain.vo.AccountDealLocationVo;
import com.intc.invest.domain.vo.AccountsDealRecordVo;
import com.intc.invest.domain.vo.AccountsVo;
import com.intc.invest.domain.vo.BankCardStatisticsVo;
import com.intc.invest.domain.vo.OpenCardVo;
@@ -209,4 +212,36 @@ public class StatisticAnalysisController extends BaseController {
return AjaxResult.success(list);
}
/**
* 查询交易地点消费地图概览
*/
@ApiOperation(value="查询交易地点消费地图概览")
@GetMapping("/accountDealLocationOverview")
public AjaxResult getAccountDealLocationOverview(AccountDealLocationDto accountDealLocationDto)
{
return AjaxResult.success(iStatisticAnalysisService.getAccountDealLocationOverview(accountDealLocationDto));
}
/**
* 查询交易地点消费地图聚合点位
*/
@ApiOperation(value="查询交易地点消费地图聚合点位",response = AccountDealLocationVo.class)
@GetMapping("/accountDealLocationPoints")
public AjaxResult getAccountDealLocationPoints(AccountDealLocationDto accountDealLocationDto)
{
List<AccountDealLocationVo> list = iStatisticAnalysisService.getAccountDealLocationPoints(accountDealLocationDto);
return AjaxResult.success(list);
}
/**
* 查询交易地点消费明细
*/
@ApiOperation(value="查询交易地点消费明细",response = AccountsDealRecordVo.class)
@GetMapping("/accountDealLocationRecords")
public AjaxResult getAccountDealLocationRecords(AccountDealLocationDto accountDealLocationDto)
{
List<AccountsDealRecordVo> list = iStatisticAnalysisService.getAccountDealLocationRecords(accountDealLocationDto);
return AjaxResult.success(list);
}
}

View File

@@ -74,6 +74,26 @@ public class AccountsDealRecord extends BaseEntity
@Excel(name = "交易子类别")
private String childCategory;
/** 地点名称 */
@ApiModelProperty(value="地点名称")
@Excel(name = "地点名称")
private String locationName;
/** 地点地址 */
@ApiModelProperty(value="地点地址")
@Excel(name = "地点地址")
private String locationAddress;
/** 经度 */
@ApiModelProperty(value="经度")
@Excel(name = "经度")
private Double longitude;
/** 纬度 */
@ApiModelProperty(value="纬度")
@Excel(name = "纬度")
private Double latitude;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -93,6 +113,10 @@ public class AccountsDealRecord extends BaseEntity
.append("transferRecordId", getTransferRecordId())
.append("currentBalance", getCurrentBalance())
.append("childCategory", getChildCategory())
.append("locationName", getLocationName())
.append("locationAddress", getLocationAddress())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.toString();
}
}

View File

@@ -0,0 +1,60 @@
package com.intc.invest.domain.dto;
import com.intc.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 交易地点消费地图查询对象
*
* @author tianyongbao
*/
@ApiModel("交易地点消费地图查询对象")
@Data
public class AccountDealLocationDto extends BaseEntity implements Serializable
{
private static final long serialVersionUID = 1L;
/** 开始日期 */
@ApiModelProperty(value="开始日期")
private String startTime;
/** 结束日期 */
@ApiModelProperty(value="结束日期")
private String endTime;
/** 账户 */
@ApiModelProperty(value="账户")
private Long accountId;
/** 交易类型 */
@ApiModelProperty(value="交易类型")
private String dealType;
/** 交易类别 */
@ApiModelProperty(value="交易类别")
private String dealCategory;
/** 交易子类别 */
@ApiModelProperty(value="交易子类别")
private String childCategory;
/** 地点名称 */
@ApiModelProperty(value="地点名称")
private String locationName;
/** 地点地址 */
@ApiModelProperty(value="地点地址")
private String locationAddress;
/** 经度 */
@ApiModelProperty(value="经度")
private Double longitude;
/** 纬度 */
@ApiModelProperty(value="纬度")
private Double latitude;
}

View File

@@ -0,0 +1,47 @@
package com.intc.invest.domain.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
/**
* 交易地点消费地图聚合对象
*
* @author tianyongbao
*/
@ApiModel("交易地点消费地图聚合对象")
@Data
public class AccountDealLocationVo
{
/** 地点聚合键 */
private String locationKey;
/** 地点名称 */
private String locationName;
/** 地点地址 */
private String locationAddress;
/** 经度 */
private Double longitude;
/** 纬度 */
private Double latitude;
/** 消费金额 */
private Double totalAmount;
/** 交易笔数 */
private Long dealCount;
/** 最近交易时间 */
private String latestTime;
/** 关联账户 */
private String accountNames;
/** 交易类别 */
private String dealCategory;
/** 交易子类别 */
private String childCategory;
}

View File

@@ -1,6 +1,7 @@
package com.intc.invest.mapper;
import com.intc.common.datascope.annotation.DataScope;
import com.intc.invest.domain.dto.AccountDealLocationDto;
import com.intc.invest.domain.dto.AccountsDealRecordDto;
import com.intc.invest.domain.dto.AccountsDto;
import com.intc.invest.domain.dto.BankCardLendDto;
@@ -122,4 +123,22 @@ public interface StatisticAnalysisMapper {
@DataScope(businessAlias = "a")
public List<BankCardStatisticsVo> selectBankCardStatistics(AccountsDto accountsDto);
/**
* 查询交易地点消费地图聚合点位
*
* @param accountDealLocationDto 查询条件
* @return 地点聚合点位集合
*/
@DataScope(businessAlias = "a")
public List<AccountDealLocationVo> selectAccountDealLocationPoints(AccountDealLocationDto accountDealLocationDto);
/**
* 查询交易地点消费明细
*
* @param accountDealLocationDto 查询条件
* @return 交易明细集合
*/
@DataScope(businessAlias = "a")
public List<AccountsDealRecordVo> selectAccountDealLocationRecords(AccountDealLocationDto accountDealLocationDto);
}

View File

@@ -1,8 +1,11 @@
package com.intc.invest.service;
import com.intc.invest.domain.dto.AccountDealLocationDto;
import com.intc.invest.domain.dto.AccountsDto;
import com.intc.invest.domain.dto.AnalysisDto;
import com.intc.invest.domain.vo.AccountCalendarVo;
import com.intc.invest.domain.vo.AccountDealLocationVo;
import com.intc.invest.domain.vo.AccountsDealRecordVo;
import com.intc.invest.domain.vo.AccountsVo;
import com.intc.invest.domain.vo.BankCardStatisticsVo;
import com.intc.invest.domain.vo.CreditReportAnalysisVO;
@@ -78,4 +81,28 @@ public interface IStatisticAnalysisService {
*/
public List<BankCardStatisticsVo> getBankCardStatistics();
/**
* 查询交易地点消费地图概览
*
* @param accountDealLocationDto 查询条件
* @return 概览数据
*/
public Map<String, Object> getAccountDealLocationOverview(AccountDealLocationDto accountDealLocationDto);
/**
* 查询交易地点消费地图聚合点位
*
* @param accountDealLocationDto 查询条件
* @return 地点聚合点位集合
*/
public List<AccountDealLocationVo> getAccountDealLocationPoints(AccountDealLocationDto accountDealLocationDto);
/**
* 查询交易地点消费明细
*
* @param accountDealLocationDto 查询条件
* @return 交易明细集合
*/
public List<AccountsDealRecordVo> getAccountDealLocationRecords(AccountDealLocationDto accountDealLocationDto);
}

View File

@@ -3429,4 +3429,71 @@ public class StatisticAnalysisImpl implements IStatisticAnalysisService {
public List<BankCardStatisticsVo> getBankCardStatistics() {
return statisticAnalysisMapper.selectBankCardStatistics(new AccountsDto());
}
@Override
public Map<String, Object> getAccountDealLocationOverview(AccountDealLocationDto accountDealLocationDto) {
if (accountDealLocationDto == null) {
accountDealLocationDto = new AccountDealLocationDto();
}
List<AccountDealLocationVo> locationList = getAccountDealLocationPoints(accountDealLocationDto);
double totalAmount = 0;
long dealCount = 0;
double maxAmount = 0;
String latestTime = "";
for (AccountDealLocationVo vo : locationList) {
double amount = vo.getTotalAmount() == null ? 0 : vo.getTotalAmount();
totalAmount += amount;
dealCount += vo.getDealCount() == null ? 0 : vo.getDealCount();
if (amount > maxAmount) {
maxAmount = amount;
}
if (StringUtils.isNotEmpty(vo.getLatestTime()) && (StringUtils.isEmpty(latestTime) || vo.getLatestTime().compareTo(latestTime) > 0)) {
latestTime = vo.getLatestTime();
}
}
HashMap<String, Object> map = new HashMap<>();
map.put("totalAmount", totalAmount);
map.put("dealCount", dealCount);
map.put("locationCount", locationList.size());
map.put("maxAmount", maxAmount);
map.put("latestTime", latestTime);
map.put("topLocations", locationList.stream().limit(10).collect(Collectors.toList()));
return map;
}
@Override
public List<AccountDealLocationVo> getAccountDealLocationPoints(AccountDealLocationDto accountDealLocationDto) {
if (accountDealLocationDto == null) {
accountDealLocationDto = new AccountDealLocationDto();
}
initAccountDealLocationDefaultQuery(accountDealLocationDto);
return statisticAnalysisMapper.selectAccountDealLocationPoints(accountDealLocationDto);
}
@Override
public List<AccountsDealRecordVo> getAccountDealLocationRecords(AccountDealLocationDto accountDealLocationDto) {
if (accountDealLocationDto == null) {
accountDealLocationDto = new AccountDealLocationDto();
}
initAccountDealLocationDefaultQuery(accountDealLocationDto);
List<AccountsDealRecordVo> list = statisticAnalysisMapper.selectAccountDealLocationRecords(accountDealLocationDto);
for (AccountsDealRecordVo vo : list) {
if (StringUtils.isNotEmpty(vo.getDealCategory())) {
vo.setDealCategoryName(DictUtils.getDictLabel("deal_category", vo.getDealCategory()));
}
if (StringUtils.isNotEmpty(vo.getChildCategory()) && "1".equals(vo.getDealCategory())) {
vo.setChildCategoryName(DictUtils.getDictLabel("daily_expenses", vo.getChildCategory()));
}
}
return list;
}
private void initAccountDealLocationDefaultQuery(AccountDealLocationDto accountDealLocationDto) {
if (accountDealLocationDto != null && StringUtils.isEmpty(accountDealLocationDto.getDealType())) {
accountDealLocationDto.setDealType("2");
}
}
}

View File

@@ -22,6 +22,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="transferRecordId" column="transfer_record_id" />
<result property="currentBalance" column="current_balance" />
<result property="childCategory" column="child_category" />
<result property="locationName" column="location_name" />
<result property="locationAddress" column="location_address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
</resultMap>
<sql id="selectAccountsDealRecordVo">
@@ -42,6 +46,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.deal_category,
a.current_balance,
a.child_category,
a.location_name,
a.location_address,
a.longitude,
a.latitude,
CONCAT(a2."name", '', right(a2.code, 4), '') as account_name
from
accounts_deal_record a
@@ -106,6 +114,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="transferRecordId != null and transferRecordId != ''">transfer_record_id,</if>
<if test="currentBalance != null">current_balance,</if>
<if test="childCategory != null">child_category,</if>
<if test="locationName != null">location_name,</if>
<if test="locationAddress != null">location_address,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
@@ -124,6 +136,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="transferRecordId != null and transferRecordId != ''">#{transferRecordId},</if>
<if test="currentBalance != null">#{currentBalance},</if>
<if test="childCategory != null">#{childCategory},</if>
<if test="locationName != null">#{locationName},</if>
<if test="locationAddress != null">#{locationAddress},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
</trim>
</insert>
@@ -145,6 +161,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="transferRecordId != null and transferRecordId != ''">transfer_record_id = #{transferRecordId},</if>
<if test="currentBalance != null ">current_balance = #{currentBalance},</if>
<if test="childCategory != null ">child_category = #{childCategory},</if>
<if test="locationName != null">location_name = #{locationName},</if>
<if test="locationAddress != null">location_address = #{locationAddress},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
</trim>
where id = #{id}
</update>

View File

@@ -68,6 +68,22 @@
<result property="transferRecordId" column="transfer_record_id" />
<result property="currentBalance" column="current_balance" />
<result property="childCategory" column="child_category" />
<result property="locationName" column="location_name" />
<result property="locationAddress" column="location_address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
</resultMap>
<resultMap type="AccountDealLocationVo" id="AccountDealLocationResult">
<result property="locationKey" column="location_key" />
<result property="locationName" column="location_name" />
<result property="locationAddress" column="location_address" />
<result property="longitude" column="longitude" />
<result property="latitude" column="latitude" />
<result property="totalAmount" column="total_amount" />
<result property="dealCount" column="deal_count" />
<result property="latestTime" column="latest_time" />
<result property="accountNames" column="account_names" />
</resultMap>
<select id="selectAccountsOutInList" parameterType="AccountsDealRecordDto" resultMap="AccountsDealRecordResult">
@@ -1026,4 +1042,102 @@
b.bank_name
</select>
</mapper>
<sql id="accountDealLocationWhere">
a.del_flag = '0'
and a.longitude is not null
and a.latitude is not null
<if test="endTime != null and endTime != ''">
and #{endTime} &gt;= to_char(a.create_time, 'yyyy-MM-dd')
</if>
<if test="startTime != null and startTime != ''">
and to_char(a.create_time, 'yyyy-MM-dd') &gt;= #{startTime}
</if>
<if test="accountId != null">
and a.account_id = #{accountId}
</if>
<if test="dealType != null and dealType != ''">
and a.deal_type = #{dealType}
</if>
<if test="dealCategory != null and dealCategory != ''">
and a.deal_category = #{dealCategory}
</if>
<if test="childCategory != null and childCategory != ''">
and a.child_category = #{childCategory}
</if>
<if test="locationName != null and locationName != ''">
and a.location_name like '%' || #{locationName} || '%'
</if>
<if test="locationAddress != null and locationAddress != ''">
and a.location_address like '%' || #{locationAddress} || '%'
</if>
</sql>
<select id="selectAccountDealLocationPoints" parameterType="AccountDealLocationDto" resultMap="AccountDealLocationResult">
select
concat(round(a.longitude::numeric, 5), '_', round(a.latitude::numeric, 5)) as location_key,
COALESCE(NULLIF(max(a.location_name), ''), NULLIF(max(a.location_address), ''), concat(round(a.longitude::numeric, 5), ',', round(a.latitude::numeric, 5))) as location_name,
max(a.location_address) as location_address,
round(a.longitude::numeric, 5)::float8 as longitude,
round(a.latitude::numeric, 5)::float8 as latitude,
COALESCE(sum(a.amount), 0) as total_amount,
count(1) as deal_count,
to_char(max(a.create_time), 'yyyy-MM-dd HH24:mi:ss') as latest_time,
string_agg(distinct COALESCE(ac."name", ''), '、') as account_names
from
accounts_deal_record a
left join accounts ac on ac.id = a.account_id
<where>
<include refid="accountDealLocationWhere"/>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
group by
round(a.longitude::numeric, 5),
round(a.latitude::numeric, 5)
order by
sum(a.amount) desc
</select>
<select id="selectAccountDealLocationRecords" parameterType="AccountDealLocationDto" resultMap="AccountsDealRecordResult">
select
a.id,
a.name,
a.type,
a.account_id,
a.amount,
a.transfer_record_id,
a.deal_type,
a.create_by,
a.create_time,
a.update_by,
a.update_time,
a.del_flag,
a.remark,
a.deal_category,
a.current_balance,
a.child_category,
a.location_name,
a.location_address,
a.longitude,
a.latitude,
CONCAT(ac."name", '', right(ac.code, 4), '') as account_name
from
accounts_deal_record a
left join accounts ac on ac.id = a.account_id
<where>
<include refid="accountDealLocationWhere"/>
<if test="longitude != null">
and round(a.longitude::numeric, 5) = round(CAST(#{longitude} AS numeric), 5)
</if>
<if test="latitude != null">
and round(a.latitude::numeric, 5) = round(CAST(#{latitude} AS numeric), 5)
</if>
</where>
<!-- 数据范围过滤 -->
${params.dataScope}
order by
a.create_time desc
limit 100
</select>
</mapper>

View File

@@ -216,6 +216,13 @@
<artifactId>intc-api-system</artifactId>
<version>${intc.version}</version>
</dependency>
<!-- 消息服务 -->
<dependency>
<groupId>com.intc</groupId>
<artifactId>intc-common-message</artifactId>
<version>${intc.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

View File

@@ -0,0 +1,32 @@
# 阿里云消息服务配置示例在Nacos配置中心添加
# 配置项intc-health-dev.yml 或独立配置文件
aliyun:
message:
# 阿里云 AccessKey请替换为实际值
accessKeyId: ${ALIYUN_ACCESS_KEY_ID:your-access-key-id}
accessKeySecret: ${ALIYUN_ACCESS_KEY_SECRET:your-access-key-secret}
# 短信配置
sms:
signName: 智聪健康
# 用药提醒短信模板CODE需要在阿里云短信服务中申请
medicationRemindTemplateCode: SMS_123456789
# 漏服提醒短信模板CODE
missedRemindTemplateCode: SMS_123456790
# 家属通知短信模板CODE
familyNotifyTemplateCode: SMS_123456791
# 语音配置
voice:
# 用药提醒语音模板CODE需要在阿里云语音服务中申请
medicationRemindTtsCode: TTS_123456789
# 漏服提醒语音模板CODE
missedRemindTtsCode: TTS_123456790
# 被叫号码显示的呼入号码(需要在阿里云购买号码)
calledShowNumber: 4001234567
# 短信模板示例(在阿里云申请时使用):
# 用药提醒模板:您好,${name}请在${time}服用${medicine},请按时服药保持健康。
# 漏服提醒模板:您好,${name}未在${time}服用${medicine},请尽快补服或咨询医生。
# 家属通知模板:您好,${name}超时未服用${medicine}(计划时间${time}),请关注提醒。

View File

@@ -0,0 +1,16 @@
-- 用药提醒功能更新SQL
-- 1. 给health_person添加phone字段
-- 2. 给medication_plan添加remind_type字段
-- 1. health_person表添加phone字段
ALTER TABLE health_person ADD COLUMN IF NOT EXISTS phone VARCHAR(20);
COMMENT ON COLUMN health_person.phone IS '手机号';
-- 2. medication_plan表添加remind_type字段
ALTER TABLE medication_plan ADD COLUMN IF NOT EXISTS remind_type INTEGER DEFAULT 1;
COMMENT ON COLUMN medication_plan.remind_type IS '提醒方式1-短信 2-电话 3-短信+电话';
-- 更新已有数据,默认提醒方式为短信
UPDATE medication_plan SET remind_type = 1 WHERE remind_type IS NULL AND remind_enabled = 1;