| | |
| | | /** |
| | | * 每隔100条存储数据库,然后清理list ,方便内存回收 |
| | | */ |
| | | private static final int BATCH_COUNT = 100; |
| | | private static final int BATCH_COUNT = 500; |
| | | |
| | | /** |
| | | * 缓存的数据 |
| | |
| | | import com.ycl.system.domain.group.Add; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.constraints.NotBlank; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | |
| | | @PostMapping("/import/{unitId}") |
| | | @ApiOperation(value = "导入数据", notes = "导入数据") |
| | | public Result importData(MultipartFile file, @PathVariable("unitId") Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantTag, Boolean importantCommandImageTag) throws IOException { |
| | | return ywPointService.importData(file, unitId, startTime, endTime, provinceTag, importantTag, importantCommandImageTag); |
| | | public Result importData(MultipartFile file, |
| | | @PathVariable("unitId") Integer unitId, |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime, |
| | | Boolean provinceTag, |
| | | Boolean importantCommandImageTag) throws IOException { |
| | | return ywPointService.importData(file, unitId, startTime, endTime, provinceTag, importantCommandImageTag); |
| | | } |
| | | |
| | | } |
| | |
| | | * @param unitId 运维单位id |
| | | * @return |
| | | */ |
| | | Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantTag, Boolean importantCommandImageTag) throws IOException; |
| | | Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantCommandImageTag) throws IOException; |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantTag, Boolean importantCommandImageTag) throws IOException { |
| | | public Result importData(MultipartFile file, Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantCommandImageTag) throws IOException { |
| | | Consumer<List<PointExport>> consumer = (dataList) -> { |
| | | this.updatePoint(dataList, unitId, startTime, endTime, provinceTag, importantTag, importantCommandImageTag); |
| | | this.updatePoint(dataList, unitId, startTime, endTime, provinceTag, importantCommandImageTag); |
| | | }; |
| | | EasyExcel.read(file.getInputStream(), PointExport.class , new CurrencyDataListener(consumer)).headRowNumber(1).doReadAll(); |
| | | return Result.ok(); |
| | |
| | | * @param dataList |
| | | * @param unitId |
| | | */ |
| | | private void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantTag, Boolean importantCommandImageTag) { |
| | | private void updatePoint(List<PointExport> dataList, Integer unitId, Date startTime, Date endTime, Boolean provinceTag, Boolean importantCommandImageTag) { |
| | | if (CollectionUtils.isEmpty(dataList)) { |
| | | throw new RuntimeException("导入数据不能为空"); |
| | | } |
| | |
| | | .set(YwPoint::getStartTime, startTime) |
| | | .set(YwPoint::getEndTime, endTime) |
| | | .set(YwPoint::getProvinceTag, provinceTag) |
| | | .set(YwPoint::getImportantTag, importantTag) |
| | | .set(YwPoint::getImportantCommandImageTag, importantCommandImageTag) |
| | | .update(); |
| | | } |