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.MessageCategoryEnum;
|
||||
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.WebPageOpenStrategy;
|
||||
import cn.axzo.msg.center.service.enums.YesOrNo;
|
||||
import cn.axzo.msg.center.utils.AsyncRunTasks;
|
||||
import cn.axzo.msg.center.utils.JSONObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
@ -61,6 +63,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ -87,7 +91,7 @@ public class MigrateMessageTemplateV3Job {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@XxlJob("migrateMessageTemplateV3Job")
|
||||
public ReturnT<String> execute(String jsonStr) {
|
||||
public ReturnT<String> execute(String jsonStr) throws Exception {
|
||||
try {
|
||||
Param param = StringUtils.isBlank(jsonStr)
|
||||
? 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();
|
||||
List<MessageBaseTemplate> baseTemplates = messageBaseTemplateDao.lambdaQuery()
|
||||
.eq(MessageBaseTemplate::getIsDelete, 0)
|
||||
.in(CollectionUtils.isNotEmpty(param.getTemplateCodes()),
|
||||
MessageBaseTemplate::getCode, param.getTemplateCodes())
|
||||
.list();
|
||||
int nThreads = 10;
|
||||
AsyncRunTasks tasks = new AsyncRunTasks(Executors.newFixedThreadPool(nThreads));
|
||||
Semaphore semaphore = new Semaphore(nThreads);
|
||||
for (int i = 0; i < baseTemplates.size(); i++) {
|
||||
MessageBaseTemplate baseTemplate = baseTemplates.get(i);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -195,7 +212,18 @@ public class MigrateMessageTemplateV3Job {
|
||||
button.setSource(routeButton.getSource());
|
||||
button.setCategory(routeButton.getCategory());
|
||||
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.setExecutorShow(routeButton.getExecutorShow());
|
||||
button.setPendingShow(routeButton.getPendingShow());
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.axzo.msg.center.service.enums.WebPageOpenStrategy;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minidev.json.annotate.JsonIgnore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -46,35 +47,35 @@ public class UrlConfig {
|
||||
*/
|
||||
private MobileUrlConfig appManager;
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@JsonIgnore @JSONField(serialize = false)
|
||||
public WebUrl getOrCreatePcOms() {
|
||||
if (pcOms == null)
|
||||
pcOms = new WebUrl();
|
||||
return pcOms;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@JsonIgnore @JSONField(serialize = false)
|
||||
public WebUrl getOrCreatePcCms() {
|
||||
if (pcCms == null)
|
||||
pcCms = new WebUrl();
|
||||
return pcCms;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@JsonIgnore @JSONField(serialize = false)
|
||||
public WebUrl getOrCreatePcGaGeneral() {
|
||||
if (pcGaGeneral == null)
|
||||
pcGaGeneral = new WebUrl();
|
||||
return pcGaGeneral;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@JsonIgnore @JSONField(serialize = false)
|
||||
public MobileUrlConfig getOrCreateAppWorker() {
|
||||
if (appWorker == null)
|
||||
appWorker = new MobileUrlConfig();
|
||||
return appWorker;
|
||||
}
|
||||
|
||||
@JSONField(serialize = false)
|
||||
@JsonIgnore @JSONField(serialize = false)
|
||||
public MobileUrlConfig getOrCreateAppManager() {
|
||||
if (appManager == null)
|
||||
appManager = new MobileUrlConfig();
|
||||
|
||||
@ -21,8 +21,8 @@ class MigrateMessageTemplateV3JobTest {
|
||||
private final MigrateMessageTemplateV3Job migrateMessageTemplateV3Job;
|
||||
|
||||
@Test @Commit @Transactional
|
||||
void exec() {
|
||||
//migrateMessageTemplateV3Job.execute("{\"templateCodes\":[\"1c7effbba987411fbb6719619d2f5f07\"]}");
|
||||
void exec() throws Exception {
|
||||
//migrateMessageTemplateV3Job.execute("{\"templateCodes\":[\"429e7d99512f4411ad521e69f88f9b71\"]}");
|
||||
migrateMessageTemplateV3Job.execute(null);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user