From c0988ce95ab6a518aefe843d9cfd84d1515cdc00 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 15 十月 2026 16:18:40 +0800
Subject: [PATCH] 【丽水】1. /smartor/serviceSubtask/getCurrentUserServiceSubtaskCount工作台里加即将超时数量字段 2. /smartor/serviceSubtask/querySubtaskList 给一个列表可以查询多少小时(可选)即将超时的随访服务,如:48小时内即将超时任务(今天15号10.40到17号10.40这段时间会到达超时时间的任务)
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java | 9 ++
smartor/src/main/java/com/smartor/domain/entity/ServiceSubtaskEntity.java | 12 ++++
smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java | 4 +
smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java | 7 ++
smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 87 +++++++++++++++++++++++++---
smartor/src/main/java/com/smartor/domain/VO/ServiceSubtaskVO.java | 12 ++++
6 files changed, 119 insertions(+), 12 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
index ed1b0f0..fc2156a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java
@@ -833,17 +833,20 @@
}
/**
- * 缁熻浠诲姟鍚勭鐘舵�佺殑鏁伴噺锛堜紭鍖栫増锛�
+ * 缁熻浠诲姟鍚勭鐘舵�佺殑鏁伴噺锛堜紭鍖栫増锛�-銆愰殢璁垮伐浣滃彴銆�
*
+ * @param soonTimeoutHours 鍗冲皢瓒呮椂鏃堕棿锛堝皬鏃讹級锛岄粯璁� 48
* @return Map<String, Object> 鍖呭惈鍚勭姸鎬佺粺璁℃暟鎹�
* pendingVisitCount: 褰撳墠鐧诲綍浜烘埅姝粖鏃ュ緟闅忚鎬婚噺
* failedVisitCount: 褰撳墠鐧诲綍浜洪殢璁夸换鍔″け璐ユ�婚噺
* abnormalVisitVount: 褰撳墠鐧诲綍浜洪殢璁夸换鍔″紓甯告�婚噺
* allVisitCount: 褰撳墠鐧诲綍浜洪殢璁夸换鍔℃�婚噺
+ * soonTimeoutCount: 褰撳墠鐧诲綍浜哄嵆灏嗚秴鏃舵暟閲忥紙瓒呮椂鎴鏃堕棿鍦� soonTimeoutHours 灏忔椂鍐咃級
*/
@ApiOperation("鑾峰彇褰撳墠鐢ㄦ埛闅忚鏁伴噺缁熻")
@PostMapping("/getCurrentUserServiceSubtaskCount")
- public Map<String, Object> getCurrentUserServiceSubtaskCount() {
+ public Map<String, Object> getCurrentUserServiceSubtaskCount(
+ @RequestParam(value = "soonTimeoutHours", required = false, defaultValue = "48") Integer soonTimeoutHours) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser == null || loginUser.getUser() == null) {
return new HashMap<>();
@@ -863,6 +866,7 @@
entity.setOrgid(sysUser.getOrgid());
entity.setLeaveldeptcodes(deptCodes);
entity.setLeavehospitaldistrictcodes(wardCodes);
+ entity.setSoonTimeoutHours(soonTimeoutHours);
// admin 鏌ョ湅鍏ㄩ櫌锛涢潪 admin 鍙閰嶇疆浜嗙瀹ゆ垨鐥呭尯浠讳竴缁村害鍗冲彲鏌ヨ锛圫QL 涓负 OR 鍏崇郴锛�
boolean isAdmin = "admin".equals(sysUser.getUserName());
if (isAdmin || CollectionUtils.isNotEmpty(deptCodes) || CollectionUtils.isNotEmpty(wardCodes)) {
@@ -875,6 +879,7 @@
empty.put("abnormalVisitCount", 0);
empty.put("warnningVisitCount", 0);
empty.put("allVisitCount", 0);
+ empty.put("soonTimeoutCount", 0);
return empty;
}
diff --git a/smartor/src/main/java/com/smartor/domain/VO/ServiceSubtaskVO.java b/smartor/src/main/java/com/smartor/domain/VO/ServiceSubtaskVO.java
index 4080fd1..6dfd9ef 100644
--- a/smartor/src/main/java/com/smartor/domain/VO/ServiceSubtaskVO.java
+++ b/smartor/src/main/java/com/smartor/domain/VO/ServiceSubtaskVO.java
@@ -806,6 +806,18 @@
@ApiModelProperty(value = "椤甸潰灞曠ず鐘舵�� 锛�1锛氬緟闅忚锛�2 寰呭彂閫侊級锛�2锛氶殢璁夸腑锛�3 宸插彂閫併��1 琚鍙栵級銆�3锛氭湭瀹屾垚锛�5 鍙戦�佸け璐ャ��7銆佽秴鏃讹級銆�4锛氬凡瀹屾垚锛� 6 宸插畬鎴愶級銆�5锛氭棤闇�闅忚锛�4 涓嶆墽琛岋級")
private Long sendstateView;
+ /**
+ * 鏄惁鍗冲皢瓒呮椂锛�1 鏄紙閰嶅悎 soonTimeoutHours 浣跨敤锛岀敤浜庢煡璇㈠嵆灏嗚秴鏃跺垪琛級
+ */
+ @ApiModelProperty(value = "鏄惁鍗冲皢瓒呮椂:1鏄�")
+ private Integer soonTimeout;
+
+ /**
+ * 鍗冲皢瓒呮椂鏃堕棿锛堝皬鏃讹級锛氭埅姝㈡椂闂村湪 N 灏忔椂鍐�
+ */
+ @ApiModelProperty(value = "鍗冲皢瓒呮椂鏃堕棿(灏忔椂)")
+ private Integer soonTimeoutHours;
+
// /**
// * 鏃ユ湡闄愬埗 鐩墠鐢卞墠绔帶鍒�
// */
diff --git a/smartor/src/main/java/com/smartor/domain/entity/ServiceSubtaskEntity.java b/smartor/src/main/java/com/smartor/domain/entity/ServiceSubtaskEntity.java
index 90041b1..099a021 100644
--- a/smartor/src/main/java/com/smartor/domain/entity/ServiceSubtaskEntity.java
+++ b/smartor/src/main/java/com/smartor/domain/entity/ServiceSubtaskEntity.java
@@ -114,6 +114,18 @@
private Integer rateDay;
/**
+ * 鏄惁鍗冲皢瓒呮椂锛�1 鏄紙閰嶅悎 soonTimeoutHours 浣跨敤锛�
+ */
+ @ApiModelProperty(value = "鏄惁鍗冲皢瓒呮椂:1鏄�")
+ private Integer soonTimeout;
+
+ /**
+ * 鍗冲皢瓒呮椂鏃堕棿锛堝皬鏃讹級锛氱粺璁¤窛瓒呮椂鎴鏃堕棿鍦� N 灏忔椂鍐呯殑寰呴殢璁挎暟閲�
+ */
+ @ApiModelProperty(value = "鍗冲皢瓒呮椂鏃堕棿(灏忔椂)")
+ private Integer soonTimeoutHours;
+
+ /**
* 鎬у埆
*/
@Excel(name = " 鎬у埆")
diff --git a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
index 1c19ff7..352f937 100644
--- a/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/ServiceSubtaskMapper.java
@@ -38,6 +38,9 @@
/**
* 鏌ヨ鍗曚竴浠诲姟锛堥殢璁匡級鍒楄〃
+ * <p>
+ * 鍏ュ弬 soonTimeout=1 涓� soonTimeoutHours=N 鏃讹紝浠呰繑鍥炩�滃皻鏈秴鏃躲�佷笖灏嗗湪 N 灏忔椂鍐呰秴鏃垛�濈殑鏁版嵁锛�
+ * 鎴鏃堕棿鍙e緞涓� getCurrentUserServiceSubtaskCount 鐨� soonTimeoutCount 涓�鑷淬��
*
* @param serviceSubtaskVO 鍗曚竴浠诲姟锛堥殢璁匡級
* @return 鍗曚竴浠诲姟锛堥殢璁匡級闆嗗悎
@@ -227,6 +230,7 @@
* failedVisitCount: 褰撳墠鐧诲綍浜洪殢璁夸换鍔″け璐ユ�婚噺
* abnormalVisitVount: 褰撳墠鐧诲綍浜洪殢璁夸换鍔″紓甯告�婚噺
* allVisitCount: 褰撳墠鐧诲綍浜洪殢璁夸换鍔℃�婚噺
+ * soonTimeoutCount: 褰撳墠鐧诲綍浜哄嵆灏嗚秴鏃舵暟閲忥紙瓒呮椂鎴鏃堕棿鍦� soonTimeoutHours 灏忔椂鍐咃紝浠呯粺璁″皻鏈秴鏃剁殑鏁版嵁锛�
*/
public Map<String, Object> getCurrentUserServiceSubtaskCount(ServiceSubtaskEntity serviceSubtaskVO);
diff --git a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
index 53b3c69..4aca18e 100644
--- a/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
+++ b/smartor/src/main/java/com/smartor/service/IServiceSubtaskService.java
@@ -196,6 +196,13 @@
public List<ServiceSubtaskDiagname> convertToDiagnameList(List<ServiceSubtask> subtaskList);
+ /**
+ * 缁熻浠诲姟鍚勭鐘舵�佺殑鏁伴噺 -銆愰殢璁垮伐浣滃彴銆�
+ *
+ * @param entity 鏌ヨ鏉′欢锛堢瀹�/鐥呭尯鏉冮檺銆乻oonTimeoutHours 鍗冲皢瓒呮椂灏忔椂鏁扮瓑锛�
+ * @return 鍚� pendingVisitCount銆乫ailedVisitCount銆乤bnormalVisitCount銆亀arnningVisitCount銆�
+ * allVisitCount銆乻oonTimeoutCount 鐨勭粺璁$粨鏋�
+ */
public Map<String, Object> getCurrentUserServiceSubtaskCount(ServiceSubtaskEntity entity);
/**
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
index 2350371..6c428cf 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml
@@ -291,6 +291,36 @@
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
</select>
+ <!-- 鍗冲皢瓒呮椂杩囨护锛氭槸鍚﹀嵆灏嗚秴鏃�(soonTimeout=1) + 鍗冲皢瓒呮椂鏃堕棿(soonTimeoutHours锛屽崟浣嶅皬鏃�)銆�
+ 鎴鏃堕棿鍙e緞涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 淇濇寔涓�鑷达細
+ service_subtask.endtime + service_task.send_day(缂虹渷1) + (危 service_subtask_preachform.compensate_time + 1) 澶╋紱
+ 浠呭綋瀛樺湪鏈夋晥琛ュ伩璁板綍鏃舵墠璁$畻鎴鏃堕棿锛堟棤琛ュ伩璁板綍涓嶅弬涓庡嵆灏嗚秴鏃讹級锛�
+ 浠呯粺璁♀�滃皻鏈秴鏃躲�佷笖鍦� N 灏忔椂鍐呭皢瑕佽秴鏃垛�濈殑鏁版嵁銆� -->
+ <sql id="soonTimeoutDeadlineExpr">
+ (
+ SELECT DATE_ADD(
+ DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+ INTERVAL (COALESCE(pf.compensate_days, 0) + 1) DAY
+ )
+ FROM service_subtask ss
+ LEFT JOIN service_task st ON st.taskid = ss.taskid AND st.del_flag = '0'
+ INNER JOIN (
+ SELECT subid,
+ SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+ FROM service_subtask_preachform
+ WHERE del_flag = 0
+ GROUP BY subid
+ ) pf ON pf.subid = ss.id
+ WHERE ss.id = service_subtask.id
+ )
+ </sql>
+
+ <sql id="soonTimeoutFilter">
+ <if test="soonTimeout != null and soonTimeout == 1">
+ AND <include refid="soonTimeoutDeadlineExpr"/> > NOW()
+ AND <include refid="soonTimeoutDeadlineExpr"/> <= DATE_ADD(NOW(), INTERVAL COALESCE(#{soonTimeoutHours}, 0) HOUR)
+ </if>
+ </sql>
<select id="selectServiceSubtaskList" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity"
resultMap="ServiceSubtaskResult">
@@ -529,6 +559,7 @@
#{visitDeptCode}
</foreach>
</if>
+ <include refid="soonTimeoutFilter"/>
<if test="sort != null and sort==0">order by endtime asc</if>
<if test="sort != null and sort==1">order by endtime desc</if>
<if test="sort != null and sort==2">order by visit_time asc</if>
@@ -538,7 +569,9 @@
<if test="sort != null and sort==7">order by visit_time asc</if>
<if test="sort != null and sort==8">order by visit_time desc</if>
<if test="sort != null and sort==9">order by sendname asc</if>
- <if test="pageSize != null and pageNum != null">limit ${pageSize} OFFSET ${pageNum}</if>
+ <if test="pageSize != null and pageNum != null">
+ LIMIT ${pageSize} OFFSET ${pageNum}
+ </if>
</select>
<select id="selectSatisfactionSubtaskList" parameterType="com.smartor.domain.VO.PatSatisfactionReqVO"
@@ -696,6 +729,7 @@
<if test="continueTimeNow != null ">and continue_time_now = #{continueTimeNow,jdbcType=TIMESTAMP}</if>
<if test="continueCount != null ">and continue_count = #{continueCount}</if>
<if test="continueTimeNext != null ">and continue_time_next = #{continueTimeNext}</if>
+ <include refid="soonTimeoutFilter"/>
</select>
<select id="selectSendstateByCondition" parameterType="com.smartor.domain.ServiceSubtask" resultType="Integer">
@@ -2846,22 +2880,54 @@
COUNT(CASE WHEN sendstate = 5 THEN 1 END) AS failedVisitCount,
SUM(CASE WHEN excep IS NOT NULL AND excep = '1' THEN 1 ELSE 0 END) AS abnormalVisitCount,
SUM(CASE WHEN excep IS NOT NULL AND excep = '2' THEN 1 ELSE 0 END) AS warnningVisitCount,
- COUNT(*) AS allVisitCount
- FROM service_subtask
- WHERE del_flag = '0'
- AND service_type = '2'
- AND visit_count = 1
+ COUNT(*) AS allVisitCount,
+ <choose>
+ <when test="soonTimeoutHours != null and soonTimeoutHours > 0">
+ COUNT(CASE WHEN t.soon_deadline > NOW()
+ AND t.soon_deadline <= DATE_ADD(NOW(), INTERVAL #{soonTimeoutHours} HOUR)
+ THEN 1 END) AS soonTimeoutCount
+ </when>
+ <otherwise>
+ 0 AS soonTimeoutCount
+ </otherwise>
+ </choose>
+ FROM (
+ SELECT ss.*,
+ <!-- 鍗冲皢瓒呮椂鎴鏃堕棿 = 鍑洪櫌鏃堕棿(endtime) + 鍙戦�佹棩(send_day, 缂虹渷1) + 琛ュ伩澶╂暟(compensate_time 姹傚拰鍚庡啀 +1 澶�)锛�
+ 涓� RyTask/RedisMqReceiver 鐨� isSubtaskDeadline 鍙e緞淇濇寔涓�鑷达紱
+ 鏃犳湁鏁堣ˉ鍋胯褰�(cp.subid 涓虹┖)鏃舵埅姝㈡椂闂翠负 NULL锛屼笉鍙備笌鍗冲皢瓒呮椂缁熻 -->
+ CASE
+ WHEN cp.subid IS NULL THEN NULL
+ ELSE DATE_ADD(
+ DATE_ADD(ss.endtime, INTERVAL COALESCE(st.send_day, 1) DAY),
+ INTERVAL (COALESCE(cp.compensate_days, 0) + 1) DAY
+ )
+ END AS soon_deadline
+ FROM service_subtask ss
+ LEFT JOIN service_task st ON st.taskid = ss.taskid AND st.del_flag = '0'
+ <!-- 琛ュ伩鏃堕棿锛氬厛鎸夊瓙浠诲姟鑱氬悎鎴愪竴琛屽啀鍏宠仈锛岄伩鍏嶄竴瀵瑰鏀惧ぇ璁℃暟锛�
+ compensate_time 鏄� varchar 涓斿彲鑳藉瓨鎴愮┖涓诧紝闇�鍏堢疆绌哄啀杞暟瀛� -->
+ LEFT JOIN (
+ SELECT subid,
+ SUM(CAST(COALESCE(NULLIF(TRIM(compensate_time), ''), '0') AS SIGNED)) AS compensate_days
+ FROM service_subtask_preachform
+ WHERE del_flag = 0
+ GROUP BY subid
+ ) cp ON cp.subid = ss.id
+ WHERE ss.del_flag = '0'
+ AND ss.service_type = '2'
+ AND ss.visit_count = 1
<if test="orgid != null and orgid != ''">
- AND orgid = #{orgid}
+ AND ss.orgid = #{orgid}
</if>
<if test="campusid != null and campusid != ''">
- and campusid = #{campusid}
+ and ss.campusid = #{campusid}
</if>
<if test="(leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0)
or (leaveldeptcodes != null and leaveldeptcodes.size() > 0)">
AND (
<if test="leavehospitaldistrictcodes != null and leavehospitaldistrictcodes.size() > 0">
- leavehospitaldistrictcode IN
+ ss.leavehospitaldistrictcode IN
<foreach collection="leavehospitaldistrictcodes" item="leavehospitaldistrictcode" open="("
separator=","
close=")">
@@ -2873,13 +2939,14 @@
OR
</if>
<if test=" leaveldeptcodes != null and leaveldeptcodes.size()>0">
- deptcode IN
+ ss.deptcode IN
<foreach collection="leaveldeptcodes" item="leaveldeptcode" open="(" separator=","
close=")">
#{leaveldeptcode}
</foreach>
</if>)
</if>
+ ) t
</select>
<select id="querySendCount" parameterType="com.smartor.domain.entity.ServiceSubtaskSatisfactionEntity"
--
Gitblit v1.9.3