From ce6a0d5d95f33025eb8782f9a933aa128f7cc168 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jan 2024 10:06:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?update:=20=E6=BC=94=E7=BB=83=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/dto/RehearsalExportDTO.java | 4 +- .../safeproduct/entity/RehearsalPlanEntity.java | 3 + .../controller/RehearsalController.java | 151 +++++++++++++++++++++ .../controller/RehearsalRecordController.java | 151 --------------------- .../service/impl/RehearsalPlanServiceImpl.java | 7 +- .../service/impl/RehearsalRecordServiceImpl.java | 17 +-- .../com/hnac/hzims/safeproduct/utils/BaseUtil.java | 39 ++++++ 7 files changed, 203 insertions(+), 169 deletions(-) create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java delete mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java index 1f2903b..800f911 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java @@ -26,11 +26,11 @@ public class RehearsalExportDTO { private String subject; @ApiModelProperty("演练计划开始时间") - @ExcelProperty(value = "演练计划开始时间", index = 2) + @ExcelProperty(value = "计划开始时间", index = 2) private Date scheduledStartTime; @ApiModelProperty("演练计划结束时间") - @ExcelProperty(value = "演练计划结束时间", index = 3) + @ExcelProperty(value = "计划结束时间", index = 3) private Date scheduledEndTime; @ApiModelProperty("演练地点") diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java index bdff1a1..4cd4306 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.safeproduct.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,10 +33,12 @@ public class RehearsalPlanEntity extends BaseEntity { private String subject; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("演练计划开始时间") private Date scheduledStartTime; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("演练计划结束时间") private Date scheduledEndTime; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java new file mode 100644 index 0000000..58b036e --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java @@ -0,0 +1,151 @@ +package com.hnac.hzims.safeproduct.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; +import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; +import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; +import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; +import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; +import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.Map; + +/** + * 演练管理接口类 + * + * @author liwen + * @date 2023-12-13 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/rehearsal") +@Api(value = "演练管理", tags = "演练管理接口") +public class RehearsalController extends BladeController { + + private final IRehearsalRecordService rehearsalRecordService; + + private final IRehearsalPlanService rehearsalPlanService; + + @PostMapping("/save") + @ApiOperation(value = "新增演练计划") + @ApiOperationSupport(order = 1) + public R save(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { + return R.status(rehearsalPlanService.save(rehearsalPlan)); + } + + @PostMapping("/update") + @ApiOperation(value = "修改演练计划") + @ApiOperationSupport(order = 2) + public R update(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { + return R.status(rehearsalPlanService.updateById(rehearsalPlan)); + } + + @PostMapping("/remove") + @ApiOperation(value = "删除演练计划") + @ApiOperationSupport(order = 3) + public R remove(@RequestParam Long id) { + return R.status(rehearsalPlanService.removeRehearsalPlan(id)); + } + + @GetMapping("/detail") + @ApiOperation(value = "演练计划详情") + @ApiOperationSupport(order = 4) + public R detail(@RequestParam Long id) { + return R.data(rehearsalPlanService.getById(id)); + } + + @GetMapping("/page") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练计划分页") + @ApiOperationSupport(order = 5) + public R> page(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = rehearsalPlanService.rehearsalPlanPage(param, query); + return R.data(page); + } + + @PostMapping("/saveRehearsalRecord") + @ApiOperation(value = "新增演练记录") + @ApiOperationSupport(order = 6) + public R saveRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + return R.status(rehearsalRecordService.saveRehearsalRecord(rehearsalRecord)); + } + + @PostMapping("/updateRehearsalRecord") + @ApiOperation(value = "修改演练记录") + @ApiOperationSupport(order = 7) + public R updateRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + return R.status(rehearsalRecordService.updateRehearsalRecord(rehearsalRecord)); + } + + @PostMapping("/removeRehearsalRecord") + @ApiOperation(value = "删除演练记录") + @ApiOperationSupport(order = 8) + public R removeRehearsalRecord(@RequestParam Long id) { + return R.status(rehearsalRecordService.removeById(id)); + } + + @GetMapping("/rehearsalRecordDetail") + @ApiOperation(value = "演练记录详情") + @ApiOperationSupport(order = 9) + public R rehearsalRecordDetail(@RequestParam Long id) { + return R.data(rehearsalRecordService.getById(id)); + } + + @GetMapping("/rehearsalRecordPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "rehearsalPlanId", value = "演练计划id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练记录分页") + @ApiOperationSupport(order = 10) + public R> rehearsalRecordPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = rehearsalRecordService.page(Condition.getPage(query), + Condition.getQueryWrapper(param, RehearsalRecordEntity.class)); + return R.data(page); + } + + @GetMapping("/dataByMonth") + @ApiOperation(value = "月度统计表") + @ApiOperationSupport(order = 11) + public R> dataByMonth(@RequestParam String month, Query query) { + IPage page = rehearsalPlanService.dataByMonth(month, query); + return R.data(page); + } + + @GetMapping("/dataByYear") + @ApiOperation(value = "年度统计表") + @ApiOperationSupport(order = 12) + public R> dataByYear(@RequestParam String year, Query query) { + IPage page = rehearsalPlanService.dataByYear(year, query); + return R.data(page); + } + + @GetMapping("/exportRehearsalData") + @ApiImplicitParams({ + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练数据导出") + @ApiOperationSupport(order = 13) + public void exportRehearsalData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { + rehearsalPlanService.exportRehearsalPlanData(param, response); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java deleted file mode 100644 index f80e0fa..0000000 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.hnac.hzims.safeproduct.controller; - -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; -import com.hnac.hzims.common.utils.Condition; -import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; -import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; -import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; -import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; -import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; -import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; -import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.mp.support.Query; -import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; - -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; -import java.util.Map; - -/** - * 演练记录接口类 - * - * @author liwen - * @date 2023-12-13 - */ -@RestController -@AllArgsConstructor -@RequestMapping("/rehearsal") -@Api(value = "演练记录", tags = "演练记录接口") -public class RehearsalRecordController extends BladeController { - - private final IRehearsalRecordService rehearsalRecordService; - - private final IRehearsalPlanService rehearsalPlanService; - - @PostMapping("/save") - @ApiOperation(value = "新增演练计划") - @ApiOperationSupport(order = 1) - public R save(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { - return R.status(rehearsalPlanService.save(rehearsalPlan)); - } - - @PostMapping("/update") - @ApiOperation(value = "修改演练计划") - @ApiOperationSupport(order = 2) - public R update(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { - return R.status(rehearsalPlanService.updateById(rehearsalPlan)); - } - - @PostMapping("/remove") - @ApiOperation(value = "删除演练计划") - @ApiOperationSupport(order = 3) - public R remove(@RequestParam Long id) { - return R.status(rehearsalPlanService.removeRehearsalPlan(id)); - } - - @GetMapping("/detail") - @ApiOperation(value = "演练计划详情") - @ApiOperationSupport(order = 4) - public R detail(@RequestParam Long id) { - return R.data(rehearsalPlanService.getById(id)); - } - - @GetMapping("/page") - @ApiImplicitParams({ - @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "演练计划分页") - @ApiOperationSupport(order = 5) - public R> page(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = rehearsalPlanService.rehearsalPlanPage(param, query); - return R.data(page); - } - - @PostMapping("/saveRehearsalRecord") - @ApiOperation(value = "新增演练记录") - @ApiOperationSupport(order = 6) - public R saveRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.saveRehearsalRecord(rehearsalRecord)); - } - - @PostMapping("/updateRehearsalRecord") - @ApiOperation(value = "修改演练记录") - @ApiOperationSupport(order = 7) - public R updateRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.updateRehearsalRecord(rehearsalRecord)); - } - - @PostMapping("/removeRehearsalRecord") - @ApiOperation(value = "删除演练记录") - @ApiOperationSupport(order = 8) - public R removeRehearsalRecord(@RequestParam Long id) { - return R.status(rehearsalRecordService.removeById(id)); - } - - @GetMapping("/rehearsalRecordDetail") - @ApiOperation(value = "演练记录详情") - @ApiOperationSupport(order = 9) - public R rehearsalRecordDetail(@RequestParam Long id) { - return R.data(rehearsalRecordService.getById(id)); - } - - @GetMapping("/rehearsalRecordPage") - @ApiImplicitParams({ - @ApiImplicitParam(name = "rehearsalPlanId", value = "演练计划id", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "演练记录分页") - @ApiOperationSupport(order = 10) - public R> rehearsalRecordPage(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = rehearsalRecordService.page(Condition.getPage(query), - Condition.getQueryWrapper(param, RehearsalRecordEntity.class)); - return R.data(page); - } - - @GetMapping("/dataByMonth") - @ApiOperation(value = "月度统计表") - @ApiOperationSupport(order = 11) - public R> dataByMonth(@RequestParam String month, Query query) { - IPage page = rehearsalPlanService.dataByMonth(month, query); - return R.data(page); - } - - @GetMapping("/dataByYear") - @ApiOperation(value = "年度统计表") - @ApiOperationSupport(order = 12) - public R> dataByYear(@RequestParam String year, Query query) { - IPage page = rehearsalPlanService.dataByYear(year, query); - return R.data(page); - } - - @GetMapping("/exportRehearsalData") - @ApiImplicitParams({ - @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") - }) - @ApiOperation(value = "演练数据导出") - @ApiOperationSupport(order = 13) - public void exportRehearsalData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { - rehearsalPlanService.exportRehearsalPlanData(param, response); - } -} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java index 647fb1f..1d1932c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -24,6 +24,7 @@ import org.springblade.core.mp.support.Query; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; @@ -72,6 +73,10 @@ public class RehearsalPlanServiceImpl extends ServiceImpl page = new Page<>(query.getCurrent(), query.getSize()); IPage unitPage = baseMapper.selectByMonth(page, month); List unitList = unitPage.getRecords(); + // 若无数据,返回空页面 + if (CollectionUtils.isEmpty(unitList)) { + return unitPage; + } // 查询当月各单位已完成的演练数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); @@ -102,7 +107,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl unitPage = baseMapper.selectUnitByYear(page, year); List records = unitPage.getRecords(); // 若无数据,返回空页面 - if (org.springframework.util.CollectionUtils.isEmpty(records)) { + if (CollectionUtils.isEmpty(records)) { return unitPage; } List unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList()); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java index b3a6701..6aa0b5d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java @@ -12,6 +12,7 @@ import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.mapper.RehearsalPlanMapper; import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -42,21 +43,7 @@ public class RehearsalRecordServiceImpl extends ServiceImpl Date: Tue, 2 Jan 2024 10:52:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?update:=20=E5=9F=B9=E8=AE=AD=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/TrainPlanEntity.java | 7 ++- .../safeproduct/entity/TrainRecordEntity.java | 1 - .../safeproduct/controller/TrainController.java | 4 +- .../safeproduct/service/impl/TestServiceImpl.java | 53 +++++++++------------- .../service/impl/TrainPlanServiceImpl.java | 4 ++ .../service/impl/TrainRecordServiceImpl.java | 18 +------- 6 files changed, 35 insertions(+), 52 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java index 9b1b0fb..93db233 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java @@ -4,6 +4,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,12 +33,14 @@ public class TrainPlanEntity extends BaseEntity { private String unit; @NotNull - @ApiModelProperty("计划培训开始时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划开始时间") @ExcelProperty(value = "计划开始时间", index = 6) private Date scheduledStartTime; @NotNull - @ApiModelProperty("计划培训结束时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划结束时间") @ExcelProperty(value = "计划结束时间", index = 7) private Date scheduledEndTime; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java index 24f2e2f..b8728dc 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java @@ -41,7 +41,6 @@ public class TrainRecordEntity extends BaseEntity { @ExcelProperty(value = "培训学员", index = 3) private String peopleName; - @Size(max = 5000, message = "培训内容字段长度超出限制范围") @ApiModelProperty("培训内容") @ExcelProperty(value = "培训内容", index = 2) private String content; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java index d306a47..172a59b 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -83,8 +83,8 @@ public class TrainController extends BladeController { @GetMapping("/trainPlanPage") @ApiImplicitParams({ @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划培训开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划培训结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划分页") @ApiOperationSupport(order = 5) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java index 8ab1dfa..9df05c4 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern; import com.alibaba.excel.util.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.TestDTO; import com.hnac.hzims.safeproduct.entity.TestEntity; @@ -14,6 +13,7 @@ import com.hnac.hzims.safeproduct.mapper.TestMapper; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.service.ITestScoreService; import com.hnac.hzims.safeproduct.service.ITestService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springblade.core.tool.api.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -56,21 +56,7 @@ public class TestServiceImpl extends ServiceImpl impleme // 查询是否存在同月编号 String lastCode = getLastCode(currentMonth); // 若不存在,新增编号 - String code; - if (StringUtils.isNull(lastCode)) { - code = "KSJL" + currentMonth + "001"; - } else { // 若存在,编号递增 - String oldNum = lastCode.substring(lastCode.length() - 3); - int value = Integer.parseInt(oldNum) + 1; - // 根据数位拼接编号 - if (value < 10) { - code = "KSJL" + currentMonth + "00" + value; - } else if (value < 100) { - code = "KSJL" + currentMonth + "0" + value; - } else { - code = "KSJL" + currentMonth + value; - } - } + String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentMonth); testEntity.setCode(code); boolean saveTest = this.save(testEntity); // 若新增考试记录成功,添加相关的参考人员数据 @@ -81,13 +67,7 @@ public class TestServiceImpl extends ServiceImpl impleme String people = test.getPeopleName(); String[] person = people.split(",|,"); // 新增参考人员成绩数据 - List scoreList = new ArrayList<>(); - for(String name : person) { - TestScoreEntity testScoreEntity = new TestScoreEntity(); - testScoreEntity.setTestId(test.getId()); - testScoreEntity.setName(name); - scoreList.add(testScoreEntity); - } + List scoreList = getReferenceTestScore(test, person); return R.status(testScoreService.saveBatch(scoreList)); } return R.fail("新增考试记录失败"); @@ -185,20 +165,31 @@ public class TestServiceImpl extends ServiceImpl impleme if (removeByIds) { String[] person = testEntity.getPeopleName().split(",|,"); // 新增参考人员成绩数据 - List res = new ArrayList<>(); - for (String name : person) { - TestScoreEntity testScoreEntity = new TestScoreEntity(); - testScoreEntity.setTestId(testEntity.getId()); - testScoreEntity.setName(name); - res.add(testScoreEntity); - } - return testScoreService.saveBatch(res); + List scoreList = getReferenceTestScore(testEntity, person); + return testScoreService.saveBatch(scoreList); } } return false; } /** + * 获取成绩列表 + * @param testEntity 考试记录实体类 + * @param person 参考人员 + * @return 成绩列表 + */ + private List getReferenceTestScore(TestEntity testEntity, String[] person) { + List res = new ArrayList<>(); + for (String name : person) { + TestScoreEntity testScoreEntity = new TestScoreEntity(); + testScoreEntity.setTestId(testEntity.getId()); + testScoreEntity.setName(name); + res.add(testScoreEntity); + } + return res; + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java index cba9def..27a8d8e 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java @@ -63,6 +63,10 @@ public class TrainPlanServiceImpl extends ServiceImpl page = new Page<>(query.getCurrent(), query.getSize()); IPage unitPage = baseMapper.selectByMonth(page, month); List unitList = unitPage.getRecords(); + // 若无数据,返回空页面 + if (CollectionUtils.isEmpty(unitList)) { + return unitPage; + } // 查询当月各单位已完成的培训数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java index 230a4d2..79d9c05 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java @@ -10,7 +10,6 @@ import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; @@ -20,6 +19,7 @@ import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper; import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITrainRecordService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springblade.core.log.exception.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -61,21 +61,7 @@ public class TrainRecordServiceImpl extends ServiceImpl Date: Tue, 2 Jan 2024 10:52:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?update:=20=E4=BC=9A=E8=AE=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/ConferencePlanEntity.java | 3 +++ .../safeproduct/entity/ConferenceRecordEntity.java | 1 - .../service/impl/ConferencePlanServiceImpl.java | 4 ++-- .../service/impl/ConferenceRecordServiceImpl.java | 18 ++---------------- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java index a7261a9..914c031 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.safeproduct.entity; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,10 +33,12 @@ public class ConferencePlanEntity extends BaseEntity { private String theme; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("会议计划开始时间") private Date scheduledStartTime; @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") @ApiModelProperty("会议计划结束时间") private Date scheduledEndTime; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java index 1aa0309..99e3341 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java @@ -41,7 +41,6 @@ public class ConferenceRecordEntity extends BaseEntity { @ApiModelProperty("记录人") private String recorder; - @Size(max = 250, message = "会议内容字段长度不能超过250") @ApiModelProperty("会议内容") private String content; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java index 2d742ce..803b972 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java @@ -62,8 +62,8 @@ public class ConferencePlanServiceImpl extends ServiceImpl planPage(Map param, Query query) { QueryWrapper queryWrapper = new QueryWrapper<>(); String unit = String.valueOf(param.get("unit")); - String startTime = String.valueOf(param.get("startTime")); - String endTime = String.valueOf((param.get("endTime"))); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf((param.get("scheduledEndTime"))); if (!unit.equals("null") && !unit.equals("")) { queryWrapper.lambda().like(ConferencePlanEntity::getUnit, unit); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java index 622683c..7350c86 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java @@ -4,7 +4,6 @@ import cn.hutool.core.date.DatePattern; import com.alibaba.excel.util.CollectionUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; @@ -12,6 +11,7 @@ import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.mapper.ConferencePlanMapper; import com.hnac.hzims.safeproduct.mapper.ConferenceRecordMapper; import com.hnac.hzims.safeproduct.service.IConferenceRecordService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -59,21 +59,7 @@ public class ConferenceRecordServiceImpl extends ServiceImpl