|
|
|
@ -2,6 +2,7 @@ package com.biutag.supervision.controller.work; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelReader; |
|
|
|
import com.alibaba.excel.ExcelReader; |
|
|
|
@ -33,16 +34,14 @@ import jakarta.validation.ConstraintViolation; |
|
|
|
import jakarta.validation.Validator; |
|
|
|
import jakarta.validation.Validator; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
import org.springframework.util.StopWatch; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Slf4j |
|
|
|
@ -69,6 +68,8 @@ public class NegativeTaskController { |
|
|
|
@PostMapping("import") |
|
|
|
@PostMapping("import") |
|
|
|
public Result<List<NegativeImportDto>> importExcel(@RequestPart("file") MultipartFile file) throws IOException { |
|
|
|
public Result<List<NegativeImportDto>> importExcel(@RequestPart("file") MultipartFile file) throws IOException { |
|
|
|
log.info("文件导入中------------------------------"); |
|
|
|
log.info("文件导入中------------------------------"); |
|
|
|
|
|
|
|
StopWatch stopWatch = new StopWatch(); |
|
|
|
|
|
|
|
stopWatch.start("tagetfin-budget-profit"); |
|
|
|
String fileNameType = FileUtil.extName(file.getOriginalFilename()); |
|
|
|
String fileNameType = FileUtil.extName(file.getOriginalFilename()); |
|
|
|
if (!"xls".equals(fileNameType) && !"xlsx".equals(fileNameType)) { |
|
|
|
if (!"xls".equals(fileNameType) && !"xlsx".equals(fileNameType)) { |
|
|
|
throw new RuntimeException("仅支持 xls/xlsx 格式文件的导入"); |
|
|
|
throw new RuntimeException("仅支持 xls/xlsx 格式文件的导入"); |
|
|
|
@ -77,7 +78,9 @@ public class NegativeTaskController { |
|
|
|
|
|
|
|
|
|
|
|
List<SupDictData> suspectProblem = dictDataService.listByDictType("suspectProblem"); |
|
|
|
List<SupDictData> suspectProblem = dictDataService.listByDictType("suspectProblem"); |
|
|
|
List<SupDictData> specialSupervision = dictDataService.listByDictType("specialSupervision"); |
|
|
|
List<SupDictData> specialSupervision = dictDataService.listByDictType("specialSupervision"); |
|
|
|
|
|
|
|
|
|
|
|
ExcelReader excelReader = EasyExcel.read(file.getInputStream(), NegativeImportDto.class, new ReadListener<NegativeImportDto>() { |
|
|
|
ExcelReader excelReader = EasyExcel.read(file.getInputStream(), NegativeImportDto.class, new ReadListener<NegativeImportDto>() { |
|
|
|
|
|
|
|
//提升导入速度:1、异步 2、缓存读取数据,减少数据请求频率
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void invoke(NegativeImportDto data, AnalysisContext analysisContext) { |
|
|
|
public void invoke(NegativeImportDto data, AnalysisContext analysisContext) { |
|
|
|
@ -114,7 +117,8 @@ public class NegativeTaskController { |
|
|
|
data.setInvolveProblem(involveProblem); |
|
|
|
data.setInvolveProblem(involveProblem); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StrUtil.isNotBlank(data.getReportNumber())){ |
|
|
|
if (StrUtil.isNotBlank(data.getReportNumber())){ |
|
|
|
List<SuperviseReport> reportList = reportService.list(new LambdaQueryWrapper<SuperviseReport>().eq(SuperviseReport::getReportName,data.getReportNumber())).stream().toList(); |
|
|
|
List<SuperviseReport> reportList = reportService.list(new LambdaQueryWrapper<SuperviseReport>() |
|
|
|
|
|
|
|
.eq(SuperviseReport::getReportName,data.getReportNumber())).stream().toList(); |
|
|
|
if(CollectionUtil.isNotEmpty(reportList)){ |
|
|
|
if(CollectionUtil.isNotEmpty(reportList)){ |
|
|
|
data.setReportId(reportList.get(0).getId()); |
|
|
|
data.setReportId(reportList.get(0).getId()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -125,18 +129,25 @@ public class NegativeTaskController { |
|
|
|
String[] departNames = data.getInvolveDepartName().split("/"); |
|
|
|
String[] departNames = data.getInvolveDepartName().split("/"); |
|
|
|
List<SupDepart> departs = departService.list(new LambdaQueryWrapper<SupDepart>().eq(SupDepart::getLevel, DepartLevelEnum.SECOND.getValue()) |
|
|
|
List<SupDepart> departs = departService.list(new LambdaQueryWrapper<SupDepart>().eq(SupDepart::getLevel, DepartLevelEnum.SECOND.getValue()) |
|
|
|
.eq(SupDepart::getShortName, departNames[0])); |
|
|
|
.eq(SupDepart::getShortName, departNames[0])); |
|
|
|
if (!departs.isEmpty()) { |
|
|
|
|
|
|
|
|
|
|
|
SupDepart depart = departService.getOne( |
|
|
|
|
|
|
|
new LambdaQueryWrapper<SupDepart>() |
|
|
|
|
|
|
|
.eq(SupDepart::getLevel, DepartLevelEnum.SECOND.getValue()) |
|
|
|
|
|
|
|
.eq(SupDepart::getShortName, departNames[0]).last("limit 1") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(depart)) { |
|
|
|
if (departNames.length > 1) { |
|
|
|
if (departNames.length > 1) { |
|
|
|
List<SupDepart> threeDeparts = departService.list(new LambdaQueryWrapper<SupDepart>() |
|
|
|
SupDepart threeDepart = departService.getOne(new LambdaQueryWrapper<SupDepart>() |
|
|
|
.eq(SupDepart::getPid, departs.get(0).getId()) |
|
|
|
.eq(SupDepart::getPid, depart.getId()) |
|
|
|
.eq(SupDepart::getShortName, departNames[1])); |
|
|
|
.eq(SupDepart::getShortName, departNames[1]).last("limit 1")); |
|
|
|
if (!threeDeparts.isEmpty()) { |
|
|
|
if (ObjectUtil.isNotEmpty(threeDepart)) { |
|
|
|
data.setInvolveDepartId(threeDeparts.get(0).getId()); |
|
|
|
data.setInvolveDepartId(threeDepart.getId()); |
|
|
|
data.setInvolveDepartName(threeDeparts.get(0).getShortName()); |
|
|
|
data.setInvolveDepartName(threeDepart.getShortName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.setInvolveDepartId(departs.get(0).getId()); |
|
|
|
data.setInvolveDepartId(depart.getId()); |
|
|
|
data.setInvolveDepartName(departs.get(0).getShortName()); |
|
|
|
data.setInvolveDepartName(depart.getShortName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -153,6 +164,7 @@ public class NegativeTaskController { |
|
|
|
ReadSheet sheet = EasyExcel.readSheet("问题信息模板").build(); |
|
|
|
ReadSheet sheet = EasyExcel.readSheet("问题信息模板").build(); |
|
|
|
excelReader.read(sheet); |
|
|
|
excelReader.read(sheet); |
|
|
|
excelReader.close(); |
|
|
|
excelReader.close(); |
|
|
|
|
|
|
|
log.debug("耗时监控: {}", stopWatch.shortSummary()); |
|
|
|
return Result.success(list); |
|
|
|
return Result.success(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|