Commit c71d141c authored by huyuchen's avatar huyuchen

优化修改

parent b567f158
......@@ -58,10 +58,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* 收入明细表
......@@ -322,53 +318,50 @@ public class TIncomeServiceImpl extends ServiceImpl<TIncomeMapper, TIncome> impl
@Override
public void pushDetail() {
ThreadPoolExecutor threadPool = new ThreadPoolExecutor(50, 50, 100, TimeUnit.SECONDS, new LinkedBlockingQueue<>(10));
List<TIncome> list = baseMapper.selectList(Wrappers.<TIncome>query().lambda()
.eq(TIncome::getSendStatus, CommonConstants.ZERO_STRING));
ConcurrentHashMap<String,Integer> map = new ConcurrentHashMap<>();
ConcurrentHashMap<String,String> idMap = new ConcurrentHashMap<>();
Map<String, Integer> map = new HashMap<>();
Map<String, String> idMap = new HashMap<>();
//收入更新
List<TIncome> updateList = new ArrayList<>();
threadPool.execute(() -> {
for (TIncome income : list) {
String sendBack = this.getSendBack(income);
income.setSendTime(new Date());
if (Common.isNotNull(sendBack) && sendBack.length() == 32) {
income.setSendStatus(CommonConstants.ONE_STRING);
income.setSendMonth(DateUtil.addMonth(0));
income.setEkpId(sendBack);
updateList.add(income);
if (updateList.size() >= CommonConstants.FIVES_INT) {
for (TIncome income : list) {
String sendBack = this.getSendBack(income);
income.setSendTime(new Date());
if (Common.isNotNull(sendBack) && sendBack.length() == 32) {
income.setSendStatus(CommonConstants.ONE_STRING);
income.setSendMonth(DateUtil.addMonth(0));
income.setEkpId(sendBack);
updateList.add(income);
if (updateList.size() >= CommonConstants.FIVES_INT) {
baseMapper.updateIncomeById(updateList);
updateList.clear();
}
} else {
if (Common.isNotNull(map.get(sendBack)) && map.get(sendBack) > 0) {
int i = map.get(sendBack) + 1;
map.put(sendBack, i);
idMap.put(sendBack, income.getId());
//单个异常超过十次,保存异常内容
if (i >= 10) {
baseMapper.updateIncomeById(updateList);
updateList.clear();
}
} else {
if (map.get(sendBack) > 0) {
int i = map.get(sendBack) + 1;
map.put(sendBack, i);
idMap.put(sendBack, income.getId());
//单个异常超过十次,保存异常内容
if (i >= 10) {
baseMapper.updateIncomeById(updateList);
for (Map.Entry<String, Integer> entry : map.entrySet()) {
TSendEkpError error = new TSendEkpError();
error.setCreateTime(new Date());
error.setCreateDay(DateUtil.getThisDay());
error.setType(CommonConstants.FIVE_STRING);
error.setLinkId(income.getId());
error.setTitle(entry.getKey());
error.setNums(entry.getValue());
tSendEkpErrorService.save(error);
}
break;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
TSendEkpError error = new TSendEkpError();
error.setCreateTime(new Date());
error.setCreateDay(DateUtil.getThisDay());
error.setType(CommonConstants.FIVE_STRING);
error.setLinkId(income.getId());
error.setTitle(entry.getKey());
error.setNums(entry.getValue());
tSendEkpErrorService.save(error);
}
} else {
map.put(sendBack, 1);
idMap.put(sendBack, income.getId());
break;
}
} else {
map.put(sendBack, 1);
idMap.put(sendBack, income.getId());
}
}
});
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
TSendEkpError error = new TSendEkpError();
error.setCreateTime(new Date());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment