From 154c3ad2069e15d8f2fbae0f065c86ad82afdc1c Mon Sep 17 00:00:00 2001 From: duwenyuan <15600000461@163.com> Date: Wed, 10 Dec 2025 09:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=BC=E5=90=88=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=BA=93=E7=9B=B8=E5=85=B3=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GardsAcceleratorController.java | 329 ++++++++++++++++ .../GardsCorrectionFactorController.java | 358 ++++++++++++++++++ .../GardsNuclearFuelFacilityController.java | 285 ++++++++++++++ .../GardsNuclearReactorsController.java | 307 +++++++++++++++ .../GardsNuclearReleaseController.java | 260 +++++++++++++ .../GardsNuclearTestingPlantController.java | 268 +++++++++++++ .../GardsResearchReactorsController.java | 256 +++++++++++++ .../controller/GardsStationsController.java | 252 ++++++++++++ .../service/GardsAcceleratorService.java | 35 ++ .../service/GardsCorrectionFactorService.java | 47 +++ .../GardsNuclearFuelFacilityService.java | 30 ++ .../service/GardsNuclearReactorsService.java | 21 + .../service/GardsNuclearReleaseService.java | 21 + .../GardsNuclearTestingPlantService.java | 20 + .../service/GardsResearchReactorsService.java | 19 + .../jeecg/service/GardsStationsService.java | 17 + .../impl/GardsAcceleratorServiceImpl.java | 52 +++ .../GardsCorrectionFactorServiceImpl.java | 79 ++++ .../GardsNuclearFuelFacilityServiceImpl.java | 56 +++ .../impl/GardsNuclearReactorsServiceImpl.java | 39 ++ .../impl/GardsNuclearReleaseServiceImpl.java | 34 ++ .../GardsNuclearTestingPlantServiceImpl.java | 29 ++ .../GardsResearchReactorsServiceImpl.java | 34 ++ .../impl/GardsStationsServiceImpl.java | 37 ++ .../java/org/jeecg/util/BizUpsertUtil.java | 170 +++++++++ .../org/jeecg/util/DbMetaObjectHandler.java | 23 ++ 26 files changed, 3078 insertions(+) create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsAcceleratorController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearFuelFacilityController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReactorsController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReleaseController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearTestingPlantController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsResearchReactorsController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsStationsController.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsAcceleratorService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearFuelFacilityService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReactorsService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReleaseService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearTestingPlantService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsResearchReactorsService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsStationsService.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsAcceleratorServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearFuelFacilityServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReactorsServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReleaseServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearTestingPlantServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsResearchReactorsServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsStationsServiceImpl.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/BizUpsertUtil.java create mode 100644 jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/DbMetaObjectHandler.java diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsAcceleratorController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsAcceleratorController.java new file mode 100644 index 0000000..2b2ed21 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsAcceleratorController.java @@ -0,0 +1,329 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.SourceRebuildMonitoringData; +import org.jeecg.modules.base.entity.configuration.GardsAccelerator; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.service.GardsAcceleratorService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/gards-accelerator") +public class GardsAcceleratorController { + + @Autowired + private GardsAcceleratorService gardsAcceleratorService; + + /** + * 新增 加速器信息 + */ + @AutoLog(value = "新增加速器信息") + @Operation(summary = "新增加速器信息") + @PostMapping("create") + public Result create(@RequestBody GardsAccelerator gardsAccelerator) { + try { + boolean success = gardsAcceleratorService.save(gardsAccelerator); + if (success) { + return Result.OK("添加成功",gardsAccelerator); + } else { + return Result.error("设施信息添加失败"); + } + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据ID删除设施信息 + */ + @AutoLog(value = "删除加速器信息") + @Operation(summary = "删除加速器信息") + @DeleteMapping("/delete") + public Result delete(@RequestParam Integer id) { + try { + boolean success = gardsAcceleratorService.removeById(id); + if (success) { + return Result.ok("删除成功"); + } else { + return Result.error("设施信息删除失败,可能该记录不存在"); + } + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 更新设施信息 + */ + @Operation(summary = "更新加速器信息") + @PutMapping("/update") + public Result update(@RequestBody GardsAccelerator gardsAccelerator) { + try { + boolean success = gardsAcceleratorService.updateById(gardsAccelerator); + if (success) { + return Result.OK("设施信息更新成功",gardsAccelerator); + } else { + return Result.error("设施信息更新失败,可能该记录不存在"); + } + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据ID查询设施详情 + */ + @Operation(summary = "查询加速器信息") + @GetMapping("/queryById") + public Result getById(@RequestParam Integer id) { + try { + GardsAccelerator facility = gardsAcceleratorService.getById(id); + if (facility != null) { + return Result.ok(facility); + } else { + return Result.error("未找到对应的设施信息"); + } + } catch (Exception e) { + log.error(e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 分页查询设施列表 + */ + @Operation(summary = "加速器信息分页查询") + @GetMapping("/page") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String country, + @RequestParam(required = false) String facilityName + ) { + try { + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.eq(GardsAccelerator::getFacilityName, facilityName); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.eq(GardsAccelerator::getCountry, country); + } + IPage pageResult = gardsAcceleratorService.page(page,wrapper); + return Result.ok(pageResult); + } catch (Exception e) { + log.error("分页查询失败: " + e.getMessage()); + return Result.error("分页查询失败"); + } + } + + /** + * 查询所有设施列表 + */ + @Operation(summary = "查询加速器所有信息") + @GetMapping("/list") + public Result> list() { + try { + List list = gardsAcceleratorService.list(); + return Result.ok(list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据设施代码查询 + */ + @Operation(summary = "根据加速器代码查询") + @GetMapping("/by-facility-code") + public Result getByFacilityCode(@RequestParam String facilityCode) { + try { + GardsAccelerator facility = gardsAcceleratorService.getByFacilityCode(facilityCode); + if (facility != null) { + return Result.ok(facility); + } else { + return Result.error("未找到设施代码为 " + facilityCode + " 的设施"); + } + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据国家查询 + */ + @Operation(summary = "根据加速器国家查询") + @GetMapping("/by-country") + public Result> getByCountry(@RequestParam String country) { + try { + List list = gardsAcceleratorService.getByCountry(country); + return Result.ok(list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败" ); + } + } + + /** + * 根据运行状态查询 + */ + @Operation(summary = "根据加速器运行状态查询") + @GetMapping("/by-status") + public Result> getByOperationalStatus(@RequestParam Integer isOperational) { + try { + List list = gardsAcceleratorService.getByOperationalStatus(isOperational); + return Result.ok(list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 条件组合查询 + */ + @GetMapping("/search") + @Operation(summary = "条件组合查询") + public Result> search( + @RequestParam(required = false) String country, + @RequestParam(required = false) String category, + @RequestParam(required = false) Integer isOperational) { + try { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (country != null && !country.isEmpty()) { + wrapper.eq(GardsAccelerator::getCountry, country); + } + if (category != null && !category.isEmpty()) { + wrapper.eq(GardsAccelerator::getCategory, category); + } + if (isOperational != null) { + wrapper.eq(GardsAccelerator::getIsOperational, isOperational); + } + + List list = gardsAcceleratorService.list(wrapper); + return Result.ok(list); + } catch (Exception e) { + log.error("条件查询失败: " + e.getMessage()); + return Result.error("条件查询失败"); + } + } + + @AutoLog(value = "导出模版") + @Operation(summary = "加速器信息导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("加速器信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsAccelerator.class, new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出数据") + @Operation(summary = "加速器信息导出数据") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String country, + @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String category) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("加速器信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (country != null && !country.isEmpty()) { + wrapper.eq(GardsAccelerator::getCountry, country); + } + if (category != null && !category.isEmpty()) { + wrapper.eq(GardsAccelerator::getCategory, category); + } + if (facilityName != null && !facilityName.isEmpty()) { + wrapper.eq(GardsAccelerator::getFacilityName, facilityName); + } + List list = gardsAcceleratorService.list(wrapper); + ExcelExportUtil.exportExcel(params, GardsAccelerator.class, list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "导入GardsAccelerator数据") + @Operation(summary = "导入加速器数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsAccelerator.class, params); + + // 4. 批量保存数据到数据库 + gardsAcceleratorService.saveBatch(list); + + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorController.java new file mode 100644 index 0000000..a5dcb87 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsCorrectionFactorController.java @@ -0,0 +1,358 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsAccelerator; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.service.GardsCorrectionFactorService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/gardsCorrectionFactor") +public class GardsCorrectionFactorController { + + @Autowired + private GardsCorrectionFactorService gardsCorrectionFactorService; + + /** + * 新增校正因子 + */ + @PostMapping("/create") + @Operation(summary = "新增校正因子") + public Result create(@RequestBody GardsCorrectionFactor gardsCorrectionFactor) { + try { + boolean success = gardsCorrectionFactorService.save(gardsCorrectionFactor); + if (success) { + return Result.OK("校正因子添加成功", gardsCorrectionFactor); + } else { + return Result.error("校正因子添加失败"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据ID删除校正因子 + */ + @DeleteMapping("/delete") + @Operation(summary = "根据ID删除校正因子") + public Result delete(@RequestParam(name="id") Integer id) { + try { + boolean success = gardsCorrectionFactorService.removeById(id); + if (success) { + return Result.ok("校正因子删除成功"); + } else { + return Result.error("校正因子删除失败,可能该记录不存在"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 更新校正因子信息 + */ + @PutMapping("/update") + @Operation(summary = "更新校正因子信息") + public Result update(@RequestBody GardsCorrectionFactor gardsCorrectionFactor) { + try { + boolean success = gardsCorrectionFactorService.updateById(gardsCorrectionFactor); + if (success) { + return Result.OK("校正因子更新成功", gardsCorrectionFactor); + } else { + return Result.error("校正因子更新失败,可能该记录不存在"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据ID查询校正因子详情 + */ + @GetMapping("/queryById") + @Operation(summary = "根据ID查询校正因子详情") + public Result getById(@RequestParam(name="id") Integer id) { + try { + GardsCorrectionFactor factor = gardsCorrectionFactorService.getById(id); + if (factor != null) { + return Result.OK("查询成功", factor); + } else { + return Result.error("未找到对应的校正因子信息"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 分页查询校正因子列表 + */ + @GetMapping("/page") + @Operation(summary = "分页查询校正因子列表") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String detectorCode) { + try { + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (stationCode != null && !stationCode.trim().isEmpty()) { + wrapper.eq(GardsCorrectionFactor::getStationCode, stationCode); + } + if (detectorCode != null && !detectorCode.trim().isEmpty()) { + wrapper.eq(GardsCorrectionFactor::getDetectorCode, detectorCode); + } + + IPage pageResult = gardsCorrectionFactorService.page(page, wrapper); + return Result.OK ("分页查询成功", pageResult); + } catch (Exception e) { + log.error("分页查询失败: " + e.getMessage()); + return Result.error("分页查询失败"); + } + } + + /** + * 查询所有校正因子列表 + */ + @GetMapping("/list") + @Operation(summary = "查询所有校正因子列表") + public Result> list() { + try { + List list = gardsCorrectionFactorService.list(); + return Result.OK ("查询成功", list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败" ); + } + } + + /** + * 根据站点代码查询 + */ + @GetMapping("/by-station") + @Operation(summary = "根据站点代码查询") + public Result> getByStationCode(@RequestParam(name = "stationCode") String stationCode) { + try { + List list = gardsCorrectionFactorService.getByStationCode(stationCode); + return Result.OK ("查询成功", list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据探测器代码查询 + */ + @GetMapping("/by-detector") + @Operation(summary = "查询所有校正因子库数据") + public Result> getByDetectorCode(@RequestParam(name="detectorCode") String detectorCode) { + try { + List list = gardsCorrectionFactorService.getByDetectorCode(detectorCode); + return Result.OK ("查询成功", list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据站点和探测器代码组合查询 + */ + @GetMapping("/by-station-detector") + @Operation(summary = "根据站点和探测器代码组合查询") + public Result> getByStationAndDetector( + @RequestParam String stationCode, + @RequestParam String detectorCode) { + try { + List factor = gardsCorrectionFactorService.getByStationAndDetector(stationCode, detectorCode); + if (factor != null) { + return Result.OK("查询成功", factor); + } else { + return Result.error("未找到对应的校正因子"); + } + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据制造商查询 + */ + @GetMapping("/by-manufacturer") + @Operation(summary = "根据制造商查询") + public Result> getByManufacturer(@RequestParam String manufacturer) { + try { + List list = gardsCorrectionFactorService.getByManufacturer(manufacturer); + return Result.OK("查询成功", list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据型号查询 + */ + @GetMapping("/by-model") + @Operation(summary = "根据型号查询") + public Result> getByModel(@RequestParam String model) { + try { + List list = gardsCorrectionFactorService.getByModel(model); + return Result.OK ("查询成功", list); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 多条件组合查询 + */ + @GetMapping("/search") + @Operation(summary = "校正因子多条件组合查询") + public Result> search( + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String detectorCode, + @RequestParam(required = false) String manufacturer, + @RequestParam(required = false) String model) { + try { + List list = gardsCorrectionFactorService.getByConditions( + stationCode, detectorCode, manufacturer, model); + return Result.OK ("查询成功", list); + } catch (Exception e) { + log.error("条件查询失败: " + e.getMessage()); + return Result.error("条件查询失败"); + } + } + + /** + * 批量更新校正因子 + */ + @PutMapping("/batch") + @Operation(summary = "校正因子批量更新") + public Result updateBatch(@RequestBody List factors) { + try { + boolean success = gardsCorrectionFactorService.updateBatchCorrectionFactors(factors); + if (success) { + return Result.ok("批量更新成功"); + } else { + return Result.error("批量更新失败"); + } + } catch (Exception e) { + log.error("批量操作失败: " + e.getMessage()); + return Result.error("批量操作失败"); + } + } + + @AutoLog(value = "导出模版") + @Operation(summary = "导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("探测器模拟及联符合校正因子信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsCorrectionFactor.class,new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "导出校正因子Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response,@RequestParam(required = false) String stationCode, + @RequestParam(required = false) String detectorCode, + @RequestParam(required = false) String manufacturer, + @RequestParam(required = false) String model) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("探测器模拟及联符合校正因子信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + + List list = gardsCorrectionFactorService.getByConditions( + stationCode, detectorCode, manufacturer, model); + + ExcelExportUtil.exportExcel(params, GardsCorrectionFactor.class,list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "导入GardsAccelerator数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request ) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsCorrectionFactor.class, params); + + // 4. 批量保存数据到数据库 + gardsCorrectionFactorService.saveBatch(list); + + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearFuelFacilityController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearFuelFacilityController.java new file mode 100644 index 0000000..ff89551 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearFuelFacilityController.java @@ -0,0 +1,285 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.modules.base.entity.configuration.GardsNuclearFuelFacilities; +import org.jeecg.service.GardsNuclearFuelFacilityService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/gardsNuclearFuelFacility") +public class GardsNuclearFuelFacilityController { + + @Autowired + private GardsNuclearFuelFacilityService nuclearFuelFacilitiesService; + + /** + * 新增核燃料设施信息 + */ + @PostMapping("/create") + @Operation(summary = "新增核燃料设施信息") + public Result create(@RequestBody GardsNuclearFuelFacilities facility) { + try { + boolean success = nuclearFuelFacilitiesService.save(facility); + if (success) { + return Result.OK("核燃料设施信息添加成功", facility); + } else { + return Result.error("核燃料设施信息添加失败"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据ID删除核燃料设施信息 + */ + @DeleteMapping("/delete") + @Operation(summary = "根据ID删除核燃料设施信息") + public Result delete(@RequestParam Integer id) { + try { + boolean success = nuclearFuelFacilitiesService.removeById(id); + if (success) { + return Result.ok("核燃料设施信息删除成功"); + } else { + return Result.error("核燃料设施信息删除失败,可能该记录不存在"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败 "); + } + } + + /** + * 更新核燃料设施信息 + */ + @PutMapping("/update") + @Operation(summary = "更新核燃料设施信息") + public Result update(@RequestBody GardsNuclearFuelFacilities facility) { + try { + boolean success = nuclearFuelFacilitiesService.updateById(facility); + if (success) { + return Result.OK("核燃料设施信息更新成功", facility); + } else { + return Result.error("核燃料设施信息更新失败,可能该记录不存在"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据ID查询核燃料设施详情 + */ + @GetMapping("/getById") + @Operation(summary = "根据ID查询核燃料设施详情") + public Result getById(@RequestParam Integer id) { + try { + GardsNuclearFuelFacilities facility = nuclearFuelFacilitiesService.getById(id); + if (facility != null) { + return Result.ok(facility); + } else { + return Result.error("未找到对应的核燃料设施信息"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 分页查询核燃料设施列表 + */ + @GetMapping("/page") + @Operation(summary = "分页查询核燃料设施列表") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String facilityType, + @RequestParam(required = false) String facilityStatus, + @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String country) { + try { + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (facilityType != null && !facilityType.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFacilityType, facilityType); + } + if (facilityStatus != null && !facilityStatus.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFacilityStatus, facilityStatus); + } + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFacilityName, facilityName); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getCountry, country); + } + + IPage pageResult = nuclearFuelFacilitiesService.page(page, wrapper); + return Result.OK("分页查询成功", pageResult); + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("分页查询失败"); + } + } + + /** + * 查询所有核燃料设施列表 + */ + @GetMapping("/list") + @Operation(summary = "查询所有核燃料设施列表") + public Result> list() { + try { + List list = nuclearFuelFacilitiesService.list(); + return Result.OK("查询成功", list); + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 根据设施名称模糊查询 + */ + @GetMapping("/by-name") + @Operation(summary = "根据设施名称模糊查询") + public Result> getByFacilityNameLike(@RequestParam String facilityName) { + try { + List list = nuclearFuelFacilitiesService.getByFacilityNameLike(facilityName); + return Result.OK("查询成功", list); + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + + /** + * 多条件组合查询 + */ + @GetMapping("/search") + @Operation(summary = "多条件组合查询") + public Result> search( + @RequestParam(required = false) String facilityType, + @RequestParam(required = false) String facilityStatus, + @RequestParam(required = false) String country, + @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String fuelType) { + try { + List list = nuclearFuelFacilitiesService.getByConditions( + facilityType, facilityStatus, country, facilityName, fuelType); + return Result.OK("查询成功", list); + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("条件查询失败"); + } + } + + @AutoLog(value = "导出模版") + @Operation(summary = "导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("后处理厂设施信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsNuclearFuelFacilities.class, new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "导出Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, @RequestParam(required = false) String facilityType, + @RequestParam(required = false) String facilityStatus, + @RequestParam(required = false) String country, + @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String fuelType) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("后处理厂设施信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + List list = nuclearFuelFacilitiesService.getByConditions( + facilityType, facilityStatus, country, facilityName, fuelType); + ExcelExportUtil.exportExcel(params, GardsNuclearFuelFacilities.class, list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @AutoLog(value = "导入GardsAccelerator数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclearFuelFacilities.class, params); + + // 4. 批量保存数据到数据库 + boolean success = nuclearFuelFacilitiesService.saveBatch(list, 500); + if (success) { + return Result.OK("文件导入成功!数据行数:" + list.size()); + } else { + return Result.error("文件导入失败"); + } + + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReactorsController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReactorsController.java new file mode 100644 index 0000000..4fbeb76 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReactorsController.java @@ -0,0 +1,307 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.log4j.Log4j; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsNuclearFuelFacilities; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors; +import org.jeecg.modules.base.mapper.GardsNuclearReactorsMapper; +import org.jeecg.service.GardsNuclearReactorsService; +import org.jeecg.util.BizUpsertUtil; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Slf4j +@RestController +@RequestMapping("/gardsNuclearReactors") +public class GardsNuclearReactorsController { + + @Autowired + private GardsNuclearReactorsService gardsNuclearReactorsService; + + /** + * 新增 核设施信息 + * + * @param gardsNuclearReactors + * @return + */ + @PostMapping("/create") + @Operation(summary = "新增核设施信息") + public Result create(@RequestBody GardsNuclearReactors gardsNuclearReactors) { + + try { + boolean success = gardsNuclearReactorsService.save(gardsNuclearReactors); + if (success) { + return Result.OK("添加核设施信息成功", gardsNuclearReactors); + } else { + return Result.error("添加核设施信息失败"); + } + } catch (Exception e) { + log.error("新增操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 删除反应堆数据 + * + * @param id + * @return + */ + @DeleteMapping("/delete") + @Operation(summary = "删除核设施信息数据") + public Result delete(@RequestParam Integer id) { + try { + boolean success = gardsNuclearReactorsService.removeById(id); + if (success) { + return Result.ok("核设施信息删除成功"); + } + return Result.error("删除核设施信息失败,可能该记录不存在"); + + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 更新反应堆数据 + * + * @param gardsNuclearReactors + * @return + */ + @PutMapping("/update") + @Operation(summary = "更新核设施数据") + public Result update(@RequestBody GardsNuclearReactors gardsNuclearReactors) { + try { + boolean success = gardsNuclearReactorsService.updateById(gardsNuclearReactors); + if (success) { + return Result.OK("更新成功", gardsNuclearReactors); + } else { + return Result.error("更新失败,或者记录不存在"); + + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 根据Id查询反应堆数据 + * + * @param id + * @return + */ + @GetMapping("/getById") + @Operation(summary = "根据Id查询反应堆数据") + public Result getById(@RequestParam Integer id) { + try { + GardsNuclearReactors nuclearReactors = gardsNuclearReactorsService.getById(id); + if (nuclearReactors != null) { + return Result.OK(nuclearReactors); + } else { + return Result.error("未找到核设施信息数据"); + } + } catch (Exception e) { + log.error("操作失败: " + e.getMessage()); + return Result.error("查询失败"); + } + + } + + /** + * 分页查询反应堆数据 + * + * @param pageNum 页码 + * @param pageSize 分页大小 + * @param unitName 单位名称 + * @param country 国家 + * @return + */ + @GetMapping("/page") + @Operation(summary = "分页查询核设施信息数据") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String unitName, + @RequestParam(required = false) String country) { + + try { + Page page = new Page<>(pageNum, pageSize); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (unitName != null && !unitName.trim().isEmpty()) { + wrapper.eq(GardsNuclearReactors::getUnitName, unitName); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.eq(GardsNuclearReactors::getCountry, country); + } + IPage pageResult = gardsNuclearReactorsService.page(page, wrapper); + + return Result.OK(pageResult); + } catch (Exception e) { + log.error("查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + + + } + + /** + * 组合条件查询 + * + * @param unitName 名称 + * @param country 国家 + * @param reactorType reactorType + * @param reactorStatus reactorStatus + * @return list + */ + @GetMapping("/search") + @Operation(summary = "核设施信息组合条件查询") + public Result> search(@RequestParam(required = false) String unitName, + @RequestParam(required = false) String country, + @RequestParam(required = false) String reactorType, + @RequestParam(required = false) String reactorStatus) { + + try { + List list = gardsNuclearReactorsService.getByConditions(unitName, country, reactorType, reactorStatus); + return Result.OK(list); + } catch (Exception e) { + log.error("条件查询失败: " + e.getMessage()); + return Result.error("条件查询失败"); + } + + + } + + + @AutoLog(value = "导出模版") + @Operation(summary = "核设施信息导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("核设施信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsNuclearReactors.class, new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "核设施信息导出Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String unitName, + @RequestParam(required = false) String country, + @RequestParam(required = false) String reactorType, + @RequestParam(required = false) String reactorStatus) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("核设施信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + List list = gardsNuclearReactorsService.getByConditions(unitName, country, reactorType, reactorStatus); + ExcelExportUtil.exportExcel(params, GardsNuclearReactors.class, list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @param + * @return + */ + @AutoLog(value = "GardsNuclearReactors") + @Operation(summary = "核设施信息导入数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + + + // 1. 【关键修复】检查请求是否为 multipart 请求 + // 如果前端没有使用 form-data 格式提交,或者 Content-Type 不对,这里会拦截 + if (!(request instanceof MultipartHttpServletRequest)) { + return Result.error("请求不是文件上传格式,请检查 Content-Type 是否为 multipart/form-data"); + } + + // 2. 安全转换为 MultipartHttpServletRequest + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 3. 检查是否有文件 + if (fileMap == null || fileMap.isEmpty()) { + return Result.error("未检测到上传的文件"); + } + + // 4. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + + // 过滤空文件 + if (file == null || file.isEmpty()) { + continue; + } + + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + // 5.使用 try-with-resources 自动关闭流 + try (InputStream inputStream = file.getInputStream()) { + + // 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(inputStream, GardsNuclearReactors.class, params); + + // 简单的校验,防止空列表报错 + if (list == null || list.isEmpty()) { + return Result.error("导入失败:文件中没有数据"); + } + + // 批量保存数据到数据库 + boolean success = BizUpsertUtil.upsert(gardsNuclearReactorsService, list, GardsNuclearReactors::getUnitName); + //gardsNuclearReactorsService.saveBatch(list); + if (success) { + return Result.OK("文件导入成功!数据行数:" + list.size()); + } else { + Result.error("文件导入失败"); + } + + } catch (Exception e) { + return Result.error("文件导入失败: " + e.getMessage()); + } + + } + + return Result.error("文件导入失败,未找到有效文件!"); + + + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReleaseController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReleaseController.java new file mode 100644 index 0000000..548b345 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearReleaseController.java @@ -0,0 +1,260 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReleaseRecords; +import org.jeecg.service.GardsNuclearReleaseService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +@Slf4j +@RestController +@RequestMapping("/gardsNuclearReleaseRecords") +public class GardsNuclearReleaseController { + + @Autowired + private GardsNuclearReleaseService gardsNuclearReleaseService; + + /** + * 新增加核设施放射性排放记录信息 + */ + @PostMapping("/create") + @Operation(summary = "新增加核设施放射性排放记录信息") + public Result create(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { + try { + boolean success = gardsNuclearReleaseService.save(gardsNuclearReleaseRecords); + if (success) { + return Result.OK("添加成功", gardsNuclearReleaseRecords); + } else { + return Result.error("添加失败"); + } + } catch (Exception e) { + log.error("create: " + e.getMessage()); + return Result.error("添加失败"); + } + } + + /** + * 删除核设施放射性排放记录信息 + */ + @DeleteMapping("/delete") + @Operation(summary = "删除核设施放射性排放记录信息") + public Result deleteById(@RequestParam Integer id) { + try { + boolean success = gardsNuclearReleaseService.removeById(id); + if (success) { + return Result.OK("删除成功"); + } else { + return Result.error("删除失败,可能数据不存在"); + + } + } catch (Exception e) { + log.error("deleteById: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 更新核设施放射性排放记录信息 + */ + @PutMapping("/update") + @Operation(summary = "更新核设施放射性排放记录信息") + public Result update(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { + try { + boolean success = gardsNuclearReleaseService.updateById(gardsNuclearReleaseRecords); + if (success) { + return Result.OK("数据更新成功", gardsNuclearReleaseRecords); + } else { + return Result.error("数据更新失败"); + + } + } catch (Exception e) { + log.error("update: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 查询核设施放射性排放记录信息 + */ + @GetMapping("/queryById") + @Operation(summary = "查询核设施放射性排放记录信息") + public Result getById(@RequestParam Integer id) { + try { + GardsNuclearReleaseRecords nuclearReactors = gardsNuclearReleaseService.getById(id); + if (nuclearReactors != null) { + return Result.OK(nuclearReactors); + } else { + return Result.error("未找到数据"); + } + } catch (Exception e) { + log.error("getById: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 分页查询 + * + * @param pageNum + * @param pageSize + * @param siteName + * @param nuclide + * @return + */ + @GetMapping("/page") + @Operation(summary = "核设施放射性排放记录分页查询") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String siteName, + @RequestParam(required = false) String nuclide) { + + try { + Page page = new Page<>(pageNum, pageSize); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (siteName != null && !siteName.trim().isEmpty()) { + wrapper.eq(GardsNuclearReleaseRecords::getSiteName, siteName); + } + if (nuclide != null && !nuclide.trim().isEmpty()) { + wrapper.eq(GardsNuclearReleaseRecords::getNuclide, nuclide); + } + IPage pageResult = gardsNuclearReleaseService.page(page, wrapper); + + return Result.OK(pageResult); + } catch (Exception e) { + log.error("page: " + e.getMessage()); + return Result.error("查询失败:"); + } + + + } + + /** + * 组合条件查询 + * + * @param siteName 地点名称 + * @param nuclide 具体核素 + * @param nuclideType 核素类型 + * @param releaseType 释放类型 + * @return + */ + @GetMapping("/search") + @Operation(summary = "核设施放射性排放记录组合条件查询") + public Result> search( + @RequestParam(required = false) String siteName, + @RequestParam(required = false) String nuclide, + @RequestParam(required = false) String nuclideType, + @RequestParam(required = false) String releaseType) { + + try { + List list = gardsNuclearReleaseService.getByConditions(siteName, nuclide, nuclideType, releaseType); + return Result.OK(list); + } catch (Exception e) { + log.error("条件查询失败: " + e.getMessage()); + return Result.error("查询失败"); + } + + } + + @AutoLog(value = "导出模版") + @Operation(summary = "核设施放射性排放记录导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("核设施放射性排放记录信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsNuclearReleaseRecords.class, new ArrayList<>()).write(response.getOutputStream()); + } + + + @AutoLog(value = "导出Excel") + @Operation(summary = "核设施放射性排放记录导出Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String siteName, + @RequestParam(required = false) String nuclide, + @RequestParam(required = false) String nuclideType, + @RequestParam(required = false) String releaseType) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("核设施放射性排放记录信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + List list = gardsNuclearReleaseService.getByConditions(siteName, nuclide, nuclideType, releaseType); + ExcelExportUtil.exportExcel(params, GardsNuclearReleaseRecords.class, list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @AutoLog(value = "GardsNuclearReleaseRecords") + @Operation(summary = "导入核设施放射性排放记录数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclearReleaseRecords.class, params); + + // 4. 批量保存数据到数据库 + gardsNuclearReleaseService.saveBatch(list); + + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearTestingPlantController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearTestingPlantController.java new file mode 100644 index 0000000..f14a36f --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclearTestingPlantController.java @@ -0,0 +1,268 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReleaseRecords; +import org.jeecg.modules.base.entity.configuration.GardsNuclearTestingPlant; +import org.jeecg.service.GardsNuclearReleaseService; +import org.jeecg.service.GardsNuclearTestingPlantService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +@Slf4j +@RestController +@RequestMapping("/gardsNuclearTestingPlant") +public class GardsNuclearTestingPlantController { + + @Autowired + private GardsNuclearTestingPlantService gardsNuclearTestingPlantService; + + /** + * 新增 核试验信息 + */ + @PostMapping("/create") + @Operation(summary = "新增核试验信息") + public Result create(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { + try { + boolean success = gardsNuclearTestingPlantService.save(gardsNuclearTestingPlant); + if (success) { + return Result.OK("添加成功", gardsNuclearTestingPlant); + } else { + return Result.error("添加失败"); + } + } catch (Exception e) { + log.error("create: " + e.getMessage()); + return Result.error("添加失败"); + } + } + + /** + * 删除核设施放射性排放记录信息 + */ + @DeleteMapping("/delete") + @Operation(summary = "删除核试验信息") + public Result deleteById(@RequestParam Integer id) { + try { + boolean success = gardsNuclearTestingPlantService.removeById(id); + if (success) { + return Result.OK("删除成功"); + } else { + return Result.error("删除失败,可能数据不存在"); + + } + } catch (Exception e) { + log.error("deleteById: " + e.getMessage()); + return Result.error("操作失败:"); + } + } + + /** + * 更新核设施放射性排放记录信息 + */ + @PutMapping("/update") + @Operation(summary = "更新核试验信息") + public Result update(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { + try { + boolean success = gardsNuclearTestingPlantService.updateById(gardsNuclearTestingPlant); + if (success) { + return Result.OK("数据更新成功", gardsNuclearTestingPlant); + } else { + return Result.error("数据更新失败"); + + } + } catch (Exception e) { + log.error("update: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 查询核设施放射性排放记录信息 + */ + @GetMapping("/queryById") + @Operation(summary = "查询核试验信息") + public Result getById(@RequestParam Integer id) { + try { + GardsNuclearTestingPlant nuclearReactors = gardsNuclearTestingPlantService.getById(id); + if (nuclearReactors != null) { + return Result.OK(nuclearReactors); + } else { + return Result.error("未找到数据"); + } + } catch (Exception e) { + log.error("getById: " + e.getMessage()); + return Result.error("查询失败:" + e.getMessage()); + } + } + + /** + * 分页查询 + * + * @param pageNum + * @param pageSize + * @param name + * @param type + * @return + */ + @GetMapping("/page") + @Operation(summary = "核试验信息分页查询") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String name, + @RequestParam(required = false) String type) { + + try { + Page page = new Page<>(pageNum, pageSize); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (name != null && !name.trim().isEmpty()) { + wrapper.eq(GardsNuclearTestingPlant::getName, name); + } + if (type != null && !type.trim().isEmpty()) { + wrapper.eq(GardsNuclearTestingPlant::getType, type); + } + IPage pageResult = gardsNuclearTestingPlantService.page(page, wrapper); + + return Result.OK(pageResult); + } catch (Exception e) { + log.error("page: " + e.getMessage()); + return Result.error("查询失败:" + e.getMessage()); + } + + + } + + /** + * 组合条件查询 + * + * @param name 地点名称 + * @param type 具体核素 + * @return + */ + @GetMapping("/search") + @Operation(summary = "核试验信息组合条件查询") + public Result> search( + @RequestParam(required = false) String name, + @RequestParam(required = false) String type) { + + try { + List list = gardsNuclearTestingPlantService.getByConditions(name, type); + return Result.OK(list); + } catch (Exception e) { + log.error("search: " + e.getMessage()); + return Result.error("查询失败"); + } + + } + + + @AutoLog(value = "导出模版") + @Operation(summary = "核试验信息导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("核试验信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsNuclearTestingPlant.class, new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "核试验信息导出Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String name, + @RequestParam(required = false) String type) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("核试验信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + List list = gardsNuclearTestingPlantService.getByConditions(name, type); + ExcelExportUtil.exportExcel(params, GardsNuclearTestingPlant.class, list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "GardsNuclearTestingPlant") + @Operation(summary = "核试验信息导入数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclearTestingPlant.class, params); + + list.forEach(testingPlant -> { + if (StringUtils.isNotBlank(testingPlant.getInfo())) { + testingPlant.setInfo(testingPlant.getInfo() + .replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("\"", """) + .replace("'", "'") + .replaceAll("(?i)\\bmegatons?\\b", "Mt") + .replaceAll("(?i)\\bkilotons?\\b", "kt") + ); + } + }); + // 4. 批量保存数据到数据库 + gardsNuclearTestingPlantService.saveBatch(list,5); + + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsResearchReactorsController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsResearchReactorsController.java new file mode 100644 index 0000000..0ed2a88 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsResearchReactorsController.java @@ -0,0 +1,256 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsNuclearTestingPlant; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; +import org.jeecg.service.GardsResearchReactorsService; +import org.jeecg.service.GardsResearchReactorsService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +@Slf4j +@RestController +@RequestMapping("/gardsResearchReactors")//C17ZNRJDMD6N +public class GardsResearchReactorsController { + @Autowired + private GardsResearchReactorsService gardsResearchReactorsService; + + /** + * 新增信息 + */ + @PostMapping("/create") + @Operation(summary = "新增反应堆信息") + public Result create(@RequestBody GardsResearchReactors gardsResearchReactors) { + try { + boolean success = gardsResearchReactorsService.save(gardsResearchReactors); + if (success) { + return Result.OK("反应堆信息添加成功", gardsResearchReactors); + } else { + return Result.error("反应堆信息添加失败"); + } + } catch (Exception e) { + log.error("create: " + e.getMessage()); + return Result.error("添加失败"); + } + } + + /** + * 删除信息 + */ + @DeleteMapping("/delete") + @Operation(summary = "删除反应堆信息") + public Result deleteById(@RequestParam Integer id) { + try { + boolean success = gardsResearchReactorsService.removeById(id); + if (success) { + return Result.OK("删除成功"); + } else { + return Result.error("删除失败,可能数据不存在"); + + } + } catch (Exception e) { + log.error("deleteById: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 更新反应堆信息 + */ + @PutMapping("/update") + @Operation(summary = "更新反应堆信息") + public Result update(@RequestBody GardsResearchReactors gardsResearchReactors) { + try { + boolean success = gardsResearchReactorsService.updateById(gardsResearchReactors); + if (success) { + return Result.OK("数据更新成功", gardsResearchReactors); + } else { + return Result.error("数据更新失败"); + + } + } catch (Exception e) { + log.error("update: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 查询信息 + */ + @GetMapping("/queryById") + @Operation(summary = "查询反应堆信息") + public Result getById(@RequestParam Integer id) { + try { + GardsResearchReactors nuclearReactors = gardsResearchReactorsService.getById(id); + if (nuclearReactors != null) { + return Result.OK(nuclearReactors); + } else { + return Result.error("未找到数据"); + } + } catch (Exception e) { + log.error("getById: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 分页查询 + * + * @param pageNum + * @param pageSize + * @param facilityName + * @param country + * @return + */ + @GetMapping("/page") + @Operation(summary = "反应堆信息分页查询") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String country) { + + try { + Page page = new Page<>(pageNum, pageSize); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.eq(GardsResearchReactors::getFacilityName, facilityName); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.eq(GardsResearchReactors::getCountry, country); + } + IPage pageResult = gardsResearchReactorsService.page(page, wrapper); + + return Result.OK(pageResult); + } catch (Exception e) { + log.error("page: " + e.getMessage()); + return Result.error("查询失败" ); + } + + + } + + /** + * 组合条件查询 + * + * @param facilityName 地点名称 + * @param country 具体核素 + * @return + */ + @GetMapping("/search") + @Operation(summary = "反应堆信息组合条件查询") + public Result> search(@RequestParam(required = false) String facilityName, + @RequestParam(required = false) String country, + @RequestParam(required = false) String reactorType, + @RequestParam(required = false) String status) { + + try { + List list = gardsResearchReactorsService.getByConditions(facilityName, country, reactorType, status); + return Result.OK(list); + } catch (Exception e) { + log.error("search: " + e.getMessage()); + return Result.error("查询失败"); + } + + } + + @AutoLog(value = "导出模版") + @Operation(summary = "反应堆信息导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("反应堆信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsResearchReactors.class, new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "反应堆信息导出Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String country, + @RequestParam(required = false) String reactorType, + @RequestParam(required = false) String status) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("反应堆信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + List list = gardsResearchReactorsService.getByConditions(facilityName, country, reactorType, status); + ExcelExportUtil.exportExcel(params, GardsResearchReactors.class, list).write(response.getOutputStream()); + } + + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "GardsResearchReactors") + @Operation(summary = "反应堆信息导入数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsResearchReactors.class, params); + + // 4. 批量保存数据到数据库 + gardsResearchReactorsService.saveBatch(list); + + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsStationsController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsStationsController.java new file mode 100644 index 0000000..ef9c8d4 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsStationsController.java @@ -0,0 +1,252 @@ +package org.jeecg.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; +import org.jeecg.modules.base.entity.configuration.GardsStations; +import org.jeecg.service.GardsResearchReactorsService; +import org.jeecg.service.GardsStationsService; +import org.jeecgframework.poi.excel.ExcelExportUtil; +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.entity.enmus.ExcelType; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +@Slf4j +@RestController +@RequestMapping("/gardsStations") +public class GardsStationsController { + @Autowired + private GardsStationsService gardsStationsService; + + /** + * 新增信息 + */ + @PostMapping("/create") + @Operation(summary = "新增台站信息") + public Result create(@RequestBody GardsStations gardsStations) { + try { + boolean success = gardsStationsService.save(gardsStations); + if (success) { + return Result.OK("添加成功", gardsStations); + } else { + return Result.error("添加失败"); + } + } catch (Exception e) { + log.error("create: " + e.getMessage()); + return Result.error("添加失败"); + } + } + + /** + * 删除信息 + */ + @DeleteMapping("/delete") + @Operation(summary = "删除台站信息") + public Result deleteById(@RequestParam Integer stationId) { + try { + boolean success = gardsStationsService.removeById(stationId); + if (success) { + return Result.OK("删除成功"); + } else { + return Result.error("删除失败,可能数据不存在"); + + } + } catch (Exception e) { + log.error("deleteById: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 更新信息 + */ + @PutMapping("/update") + @Operation(summary = "更新台站信息") + public Result update(@RequestBody GardsStations gardsStations) { + try { + boolean success = gardsStationsService.updateById(gardsStations); + if (success) { + return Result.OK("数据更新成功", gardsStations); + } else { + return Result.error("数据更新失败"); + + } + } catch (Exception e) { + log.error("update: " + e.getMessage()); + return Result.error("操作失败"); + } + } + + /** + * 查询信息 + */ + @GetMapping("/queryById") + @Operation(summary = "查询台站信息") + public Result getById(@RequestParam Integer stationId) { + try { + GardsStations nuclearReactors = gardsStationsService.getById(stationId); + if (nuclearReactors != null) { + return Result.OK(nuclearReactors); + } else { + return Result.error("未找到数据"); + } + } catch (Exception e) { + log.error("getById: " + e.getMessage()); + return Result.error("查询失败" ); + } + } + + /** + * 分页查询 + * + * @param pageNum + * @param pageSize + * @param stationCode + * @param countryCode + * @return + */ + @GetMapping("/page") + @Operation(summary = "台站分页查询") + public Result> page( + @RequestParam(defaultValue = "1") Integer pageNum, + @RequestParam(defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String countryCode) { + + try { + Page page = new Page<>(pageNum, pageSize); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (stationCode != null && !stationCode.trim().isEmpty()) { + wrapper.eq(GardsStations::getStationCode, stationCode); + } + if (countryCode != null && !countryCode.trim().isEmpty()) { + wrapper.eq(GardsStations::getCountryCode, countryCode); + } + IPage pageResult = gardsStationsService.page(page, wrapper); + + return Result.OK(pageResult); + } catch (Exception e) { + log.error("page: " + e.getMessage()); + return Result.error("查询失败"); + } + } + + /** + * 组合条件查询 + * + * @param stationCode 地点名称 + * @param type 类型 + * @return + */ + @GetMapping("/search") + @Operation(summary = "台站组合条件查询") + public Result> search(@RequestParam(required = false) String stationCode, + @RequestParam(required = false) String type, + @RequestParam(required = false) String status, + @RequestParam(required = false) String countryCode) { + + try { + List list = gardsStationsService.getByConditions(stationCode, type, status, countryCode); + return Result.OK(list); + } catch (Exception e) { + log.error("search: " + e.getMessage()); + return Result.error("查询失败"); + } + + } + + @AutoLog(value = "导出模版") + @Operation(summary = "台站导出模版") + @GetMapping("/exportTemplate") + public void exportTemplate(HttpServletResponse response) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("台站信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + ExcelExportUtil.exportExcel(params, GardsStations.class, new ArrayList<>()).write(response.getOutputStream()); + } + + @AutoLog(value = "导出Excel") + @Operation(summary = "台站导出Excel") + @GetMapping("/exportExcel") + public void exportExcel(HttpServletResponse response, + @RequestParam(required = false) String stationCode, + @RequestParam(required = false) String type, + @RequestParam(required = false) String status, + @RequestParam(required = false) String countryCode) throws IOException { + ExportParams params = new ExportParams(); + params.setTitle("台站信息"); + params.setFixedTitle(true); + params.setTitleHeight((short) 8); + params.setType(ExcelType.XSSF); + List list = gardsStationsService.getByConditions(stationCode, type, status, countryCode); + ExcelExportUtil.exportExcel(params, GardsStations.class, list).write(response.getOutputStream()); + } + + /** + * 通过excel导入数据 + * + * @param request + * @return + */ + @AutoLog(value = "GardsStations") + @Operation(summary = "导入台站数据") + @PostMapping(value = "/importExcel") + public Result importExcel(HttpServletRequest request) { + // 1. 获取上传文件 + MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; + Map fileMap = multipartRequest.getFileMap(); + + // 2. 遍历文件进行处理 + for (Map.Entry entity : fileMap.entrySet()) { + // 获取上传文件对象 + MultipartFile file = entity.getValue(); + ImportParams params = new ImportParams(); + // 设置标题行行数(通常为1,如果没有标题填0) + params.setTitleRows(1); + // 设置表头行数(通常为1) + params.setHeadRows(1); + params.setNeedSave(true); + + try { + // 3. 使用 AutoPoi 工具类解析 Excel + List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsStations.class, params); + + // 4. 批量保存数据到数据库 + gardsStationsService.saveBatch(list); + + return Result.OK("文件导入成功!数据行数:" + list.size()); + } catch (Exception e) { + return Result.error("文件导入失败:" + e.getMessage()); + } finally { + try { + file.getInputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return Result.error("文件导入失败!"); + } + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsAcceleratorService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsAcceleratorService.java new file mode 100644 index 0000000..ae334b9 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsAcceleratorService.java @@ -0,0 +1,35 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsAccelerator; + +import java.util.List; + +public interface GardsAcceleratorService extends IService { + + /** + * 根据设施代码查询设施信息 + */ + GardsAccelerator getByFacilityCode(String facilityCode); + + /** + * 根据国家查询设施列表 + */ + List getByCountry(String country); + + /** + * 根据运行状态查询设施列表 + */ + List getByOperationalStatus(Integer isOperational); + + /** + * 根据分类查询设施列表 + */ + List getByCategory(String category); + + /** + * 条件查询:国家 + 运行状态 + */ + List getByCountryAndStatus(String country, Integer isOperational); + +} \ No newline at end of file diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorService.java new file mode 100644 index 0000000..4fd9f80 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsCorrectionFactorService.java @@ -0,0 +1,47 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; + +import java.util.List; + +public interface GardsCorrectionFactorService extends IService { + + + /** + * 根据站点代码查询校正因子列表 + */ + List getByStationCode(String stationCode); + + /** + * 根据探测器代码查询校正因子列表 + */ + List getByDetectorCode(String detectorCode); + + /** + * 根据站点和探测器代码查询校正因子 + */ + List getByStationAndDetector(String stationCode, String detectorCode); + + /** + * 根据制造商查询校正因子列表 + */ + List getByManufacturer(String manufacturer); + + /** + * 根据型号查询校正因子列表 + */ + List getByModel(String model); + + /** + * 条件组合查询 + */ + List getByConditions(String stationCode, String detectorCode, + String manufacturer, String model); + + /** + * 批量更新校正因子 + */ + boolean updateBatchCorrectionFactors(List factors); + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearFuelFacilityService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearFuelFacilityService.java new file mode 100644 index 0000000..8f16b00 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearFuelFacilityService.java @@ -0,0 +1,30 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsNuclearFuelFacilities; + +import java.util.List; + +/** + * 核燃料设施信息 + */ +public interface GardsNuclearFuelFacilityService extends IService { + + /** + * 根据设施名称模糊查询 + */ + List getByFacilityNameLike(String facilityName); + + /** + * 多条件组合查询 + */ + List getByConditions(String facilityType, String facilityStatus, String country,String facilityName, String fuelType); + + /** + * 批量更新设施状态 + */ + boolean updateBatchFacilityStatus(List ids, String status); + + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReactorsService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReactorsService.java new file mode 100644 index 0000000..bd7f2ae --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReactorsService.java @@ -0,0 +1,21 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors; +import org.jeecg.modules.base.mapper.GardsNuclearReactorsMapper; + +import java.util.List; + +public interface GardsNuclearReactorsService extends IService { + + /** + * 多条件组合查询 + * @return List + */ + List getByConditions(String unitName,String country,String reactorType,String reactorStatus); + + void saveOrUpdateBatchByUniqueFields(List list); + + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReleaseService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReleaseService.java new file mode 100644 index 0000000..56959c0 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearReleaseService.java @@ -0,0 +1,21 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReleaseRecords; + +import java.util.List; + +public interface GardsNuclearReleaseService extends IService { + /** + * 多条件组合查询 + * @param siteName 站点/电厂名称 + * @param nuclide 具体核素 + * @param nuclideType 核素类别 + * @param releaseType 排放类型 + * @return List + */ + List getByConditions(String siteName, String nuclide, String nuclideType, String releaseType); + + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearTestingPlantService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearTestingPlantService.java new file mode 100644 index 0000000..8e92373 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclearTestingPlantService.java @@ -0,0 +1,20 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReleaseRecords; +import org.jeecg.modules.base.entity.configuration.GardsNuclearTestingPlant; + +import java.util.List; + +public interface GardsNuclearTestingPlantService extends IService { + + + /** + * 多条件组合查询 + * @param name 名称 + * @param type 类型 + * @return List + */ + List getByConditions(String name, String type); + +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsResearchReactorsService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsResearchReactorsService.java new file mode 100644 index 0000000..bbe8ef0 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsResearchReactorsService.java @@ -0,0 +1,19 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsNuclearTestingPlant; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; + +import java.util.List; + +public interface GardsResearchReactorsService extends IService { + + + /** + * 多条件组合查询 + * @param facilityName 名称 + * @param country 类型 + * @return List + */ + List getByConditions(String facilityName, String country,String reactorType,String status); +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsStationsService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsStationsService.java new file mode 100644 index 0000000..a19cb65 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsStationsService.java @@ -0,0 +1,17 @@ +package org.jeecg.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; +import org.jeecg.modules.base.entity.configuration.GardsStations; + +import java.util.List; + +public interface GardsStationsService extends IService { + /** + * 多条件组合查询 + * @param stationCode 名称 + * @param type 类型 + * @return List + */ + List getByConditions(String stationCode, String type, String status,String countryCode); +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsAcceleratorServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsAcceleratorServiceImpl.java new file mode 100644 index 0000000..c396a6d --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsAcceleratorServiceImpl.java @@ -0,0 +1,52 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsAccelerator; +import org.jeecg.modules.base.mapper.GardsAcceleratorMapper; +import org.jeecg.service.GardsAcceleratorService; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +@DS("ora") +public class GardsAcceleratorServiceImpl extends ServiceImpl implements GardsAcceleratorService { + + + @Override + public GardsAccelerator getByFacilityCode(String facilityCode) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsAccelerator::getFacilityCode, facilityCode); + return this.getOne(wrapper); + } + + @Override + public List getByCountry(String country) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsAccelerator::getCountry, country); + return this.list(wrapper); + } + + @Override + public List getByOperationalStatus(Integer isOperational) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsAccelerator::getIsOperational, isOperational); + return this.list(wrapper); + } + + @Override + public List getByCategory(String category) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsAccelerator::getCategory, category); + return this.list(wrapper); + } + + @Override + public List getByCountryAndStatus(String country, Integer isOperational) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsAccelerator::getCountry, country) + .eq(GardsAccelerator::getIsOperational, isOperational); + return this.list(wrapper); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorServiceImpl.java new file mode 100644 index 0000000..d0f8e0e --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsCorrectionFactorServiceImpl.java @@ -0,0 +1,79 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsCorrectionFactor; +import org.jeecg.modules.base.mapper.GardsCorrectionFactorMapper; +import org.jeecg.service.GardsCorrectionFactorService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@DS("ora") +public class GardsCorrectionFactorServiceImpl extends ServiceImpl implements GardsCorrectionFactorService { + + @Override + public List getByStationCode(String stationCode) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsCorrectionFactor::getStationCode, stationCode); + return this.list(wrapper); + } + + @Override + public List getByDetectorCode(String detectorCode) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsCorrectionFactor::getDetectorCode, detectorCode); + return this.list(wrapper); + } + + @Override + public List getByStationAndDetector(String stationCode, String detectorCode) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsCorrectionFactor::getStationCode, stationCode) + .eq(GardsCorrectionFactor::getDetectorCode, detectorCode); + return this.list(wrapper); + } + + @Override + public List getByManufacturer(String manufacturer) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsCorrectionFactor::getManufacturer, manufacturer); + return this.list(wrapper); + } + + @Override + public List getByModel(String model) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(GardsCorrectionFactor::getModel, model); + return this.list(wrapper); + } + + @Override + public List getByConditions(String stationCode, String detectorCode, + String manufacturer, String model) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (stationCode != null && !stationCode.trim().isEmpty()) { + wrapper.eq(GardsCorrectionFactor::getStationCode, stationCode); + } + if (detectorCode != null && !detectorCode.trim().isEmpty()) { + wrapper.eq(GardsCorrectionFactor::getDetectorCode, detectorCode); + } + if (manufacturer != null && !manufacturer.trim().isEmpty()) { + wrapper.eq(GardsCorrectionFactor::getManufacturer, manufacturer); + } + if (model != null && !model.trim().isEmpty()) { + wrapper.eq(GardsCorrectionFactor::getModel, model); + } + + return this.list(wrapper); + } + + @Override + public boolean updateBatchCorrectionFactors(List factors) { + return this.updateBatchById(factors); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearFuelFacilityServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearFuelFacilityServiceImpl.java new file mode 100644 index 0000000..485b7ca --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearFuelFacilityServiceImpl.java @@ -0,0 +1,56 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsNuclearFuelFacilities; +import org.jeecg.modules.base.mapper.GardsNuclearFuelFacilitiesMapper; +import org.jeecg.service.GardsNuclearFuelFacilityService; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +@DS("ora") +public class GardsNuclearFuelFacilityServiceImpl extends ServiceImpl implements GardsNuclearFuelFacilityService { + + + @Override + public List getByFacilityNameLike(String facilityName) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.like(GardsNuclearFuelFacilities::getFacilityName, facilityName); + return this.list(wrapper); + } + + @Override + public List getByConditions(String facilityType, String facilityStatus, String country,String facilityName, String fuelType) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + + if (facilityType != null && !facilityType.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFacilityType, facilityType); + } + if (facilityStatus != null && !facilityStatus.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFacilityStatus, facilityStatus); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getCountry, country); + } + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFacilityName, facilityName); + } + if (fuelType != null && !fuelType.trim().isEmpty()) { + wrapper.eq(GardsNuclearFuelFacilities::getFuelType, fuelType); + } + + return this.list(wrapper); + } + + @Override + public boolean updateBatchFacilityStatus(List ids, String status) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(GardsNuclearFuelFacilities::getId, ids); + + GardsNuclearFuelFacilities updateEntity = new GardsNuclearFuelFacilities(); + + return this.update(updateEntity, wrapper); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReactorsServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReactorsServiceImpl.java new file mode 100644 index 0000000..4b6247f --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReactorsServiceImpl.java @@ -0,0 +1,39 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors; +import org.jeecg.modules.base.mapper.GardsNuclearReactorsMapper; +import org.jeecg.service.GardsNuclearReactorsService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +@Service +@DS("ora") +public class GardsNuclearReactorsServiceImpl extends ServiceImpl implements GardsNuclearReactorsService { + @Override + public List getByConditions(String unitName, String country, String reactorType, String reactorStatus) { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (unitName != null && !unitName.trim().isEmpty()) { + wrapper.eq(GardsNuclearReactors::getUnitName, unitName); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.eq(GardsNuclearReactors::getCountry, country); + } + if (reactorType != null && !reactorType.trim().isEmpty()) { + wrapper.eq(GardsNuclearReactors::getReactorType, reactorType); + } + if (reactorStatus != null && !reactorStatus.trim().isEmpty()) { + wrapper.eq(GardsNuclearReactors::getReactorStatus, reactorStatus); + } + return this.list(wrapper); + } + @Transactional(rollbackFor = Exception.class) + @Override + public void saveOrUpdateBatchByUniqueFields(List list) { +this.saveOrUpdateBatch(list); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReleaseServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReleaseServiceImpl.java new file mode 100644 index 0000000..9c0855b --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearReleaseServiceImpl.java @@ -0,0 +1,34 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReactors; +import org.jeecg.modules.base.entity.configuration.GardsNuclearReleaseRecords; +import org.jeecg.modules.base.mapper.GardsNuclearReleaseRecordsMapper; +import org.jeecg.service.GardsNuclearReleaseService; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +@DS("ora") +public class GardsNuclearReleaseServiceImpl extends ServiceImpl implements GardsNuclearReleaseService { + @Override + public List getByConditions(String siteName, String nuclide, String nuclideType, String releaseType) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (siteName != null && !siteName.trim().isEmpty()) { + queryWrapper.eq(GardsNuclearReleaseRecords::getSiteName, siteName); + } + if (nuclide != null && !nuclide.trim().isEmpty()) { + queryWrapper.eq(GardsNuclearReleaseRecords::getNuclide, nuclide); + } + if (nuclideType != null && !nuclideType.trim().isEmpty()) { + queryWrapper.eq(GardsNuclearReleaseRecords::getNuclideType, nuclideType); + } + if (releaseType != null && !releaseType.trim().isEmpty()) { + queryWrapper.eq(GardsNuclearReleaseRecords::getReleaseType, releaseType); + } + return this.list(queryWrapper); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearTestingPlantServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearTestingPlantServiceImpl.java new file mode 100644 index 0000000..5243572 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclearTestingPlantServiceImpl.java @@ -0,0 +1,29 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsNuclearTestingPlant; +import org.jeecg.modules.base.mapper.GardsNuclearTestingPlantMapper; +import org.jeecg.service.GardsNuclearTestingPlantService; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +@DS("ora") +public class GardsNuclearTestingPlantServiceImpl extends ServiceImpl implements GardsNuclearTestingPlantService { + + @Override + public List getByConditions(String name, String type) { + + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + + if (name != null&&!name.trim().isEmpty()) { + query.eq(GardsNuclearTestingPlant::getName, name); + } + if (type != null&&!type.trim().isEmpty()) { + query.eq(GardsNuclearTestingPlant::getType, type); + } + return this.list(query); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsResearchReactorsServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsResearchReactorsServiceImpl.java new file mode 100644 index 0000000..368eb79 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsResearchReactorsServiceImpl.java @@ -0,0 +1,34 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsNuclearTestingPlant; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; +import org.jeecg.modules.base.mapper.GardsResearchReactorsMapper; +import org.jeecg.service.GardsResearchReactorsService; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +@DS("ora") +public class GardsResearchReactorsServiceImpl extends ServiceImpl implements GardsResearchReactorsService { + @Override + public List getByConditions(String facilityName, String country,String reactorType,String status) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + + if (facilityName != null&&!facilityName.trim().isEmpty()) { + query.eq(GardsResearchReactors::getFacilityName, facilityName); + } + if (country != null&&!country.trim().isEmpty()) { + query.eq(GardsResearchReactors::getCountry, country); + } + if (reactorType != null&&!reactorType.trim().isEmpty()) { + query.eq(GardsResearchReactors::getReactorType, reactorType); + } + if (status != null&&!status.trim().isEmpty()) { + query.eq(GardsResearchReactors::getStatus, status); + } + return this.list(query); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsStationsServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsStationsServiceImpl.java new file mode 100644 index 0000000..1b0cfd0 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsStationsServiceImpl.java @@ -0,0 +1,37 @@ +package org.jeecg.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.configuration.GardsResearchReactors; +import org.jeecg.modules.base.entity.configuration.GardsStations; +import org.jeecg.modules.base.mapper.GardsStationsMapper; +import org.jeecg.service.GardsStationsService; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +@DS("ora") +public class GardsStationsServiceImpl extends ServiceImpl implements GardsStationsService { + + + @Override + public List getByConditions(String stationCode, String type, String status,String countryCode) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + + if (stationCode != null&&!stationCode.trim().isEmpty()) { + query.eq(GardsStations::getStationCode, stationCode); + } + if (type != null&&!type.trim().isEmpty()) { + query.eq(GardsStations::getType, type); + } + if (status != null&&!status.trim().isEmpty()) { + query.eq(GardsStations::getStatus, status); + } + if (countryCode != null&&!countryCode.trim().isEmpty()) { + query.eq(GardsStations::getCountryCode, countryCode); + } + + return this.list(query); + } +} diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/BizUpsertUtil.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/BizUpsertUtil.java new file mode 100644 index 0000000..a2c44d9 --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/BizUpsertUtil.java @@ -0,0 +1,170 @@ +package org.jeecg.util; + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.support.SFunction; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.lang.reflect.Field; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class BizUpsertUtil { + + @SafeVarargs + public static boolean upsert(IService service, List list, + SFunction... uniqueColumns) { + return upsert(service, list, Arrays.asList(uniqueColumns)); + } + + // + public static boolean upsertByColumnNames(IService service, List list, + String... uniqueColumnNames) { + if (list.isEmpty()) return true; + + String firstCol = uniqueColumnNames[0]; + + // 提取第一个字段的值用于 IN 查询(反射取值) + List firstValues = list.stream() + .map(entity -> getFieldValue(entity, firstCol)) + .filter(Objects::nonNull) + .distinct() + .toList(); + + // 用 QueryWrapper,完全不涉及 SFunction + List existList = service.list(new QueryWrapper() + .in(firstCol, firstValues) + .select(uniqueColumnNames) // 可选:只查需要的字段 + ); + + Map existMap = existList.stream() + .collect(Collectors.toMap( + e -> buildKey(e, uniqueColumnNames), + e -> e + )); + + List insert = new ArrayList<>(); + List update = new ArrayList<>(); + + for (T entity : list) { + String key = buildKey(entity, uniqueColumnNames); + T db = existMap.get(key); + if (db == null) { + insert.add(entity); + } else { + copyId(db, entity); + update.add(entity); + } + } + + boolean ok1 = insert.isEmpty() || service.saveBatch(insert, 1000); + boolean ok2 = update.isEmpty() || service.updateBatchById(update, 1000); + + System.out.println("插入:" + insert.size() + " 更新:" + update.size()); + return ok1 && ok2; + } + + // 反射取字段值(支持驼峰转下划线) + private static Object getFieldValue(T entity, String fieldName) { + try { + Field field = entity.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + return field.get(entity); + } catch (Exception e) { + // 如果字段名是 username,但数据库是 user_name,可以自动转换 + String dbColumn = StringUtils.camelToUnderline(fieldName); + try { + Field field = entity.getClass().getDeclaredField(dbColumn); + field.setAccessible(true); + return field.get(entity); + } catch (Exception ex) { + return null; + } + } + } + + // 构建 key + private static String buildKey(T entity, String[] columnNames) { + return Arrays.stream(columnNames) + .map(col -> Objects.toString(getFieldValue(entity, col), "NULL")) + .collect(Collectors.joining("::")); + } + public static boolean upsert(IService service, List list, + List> uniqueColumns) { + if (list == null || list.isEmpty()) return true; + + // 1. 提取所有业务唯一键(用于匹配) + Map keyToEntity = new HashMap<>(); + for (T entity : list) { + String key = buildKey(entity, uniqueColumns); + keyToEntity.put(key, entity); + } + + // 2. 用第一个字段去数据库查已存在的记录(关键修复!) + SFunction firstCol = uniqueColumns.get(0); + + List firstColumnValues = list.stream() + .map(firstCol) + .filter(Objects::nonNull) + .distinct() + .toList(); + + List existList = service.list( + (new LambdaQueryWrapper()).in( firstCol, firstColumnValues) + ); + + // 3. 构建已存在记录的 key 映射 + Map existMap = existList.stream() + .collect(Collectors.toMap( + e -> buildKey(e, uniqueColumns), + e -> e + )); + + List insertList = new ArrayList<>(); + List updateList = new ArrayList<>(); + + for (T entity : list) { + String key = buildKey(entity, uniqueColumns); + T dbEntity = existMap.get(key); + if (dbEntity == null) { + insertList.add(entity); + } else { + // 把数据库的主键 ID 复制回来(最简单方式) + copyId(dbEntity, entity); + updateList.add(entity); + } + } + + boolean ok1 = insertList.isEmpty() || service.saveBatch(insertList, 1000); + boolean ok2 = updateList.isEmpty() || service.updateBatchById(updateList, 1000); + + System.out.println("插入: " + insertList.size() + ", 更新: " + updateList.size()); + return ok1 && ok2; + } + + // 拼接 key:value1::value2 + private static String buildKey(T entity, List> columns) { + return columns.stream() + .map(col -> { + Object v = col.apply(entity); + return v == null ? "NULL" : v.toString(); + }) + .collect(Collectors.joining("::")); + } + + // 复制主键(假设主键字段叫 id,改成你的就行) + private static void copyId(T from, T to) { + try { + var fromId = from.getClass().getMethod("getId").invoke(from); + if (fromId != null) { + var setId = to.getClass().getMethod("setId", fromId.getClass()); + setId.invoke(to, fromId); + } + } catch (Exception ignored) { + // 如果没有 getId/setId 方法,就忽略(或者你改成自己的主键名) + } + } +} \ No newline at end of file diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/DbMetaObjectHandler.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/DbMetaObjectHandler.java new file mode 100644 index 0000000..83bc51e --- /dev/null +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/util/DbMetaObjectHandler.java @@ -0,0 +1,23 @@ +package org.jeecg.util; + +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import org.apache.ibatis.reflection.MetaObject; +import org.springframework.stereotype.Component; + +import java.time.LocalDateTime; +import java.util.Date; +@Component +public class DbMetaObjectHandler implements MetaObjectHandler { + @Override + public void insertFill(MetaObject metaObject) { + + this.strictInsertFill(metaObject, "moddate", java.util.Date.class, new Date()); + //this.strictInsertFill(metaObject, "updatedAt", java.util.Date.class, new Date()); + } + + @Override + public void updateFill(MetaObject metaObject) { + LocalDateTime now = LocalDateTime.now(); + this.strictUpdateFill(metaObject, "moddate", java.util.Date.class, new Date()); + } +}