From acc979538fbcb88047e14ae460ef58534164edb3 Mon Sep 17 00:00:00 2001 From: liwen Date: Fri, 15 Dec 2023 11:34:09 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E6=BC=94=E7=BB=83=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/dto/RehearsalRecordDTO.java | 95 ++++++++++++++++++++++ .../safeproduct/entity/RehearsalRecordEntity.java | 6 +- .../safeproduct/enums/RehearsalMethodEnum.java | 31 +++++++ .../controller/RehearsalRecordController.java | 18 +++- .../service/IRehearsalRecordService.java | 12 ++- .../service/impl/RehearsalRecordServiceImpl.java | 70 +++++++++++----- 6 files changed, 206 insertions(+), 26 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalMethodEnum.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java new file mode 100644 index 0000000..4500ea5 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java @@ -0,0 +1,95 @@ +package com.hnac.hzims.safeproduct.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; + +/** + * @author liwen + * @date 2023-12-15 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "演练记录DTO类") +public class RehearsalRecordDTO extends BaseEntity { + + @Size(max = 50, message = "编码字段长度不能超过50") + @ApiModelProperty("编码") + private String code; + + @NotNull + @Size(max = 50, message = "单位字段长度不能超过50") + @ApiModelProperty("单位") + private String unit; + + @NotNull + @Size(max = 50, message = "演练科目字段长度不能超过50") + @ApiModelProperty("演练科目") + private String subject; + + @NotNull + @ApiModelProperty("演练计划开始时间") + private Date scheduledStartTime; + + @NotNull + @ApiModelProperty("演练计划结束时间") + private Date scheduledEndTime; + + @NotNull + @Size(max = 255, message = "演练地点字段长度不能超过255") + @ApiModelProperty("演练地点") + private String location; + + @Min(value = 0, message = "参演人数不能小于0") + @Max(value = 1000, message = "参演人数字段长度超出限制范围") + @ApiModelProperty("参演人数") + private Integer peopleNum; + + @Size(max = 5000, message = "参演人员字段长度超出限制范围") + @ApiModelProperty("参演人员") + private String[] people; + + @NotNull + @Size(max = 10, message = "总指挥字段长度不能超过10") + @ApiModelProperty("总指挥") + private String commander; + + @ApiModelProperty("演练实际开始时间") + private Date actualStartTime; + + @ApiModelProperty("演练实际结束时间") + private Date actualEndTime; + + @Size(max = 250, message = "演练记录字段长度不能超过250") + @ApiModelProperty("演练记录") + private String record; + + @Size(max = 250, message = "演练评价字段长度不能超过250") + @ApiModelProperty("演练评价") + private String comment; + + @Size(max = 20, message = "演练方式字段长度不能超过20") + @ApiModelProperty("演练方式") + private String rehearsalMethod; + + @NotNull + @Size(max = 20, message = "演练状态字段长度不能超过20") + @ApiModelProperty("演练状态") + private String rehearsalStatus; + + @Size(max = 1000, message = "演练图片字段长度不能超过1000") + @ApiModelProperty("演练图片") + private String[] images; + + @Size(max = 1000, message = "演练附件字段长度不能超过1000") + @ApiModelProperty("演练附件") + private String[] files; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java index 1ae07b8..6d027ea 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java @@ -51,10 +51,14 @@ public class RehearsalRecordEntity extends BaseEntity { private String location; @Min(value = 0, message = "参演人数不能小于0") - @Max(value = 1000000000, message = "参演人数超出限制范围") + @Max(value = 1000, message = "参演人数字段长度超出限制范围") @ApiModelProperty("参演人数") private Integer peopleNum; + @Size(max = 5000, message = "参演人员字段长度超出限制范围") + @ApiModelProperty("参演人员") + private String peopleName; + @NotNull @Size(max = 10, message = "总指挥字段长度不能超过10") @ApiModelProperty("总指挥") diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalMethodEnum.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalMethodEnum.java new file mode 100644 index 0000000..a1cb0f8 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/RehearsalMethodEnum.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.safeproduct.enums; + +/** + * 演练方式枚举类 + * + * @author liwen + * @date 2023-12-14 + */ +public enum RehearsalMethodEnum { + + ONLINE("ONLINE", "线上"), + OFFLINE("OFFLINE", "线下"), + MIXED("MIXED", "线上+线下"); + + private final String value; + + private final String desc; + + RehearsalMethodEnum(String value, String desc) { + this.value = value; + this.desc = desc; + } + + public String getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} 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 index 3d81120..bef9dfc 100644 --- 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 @@ -3,6 +3,7 @@ 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.dto.RehearsalRecordDTO; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; @@ -38,15 +39,15 @@ public class RehearsalRecordController extends BladeController { @PostMapping("/save") @ApiOperation(value = "新增") @ApiOperationSupport(order = 1) - public R save(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + public R save(@Valid @RequestBody RehearsalRecordDTO rehearsalRecord) { return R.status(rehearsalRecordService.saveRehearsal(rehearsalRecord)); } @PostMapping("/update") @ApiOperation(value = "修改") @ApiOperationSupport(order = 2) - public R update(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.updateById(rehearsalRecord)); + public R update(@Valid @RequestBody RehearsalRecordDTO rehearsalRecord) { + return R.status(rehearsalRecordService.updateRehearsal(rehearsalRecord)); } @PostMapping("/remove") @@ -65,7 +66,9 @@ public class RehearsalRecordController extends BladeController { @GetMapping("/page") @ApiImplicitParams({ - @ApiImplicitParam() + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "actualStartTime", value = "实际开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "actualEndTime", value = "实际结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "分页") @ApiOperationSupport(order = 5) @@ -90,4 +93,11 @@ public class RehearsalRecordController extends BladeController { IPage page = rehearsalRecordService.dataByYear(year, query); return R.data(page); } + + @GetMapping("/exportRehearsalData") + @ApiOperation(value = "导出演练页数据") + @ApiOperationSupport(order = 8) + public void exportRehearsalData() { + + } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java index ae85eda..0cb3e1f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java @@ -2,6 +2,7 @@ package com.hnac.hzims.safeproduct.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.RehearsalRecordDTO; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; @@ -33,8 +34,15 @@ public interface IRehearsalRecordService extends IService /** * 新增演练 - * @param rehearsalRecord 演练记录实体类 + * @param rehearsalRecord 演练记录DTO类 * @return 新增是否成功 */ - boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord); + boolean saveRehearsal(RehearsalRecordDTO rehearsalRecord); + + /** + * 修改演练 + * @param rehearsalRecord 演练记录DTO类 + * @return 更新是否成功 + */ + boolean updateRehearsal(RehearsalRecordDTO rehearsalRecord); } 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 98ed350..007f7ec 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 @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.logs.utils.StringUtils; +import com.hnac.hzims.safeproduct.dto.RehearsalRecordDTO; import com.hnac.hzims.safeproduct.dto.RehearsalYearDTO; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; @@ -14,10 +15,12 @@ import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; import org.springblade.core.mp.support.Query; +import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Optional; @@ -37,12 +40,13 @@ public class RehearsalRecordServiceImpl extends ServiceImpl dataByMonth(String month, Query query) { - IPage page = new Page<>(query.getCurrent(), query.getSize()); // 查询当月各单位的演练总数 + IPage page = new Page<>(query.getCurrent(), query.getSize()); IPage unitPage = baseMapper.selectByMonth(page, month); List unitList = unitPage.getRecords(); // 查询当月各单位已完成的演练数据 - IPage finishedPage = baseMapper.selectFinishedDataByMonth(page, month); + IPage page1 = new Page<>(query.getCurrent(), query.getSize()); + IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); List finishedList = finishedPage.getRecords(); // 处理统计数据 for (RehearsalMonthVO unit : unitList) { @@ -123,31 +127,41 @@ public class RehearsalRecordServiceImpl extends ServiceImpl