From ea48f29a575d74b593d4caa9619251a608b884e6 Mon Sep 17 00:00:00 2001
From: "1437892690@qq.com" <1437892690@qq.com>
Date: Mon, 19 Aug 2024 17:11:22 +0800
Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E7=AA=97=E5=8F=A3=E4=BF=9D=E5=AD=98=E6=80=A7=E8=83=BD=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
关联 #[1224618499604480]服务窗口保存性能问题 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1224618499604480
---
.../api/worktime/WorktimeCalendarSaveApi.java | 27 +++++++++-------
.../tenant/api/worktime/WorktimeSaveApi.java | 31 +++++++++++--------
2 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeCalendarSaveApi.java b/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeCalendarSaveApi.java
index ef5da8be..9834913c 100644
--- a/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeCalendarSaveApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeCalendarSaveApi.java
@@ -15,6 +15,9 @@ along with this program. If not, see .*/
package neatlogic.module.tenant.api.worktime;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.asynchronization.thread.NeatLogicThread;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.auth.label.WORKTIME_MODIFY;
import neatlogic.framework.common.constvalue.ApiParamType;
@@ -25,13 +28,11 @@ import neatlogic.framework.restful.annotation.Param;
import neatlogic.framework.restful.constvalue.OperationTypeEnum;
import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
import neatlogic.framework.sla.core.SlaRecalculateManager;
-import neatlogic.framework.transaction.core.EscapeTransactionJob;
+import neatlogic.framework.transaction.core.AfterTransactionJob;
import neatlogic.framework.worktime.dao.mapper.WorktimeMapper;
import neatlogic.framework.worktime.dto.WorktimeVo;
import neatlogic.framework.worktime.exception.WorktimeNotFoundException;
import neatlogic.module.tenant.service.WorktimeService;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -58,7 +59,7 @@ public class WorktimeCalendarSaveApi extends PrivateApiComponentBase {
@Override
public String getName() {
- return "工作日历信息保存接口";
+ return "nmtaw.worktimecalendarsaveapi.getname";
}
@Override
@@ -67,11 +68,11 @@ public class WorktimeCalendarSaveApi extends PrivateApiComponentBase {
}
@Input({
- @Param(name = "worktimeUuid", type = ApiParamType.STRING, isRequired = true, desc = "工作时间窗口uuid"),
- @Param(name = "year", type = ApiParamType.INTEGER, isRequired = true, desc = "年份"),
- @Param(name = "calendarList", type = ApiParamType.JSONARRAY, isRequired = true, desc = "工作日历列表")
+ @Param(name = "worktimeUuid", type = ApiParamType.STRING, isRequired = true, desc = "common.worktimeuuid"),
+ @Param(name = "year", type = ApiParamType.INTEGER, isRequired = true, desc = "common.year"),
+ @Param(name = "calendarList", type = ApiParamType.JSONARRAY, isRequired = true, desc = "term.framework.calendarlist")
})
- @Description(desc = "工作日历信息保存接口")
+ @Description(desc = "nmtaw.worktimecalendarsaveapi.getname")
@Override
public Object myDoService(JSONObject jsonObj) throws Exception {
String worktimeUuid = jsonObj.getString("worktimeUuid");
@@ -84,9 +85,13 @@ public class WorktimeCalendarSaveApi extends PrivateApiComponentBase {
JSONArray calendarList = jsonObj.getJSONArray("calendarList");
worktimeService.saveWorktimeRange(worktimeVo, year, generateDateList(calendarList));
// 当服务窗口排班更新时,对与该服务窗口相关的未完成SLA进行耗时重算
- EscapeTransactionJob.State s = new EscapeTransactionJob(() -> {
- SlaRecalculateManager.execute(worktimeUuid);
- }).execute();
+ AfterTransactionJob afterTransactionJob = new AfterTransactionJob<>("SLA-RECALCULATE-MANAGER");
+ afterTransactionJob.execute(new NeatLogicThread("SLA-RECALCULATE-MANAGER-THREAD") {
+ @Override
+ protected void execute() {
+ SlaRecalculateManager.execute(worktimeUuid);
+ }
+ });
return null;
}
diff --git a/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeSaveApi.java b/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeSaveApi.java
index a41b0008..fd693b8c 100644
--- a/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeSaveApi.java
+++ b/src/main/java/neatlogic/module/tenant/api/worktime/WorktimeSaveApi.java
@@ -15,6 +15,9 @@ along with this program. If not, see .*/
package neatlogic.module.tenant.api.worktime;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import neatlogic.framework.asynchronization.thread.NeatLogicThread;
import neatlogic.framework.asynchronization.threadlocal.UserContext;
import neatlogic.framework.auth.core.AuthAction;
import neatlogic.framework.auth.label.WORKTIME_MODIFY;
@@ -25,7 +28,7 @@ import neatlogic.framework.restful.constvalue.OperationTypeEnum;
import neatlogic.framework.restful.core.IValid;
import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase;
import neatlogic.framework.sla.core.SlaRecalculateManager;
-import neatlogic.framework.transaction.core.EscapeTransactionJob;
+import neatlogic.framework.transaction.core.AfterTransactionJob;
import neatlogic.framework.util.RegexUtils;
import neatlogic.framework.worktime.dao.mapper.WorktimeMapper;
import neatlogic.framework.worktime.dto.WorktimeRangeVo;
@@ -34,8 +37,6 @@ import neatlogic.framework.worktime.exception.WorktimeConfigIllegalException;
import neatlogic.framework.worktime.exception.WorktimeNameRepeatException;
import neatlogic.framework.worktime.exception.WorktimeStartTimeGreaterThanOrEqualToEndTimeException;
import neatlogic.module.tenant.service.WorktimeService;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -66,7 +67,7 @@ public class WorktimeSaveApi extends PrivateApiComponentBase {
@Override
public String getName() {
- return "工作时间窗口信息保存接口";
+ return "nmtaw.worktimesaveapi.getname";
}
@Override
@@ -75,15 +76,15 @@ public class WorktimeSaveApi extends PrivateApiComponentBase {
}
@Input({
- @Param(name = "uuid", type = ApiParamType.STRING, desc = "工作时间窗口uuid"),
- @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, isRequired = true, maxLength = 50, desc = "工作时间窗口名称"),
- @Param(name = "isActive", type = ApiParamType.ENUM, isRequired = true, desc = "是否激活", rule = "0,1"),
- @Param(name = "config", type = ApiParamType.JSONOBJECT, isRequired = true, desc = "每周工作时段的定义")
+ @Param(name = "uuid", type = ApiParamType.STRING, desc = "common.uuid"),
+ @Param(name = "name", type = ApiParamType.REGEX, rule = RegexUtils.NAME, isRequired = true, maxLength = 50, desc = "common.name"),
+ @Param(name = "isActive", type = ApiParamType.ENUM, isRequired = true, desc = "common.isactive", rule = "0,1"),
+ @Param(name = "config", type = ApiParamType.JSONOBJECT, isRequired = true, desc = "common.config", help = "每周工作时段的定义")
})
@Output({
- @Param(name = "Return", type = ApiParamType.STRING, desc = "工作时间窗口uuid")
+ @Param(name = "Return", type = ApiParamType.STRING, desc = "common.uuid")
})
- @Description(desc = "工作时间窗口信息保存接口")
+ @Description(desc = "nmtaw.worktimesaveapi.getname")
@Override
public Object myDoService(JSONObject jsonObj) throws Exception {
WorktimeVo worktimeVo = JSONObject.toJavaObject(jsonObj, WorktimeVo.class);
@@ -151,9 +152,13 @@ public class WorktimeSaveApi extends PrivateApiComponentBase {
}
// 当服务窗口排班更新时,对与该服务窗口相关的未完成SLA进行耗时重算
final String worktimeUuid = uuid;
- EscapeTransactionJob.State s = new EscapeTransactionJob(() -> {
- SlaRecalculateManager.execute(worktimeUuid);
- }).execute();
+ AfterTransactionJob afterTransactionJob = new AfterTransactionJob<>("SLA-RECALCULATE-MANAGER");
+ afterTransactionJob.execute(new NeatLogicThread("SLA-RECALCULATE-MANAGER-THREAD") {
+ @Override
+ protected void execute() {
+ SlaRecalculateManager.execute(worktimeUuid);
+ }
+ });
return uuid;
}
--
Gitee