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 index 3dc2960..21251cd 100644 --- 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 @@ -2,7 +2,6 @@ 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; @@ -10,9 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; 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; @@ -20,7 +17,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -30,11 +27,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * 加速器信息 + */ @Slf4j @RestController @RequestMapping("/gards-accelerator") public class GardsAcceleratorController { - + final short titleHeight = 8; @Autowired private GardsAcceleratorService gardsAcceleratorService; @@ -45,7 +45,8 @@ public class GardsAcceleratorController { @Operation(summary = "新增加速器信息") @PostMapping("create") public Result create(@RequestBody GardsAccelerator gardsAccelerator) { - return gardsAcceleratorService.create(gardsAccelerator); + gardsAcceleratorService.create(gardsAccelerator); + return Result.OK("新增成功!"); } /** @@ -55,7 +56,8 @@ public class GardsAcceleratorController { @Operation(summary = "删除加速器信息") @DeleteMapping("/delete") public Result delete(@RequestParam Integer id) { - return gardsAcceleratorService.delete(id); + gardsAcceleratorService.delete(id); + return Result.OK("删除成功!"); } /** @@ -64,8 +66,8 @@ public class GardsAcceleratorController { @Operation(summary = "更新加速器信息") @PutMapping("/update") public Result update(@RequestBody GardsAccelerator gardsAccelerator) { - return gardsAcceleratorService.update(gardsAccelerator); - + gardsAcceleratorService.update(gardsAccelerator); + return Result.OK(); } /** @@ -74,7 +76,7 @@ public class GardsAcceleratorController { @Operation(summary = "查询加速器信息") @GetMapping("/queryById") public Result getById(@RequestParam Integer id) { - return gardsAcceleratorService.queryById(id); + return Result.OK(gardsAcceleratorService.queryById(id)); } /** @@ -88,107 +90,10 @@ public class GardsAcceleratorController { @RequestParam(required = false) String country, @RequestParam(required = false) String facilityName ) { - return gardsAcceleratorService.queryPage(pageNum, pageSize, country, facilityName); + return Result.OK( + gardsAcceleratorService.queryPage(pageNum, pageSize, country, facilityName)); } - //region 注释代码 -// -// /** -// * 查询所有设施列表 -// */ -// @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("条件查询失败"); -// } -// } - - //endregion - @AutoLog(value = "导出模版") @Operation(summary = "加速器信息导出模版") @GetMapping("/exportTemplate") @@ -196,9 +101,10 @@ public class GardsAcceleratorController { ExportParams params = new ExportParams(); params.setTitle("加速器信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsAccelerator.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsAccelerator.class, new ArrayList<>()) + .write(response.getOutputStream()); } @AutoLog(value = "导出数据") @@ -211,7 +117,7 @@ public class GardsAcceleratorController { ExportParams params = new ExportParams(); params.setTitle("加速器信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -228,7 +134,8 @@ public class GardsAcceleratorController { wrapper.orderByDesc(GardsAccelerator::getId); List list = gardsAcceleratorService.list(wrapper); - ExcelExportUtil.exportExcel(params, GardsAccelerator.class, list).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsAccelerator.class, list) + .write(response.getOutputStream()); } @@ -259,11 +166,15 @@ public class GardsAcceleratorController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsAccelerator.class, params); + List list = + ExcelImportUtil.importExcel(file.getInputStream(), GardsAccelerator.class, + params); // 4. 批量保存数据到数据库 - gardsAcceleratorService.saveBatch(list); - + //gardsAcceleratorService.saveBatch(list); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> gardsAcceleratorService.save(item)); + } return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); 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 index 282567c..44e6219 100644 --- 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 @@ -1,16 +1,12 @@ 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; @@ -19,6 +15,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -28,11 +25,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * 校正因子 + */ @Slf4j @RestController @RequestMapping("/gardsCorrectionFactor") public class GardsCorrectionFactorController { - + final short titleHeight = 8; @Autowired private GardsCorrectionFactorService gardsCorrectionFactorService; @@ -42,7 +42,8 @@ public class GardsCorrectionFactorController { @PostMapping("/create") @Operation(summary = "新增校正因子") public Result create(@RequestBody GardsCorrectionFactor gardsCorrectionFactor) { - return gardsCorrectionFactorService.create(gardsCorrectionFactor); + gardsCorrectionFactorService.create(gardsCorrectionFactor); + return Result.OK("新增成功!"); } /** @@ -50,8 +51,9 @@ public class GardsCorrectionFactorController { */ @DeleteMapping("/delete") @Operation(summary = "根据ID删除校正因子") - public Result delete(@RequestParam(name="id") Integer id) { - return gardsCorrectionFactorService.delete(id); + public Result delete(@RequestParam(name = "id") Integer id) { + gardsCorrectionFactorService.delete(id); + return Result.OK("删除成功!"); } /** @@ -60,7 +62,8 @@ public class GardsCorrectionFactorController { @PutMapping("/update") @Operation(summary = "更新校正因子信息") public Result update(@RequestBody GardsCorrectionFactor gardsCorrectionFactor) { - return gardsCorrectionFactorService.update(gardsCorrectionFactor); + gardsCorrectionFactorService.update(gardsCorrectionFactor); + return Result.OK(); } /** @@ -68,8 +71,8 @@ public class GardsCorrectionFactorController { */ @GetMapping("/queryById") @Operation(summary = "根据ID查询校正因子详情") - public Result getById(@RequestParam(name="id") Integer id) { - return gardsCorrectionFactorService.queryById(id); + public Result getById(@RequestParam(name = "id") Integer id) { + return Result.OK(gardsCorrectionFactorService.queryById(id)); } /** @@ -82,147 +85,10 @@ public class GardsCorrectionFactorController { @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String stationCode, @RequestParam(required = false) String detectorCode) { - return gardsCorrectionFactorService.page(pageNum, pageSize, stationCode, detectorCode); + return Result.OK( + gardsCorrectionFactorService.page(pageNum, pageSize, stationCode, detectorCode)); } - //region 注释代码 -// -// /** -// * 查询所有校正因子列表 -// */ -// @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("批量操作失败"); -// } -// } -// - //endregion @AutoLog(value = "导出模版") @Operation(summary = "导出模版") @@ -231,28 +97,30 @@ public class GardsCorrectionFactorController { ExportParams params = new ExportParams(); params.setTitle("探测器模拟及联符合校正因子信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsCorrectionFactor.class,new ArrayList<>()).write(response.getOutputStream()); + 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, + 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.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); List list = gardsCorrectionFactorService.getByConditions( stationCode, detectorCode, manufacturer, model); - - ExcelExportUtil.exportExcel(params, GardsCorrectionFactor.class,list).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsCorrectionFactor.class, list) + .write(response.getOutputStream()); } @@ -264,7 +132,7 @@ public class GardsCorrectionFactorController { */ @AutoLog(value = "导入GardsAccelerator数据") @PostMapping(value = "/importExcel") - public Result importExcel(HttpServletRequest request ) { + public Result importExcel(HttpServletRequest request) { // 1. 获取上传文件 MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; Map fileMap = multipartRequest.getFileMap(); @@ -282,11 +150,14 @@ public class GardsCorrectionFactorController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsCorrectionFactor.class, params); + List list = + ExcelImportUtil.importExcel(file.getInputStream(), + GardsCorrectionFactor.class, params); // 4. 批量保存数据到数据库 - gardsCorrectionFactorService.saveBatch(list); - + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> gardsCorrectionFactorService.save(item)); + } return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); @@ -302,5 +173,4 @@ public class GardsCorrectionFactorController { } - } 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 index 3d302fe..005162a 100644 --- 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 @@ -1,15 +1,12 @@ 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; @@ -18,6 +15,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -27,11 +25,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * 后处理厂信息 + */ @Slf4j @RestController @RequestMapping("/gardsNuclearFuelFacility") public class GardsNuclearFuelFacilityController { - + final short titleHeight = 8; @Autowired private GardsNuclearFuelFacilityService nuclearFuelFacilitiesService; @@ -41,7 +42,8 @@ public class GardsNuclearFuelFacilityController { @PostMapping("/create") @Operation(summary = "新增核燃料设施信息") public Result create(@RequestBody GardsNuclearFuelFacilities facility) { - return nuclearFuelFacilitiesService.create(facility); + nuclearFuelFacilitiesService.create(facility); + return Result.OK("新增成功!"); } /** @@ -50,7 +52,8 @@ public class GardsNuclearFuelFacilityController { @DeleteMapping("/delete") @Operation(summary = "根据ID删除核燃料设施信息") public Result delete(@RequestParam Integer id) { - return nuclearFuelFacilitiesService.delete(id); + nuclearFuelFacilitiesService.delete(id); + return Result.OK("删除成功!"); } /** @@ -59,7 +62,8 @@ public class GardsNuclearFuelFacilityController { @PutMapping("/update") @Operation(summary = "更新核燃料设施信息") public Result update(@RequestBody GardsNuclearFuelFacilities facility) { - return nuclearFuelFacilitiesService.update(facility); + nuclearFuelFacilitiesService.update(facility); + return Result.OK(""); } /** @@ -68,7 +72,8 @@ public class GardsNuclearFuelFacilityController { @GetMapping("/getById") @Operation(summary = "根据ID查询核燃料设施详情") public Result getById(@RequestParam Integer id) { - return nuclearFuelFacilitiesService.queryById(id); + nuclearFuelFacilitiesService.queryById(id); + return Result.OK(""); } /** @@ -81,66 +86,14 @@ public class GardsNuclearFuelFacilityController { @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String facilityType, @RequestParam(required = false) String facilityStatus, - @RequestParam(required = false) String facilityName, + @RequestParam(required = false) String facility_name, @RequestParam(required = false) String country) { - return nuclearFuelFacilitiesService.page(pageNum, pageSize, facilityType, facilityStatus, facilityName, country); + IPage page = + nuclearFuelFacilitiesService.page(pageNum, pageSize, facilityType, facilityStatus, + facility_name, country); + return Result.OK("", page); } - //region 注释代码 - -// /** -// * 查询所有核燃料设施列表 -// */ -// @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("条件查询失败"); -// } -// } - - //endregion @AutoLog(value = "导出模版") @Operation(summary = "导出模版") @@ -149,15 +102,17 @@ public class GardsNuclearFuelFacilityController { ExportParams params = new ExportParams(); params.setTitle("后处理厂设施信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsNuclearFuelFacilities.class, new ArrayList<>()).write(response.getOutputStream()); + 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, + 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, @@ -165,11 +120,12 @@ public class GardsNuclearFuelFacilityController { ExportParams params = new ExportParams(); params.setTitle("后处理厂设施信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); List list = nuclearFuelFacilitiesService.getByConditions( facilityType, facilityStatus, country, facilityName, fuelType); - ExcelExportUtil.exportExcel(params, GardsNuclearFuelFacilities.class, list).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsNuclearFuelFacilities.class, list) + .write(response.getOutputStream()); } @@ -200,16 +156,16 @@ public class GardsNuclearFuelFacilityController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclearFuelFacilities.class, params); + 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("文件导入失败"); + //boolean success = nuclearFuelFacilitiesService.saveBatch(list, 500); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> nuclearFuelFacilitiesService.save(item)); } - + return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); } finally { 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 index 3e6f2b8..6854a23 100644 --- 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 @@ -1,18 +1,13 @@ 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; @@ -21,6 +16,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -30,12 +26,17 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +/** + * 核设施信息 + */ @Slf4j @RestController @RequestMapping("/gardsNuclearReactors") public class GardsNuclearReactorsController { - + final short titleHeight = 8; @Autowired private GardsNuclearReactorsService gardsNuclearReactorsService; @@ -48,8 +49,8 @@ public class GardsNuclearReactorsController { @PostMapping("/create") @Operation(summary = "新增核设施信息") public Result create(@RequestBody GardsNuclearReactors gardsNuclearReactors) { - - return gardsNuclearReactorsService.create(gardsNuclearReactors); + gardsNuclearReactorsService.save(gardsNuclearReactors); + return Result.OK("新增成功!"); } /** @@ -61,7 +62,8 @@ public class GardsNuclearReactorsController { @DeleteMapping("/delete") @Operation(summary = "删除核设施信息数据") public Result delete(@RequestParam Integer id) { - return gardsNuclearReactorsService.delete(id); + gardsNuclearReactorsService.removeById(id); + return Result.OK("删除成功!"); } /** @@ -73,7 +75,8 @@ public class GardsNuclearReactorsController { @PutMapping("/update") @Operation(summary = "更新核设施数据") public Result update(@RequestBody GardsNuclearReactors gardsNuclearReactors) { - return gardsNuclearReactorsService.update(gardsNuclearReactors); + gardsNuclearReactorsService.update(gardsNuclearReactors); + return Result.OK(""); } /** @@ -85,7 +88,7 @@ public class GardsNuclearReactorsController { @GetMapping("/getById") @Operation(summary = "根据Id查询反应堆数据") public Result queryById(@RequestParam Integer id) { - return gardsNuclearReactorsService.queryById(id); + return Result.OK(gardsNuclearReactorsService.queryById(id)); } @@ -105,44 +108,13 @@ public class GardsNuclearReactorsController { @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String unitName, @RequestParam(required = false) String country) { - - return gardsNuclearReactorsService.page(pageNum, pageSize, unitName, country); + IPage page = + gardsNuclearReactorsService.page(pageNum, pageSize, unitName, country); + return Result.OK(page); } - //region 注释代码 - -// /** -// * 组合条件查询 -// * -// * @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("条件查询失败"); -// } -// -// -// } -// - - //endregion - @AutoLog(value = "导出模版") @Operation(summary = "核设施信息导出模版") @GetMapping("/exportTemplate") @@ -150,9 +122,10 @@ public class GardsNuclearReactorsController { ExportParams params = new ExportParams(); params.setTitle("核设施信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsNuclearReactors.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsNuclearReactors.class, new ArrayList<>()) + .write(response.getOutputStream()); } @AutoLog(value = "导出Excel") @@ -162,14 +135,18 @@ public class GardsNuclearReactorsController { @RequestParam(required = false) String unitName, @RequestParam(required = false) String country, @RequestParam(required = false) String reactorType, - @RequestParam(required = false) String reactorStatus) throws IOException { + @RequestParam(required = false) String reactorStatus) + throws IOException { ExportParams params = new ExportParams(); params.setTitle("核设施信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - List list = gardsNuclearReactorsService.getByConditions(unitName, country, reactorType, reactorStatus); - ExcelExportUtil.exportExcel(params, GardsNuclearReactors.class, list).write(response.getOutputStream()); + List list = + gardsNuclearReactorsService.getByConditions(unitName, country, reactorType, + reactorStatus); + ExcelExportUtil.exportExcel(params, GardsNuclearReactors.class, list) + .write(response.getOutputStream()); } @@ -189,7 +166,8 @@ public class GardsNuclearReactorsController { // 1. 【关键修复】检查请求是否为 multipart 请求 // 如果前端没有使用 form-data 格式提交,或者 Content-Type 不对,这里会拦截 if (!(request instanceof MultipartHttpServletRequest)) { - return Result.error("请求不是文件上传格式,请检查 Content-Type 是否为 multipart/form-data"); + return Result.error( + "请求不是文件上传格式,请检查 Content-Type 是否为 multipart/form-data"); } // 2. 安全转换为 MultipartHttpServletRequest @@ -222,32 +200,36 @@ public class GardsNuclearReactorsController { try (InputStream inputStream = file.getInputStream()) { // 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(inputStream, GardsNuclearReactors.class, params); + 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("文件导入失败"); + // 提取 unitName + List unitNames = list.stream() + .map(GardsNuclearReactors::getUnitName) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + if (unitNames.isEmpty()) { + return Result.error("所有记录的 UNIT_NAME 为空,无法导入"); } + // 批量保存数据到数据库 + boolean success = BizUpsertUtil.upsert(gardsNuclearReactorsService, list, + GardsNuclearReactors::getUnitName); + //gardsNuclearReactorsService.saveBatch(list); +// if (!CollectionUtils.isEmpty(list)) { +// list.forEach(item -> gardsNuclearReactorsService.save(item)); +// } + return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { + log.error(e.getMessage(), 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 index aee6248..c5e35df 100644 --- 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 @@ -1,15 +1,12 @@ 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; @@ -18,6 +15,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -27,11 +25,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * 核设施放射性排放记录信息 + */ @Slf4j @RestController @RequestMapping("/gardsNuclearReleaseRecords") public class GardsNuclearReleaseController { - + final short titleHeight = 8; @Autowired private GardsNuclearReleaseService gardsNuclearReleaseService; @@ -41,7 +42,8 @@ public class GardsNuclearReleaseController { @PostMapping("/create") @Operation(summary = "新增加核设施放射性排放记录信息") public Result create(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { - return gardsNuclearReleaseService.create(gardsNuclearReleaseRecords); + gardsNuclearReleaseService.save(gardsNuclearReleaseRecords); + return Result.OK("新增成功!"); } /** @@ -50,7 +52,8 @@ public class GardsNuclearReleaseController { @DeleteMapping("/delete") @Operation(summary = "删除核设施放射性排放记录信息") public Result deleteById(@RequestParam Integer id) { - return gardsNuclearReleaseService.deleteById(id); + gardsNuclearReleaseService.removeById(id); + return Result.OK("删除成功!"); } /** @@ -59,7 +62,8 @@ public class GardsNuclearReleaseController { @PutMapping("/update") @Operation(summary = "更新核设施放射性排放记录信息") public Result update(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { - return gardsNuclearReleaseService.update(gardsNuclearReleaseRecords); + gardsNuclearReleaseService.update(gardsNuclearReleaseRecords); + return Result.OK(""); } /** @@ -68,14 +72,14 @@ public class GardsNuclearReleaseController { @GetMapping("/queryById") @Operation(summary = "查询核设施放射性排放记录信息") public Result getById(@RequestParam Integer id) { - return gardsNuclearReleaseService.queryById(id); + return Result.OK(gardsNuclearReleaseService.queryById(id)); } /** * 分页查询 * - * @param pageNum 页数 - * @param pageSize 每页大小 + * @param pageNum 页数 + * @param pageSize 每页大小 * @param facilityName * @param nuclide * @return @@ -87,41 +91,11 @@ public class GardsNuclearReleaseController { @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String facilityName, @RequestParam(required = false) String nuclide) { - return gardsNuclearReleaseService.page(pageNum, pageSize, facilityName, nuclide); + return Result.OK(gardsNuclearReleaseService.page(pageNum, pageSize, facilityName, nuclide)); } - //region 注释代码 -// -// /** -// * 组合条件查询 -// * -// * @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("查询失败"); -// } -// -// } - - //endregion @AutoLog(value = "导出模版") @Operation(summary = "核设施放射性排放记录导出模版") @@ -130,9 +104,10 @@ public class GardsNuclearReleaseController { ExportParams params = new ExportParams(); params.setTitle("核设施放射性排放记录信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsNuclearReleaseRecords.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsNuclearReleaseRecords.class, new ArrayList<>()) + .write(response.getOutputStream()); } @@ -146,10 +121,12 @@ public class GardsNuclearReleaseController { ExportParams params = new ExportParams(); params.setTitle("核设施放射性排放记录信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - List list = gardsNuclearReleaseService.getByConditions(facilityName, nuclide, matterState); - ExcelExportUtil.exportExcel(params, GardsNuclearReleaseRecords.class, list).write(response.getOutputStream()); + List list = + gardsNuclearReleaseService.getByConditions(facilityName, nuclide, matterState); + ExcelExportUtil.exportExcel(params, GardsNuclearReleaseRecords.class, list) + .write(response.getOutputStream()); } @@ -181,11 +158,13 @@ public class GardsNuclearReleaseController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclearReleaseRecords.class, params); - + List list = + ExcelImportUtil.importExcel(file.getInputStream(), + GardsNuclearReleaseRecords.class, params); // 4. 批量保存数据到数据库 - gardsNuclearReleaseService.saveBatch(list); - + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> gardsNuclearReleaseService.save(item)); + } return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); 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 index baa8a3a..1c75d26 100644 --- 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 @@ -10,9 +10,7 @@ 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; @@ -20,6 +18,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -28,11 +27,15 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; + +/** + * 核试验信息 + */ @Slf4j @RestController @RequestMapping("/gardsNuclearTestingPlant") public class GardsNuclearTestingPlantController { - + final short titleHeight = 8; @Autowired private GardsNuclearTestingPlantService gardsNuclearTestingPlantService; @@ -42,7 +45,8 @@ public class GardsNuclearTestingPlantController { @PostMapping("/create") @Operation(summary = "新增核试验信息") public Result create(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { - return gardsNuclearTestingPlantService.create(gardsNuclearTestingPlant); + gardsNuclearTestingPlantService.save(gardsNuclearTestingPlant); + return Result.OK("新增成功!"); } /** @@ -51,7 +55,8 @@ public class GardsNuclearTestingPlantController { @DeleteMapping("/delete") @Operation(summary = "删除核试验信息") public Result deleteById(@RequestParam Integer id) { - return gardsNuclearTestingPlantService.deleteById(id); + gardsNuclearTestingPlantService.removeById(id); + return Result.OK("删除成功!"); } /** @@ -60,7 +65,8 @@ public class GardsNuclearTestingPlantController { @PutMapping("/update") @Operation(summary = "更新核试验信息") public Result update(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { - return gardsNuclearTestingPlantService.update(gardsNuclearTestingPlant); + gardsNuclearTestingPlantService.update(gardsNuclearTestingPlant); + return Result.OK(""); } /** @@ -69,7 +75,7 @@ public class GardsNuclearTestingPlantController { @GetMapping("/queryById") @Operation(summary = "查询核试验信息") public Result getById(@RequestParam Integer id) { - return gardsNuclearTestingPlantService.queryById(id); + return Result.OK(gardsNuclearTestingPlantService.queryById(id)); } /** @@ -88,48 +94,10 @@ public class GardsNuclearTestingPlantController { @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String name, @RequestParam(required = false) String type) { - try { - Page page = new Page<>(pageNum, pageSize); + IPage pageResult = + gardsNuclearTestingPlantService.page(pageNum, pageSize, name, type); + return Result.OK(pageResult); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (name != null && !name.trim().isEmpty()) { - wrapper.eq(GardsNuclearTestingPlant::getName, name); - } - if (type != null && !type.trim().isEmpty()) { - wrapper.eq(GardsNuclearTestingPlant::getCountry, 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("查询失败"); - } } @@ -141,9 +109,10 @@ public class GardsNuclearTestingPlantController { ExportParams params = new ExportParams(); params.setTitle("核试验信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsNuclearTestingPlant.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsNuclearTestingPlant.class, new ArrayList<>()) + .write(response.getOutputStream()); } @AutoLog(value = "导出Excel") @@ -155,10 +124,12 @@ public class GardsNuclearTestingPlantController { ExportParams params = new ExportParams(); params.setTitle("核试验信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - List list = gardsNuclearTestingPlantService.getByConditions(name, type); - ExcelExportUtil.exportExcel(params, GardsNuclearTestingPlant.class, list).write(response.getOutputStream()); + List list = + gardsNuclearTestingPlantService.getByConditions(name, type); + ExcelExportUtil.exportExcel(params, GardsNuclearTestingPlant.class, list) + .write(response.getOutputStream()); } @@ -189,7 +160,9 @@ public class GardsNuclearTestingPlantController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclearTestingPlant.class, params); + List list = + ExcelImportUtil.importExcel(file.getInputStream(), + GardsNuclearTestingPlant.class, params); list.forEach(testingPlant -> { if (StringUtils.isNotBlank(testingPlant.getInfo())) { @@ -205,8 +178,10 @@ public class GardsNuclearTestingPlantController { } }); // 4. 批量保存数据到数据库 - gardsNuclearTestingPlantService.saveBatch(list,5); - + //gardsNuclearTestingPlantService.saveBatch(list,5); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> gardsNuclearTestingPlantService.save(item)); + } return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclideDecayController.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclideDecayController.java index 52a0137..f0f7281 100644 --- a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclideDecayController.java +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/controller/GardsNuclideDecayController.java @@ -15,6 +15,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -24,10 +25,14 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +/** + * 核素衰变信息 + */ @RestController @RequestMapping("/getGardsNuclideDecay") @Slf4j public class GardsNuclideDecayController { + final short titleHeight = 8; @Autowired private GardsNuclideDecayService gardsNuclideDecayService; @@ -37,7 +42,8 @@ public class GardsNuclideDecayController { @PostMapping("/create") @Operation(summary = "新增信息") public Result create(@RequestBody GardsNuclideDecay gardsNuclideDecay) { - return gardsNuclideDecayService.create(gardsNuclideDecay); + gardsNuclideDecayService.save(gardsNuclideDecay); + return Result.OK("新增成功!"); } /** @@ -45,8 +51,9 @@ public class GardsNuclideDecayController { */ @DeleteMapping("/delete") @Operation(summary = "删除信息") - public Result deleteById(@RequestParam Integer Id) { - return gardsNuclideDecayService.deleteById(Id); + public Result deleteById(Integer id) { + gardsNuclideDecayService.removeById(id); + return Result.OK("删除成功!"); } /** @@ -55,7 +62,8 @@ public class GardsNuclideDecayController { @PutMapping("/update") @Operation(summary = "更新信息") public Result update(@RequestBody GardsNuclideDecay gardsNuclideDecay) { - return gardsNuclideDecayService.update(gardsNuclideDecay); + gardsNuclideDecayService.update(gardsNuclideDecay); + return Result.OK(""); } /** @@ -63,8 +71,9 @@ public class GardsNuclideDecayController { */ @GetMapping("/queryById") @Operation(summary = "查询信息") - public Result getById(@RequestParam Integer Id) { - return gardsNuclideDecayService.queryById(Id); + public Result getById(@RequestParam Integer id) { + + return Result.OK(gardsNuclideDecayService.queryById(id)); } /** @@ -72,7 +81,7 @@ public class GardsNuclideDecayController { * * @param pageNum * @param pageSize - * @param nuclide 核素名称 + * @param nuclide 核素名称 * @return */ @GetMapping("/page") @@ -80,29 +89,10 @@ public class GardsNuclideDecayController { public Result> page( @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, - @RequestParam(required = false) String nuclide) { - - return gardsNuclideDecayService.page(pageNum, pageSize, nuclide); - } - - /** - * 组合条件查询 - * - * @param nuclide 名称 - * @return - */ - @GetMapping("/search") - @Operation(summary = "组合条件查询") - public Result> search(@RequestParam(required = false) String nuclide ) { - - try { - List list = gardsNuclideDecayService.getByConditions(nuclide); - return Result.OK(list); - } catch (Exception e) { - log.error("search: " + e.getMessage()); - return Result.error("查询失败"); - } + @RequestParam(required = false) String nuclide, + @RequestParam(required = false) String energy) { + return Result.OK(gardsNuclideDecayService.page(pageNum, pageSize, nuclide, energy)); } @AutoLog(value = "导出模版") @@ -112,23 +102,26 @@ public class GardsNuclideDecayController { ExportParams params = new ExportParams(); params.setTitle("加合峰信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsNuclideDecay.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsNuclideDecay.class, new ArrayList<>()) + .write(response.getOutputStream()); } @AutoLog(value = "导出Excel") @Operation(summary = "台站导出Excel") @GetMapping("/exportExcel") public void exportExcel(HttpServletResponse response, - @RequestParam(required = false) String nuclide) throws IOException { + @RequestParam(required = false) String nuclide, + @RequestParam(required = false) String energy) throws IOException { ExportParams params = new ExportParams(); params.setTitle("加合峰信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - List list = gardsNuclideDecayService.getByConditions(nuclide); - ExcelExportUtil.exportExcel(params, GardsNuclideDecay.class, list).write(response.getOutputStream()); + List list = gardsNuclideDecayService.getByConditions(nuclide, energy); + ExcelExportUtil.exportExcel(params, GardsNuclideDecay.class, list) + .write(response.getOutputStream()); } /** @@ -158,11 +151,15 @@ public class GardsNuclideDecayController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclideDecay.class, params); + List list = + ExcelImportUtil.importExcel(file.getInputStream(), GardsNuclideDecay.class, + params); // 4. 批量保存数据到数据库 - gardsNuclideDecayService.saveBatch(list); - + //gardsNuclideDecayService.saveBatch(list); + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> gardsNuclideDecayService.save(item)); + } return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); 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 index 3aba436..b991b07 100644 --- 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 @@ -1,18 +1,13 @@ 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; @@ -20,6 +15,7 @@ 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.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; @@ -28,10 +24,15 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; + +/** + * 研究型、生产反应堆信息 + */ @Slf4j @RestController @RequestMapping("/gardsResearchReactors")//C17ZNRJDMD6N public class GardsResearchReactorsController { + final short titleHeight = 8; @Autowired private GardsResearchReactorsService gardsResearchReactorsService; @@ -41,7 +42,8 @@ public class GardsResearchReactorsController { @PostMapping("/create") @Operation(summary = "新增反应堆信息") public Result create(@RequestBody GardsResearchReactors gardsResearchReactors) { - return gardsResearchReactorsService.create(gardsResearchReactors); + gardsResearchReactorsService.save(gardsResearchReactors); + return Result.OK("新增成功!"); } /** @@ -50,7 +52,8 @@ public class GardsResearchReactorsController { @DeleteMapping("/delete") @Operation(summary = "删除反应堆信息") public Result deleteById(@RequestParam Integer id) { - return gardsResearchReactorsService.deleteById(id); + gardsResearchReactorsService.removeById(id); + return Result.OK("删除成功!"); } /** @@ -59,7 +62,8 @@ public class GardsResearchReactorsController { @PutMapping("/update") @Operation(summary = "更新反应堆信息") public Result update(@RequestBody GardsResearchReactors gardsResearchReactors) { - return gardsResearchReactorsService.update(gardsResearchReactors); + gardsResearchReactorsService.update(gardsResearchReactors); + return Result.OK(""); } /** @@ -68,7 +72,7 @@ public class GardsResearchReactorsController { @GetMapping("/queryById") @Operation(summary = "查询反应堆信息") public Result getById(@RequestParam Integer id) { - return gardsResearchReactorsService.queryById(id); + return Result.OK(gardsResearchReactorsService.queryById(id)); } /** @@ -88,33 +92,8 @@ public class GardsResearchReactorsController { @RequestParam(required = false) String facilityName, @RequestParam(required = false) String country) { - return gardsResearchReactorsService.page(pageNum, pageSize,facilityName,country); - - - } - - /** - * 组合条件查询 - * - * @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("查询失败"); - } - + return Result.OK( + gardsResearchReactorsService.page(pageNum, pageSize, facilityName, country)); } @AutoLog(value = "导出模版") @@ -124,9 +103,10 @@ public class GardsResearchReactorsController { ExportParams params = new ExportParams(); params.setTitle("反应堆信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsResearchReactors.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsResearchReactors.class, new ArrayList<>()) + .write(response.getOutputStream()); } @AutoLog(value = "导出Excel") @@ -142,8 +122,11 @@ public class GardsResearchReactorsController { 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()); + List list = + gardsResearchReactorsService.getByConditions(facilityName, country, reactorType, + status); + ExcelExportUtil.exportExcel(params, GardsResearchReactors.class, list) + .write(response.getOutputStream()); } @@ -174,11 +157,14 @@ public class GardsResearchReactorsController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsResearchReactors.class, params); + List list = + ExcelImportUtil.importExcel(file.getInputStream(), + GardsResearchReactors.class, params); // 4. 批量保存数据到数据库 - gardsResearchReactorsService.saveBatch(list); - + if (!CollectionUtils.isEmpty(list)) { + list.forEach(item -> gardsResearchReactorsService.save(item)); + } return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); 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 index c38c0a0..750cea9 100644 --- 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 @@ -1,17 +1,13 @@ 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; @@ -27,10 +23,15 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; + +/** + * 台站信息 + */ @Slf4j @RestController @RequestMapping("/gardsStations") public class GardsStationsController { + final short titleHeight = 8; @Autowired private GardsStationsService gardsStationsService; @@ -40,7 +41,8 @@ public class GardsStationsController { @PostMapping("/create") @Operation(summary = "新增台站信息") public Result create(@RequestBody GardsStations gardsStations) { - return gardsStationsService.create(gardsStations); + gardsStationsService.save(gardsStations); + return Result.OK("新增成功!"); } /** @@ -49,7 +51,8 @@ public class GardsStationsController { @DeleteMapping("/delete") @Operation(summary = "删除台站信息") public Result deleteById(@RequestParam Integer stationId) { - return gardsStationsService.deleteById(stationId); + gardsStationsService.removeById(stationId); + return Result.OK("删除成功!"); } /** @@ -58,7 +61,8 @@ public class GardsStationsController { @PutMapping("/update") @Operation(summary = "更新台站信息") public Result update(@RequestBody GardsStations gardsStations) { - return gardsStationsService.update(gardsStations); + gardsStationsService.update(gardsStations); + return Result.OK(); } /** @@ -67,7 +71,7 @@ public class GardsStationsController { @GetMapping("/queryById") @Operation(summary = "查询台站信息") public Result getById(@RequestParam Integer stationId) { - return gardsStationsService.queryById(stationId); + return Result.OK(gardsStationsService.queryById(stationId)); } /** @@ -87,32 +91,9 @@ public class GardsStationsController { @RequestParam(required = false) String stationCode, @RequestParam(required = false) String countryCode) { - return gardsStationsService.page(pageNum, pageSize, stationCode, countryCode); + return Result.OK(gardsStationsService.page(pageNum, pageSize, stationCode, countryCode)); } - /** - * 组合条件查询 - * - * @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 = "台站导出模版") @@ -121,9 +102,10 @@ public class GardsStationsController { ExportParams params = new ExportParams(); params.setTitle("台站信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - ExcelExportUtil.exportExcel(params, GardsStations.class, new ArrayList<>()).write(response.getOutputStream()); + ExcelExportUtil.exportExcel(params, GardsStations.class, new ArrayList<>()) + .write(response.getOutputStream()); } @AutoLog(value = "导出Excel") @@ -137,10 +119,12 @@ public class GardsStationsController { ExportParams params = new ExportParams(); params.setTitle("台站信息"); params.setFixedTitle(true); - params.setTitleHeight((short) 8); + params.setTitleHeight(titleHeight); params.setType(ExcelType.XSSF); - List list = gardsStationsService.getByConditions(stationCode, type, status, countryCode); - ExcelExportUtil.exportExcel(params, GardsStations.class, list).write(response.getOutputStream()); + List list = + gardsStationsService.getByConditions(stationCode, type, status, countryCode); + ExcelExportUtil.exportExcel(params, GardsStations.class, list) + .write(response.getOutputStream()); } /** @@ -170,11 +154,13 @@ public class GardsStationsController { try { // 3. 使用 AutoPoi 工具类解析 Excel - List list = ExcelImportUtil.importExcel(file.getInputStream(), GardsStations.class, params); + List list = + ExcelImportUtil.importExcel(file.getInputStream(), GardsStations.class, + params); // 4. 批量保存数据到数据库 - gardsStationsService.saveBatch(list); - + //gardsStationsService.saveBatch(list); + list.forEach(item -> gardsStationsService.save(item)); return Result.OK("文件导入成功!数据行数:" + list.size()); } catch (Exception e) { return Result.error("文件导入失败:" + e.getMessage()); 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 index e896fc3..5bd1b99 100644 --- 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 @@ -11,41 +11,14 @@ import java.util.List; public interface GardsAcceleratorService extends IService { - Result create(GardsAccelerator gardsAccelerator); + void create(GardsAccelerator gardsAccelerator); - Result delete(Integer id); + void delete(Integer id); - Result update(GardsAccelerator gardsAccelerator); + void update(GardsAccelerator gardsAccelerator); - Result queryById(Integer id); + GardsAccelerator queryById(Integer id); - Result> queryPage(Integer pageNum, Integer pageSize, String country, String facilityName); - - - /** - * 根据设施代码查询设施信息 - * 根据设施代码查询设施信息 - */ - GardsAccelerator getByFacilityCode(String facilityCode); - - /** - * 根据国家查询设施列表 - */ - List getByCountry(String country); - - /** - * 根据运行状态查询设施列表 - */ - List getByOperationalStatus(Integer isOperational); - - /** - * 根据分类查询设施列表 - */ - List getByCategory(String category); - - /** - * 条件查询:国家 + 运行状态 - */ - List getByCountryAndStatus(String country, Integer isOperational); + IPage queryPage(Integer pageNum, Integer pageSize, String country, String facilityName); } \ 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 index d186164..c50fb77 100644 --- 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 @@ -18,58 +18,30 @@ public interface GardsCorrectionFactorService extends IService create(GardsCorrectionFactor gardsCorrectionFactor) ; + void create(GardsCorrectionFactor gardsCorrectionFactor); /** * 根据ID删除校正因子 */ - Result delete( Integer id); + void delete(Integer id); /** * 更新校正因子信息 */ - Result update(GardsCorrectionFactor gardsCorrectionFactor) ; + void update(GardsCorrectionFactor gardsCorrectionFactor); /** * 根据ID查询校正因子详情 */ - Result queryById(Integer id); - + GardsCorrectionFactor queryById(Integer id); /** * 分页查询校正因子列表 */ - - Result> page(Integer pageNum, Integer pageSize, String stationCode, String detectorCode); - - - /** - * 根据站点代码查询校正因子列表 - */ - List getByStationCode(String stationCode); - - /** - * 根据探测器代码查询校正因子列表 - */ - List getByDetectorCode(String detectorCode); - - /** - * 根据站点和探测器代码查询校正因子 - */ - List getByStationAndDetector(String stationCode, String detectorCode); - - /** - * 根据制造商查询校正因子列表 - */ - List getByManufacturer(String manufacturer); - - /** - * 根据型号查询校正因子列表 - */ - List getByModel(String model); + IPage page(Integer pageNum, Integer pageSize, String stationCode, String detectorCode); /** * 条件组合查询 @@ -77,9 +49,4 @@ public interface GardsCorrectionFactorService extends IService 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 index d312439..87787b6 100644 --- 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 @@ -21,51 +21,40 @@ public interface GardsNuclearFuelFacilityService extends IService create(GardsNuclearFuelFacilities facility); + void create(GardsNuclearFuelFacilities facility); /** * 根据ID删除核燃料设施信息 */ - Result delete(Integer id); + void delete(Integer id); /** * 更新核燃料设施信息 */ - Result update(GardsNuclearFuelFacilities facility); + void update(GardsNuclearFuelFacilities facility); /** * 根据ID查询核燃料设施详情 */ - Result queryById(Integer id); + GardsNuclearFuelFacilities queryById(Integer id); /** * 分页查询核燃料设施列表 */ - Result> page(Integer pageNum, Integer pageSize, + IPage page(Integer pageNum, Integer pageSize, String facilityType, String facilityStatus, String facilityName, String country); - - - /** - * 根据设施名称模糊查询 - */ - 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 index fd5f0e1..335149e 100644 --- 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 @@ -21,7 +21,7 @@ public interface GardsNuclearReactorsService extends IService create(@RequestBody GardsNuclearReactors gardsNuclearReactors); + void create(@RequestBody GardsNuclearReactors gardsNuclearReactors); /** * 删除反应堆数据 @@ -30,7 +30,7 @@ public interface GardsNuclearReactorsService extends IService delete(@RequestParam Integer id); + void delete(@RequestParam Integer id); /** * 更新反应堆数据 @@ -39,7 +39,7 @@ public interface GardsNuclearReactorsService extends IService update(@RequestBody GardsNuclearReactors gardsNuclearReactors); + void update(@RequestBody GardsNuclearReactors gardsNuclearReactors); /** * 根据Id查询反应堆数据 @@ -48,7 +48,7 @@ public interface GardsNuclearReactorsService extends IService queryById(@RequestParam Integer id); + GardsNuclearReactors queryById(@RequestParam Integer id); /** * 分页查询反应堆数据 @@ -60,19 +60,17 @@ public interface GardsNuclearReactorsService extends IService> page( Integer pageNum, - Integer pageSize, - String unitName, - String country); + IPage page(Integer pageNum, + Integer pageSize, + String unitName, + String country); /** * 多条件组合查询 + * * @return List */ - List getByConditions(String unitName,String country,String reactorType,String reactorStatus); - - void saveOrUpdateBatchByUniqueFields(List list); - + List getByConditions(String unitName, String country, String reactorType, String reactorStatus); } 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 index 18cea04..dd5c739 100644 --- 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 @@ -18,45 +18,45 @@ public interface GardsNuclearReleaseService extends IService create(GardsNuclearReleaseRecords gardsNuclearReleaseRecords); + void create(GardsNuclearReleaseRecords gardsNuclearReleaseRecords); /** * 删除核设施放射性排放记录信息 */ - Result deleteById(Integer id); + void deleteById(Integer id); /** * 更新核设施放射性排放记录信息 */ - Result update(GardsNuclearReleaseRecords gardsNuclearReleaseRecords); + void update(GardsNuclearReleaseRecords gardsNuclearReleaseRecords); /** * 查询核设施放射性排放记录信息 */ - Result queryById(Integer id); + GardsNuclearReleaseRecords queryById(Integer id); /** * 分页查询 * - * @param pageNum 页数 - * @param pageSize 每页大小 + * @param pageNum 页数 + * @param pageSize 每页大小 * @param facilityName 设施名称 - * @param nuclide 核素 + * @param nuclide 核素 * @return 分页结果 */ - Result> page(Integer pageNum, Integer pageSize, String facilityName, String nuclide); + IPage page(Integer pageNum, Integer pageSize, String facilityName, String nuclide); /** * 多条件组合查询 * - * @param facilityName 站点/电厂名称 - * @param nuclide 具体核素 - * @param matterState 物质状态 1-气体,2-气溶胶 + * @param facilityName 站点/电厂名称 + * @param nuclide 具体核素 + * @param matterState 物质状态 1-气体,2-气溶胶 * @return List */ List getByConditions(String facilityName, String nuclide, String matterState); 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 index 5cce698..b6d6c41 100644 --- 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 @@ -19,27 +19,27 @@ public interface GardsNuclearTestingPlantService extends IService create(GardsNuclearTestingPlant gardsNuclearTestingPlant); + void create(GardsNuclearTestingPlant gardsNuclearTestingPlant); /** * 删除核设施放射性排放记录信息 */ - Result deleteById(Integer id); + void deleteById(Integer id); /** * 更新核设施放射性排放记录信息 */ - Result update(GardsNuclearTestingPlant gardsNuclearTestingPlant); + void update(GardsNuclearTestingPlant gardsNuclearTestingPlant); /** * 查询核设施放射性排放记录信息 */ - Result queryById(Integer id); + GardsNuclearTestingPlant queryById(Integer id); - Result> page( + IPage page( Integer pageNum, Integer pageSize, String name, diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclideDecayService.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclideDecayService.java index cd2be2d..cc66d12 100644 --- a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclideDecayService.java +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/GardsNuclideDecayService.java @@ -14,22 +14,22 @@ public interface GardsNuclideDecayService extends IService { * 新增信息 */ - Result create(GardsNuclideDecay gardsNuclideDecay); + void create(GardsNuclideDecay GardsNuclideDecay); /** * 删除信息 */ - Result deleteById(Integer Id); + void deleteById(Integer id); /** * 更新信息 */ - Result update(GardsNuclideDecay gardsNuclideDecay); + void update(GardsNuclideDecay GardsNuclideDecay); /** * 查询信息 */ - Result queryById(Integer Id); + GardsNuclideDecay queryById(Integer id); /** * 分页查询 @@ -39,10 +39,11 @@ public interface GardsNuclideDecayService extends IService { * @param nuclide * @return */ - Result> page( + IPage page( Integer pageNum, Integer pageSize, - String nuclide); + String nuclide, + String energy); /** * 多条件组合查询 @@ -50,7 +51,7 @@ public interface GardsNuclideDecayService extends IService { * @param nuclide 名称 * @return List */ - List getByConditions(String nuclide); + List getByConditions(String nuclide, String energy); } 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 index 5ad910a..ec02f52 100644 --- 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 @@ -18,25 +18,25 @@ public interface GardsResearchReactorsService extends IService create(@RequestBody GardsResearchReactors gardsResearchReactors); + void create(@RequestBody GardsResearchReactors gardsResearchReactors); /** * 删除信息 */ - Result deleteById(@RequestParam Integer id) ; + void deleteById(@RequestParam Integer id) ; /** * 更新反应堆信息 */ - Result update(@RequestBody GardsResearchReactors gardsResearchReactors) ; + void update(@RequestBody GardsResearchReactors gardsResearchReactors) ; /** * 查询信息 */ - Result queryById(@RequestParam Integer id) ; + GardsResearchReactors queryById(@RequestParam Integer id) ; /** * 分页查询 @@ -48,7 +48,7 @@ public interface GardsResearchReactorsService extends IService> page( + IPage page( @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String facilityName, 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 index 9ec2f6f..1511712 100644 --- 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 @@ -15,27 +15,26 @@ import java.util.List; public interface GardsStationsService extends IService { - /** * 新增信息 */ - Result create( GardsStations gardsStations) ; + void create(GardsStations gardsStations); /** * 删除信息 */ - Result deleteById( Integer stationId) ; + void deleteById(Integer stationId); /** * 更新信息 */ - Result update( GardsStations gardsStations); + void update(GardsStations gardsStations); /** * 查询信息 */ - Result queryById( Integer stationId) ; + GardsStations queryById(Integer stationId); /** * 分页查询 @@ -46,23 +45,19 @@ public interface GardsStationsService extends IService { * @param countryCode * @return */ - Result> page( - Integer pageNum, + IPage page( + Integer pageNum, Integer pageSize, String stationCode, String countryCode); - - - - - /** * 多条件组合查询 - * @param stationCode 名称 - * @param type 类型 + * + * @param stationCode 名称 + * @param type 类型 * @return List */ - List getByConditions(String stationCode, String type, String status,String countryCode); + 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 index 85c08bb..dcf3c3b 100644 --- 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 @@ -5,141 +5,60 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.common.api.vo.Result; 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 org.springframework.transaction.annotation.Transactional; -import java.util.List; +import java.util.Objects; + @Service @DS("ora") -public class GardsAcceleratorServiceImpl extends ServiceImpl implements GardsAcceleratorService { +public class GardsAcceleratorServiceImpl + extends ServiceImpl + implements GardsAcceleratorService { @Override @Transactional(rollbackFor = RuntimeException.class) - public Result create(GardsAccelerator gardsAccelerator) { - try { - boolean success = this.save(gardsAccelerator); - if (success) { - return Result.OK("添加成功",gardsAccelerator); - } else { - return Result.error("设施信息添加失败"); - } - } catch (Exception e) { - log.error(e.getMessage()); - return Result.error("操作失败"); - } - } - @Override - @Transactional(rollbackFor = RuntimeException.class) - public Result delete(Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.ok("删除成功"); - } else { - return Result.error("设施信息删除失败,可能该记录不存在"); - } - } catch (Exception e) { - log.error(e.getMessage()); - return Result.error("操作失败"); - } + public void create(GardsAccelerator gardsAccelerator) { + this.save(gardsAccelerator); } @Override @Transactional(rollbackFor = RuntimeException.class) - public Result update(GardsAccelerator gardsAccelerator) { - try { - boolean success = this.updateById(gardsAccelerator); - if (success) { - return Result.OK("设施信息更新成功",gardsAccelerator); - } else { - return Result.error("设施信息更新失败,可能该记录不存在"); - } - } catch (Exception e) { - log.error(e.getMessage()); - return Result.error("操作失败"); + public void delete(Integer id) { + this.removeById(id); + } + + @Override + @Transactional(rollbackFor = RuntimeException.class) + public void update(GardsAccelerator gardsAccelerator) { + this.updateById(gardsAccelerator); + } + + @Override + public IPage queryPage(Integer pageNum, Integer pageSize, String country, + String facilityName) { + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.like(GardsAccelerator::getFacilityName, facilityName); } - } - - @Override - public Result> queryPage(Integer pageNum, Integer pageSize, String country, String facilityName) - { - try { - Page page = new Page<>(pageNum, pageSize); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (facilityName != null && !facilityName.trim().isEmpty()) { - wrapper.like(GardsAccelerator::getFacilityName, facilityName); - } - if (country != null && !country.trim().isEmpty()) { - wrapper.like(GardsAccelerator::getCountry, country); - } - wrapper.orderByDesc(GardsAccelerator::getId); - - IPage pageResult = this.page(page, wrapper); - return Result.ok(pageResult); - } catch (Exception e) { - log.error("分页查询失败: " + e.getMessage()); - return Result.error("分页查询失败"); + if (country != null && !country.trim().isEmpty()) { + wrapper.like(GardsAccelerator::getCountry, country); } - + wrapper.orderByDesc(GardsAccelerator::getId); + return this.page(page, wrapper); } - - - @Override - public Result queryById(Integer id) { - try { - GardsAccelerator facility = this.getById(id); - if (facility != null) { - return Result.ok(facility); - } else { - return Result.error("未找到对应的设施信息"); - } - } catch (Exception e) { - log.error(e.getMessage()); - return Result.error("查询失败"); + public GardsAccelerator queryById(Integer id) { + GardsAccelerator facility = this.getById(id); + if (Objects.isNull(facility)) { + throw new RuntimeException("未找到对应的数据"); } - } - - @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); + return facility; } } 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 index 6bb1c8f..e98964d 100644 --- 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 @@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; @Service @DS("ora") @@ -28,38 +29,17 @@ public class GardsCorrectionFactorServiceImpl extends ServiceImpl create(@RequestBody GardsCorrectionFactor gardsCorrectionFactor) { - try { - boolean success = this.save(gardsCorrectionFactor); - if (success) { - return Result.OK("校正因子添加成功", gardsCorrectionFactor); - } else { - return Result.error("校正因子添加失败"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void create(@RequestBody GardsCorrectionFactor gardsCorrectionFactor) { + this.save(gardsCorrectionFactor); } - /** * 根据ID删除校正因子 */ @Override @Transactional(rollbackFor = RuntimeException.class) - public Result delete(Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.ok("校正因子删除成功"); - } else { - return Result.error("校正因子删除失败,可能该记录不存在"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void delete(Integer id) { + this.removeById(id); } /** @@ -67,18 +47,8 @@ public class GardsCorrectionFactorServiceImpl extends ServiceImpl update(GardsCorrectionFactor gardsCorrectionFactor) { - try { - boolean success = this.updateById(gardsCorrectionFactor); - if (success) { - return Result.OK("校正因子更新成功", gardsCorrectionFactor); - } else { - return Result.error("校正因子更新失败,可能该记录不存在"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(GardsCorrectionFactor gardsCorrectionFactor) { + this.updateById(gardsCorrectionFactor); } /** @@ -86,33 +56,25 @@ public class GardsCorrectionFactorServiceImpl extends ServiceImpl queryById(Integer id) { - try { + public GardsCorrectionFactor queryById(Integer id) { GardsCorrectionFactor factor = this.getById(id); - if (factor != null) { - return Result.OK("查询成功", factor); - } else { - return Result.error("未找到对应的校正因子信息"); + if (Objects.isNull(factor)) { + throw new RuntimeException("未找到对应的数据"); } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("查询失败"); - } + return factor; } /** * 分页查询校正因子列表 */ @Override - public Result> page( + public IPage 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.like(GardsCorrectionFactor::getStationCode, stationCode); } @@ -120,49 +82,7 @@ public class GardsCorrectionFactorServiceImpl extends ServiceImpl pageResult = this.page(page, wrapper); - return Result.OK("分页查询成功", pageResult); - } catch (Exception e) { - log.error("分页查询失败: " + e.getMessage()); - return Result.error("分页查询失败"); - } - } - - - @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); + return this.page(page, wrapper); } @Override @@ -186,8 +106,4 @@ public class GardsCorrectionFactorServiceImpl extends ServiceImpl 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 index ce83b3c..da988b5 100644 --- 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 @@ -5,8 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import io.swagger.v3.oas.annotations.Operation; -import org.jeecg.common.api.vo.Result; import org.jeecg.modules.base.entity.configuration.GardsNuclearFuelFacilities; import org.jeecg.modules.base.mapper.GardsNuclearFuelFacilitiesMapper; import org.jeecg.service.GardsNuclearFuelFacilityService; @@ -15,10 +13,13 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; @Service @DS("ora") -public class GardsNuclearFuelFacilityServiceImpl extends ServiceImpl implements GardsNuclearFuelFacilityService { +public class GardsNuclearFuelFacilityServiceImpl + extends ServiceImpl + implements GardsNuclearFuelFacilityService { /** @@ -26,18 +27,8 @@ public class GardsNuclearFuelFacilityServiceImpl extends ServiceImpl create(GardsNuclearFuelFacilities facility) { - try { - boolean success = this.save(facility); - if (success) { - return Result.OK("核燃料设施信息添加成功", facility); - } else { - return Result.error("核燃料设施信息添加失败"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void create(GardsNuclearFuelFacilities facility) { + this.save(facility); } /** @@ -45,18 +36,8 @@ public class GardsNuclearFuelFacilityServiceImpl extends ServiceImpl delete(Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.ok("核燃料设施信息删除成功"); - } else { - return Result.error("核燃料设施信息删除失败,可能该记录不存在"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败 "); - } + public void delete(Integer id) { + this.removeById(id); } /** @@ -64,82 +45,55 @@ public class GardsNuclearFuelFacilityServiceImpl extends ServiceImpl update(GardsNuclearFuelFacilities facility) { - try { - boolean success = this.updateById(facility); - if (success) { - return Result.OK("核燃料设施信息更新成功", facility); - } else { - return Result.error("核燃料设施信息更新失败,可能该记录不存在"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(GardsNuclearFuelFacilities facility) { + this.updateById(facility); } /** * 根据ID查询核燃料设施详情 */ @Override - public Result queryById(Integer id) { - try { - GardsNuclearFuelFacilities facility = this.getById(id); - if (facility != null) { - return Result.ok(facility); - } else { - return Result.error("未找到对应的核燃料设施信息"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("查询失败"); + public GardsNuclearFuelFacilities queryById(Integer id) { + GardsNuclearFuelFacilities facility = this.getById(id); + if (Objects.isNull(facility)) { + throw new RuntimeException("未找到对应数据"); } + return facility; } /** * 分页查询核燃料设施列表 */ @Override - public Result> page( + public IPage page( Integer pageNum, Integer pageSize, String facilityType, String facilityStatus, String facilityName, String country) { - try { - Page page = new Page<>(pageNum, pageSize); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (facilityType != null && !facilityType.trim().isEmpty()) { - wrapper.like(GardsNuclearFuelFacilities::getFacilityType, facilityType); - } - if (facilityStatus != null && !facilityStatus.trim().isEmpty()) { - wrapper.like(GardsNuclearFuelFacilities::getFacilityStatus, facilityStatus); - } - if (facilityName != null && !facilityName.trim().isEmpty()) { - wrapper.like(GardsNuclearFuelFacilities::getFacilityName, facilityName); - } - if (country != null && !country.trim().isEmpty()) { - wrapper.like(GardsNuclearFuelFacilities::getCountry, country); - } - wrapper.orderByDesc(GardsNuclearFuelFacilities::getId); - IPage pageResult = this.page(page, wrapper); - return Result.OK("分页查询成功", pageResult); - } catch ( - Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("分页查询失败"); - } - } - - - @Override - public List getByFacilityNameLike(String facilityName) { + Page page = new Page<>(pageNum, pageSize); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.like(GardsNuclearFuelFacilities::getFacilityName, facilityName); - return this.list(wrapper); + + if (facilityType != null && !facilityType.trim().isEmpty()) { + wrapper.like(GardsNuclearFuelFacilities::getFacilityType, facilityType); + } + if (facilityStatus != null && !facilityStatus.trim().isEmpty()) { + wrapper.like(GardsNuclearFuelFacilities::getFacilityStatus, facilityStatus); + } + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.like(GardsNuclearFuelFacilities::getFacilityName, facilityName); + } + if (country != null && !country.trim().isEmpty()) { + wrapper.like(GardsNuclearFuelFacilities::getCountry, country); + } + wrapper.orderByDesc(GardsNuclearFuelFacilities::getId); + IPage pageResult = this.page(page, wrapper); + return pageResult; + } @Override - public List getByConditions(String facilityType, String facilityStatus, String country, String facilityName, String fuelType) { + public List getByConditions(String facilityType, + String facilityStatus, String country, + String facilityName, String fuelType) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if (facilityType != null && !facilityType.trim().isEmpty()) { @@ -161,13 +115,4 @@ public class GardsNuclearFuelFacilityServiceImpl extends ServiceImpl 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 index a0a7d1f..719d4ab 100644 --- 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 @@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; @Service @DS("ora") @@ -29,19 +30,8 @@ public class GardsNuclearReactorsServiceImpl extends ServiceImpl create(GardsNuclearReactors gardsNuclearReactors) { - - try { - boolean success = this.save(gardsNuclearReactors); - if (success) { - return Result.OK("添加核设施信息成功", gardsNuclearReactors); - } else { - return Result.error("添加核设施信息失败"); - } - } catch (Exception e) { - log.error("新增操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void create(GardsNuclearReactors gardsNuclearReactors) { + this.save(gardsNuclearReactors); } /** @@ -52,18 +42,8 @@ public class GardsNuclearReactorsServiceImpl extends ServiceImpl delete(Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.ok("核设施信息删除成功"); - } - return Result.error("删除核设施信息失败,可能该记录不存在"); - - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void delete(Integer id) { + this.removeById(id); } /** @@ -74,19 +54,8 @@ public class GardsNuclearReactorsServiceImpl extends ServiceImpl update(GardsNuclearReactors gardsNuclearReactors) { - try { - boolean success = this.updateById(gardsNuclearReactors); - if (success) { - return Result.OK("更新成功", gardsNuclearReactors); - } else { - return Result.error("更新失败,或者记录不存在"); - - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(GardsNuclearReactors gardsNuclearReactors) { + this.updateById(gardsNuclearReactors); } /** @@ -96,19 +65,13 @@ public class GardsNuclearReactorsServiceImpl extends ServiceImpl queryById(Integer id) { - try { - GardsNuclearReactors nuclearReactors = this.getById(id); - if (nuclearReactors != null) { - return Result.OK(nuclearReactors); - } else { - return Result.error("未找到核设施信息数据"); - } - } catch (Exception e) { - log.error("操作失败: " + e.getMessage()); - return Result.error("查询失败"); - } + public GardsNuclearReactors queryById(Integer id) { + GardsNuclearReactors nuclearReactors = this.getById(id); + if (Objects.isNull(nuclearReactors)) { + throw new RuntimeException("未找到对应的数据"); + } + return nuclearReactors; } /** @@ -121,39 +84,29 @@ public class GardsNuclearReactorsServiceImpl extends ServiceImpl> page( + public IPage page( Integer pageNum, Integer pageSize, String unitName, String country) { + Page page = new Page<>(pageNum, pageSize); - try { - Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (unitName != null && !unitName.trim().isEmpty()) { - wrapper.like(GardsNuclearReactors::getUnitName, unitName); - } - if (country != null && !country.trim().isEmpty()) { - wrapper.like(GardsNuclearReactors::getCountry, country); - } - wrapper.orderByDesc(GardsNuclearReactors::getId); - IPage pageResult = this.page(page, wrapper); - - return Result.OK(pageResult); - } catch (Exception e) { - log.error("查询失败: " + e.getMessage()); - return Result.error("查询失败"); + if (unitName != null && !unitName.trim().isEmpty()) { + wrapper.like(GardsNuclearReactors::getUnitName, unitName); } - - + if (country != null && !country.trim().isEmpty()) { + wrapper.like(GardsNuclearReactors::getCountry, country); + } + wrapper.orderByDesc(GardsNuclearReactors::getId); + IPage pageResult = this.page(page, wrapper); + return pageResult; } @Override public List getByConditions(String unitName, String country, String reactorType, String reactorStatus) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); if (unitName != null && !unitName.trim().isEmpty()) { wrapper.like(GardsNuclearReactors::getUnitName, unitName); @@ -170,10 +123,4 @@ public class GardsNuclearReactorsServiceImpl extends ServiceImpl 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 index 6247a20..9b2a7f0 100644 --- 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 @@ -16,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; + @Service @DS("ora") public class GardsNuclearReleaseServiceImpl extends ServiceImpl implements GardsNuclearReleaseService { @@ -26,18 +28,8 @@ public class GardsNuclearReleaseServiceImpl extends ServiceImpl create(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { - try { - boolean success = this.save(gardsNuclearReleaseRecords); - if (success) { - return Result.OK("添加成功", gardsNuclearReleaseRecords); - } else { - return Result.error("添加失败"); - } - } catch (Exception e) { - log.error("create: " + e.getMessage()); - return Result.error("添加失败"); - } + public void create(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { + this.save(gardsNuclearReleaseRecords); } /** @@ -45,19 +37,8 @@ public class GardsNuclearReleaseServiceImpl extends ServiceImpl deleteById(@RequestParam Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.OK("删除成功"); - } else { - return Result.error("删除失败,可能数据不存在"); - - } - } catch (Exception e) { - log.error("deleteById: " + e.getMessage()); - return Result.error("操作失败"); - } + public void deleteById(@RequestParam Integer id) { + this.removeById(id); } /** @@ -65,89 +46,60 @@ public class GardsNuclearReleaseServiceImpl extends ServiceImpl update(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { - try { - boolean success = this.updateById(gardsNuclearReleaseRecords); - if (success) { - return Result.OK("数据更新成功", gardsNuclearReleaseRecords); - } else { - return Result.error("数据更新失败"); - - } - } catch (Exception e) { - log.error("update: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(@RequestBody GardsNuclearReleaseRecords gardsNuclearReleaseRecords) { + this.updateById(gardsNuclearReleaseRecords); } /** * 查询核设施放射性排放记录信息 */ @Override - public Result queryById(@RequestParam Integer id) { - try { - GardsNuclearReleaseRecords nuclearReactors = this.getById(id); - if (nuclearReactors != null) { - return Result.OK(nuclearReactors); - } else { - return Result.error("未找到数据"); - } - } catch (Exception e) { - log.error("getById: " + e.getMessage()); - return Result.error("查询失败"); + public GardsNuclearReleaseRecords queryById(@RequestParam Integer id) { + GardsNuclearReleaseRecords nuclearReactors = this.getById(id); + if (Objects.isNull(nuclearReactors)) { + throw new RuntimeException("未找到对应的数据"); } + return nuclearReactors; } /** * 分页查询 * - * @param pageNum 页数 - * @param pageSize 每页大小 + * @param pageNum 页数 + * @param pageSize 每页大小 * @param facilityName 设施名称 - * @param nuclide 核素 + * @param nuclide 核素 * @return 分页结果 */ @Override - public Result> page( + public IPage page( @RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize, @RequestParam(required = false) String facilityName, @RequestParam(required = false) String nuclide) { - try { - Page page = new Page<>(pageNum, pageSize); - - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (facilityName != null && !facilityName.trim().isEmpty()) { - wrapper.like(GardsNuclearReleaseRecords::getFacilityName, facilityName); - } - if (nuclide != null && !nuclide.trim().isEmpty()) { - wrapper.like(GardsNuclearReleaseRecords::getNuclide, nuclide); - } - wrapper.orderByDesc(GardsNuclearReleaseRecords::getId); - IPage pageResult = this.page(page, wrapper); - - return Result.OK(pageResult); - } catch (Exception e) { - log.error("page: " + e.getMessage()); - return Result.error("查询失败:"); + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.like(GardsNuclearReleaseRecords::getFacilityName, facilityName); } - - + if (nuclide != null && !nuclide.trim().isEmpty()) { + wrapper.like(GardsNuclearReleaseRecords::getNuclide, nuclide); + } + wrapper.orderByDesc(GardsNuclearReleaseRecords::getId); + IPage pageResult = this.page(page, wrapper); + return pageResult; } @Override public List getByConditions(String facilityName, String nuclide, String matterState) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - if (facilityName != null && !facilityName.trim().isEmpty()) { queryWrapper.like(GardsNuclearReleaseRecords::getFacilityName, facilityName); } if (nuclide != null && !nuclide.trim().isEmpty()) { queryWrapper.like(GardsNuclearReleaseRecords::getNuclide, nuclide); } - if (matterState != null && !matterState.trim().isEmpty()) { queryWrapper.like(GardsNuclearReleaseRecords::getMatterState, matterState); } 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 index 244310b..10b84bd 100644 --- 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 @@ -15,29 +15,20 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; + @Service @DS("ora") public class GardsNuclearTestingPlantServiceImpl extends ServiceImpl implements GardsNuclearTestingPlantService { - /** * 新增 核试验信息 */ @Override @Transactional(rollbackFor = RuntimeException.class) - public Result create(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { - try { - boolean success = this.save(gardsNuclearTestingPlant); - if (success) { - return Result.OK("添加成功", gardsNuclearTestingPlant); - } else { - return Result.error("添加失败"); - } - } catch (Exception e) { - log.error("create: " + e.getMessage()); - return Result.error("添加失败"); - } + public void create(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { + this.save(gardsNuclearTestingPlant); } /** @@ -45,19 +36,8 @@ public class GardsNuclearTestingPlantServiceImpl extends ServiceImpl deleteById(@RequestParam Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.OK("删除成功"); - } else { - return Result.error("删除失败,可能数据不存在"); - - } - } catch (Exception e) { - log.error("deleteById: " + e.getMessage()); - return Result.error("操作失败:"); - } + public void deleteById(@RequestParam Integer id) { + this.removeById(id); } /** @@ -65,50 +45,29 @@ public class GardsNuclearTestingPlantServiceImpl extends ServiceImpl update(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { - try { - boolean success = this.updateById(gardsNuclearTestingPlant); - if (success) { - return Result.OK("数据更新成功", gardsNuclearTestingPlant); - } else { - return Result.error("数据更新失败"); - - } - } catch (Exception e) { - log.error("update: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(@RequestBody GardsNuclearTestingPlant gardsNuclearTestingPlant) { + this.updateById(gardsNuclearTestingPlant); } /** * 查询核设施放射性排放记录信息 */ @Override - public Result queryById(@RequestParam Integer id) { - try { - GardsNuclearTestingPlant nuclearReactors = this.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()); + public GardsNuclearTestingPlant queryById(@RequestParam Integer id) { + GardsNuclearTestingPlant nuclearReactors = this.getById(id); + if (Objects.isNull(nuclearReactors)) { + throw new RuntimeException("未找到对应的数据"); } + return nuclearReactors; } - public Result> page( + public IPage 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.like(GardsNuclearTestingPlant::getName, name); } @@ -118,26 +77,19 @@ public class GardsNuclearTestingPlantServiceImpl extends ServiceImpl pageResult = this.page(page, wrapper); - return Result.OK(pageResult); - } catch (Exception e) { - log.error("page: " + e.getMessage()); - return Result.error("查询失败:" + e.getMessage()); - } + return pageResult ; } - - - @Override public List getByConditions(String name, String type) { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - if (name != null&&!name.trim().isEmpty()) { + if (name != null && !name.trim().isEmpty()) { query.like(GardsNuclearTestingPlant::getName, name); } - if (type != null&&!type.trim().isEmpty()) { + if (type != null && !type.trim().isEmpty()) { query.like(GardsNuclearTestingPlant::getCountry, type); } query.orderByDesc(GardsNuclearTestingPlant::getId); diff --git a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclideDecayServiceImpl.java b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclideDecayServiceImpl.java index 2f4a7ae..2d78f87 100644 --- a/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclideDecayServiceImpl.java +++ b/jeecg-module-monitor-info-database/src/main/java/org/jeecg/service/impl/GardsNuclideDecayServiceImpl.java @@ -5,17 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.jeecg.common.api.vo.Result; import org.jeecg.modules.base.entity.configuration.GardsNuclideDecay; -import org.jeecg.modules.base.entity.configuration.GardsStations; -import org.jeecg.modules.base.entity.configuration.GardsNuclideDecay; -import org.jeecg.modules.base.mapper.GardsNuclideDecayMapper; import org.jeecg.modules.base.mapper.GardsNuclideDecayMapper; import org.jeecg.service.GardsNuclideDecayService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Objects; + @Service @DS("ora") public class GardsNuclideDecayServiceImpl extends ServiceImpl implements GardsNuclideDecayService { @@ -24,20 +22,8 @@ public class GardsNuclideDecayServiceImpl extends ServiceImpl create(GardsNuclideDecay gardsNuclideDecay) { - try { - - - boolean success = this.save(gardsNuclideDecay); - if (success) { - return Result.OK("添加成功", gardsNuclideDecay); - } else { - return Result.error("添加失败"); - } - } catch (Exception e) { - log.error("create: " + e.getMessage()); - return Result.error("添加失败"); - } + public void create(GardsNuclideDecay gardsNuclideDecay) { + this.save(gardsNuclideDecay); } /** @@ -45,19 +31,8 @@ public class GardsNuclideDecayServiceImpl extends ServiceImpl deleteById(Integer Id) { - try { - boolean success = this.removeById(Id); - if (success) { - return Result.OK("删除成功"); - } else { - return Result.error("删除失败,可能数据不存在"); - - } - } catch (Exception e) { - log.error("deleteById: " + e.getMessage()); - return Result.error("操作失败"); - } + public void deleteById(Integer id) { + this.removeById(id); } /** @@ -65,67 +40,46 @@ public class GardsNuclideDecayServiceImpl extends ServiceImpl update(GardsNuclideDecay gardsNuclideDecay) { - try { - boolean success = this.updateById(gardsNuclideDecay); - if (success) { - return Result.OK("数据更新成功", gardsNuclideDecay); - } else { - return Result.error("数据更新失败"); - - } - } catch (Exception e) { - log.error("update: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(GardsNuclideDecay gardsNuclideDecay) { + this.updateById(gardsNuclideDecay); } /** * 查询信息 */ @Override - public Result queryById(Integer Id) { - try { - GardsNuclideDecay nuclearReactors = this.getById(Id); - if (nuclearReactors != null) { - return Result.OK(nuclearReactors); - } else { - return Result.error("未找到数据"); - } - } catch (Exception e) { - log.error("getById: " + e.getMessage()); - return Result.error("查询失败"); + public GardsNuclideDecay queryById(Integer id) { + GardsNuclideDecay nuclearReactors = this.getById(id); + if (Objects.isNull(nuclearReactors)) { + throw new RuntimeException("未找到对应的数据"); } + return nuclearReactors; } @Override - public Result> page(Integer pageNum, Integer pageSize, String nuclide) { - try { - Page page = new Page<>(pageNum, pageSize); - - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (nuclide != null && !nuclide.trim().isEmpty()) { - wrapper.like(GardsNuclideDecay::getNuclide, nuclide); - } - wrapper.orderByDesc(GardsNuclideDecay::getId); - IPage pageResult = this.page(page, wrapper); - - return Result.OK(pageResult); - } catch (Exception e) { - log.error("page: " + e.getMessage()); - return Result.error("查询失败"); + public IPage page(Integer pageNum, Integer pageSize, String nuclide, String energy) { + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (nuclide != null && !nuclide.trim().isEmpty()) { + wrapper.like(GardsNuclideDecay::getNuclide, nuclide); } + if (energy != null && !energy.trim().isEmpty()) { + wrapper.like(GardsNuclideDecay::getEnergy, energy); + } + wrapper.orderByDesc(GardsNuclideDecay::getId); + IPage pageResult = this.page(page, wrapper); + return pageResult; } @Override - public List getByConditions(String nuclide) { + public List getByConditions(String nuclide, String energy) { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - if (nuclide != null && !nuclide.trim().isEmpty()) { query.like(GardsNuclideDecay::getNuclide, nuclide); } - + if (energy != null && !energy.trim().isEmpty()) { + query.like(GardsNuclideDecay::getEnergy, energy); + } query.orderByDesc(GardsNuclideDecay::getId); 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 index a05a086..99cffcd 100644 --- 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 @@ -16,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; + @Service @DS("ora") public class GardsResearchReactorsServiceImpl extends ServiceImpl implements GardsResearchReactorsService { @@ -25,18 +27,8 @@ public class GardsResearchReactorsServiceImpl extends ServiceImpl create( GardsResearchReactors gardsResearchReactors) { - try { - boolean success = this.save(gardsResearchReactors); - if (success) { - return Result.OK("反应堆信息添加成功", gardsResearchReactors); - } else { - return Result.error("反应堆信息添加失败"); - } - } catch (Exception e) { - log.error("create: " + e.getMessage()); - return Result.error("添加失败"); - } + public void create(GardsResearchReactors gardsResearchReactors) { + this.save(gardsResearchReactors); } /** @@ -44,19 +36,8 @@ public class GardsResearchReactorsServiceImpl extends ServiceImpl deleteById( Integer id) { - try { - boolean success = this.removeById(id); - if (success) { - return Result.OK("删除成功"); - } else { - return Result.error("删除失败,可能数据不存在"); - - } - } catch (Exception e) { - log.error("deleteById: " + e.getMessage()); - return Result.error("操作失败"); - } + public void deleteById(Integer id) { + this.removeById(id); } /** @@ -64,37 +45,20 @@ public class GardsResearchReactorsServiceImpl extends ServiceImpl update( GardsResearchReactors gardsResearchReactors) { - try { - boolean success = this.updateById(gardsResearchReactors); - if (success) { - return Result.OK("数据更新成功", gardsResearchReactors); - } else { - return Result.error("数据更新失败"); - - } - } catch (Exception e) { - log.error("update: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(GardsResearchReactors gardsResearchReactors) { + this.updateById(gardsResearchReactors); } /** * 查询信息 */ @Override - public Result queryById( Integer id) { - try { - GardsResearchReactors nuclearReactors = this.getById(id); - if (nuclearReactors != null) { - return Result.OK(nuclearReactors); - } else { - return Result.error("未找到数据"); - } - } catch (Exception e) { - log.error("getById: " + e.getMessage()); - return Result.error("查询失败"); + public GardsResearchReactors queryById(Integer id) { + GardsResearchReactors nuclearReactors = this.getById(id); + if (Objects.isNull(nuclearReactors)) { + throw new RuntimeException("未找到对应的数据"); } + return nuclearReactors; } /** @@ -107,50 +71,41 @@ public class GardsResearchReactorsServiceImpl extends ServiceImpl> page( - Integer pageNum, - Integer pageSize, - String facilityName, - String country) { + public IPage page( + Integer pageNum, + Integer pageSize, + String facilityName, + String country) { + Page page = new Page<>(pageNum, pageSize); - try { - Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (facilityName != null && !facilityName.trim().isEmpty()) { - wrapper.like(GardsResearchReactors::getFacilityName, facilityName); - } - if (country != null && !country.trim().isEmpty()) { - wrapper.like(GardsResearchReactors::getCountry, country); - } - wrapper.orderByDesc(GardsResearchReactors::getId); - IPage pageResult = this.page(page, wrapper); - - return Result.OK(pageResult); - } catch (Exception e) { - log.error("page: " + e.getMessage()); - return Result.error("查询失败" ); + if (facilityName != null && !facilityName.trim().isEmpty()) { + wrapper.like(GardsResearchReactors::getFacilityName, facilityName); } - - + if (country != null && !country.trim().isEmpty()) { + wrapper.like(GardsResearchReactors::getCountry, country); + } + wrapper.orderByDesc(GardsResearchReactors::getId); + IPage pageResult = this.page(page, wrapper); + return pageResult; } @Override - public List getByConditions(String facilityName, String country,String reactorType,String status) { + public List getByConditions(String facilityName, String country, String reactorType, String status) { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - if (facilityName != null&&!facilityName.trim().isEmpty()) { + if (facilityName != null && !facilityName.trim().isEmpty()) { query.like(GardsResearchReactors::getFacilityName, facilityName); } - if (country != null&&!country.trim().isEmpty()) { + if (country != null && !country.trim().isEmpty()) { query.like(GardsResearchReactors::getCountry, country); } - if (reactorType != null&&!reactorType.trim().isEmpty()) { + if (reactorType != null && !reactorType.trim().isEmpty()) { query.like(GardsResearchReactors::getReactorType, reactorType); } - if (status != null&&!status.trim().isEmpty()) { + if (status != null && !status.trim().isEmpty()) { query.like(GardsResearchReactors::getStatus, status); } query.orderByDesc(GardsResearchReactors::getId); 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 index 4214436..b3a73bc 100644 --- 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 @@ -5,9 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import io.swagger.v3.oas.annotations.Operation; -import org.jeecg.common.api.vo.Result; -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; @@ -16,32 +13,27 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.Objects; + @Service @DS("ora") -public class GardsStationsServiceImpl extends ServiceImpl implements GardsStationsService { +public class GardsStationsServiceImpl extends ServiceImpl + implements GardsStationsService { + final Integer stationLength = 5; /** * 新增信息 */ @Override @Transactional(rollbackFor = RuntimeException.class) - public Result create( GardsStations gardsStations) { - try { - if (gardsStations.getStationCode().length()>5){ - return Result.error("添加失败:StationCode 最大长度为5,实际长度是:"+gardsStations.getStationCode().length()); - } - - boolean success = this.save(gardsStations); - if (success) { - return Result.OK("添加成功", gardsStations); - } else { - return Result.error("添加失败"); - } - } catch (Exception e) { - log.error("create: " + e.getMessage()); - return Result.error("添加失败"); + public void create(GardsStations gardsStations) { + if (gardsStations.getStationCode().length() > stationLength) { + throw new RuntimeException("添加失败:StationCode 最大长度为5,实际长度是:" + + gardsStations.getStationCode().length()); } + this.save(gardsStations); + } /** @@ -49,19 +41,8 @@ public class GardsStationsServiceImpl extends ServiceImpl deleteById( Integer stationId) { - try { - boolean success = this.removeById(stationId); - if (success) { - return Result.OK("删除成功"); - } else { - return Result.error("删除失败,可能数据不存在"); - - } - } catch (Exception e) { - log.error("deleteById: " + e.getMessage()); - return Result.error("操作失败"); - } + public void deleteById(Integer stationId) { + this.removeById(stationId); } /** @@ -69,37 +50,20 @@ public class GardsStationsServiceImpl extends ServiceImpl update(GardsStations gardsStations) { - try { - boolean success = this.updateById(gardsStations); - if (success) { - return Result.OK("数据更新成功", gardsStations); - } else { - return Result.error("数据更新失败"); - - } - } catch (Exception e) { - log.error("update: " + e.getMessage()); - return Result.error("操作失败"); - } + public void update(GardsStations gardsStations) { + this.updateById(gardsStations); } /** * 查询信息 */ @Override - public Result queryById( Integer stationId) { - try { - GardsStations nuclearReactors = this.getById(stationId); - if (nuclearReactors != null) { - return Result.OK(nuclearReactors); - } else { - return Result.error("未找到数据"); - } - } catch (Exception e) { - log.error("getById: " + e.getMessage()); - return Result.error("查询失败" ); + public GardsStations queryById(Integer stationId) { + GardsStations nuclearReactors = this.getById(stationId); + if (Objects.isNull(nuclearReactors)) { + throw new RuntimeException("未找到对应的数据"); } + return nuclearReactors; } /** @@ -112,48 +76,40 @@ public class GardsStationsServiceImpl extends ServiceImpl> page( + public IPage page( Integer pageNum, - Integer pageSize, + Integer pageSize, String stationCode, String countryCode) { - - try { - Page page = new Page<>(pageNum, pageSize); - - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - - if (stationCode != null && !stationCode.trim().isEmpty()) { - wrapper.like(GardsStations::getStationCode, stationCode); - } - if (countryCode != null && !countryCode.trim().isEmpty()) { - wrapper.like(GardsStations::getCountryCode, countryCode); - } - wrapper.orderByDesc(GardsStations::getStationId); - IPage pageResult = this.page(page, wrapper); - - return Result.OK(pageResult); - } catch (Exception e) { - log.error("page: " + e.getMessage()); - return Result.error("查询失败"); + Page page = new Page<>(pageNum, pageSize); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (stationCode != null && !stationCode.trim().isEmpty()) { + wrapper.like(GardsStations::getStationCode, stationCode); } + if (countryCode != null && !countryCode.trim().isEmpty()) { + wrapper.like(GardsStations::getCountryCode, countryCode); + } + wrapper.orderByDesc(GardsStations::getStationId); + IPage pageResult = this.page(page, wrapper); + return pageResult; } @Override - public List getByConditions(String stationCode, String type, String status,String countryCode) { + public List getByConditions(String stationCode, String type, String status, + String countryCode) { LambdaQueryWrapper query = new LambdaQueryWrapper<>(); - if (stationCode != null&&!stationCode.trim().isEmpty()) { + if (stationCode != null && !stationCode.trim().isEmpty()) { query.like(GardsStations::getStationCode, stationCode); } - if (type != null&&!type.trim().isEmpty()) { + if (type != null && !type.trim().isEmpty()) { query.like(GardsStations::getType, type); } - if (status != null&&!status.trim().isEmpty()) { + if (status != null && !status.trim().isEmpty()) { query.like(GardsStations::getStatus, status); } - if (countryCode != null&&!countryCode.trim().isEmpty()) { + if (countryCode != null && !countryCode.trim().isEmpty()) { query.like(GardsStations::getCountryCode, countryCode); } query.orderByDesc(GardsStations::getStationId); 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 index a2c44d9..6efa5b5 100644 --- 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 @@ -23,7 +23,9 @@ public class BizUpsertUtil { // public static boolean upsertByColumnNames(IService service, List list, String... uniqueColumnNames) { - if (list.isEmpty()) return true; + if (list.isEmpty()) { + return true; + } String firstCol = uniqueColumnNames[0]; @@ -92,9 +94,12 @@ public class BizUpsertUtil { .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; + if (list == null || list.isEmpty()) { + return true; + } // 1. 提取所有业务唯一键(用于匹配) Map keyToEntity = new HashMap<>(); @@ -113,7 +118,7 @@ public class BizUpsertUtil { .toList(); List existList = service.list( - (new LambdaQueryWrapper()).in( firstCol, firstColumnValues) + (new LambdaQueryWrapper()).in(firstCol, firstColumnValues) ); // 3. 构建已存在记录的 key 映射 @@ -138,7 +143,7 @@ public class BizUpsertUtil { } } - boolean ok1 = insertList.isEmpty() || service.saveBatch(insertList, 1000); + boolean ok1 = insertList.isEmpty() || service.saveBatch(insertList, 1); boolean ok2 = updateList.isEmpty() || service.updateBatchById(updateList, 1000); System.out.println("插入: " + insertList.size() + ", 更新: " + updateList.size());