提交 c023deac authored 作者: inroi's avatar inroi

微调

上级 fb8a16c0
package com.nzwz.serivce.impl; package com.nzwz.serivce.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.nzwz.common.constants.Constants; import com.nzwz.common.constants.Constants;
import com.nzwz.common.response.RestResponse; import com.nzwz.common.response.RestResponse;
import com.nzwz.quartz.model.QuartzJob; import com.nzwz.quartz.model.QuartzJob;
...@@ -29,6 +30,10 @@ import org.springframework.stereotype.Service; ...@@ -29,6 +30,10 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -52,6 +57,13 @@ public class SynchronizationServiceImpl implements ISynchronizationService { ...@@ -52,6 +57,13 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
@Autowired @Autowired
private InitConnectParamMapper initConnectParamMapper; private InitConnectParamMapper initConnectParamMapper;
private ExecutorService threadPool = new ThreadPoolExecutor(5, 5,
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024),
new ThreadFactoryBuilder().setNameFormat("syn-pool-%d").build(),
new ThreadPoolExecutor.AbortPolicy());
@Override @Override
public RestResponse startSynchronization() { public RestResponse startSynchronization() {
...@@ -142,7 +154,7 @@ public class SynchronizationServiceImpl implements ISynchronizationService { ...@@ -142,7 +154,7 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
return RestResponse.fail("自动同步定时任务不存在!"); return RestResponse.fail("自动同步定时任务不存在!");
} }
this.synchronization(); threadPool.execute(this::synchronization);
return RestResponse.success(); return RestResponse.success();
} }
...@@ -237,18 +249,19 @@ public class SynchronizationServiceImpl implements ISynchronizationService { ...@@ -237,18 +249,19 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
System.out.println("金蝶返回值: " + result); System.out.println("金蝶返回值: " + result);
Map<String, Object> tempMap = ThreadLocalConfig.get();
int costTime = StringUtil.isNotNull(tempMap.get("costTime")) ? Integer.parseInt(tempMap.get("costTime").toString()) : 0;
String flagName = "DNResult"; String flagName = "DNResult";
Map<String, Object> map = JsonUtil.toMap(result, String.class, Object.class); Map<String, Object> map = JsonUtil.toMap(result, String.class, Object.class);
if (!CollectionUtils.isEmpty(map)) { if (!CollectionUtils.isEmpty(map)) {
Map<String, Object> tempMap = ThreadLocalConfig.get();
int costTime = StringUtil.isNotNull(tempMap.get("costTime")) ? Integer.parseInt(tempMap.get("costTime").toString()) : 0;
if (KingDeeUtil.isError(result)) { if (KingDeeUtil.isError(result)) {
logMapper.updateById(new Log(log.getId(), 0, result, costTime)); logMapper.updateById(new Log(log.getId(), 0, result, costTime));
} else { } else {
if (map.containsKey(flagName)) { if (map.containsKey(flagName)) {
if (Constants.SYN_SUCCESS_CODE.equals(map.get(flagName))) { if (Constants.SYN_SUCCESS_CODE.equals(String.valueOf(map.get(flagName)))) {
logMapper.updateById(new Log(log.getId(), 1, result, costTime)); logMapper.updateById(new Log(log.getId(), 1, result, costTime));
} else if (Constants.ROOT_MENU_CODE.equals(map.get(flagName))) { } else if (Constants.ROOT_MENU_CODE.equals(String.valueOf(map.get(flagName)))) {
logMapper.updateById(new Log(log.getId(), 0, "未查询到数据", 0)); logMapper.updateById(new Log(log.getId(), 0, "未查询到数据", 0));
} else { } else {
logMapper.updateById(new Log(log.getId(), 0, result, costTime)); logMapper.updateById(new Log(log.getId(), 0, result, costTime));
...@@ -257,6 +270,8 @@ public class SynchronizationServiceImpl implements ISynchronizationService { ...@@ -257,6 +270,8 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
logMapper.updateById(new Log(log.getId(), 0, result, costTime)); logMapper.updateById(new Log(log.getId(), 0, result, costTime));
} }
} }
} else {
logMapper.updateById(new Log(log.getId(), 0, result, costTime));
} }
return result; return result;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论