76 lines
2.7 KiB
Plaintext
76 lines
2.7 KiB
Plaintext
|
|
package com.sercurityControl.proteam.dutyTask.service;
|
||
|
|
|
||
|
|
import com.github.pagehelper.PageInfo;
|
||
|
|
import com.securityControl.common.core.utils.StringUtils;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.domain.AbnormalRepDto;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.domain.AbnormalRepVo;
|
||
|
|
import com.sercurityControl.proteam.dutyTask.mapper.AbnormalRepMapper;
|
||
|
|
import org.slf4j.Logger;
|
||
|
|
import org.slf4j.LoggerFactory;
|
||
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import javax.annotation.Resource;
|
||
|
|
import java.util.ArrayList;
|
||
|
|
import java.util.Arrays;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.concurrent.Callable;
|
||
|
|
import java.util.concurrent.Future;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 异常上报统计业务逻辑层
|
||
|
|
*/
|
||
|
|
@Service(value = "AbnormalRepService")
|
||
|
|
public class AbnormalRepServiceImpl implements AbnormalRepService {
|
||
|
|
|
||
|
|
Logger logger = LoggerFactory.getLogger(AbnormalRepServiceImpl.class);
|
||
|
|
|
||
|
|
@Resource(name = "AbnormalRepMapper")
|
||
|
|
private AbnormalRepMapper mapper;
|
||
|
|
|
||
|
|
@Resource(name = "testTaskExecutor")
|
||
|
|
private ThreadPoolTaskExecutor testTaskExecutor;
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public PageInfo<AbnormalRepVo> getAbnormalRepList(AbnormalRepDto dto) {
|
||
|
|
if (StringUtils.isNotBlank(dto.getRiskLevel())) {
|
||
|
|
String[] riskLevelArr = dto.getRiskLevel().split(",");
|
||
|
|
List<String> riskLevelList = Arrays.asList(riskLevelArr);
|
||
|
|
dto.setRiskLevelList(riskLevelList);
|
||
|
|
}
|
||
|
|
// 多线程执行操作,存放的数据集合
|
||
|
|
List<Future> futureList = new ArrayList<>();
|
||
|
|
List<AbnormalRepVo> newList = new ArrayList<>();
|
||
|
|
List<AbnormalRepVo> list = mapper.getAbnormalRepList(dto);
|
||
|
|
PageInfo<AbnormalRepVo> pageInfo = new PageInfo<>(list);
|
||
|
|
for (AbnormalRepVo vo : list) {
|
||
|
|
Future<AbnormalRepVo> future = testTaskExecutor.submit(new Callable<AbnormalRepVo>() {
|
||
|
|
@Override
|
||
|
|
public AbnormalRepVo call() throws Exception {
|
||
|
|
List<String> imgList= mapper.getAbnormalRepImgById(vo.getId());
|
||
|
|
vo.setNum(imgList.size());
|
||
|
|
return vo;
|
||
|
|
}
|
||
|
|
});
|
||
|
|
futureList.add(future);
|
||
|
|
}
|
||
|
|
for (Future<AbnormalRepVo> future : futureList) {
|
||
|
|
AbnormalRepVo vo = new AbnormalRepVo();
|
||
|
|
try {
|
||
|
|
vo = future.get();
|
||
|
|
} catch (Exception e) {
|
||
|
|
logger.error("多线程返回结果异常", e);
|
||
|
|
}
|
||
|
|
newList.add(vo);
|
||
|
|
}
|
||
|
|
pageInfo.setList(newList);
|
||
|
|
return pageInfo;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public List<String> getAbnormalImgById(String id) {
|
||
|
|
List<String> imgList= mapper.getAbnormalRepImgById(id);
|
||
|
|
return imgList;
|
||
|
|
}
|
||
|
|
}
|