REQ-2752: 刷审批流程按钮
This commit is contained in:
parent
4e92024d56
commit
5c78b6a3ca
@ -37,9 +37,11 @@ import cn.axzo.msg.center.service.enums.GroupType;
|
|||||||
import cn.axzo.msg.center.service.enums.KVContentType;
|
import cn.axzo.msg.center.service.enums.KVContentType;
|
||||||
import cn.axzo.msg.center.service.enums.MessageCategoryEnum;
|
import cn.axzo.msg.center.service.enums.MessageCategoryEnum;
|
||||||
import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
import cn.axzo.msg.center.service.enums.PushTerminalEnum;
|
||||||
|
import cn.axzo.msg.center.service.enums.RouterCategoryEnum;
|
||||||
import cn.axzo.msg.center.service.enums.TerminalTypeEnum;
|
import cn.axzo.msg.center.service.enums.TerminalTypeEnum;
|
||||||
import cn.axzo.msg.center.service.enums.WebPageOpenStrategy;
|
import cn.axzo.msg.center.service.enums.WebPageOpenStrategy;
|
||||||
import cn.axzo.msg.center.service.enums.YesOrNo;
|
import cn.axzo.msg.center.service.enums.YesOrNo;
|
||||||
|
import cn.axzo.msg.center.utils.AsyncRunTasks;
|
||||||
import cn.axzo.msg.center.utils.JSONObjectUtil;
|
import cn.axzo.msg.center.utils.JSONObjectUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
@ -61,6 +63,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -87,7 +91,7 @@ public class MigrateMessageTemplateV3Job {
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@XxlJob("migrateMessageTemplateV3Job")
|
@XxlJob("migrateMessageTemplateV3Job")
|
||||||
public ReturnT<String> execute(String jsonStr) {
|
public ReturnT<String> execute(String jsonStr) throws Exception {
|
||||||
try {
|
try {
|
||||||
Param param = StringUtils.isBlank(jsonStr)
|
Param param = StringUtils.isBlank(jsonStr)
|
||||||
? new Param()
|
? new Param()
|
||||||
@ -99,18 +103,31 @@ public class MigrateMessageTemplateV3Job {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReturnT<String> executeImpl(Param param) {
|
private ReturnT<String> executeImpl(Param param) throws Exception {
|
||||||
RootNodeWrapper groupRoot = groupTemplateService.getGroupRoot();
|
RootNodeWrapper groupRoot = groupTemplateService.getGroupRoot();
|
||||||
List<MessageBaseTemplate> baseTemplates = messageBaseTemplateDao.lambdaQuery()
|
List<MessageBaseTemplate> baseTemplates = messageBaseTemplateDao.lambdaQuery()
|
||||||
.eq(MessageBaseTemplate::getIsDelete, 0)
|
.eq(MessageBaseTemplate::getIsDelete, 0)
|
||||||
.in(CollectionUtils.isNotEmpty(param.getTemplateCodes()),
|
.in(CollectionUtils.isNotEmpty(param.getTemplateCodes()),
|
||||||
MessageBaseTemplate::getCode, param.getTemplateCodes())
|
MessageBaseTemplate::getCode, param.getTemplateCodes())
|
||||||
.list();
|
.list();
|
||||||
|
int nThreads = 10;
|
||||||
|
AsyncRunTasks tasks = new AsyncRunTasks(Executors.newFixedThreadPool(nThreads));
|
||||||
|
Semaphore semaphore = new Semaphore(nThreads);
|
||||||
for (int i = 0; i < baseTemplates.size(); i++) {
|
for (int i = 0; i < baseTemplates.size(); i++) {
|
||||||
MessageBaseTemplate baseTemplate = baseTemplates.get(i);
|
MessageBaseTemplate baseTemplate = baseTemplates.get(i);
|
||||||
log.info("migrating template: {}/{}", i + 1, baseTemplates.size());
|
log.info("migrating template: {}/{}", i + 1, baseTemplates.size());
|
||||||
transactionTemplate.executeWithoutResult(unused -> migrateTemplate(groupRoot, baseTemplate));
|
semaphore.acquire();
|
||||||
|
tasks.runAsync(() -> {
|
||||||
|
try {
|
||||||
|
transactionTemplate.executeWithoutResult(unused -> migrateTemplate(groupRoot, baseTemplate));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
semaphore.release();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
tasks.awaitTermination();
|
||||||
return ReturnT.SUCCESS;
|
return ReturnT.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +212,18 @@ public class MigrateMessageTemplateV3Job {
|
|||||||
button.setSource(routeButton.getSource());
|
button.setSource(routeButton.getSource());
|
||||||
button.setCategory(routeButton.getCategory());
|
button.setCategory(routeButton.getCategory());
|
||||||
button.setApiUrl(routeButton.getApiUrl());
|
button.setApiUrl(routeButton.getApiUrl());
|
||||||
button.setUrlConfig(buildUrlConfig(groupRoot, baseTemplate, routeButton.getRouterConfigs()));
|
if (baseTemplate.getMsgCategory() == MessageCategoryEnum.APPROVAL_PENDING_MESSAGE) {
|
||||||
|
// 不要和上面的if合并, 不然业务上不对了
|
||||||
|
if (routeButton.getCategory() == RouterCategoryEnum.JUMP) {
|
||||||
|
searchRouter(routeButton.getRouterConfigs(), TerminalTypeEnum.WEB_VIEW).ifPresent(router -> {
|
||||||
|
UrlConfig urlConfig = new UrlConfig();
|
||||||
|
urlConfig.applyUrlAsDefaults(router.getUrl());
|
||||||
|
button.setUrlConfig(urlConfig);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
button.setUrlConfig(buildUrlConfig(groupRoot, baseTemplate, routeButton.getRouterConfigs()));
|
||||||
|
}
|
||||||
button.setStyle(routeButton.getStyle());
|
button.setStyle(routeButton.getStyle());
|
||||||
button.setExecutorShow(routeButton.getExecutorShow());
|
button.setExecutorShow(routeButton.getExecutorShow());
|
||||||
button.setPendingShow(routeButton.getPendingShow());
|
button.setPendingShow(routeButton.getPendingShow());
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import cn.axzo.msg.center.service.enums.WebPageOpenStrategy;
|
|||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import net.minidev.json.annotate.JsonIgnore;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -46,35 +47,35 @@ public class UrlConfig {
|
|||||||
*/
|
*/
|
||||||
private MobileUrlConfig appManager;
|
private MobileUrlConfig appManager;
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore @JSONField(serialize = false)
|
||||||
public WebUrl getOrCreatePcOms() {
|
public WebUrl getOrCreatePcOms() {
|
||||||
if (pcOms == null)
|
if (pcOms == null)
|
||||||
pcOms = new WebUrl();
|
pcOms = new WebUrl();
|
||||||
return pcOms;
|
return pcOms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore @JSONField(serialize = false)
|
||||||
public WebUrl getOrCreatePcCms() {
|
public WebUrl getOrCreatePcCms() {
|
||||||
if (pcCms == null)
|
if (pcCms == null)
|
||||||
pcCms = new WebUrl();
|
pcCms = new WebUrl();
|
||||||
return pcCms;
|
return pcCms;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore @JSONField(serialize = false)
|
||||||
public WebUrl getOrCreatePcGaGeneral() {
|
public WebUrl getOrCreatePcGaGeneral() {
|
||||||
if (pcGaGeneral == null)
|
if (pcGaGeneral == null)
|
||||||
pcGaGeneral = new WebUrl();
|
pcGaGeneral = new WebUrl();
|
||||||
return pcGaGeneral;
|
return pcGaGeneral;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore @JSONField(serialize = false)
|
||||||
public MobileUrlConfig getOrCreateAppWorker() {
|
public MobileUrlConfig getOrCreateAppWorker() {
|
||||||
if (appWorker == null)
|
if (appWorker == null)
|
||||||
appWorker = new MobileUrlConfig();
|
appWorker = new MobileUrlConfig();
|
||||||
return appWorker;
|
return appWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
@JsonIgnore @JSONField(serialize = false)
|
||||||
public MobileUrlConfig getOrCreateAppManager() {
|
public MobileUrlConfig getOrCreateAppManager() {
|
||||||
if (appManager == null)
|
if (appManager == null)
|
||||||
appManager = new MobileUrlConfig();
|
appManager = new MobileUrlConfig();
|
||||||
|
|||||||
@ -21,8 +21,8 @@ class MigrateMessageTemplateV3JobTest {
|
|||||||
private final MigrateMessageTemplateV3Job migrateMessageTemplateV3Job;
|
private final MigrateMessageTemplateV3Job migrateMessageTemplateV3Job;
|
||||||
|
|
||||||
@Test @Commit @Transactional
|
@Test @Commit @Transactional
|
||||||
void exec() {
|
void exec() throws Exception {
|
||||||
//migrateMessageTemplateV3Job.execute("{\"templateCodes\":[\"1c7effbba987411fbb6719619d2f5f07\"]}");
|
//migrateMessageTemplateV3Job.execute("{\"templateCodes\":[\"429e7d99512f4411ad521e69f88f9b71\"]}");
|
||||||
migrateMessageTemplateV3Job.execute(null);
|
migrateMessageTemplateV3Job.execute(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user