Browse Source

update: 演练模块逻辑优化

zhongwei
liwen 11 months ago
parent
commit
ce6a0d5d95
  1. 4
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java
  2. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java
  3. 6
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java
  4. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java
  5. 17
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java
  6. 39
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

4
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; private String subject;
@ApiModelProperty("演练计划开始时间") @ApiModelProperty("演练计划开始时间")
@ExcelProperty(value = "演练计划开始时间", index = 2) @ExcelProperty(value = "计划开始时间", index = 2)
private Date scheduledStartTime; private Date scheduledStartTime;
@ApiModelProperty("演练计划结束时间") @ApiModelProperty("演练计划结束时间")
@ExcelProperty(value = "演练计划结束时间", index = 3) @ExcelProperty(value = "计划结束时间", index = 3)
private Date scheduledEndTime; private Date scheduledEndTime;
@ApiModelProperty("演练地点") @ApiModelProperty("演练地点")

3
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; package com.hnac.hzims.safeproduct.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -32,10 +33,12 @@ public class RehearsalPlanEntity extends BaseEntity {
private String subject; private String subject;
@NotNull @NotNull
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("演练计划开始时间") @ApiModelProperty("演练计划开始时间")
private Date scheduledStartTime; private Date scheduledStartTime;
@NotNull @NotNull
@JsonFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty("演练计划结束时间") @ApiModelProperty("演练计划结束时间")
private Date scheduledEndTime; private Date scheduledEndTime;

6
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java → hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalController.java

@ -25,7 +25,7 @@ import javax.validation.Valid;
import java.util.Map; import java.util.Map;
/** /**
* 演练记录接口类 * 演练管理接口类
* *
* @author liwen * @author liwen
* @date 2023-12-13 * @date 2023-12-13
@ -33,8 +33,8 @@ import java.util.Map;
@RestController @RestController
@AllArgsConstructor @AllArgsConstructor
@RequestMapping("/rehearsal") @RequestMapping("/rehearsal")
@Api(value = "演练记录", tags = "演练记录接口") @Api(value = "演练管理", tags = "演练管理接口")
public class RehearsalRecordController extends BladeController { public class RehearsalController extends BladeController {
private final IRehearsalRecordService rehearsalRecordService; private final IRehearsalRecordService rehearsalRecordService;

7
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -72,6 +73,10 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize()); IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize());
IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, month); IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, month);
List<RehearsalMonthVO> unitList = unitPage.getRecords(); List<RehearsalMonthVO> unitList = unitPage.getRecords();
// 若无数据,返回空页面
if (CollectionUtils.isEmpty(unitList)) {
return unitPage;
}
// 查询当月各单位已完成的演练数据 // 查询当月各单位已完成的演练数据
IPage<RehearsalMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize()); IPage<RehearsalMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize());
IPage<RehearsalMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); IPage<RehearsalMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page1, month);
@ -102,7 +107,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl<RehearsalPlanMapper, R
IPage<RehearsalYearVO> unitPage = baseMapper.selectUnitByYear(page, year); IPage<RehearsalYearVO> unitPage = baseMapper.selectUnitByYear(page, year);
List<RehearsalYearVO> records = unitPage.getRecords(); List<RehearsalYearVO> records = unitPage.getRecords();
// 若无数据,返回空页面 // 若无数据,返回空页面
if (org.springframework.util.CollectionUtils.isEmpty(records)) { if (CollectionUtils.isEmpty(records)) {
return unitPage; return unitPage;
} }
List<String> unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList()); List<String> unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList());

17
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.RehearsalPlanMapper;
import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper;
import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService;
import com.hnac.hzims.safeproduct.utils.BaseUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -42,21 +43,7 @@ public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMappe
// 查询是否存在同月编号 // 查询是否存在同月编号
String lastCode = getLastCode(currentMonth); String lastCode = getLastCode(currentMonth);
// 若不存在,新增编号 // 若不存在,新增编号
String code; String code = BaseUtil.getUniqueCode("YLJL", lastCode, currentMonth);
if (StringUtils.isNull(lastCode)) {
code = "YLJL" + currentMonth + "001";
} else { // 若存在,编号递增
String oldNum = lastCode.substring(lastCode.length() - 3);
int value = Integer.parseInt(oldNum) + 1;
// 根据数位拼接编号
if (value < 10) {
code = "YLJL" + currentMonth + "00" + value;
} else if (value < 100) {
code = "YLJL" + currentMonth + "0" + value;
} else {
code = "YLJL" + currentMonth + value;
}
}
rehearsalRecord.setCode(code); rehearsalRecord.setCode(code);
// 参演人数 // 参演人数
String peopleName = rehearsalRecord.getPeopleName(); String peopleName = rehearsalRecord.getPeopleName();

39
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/utils/BaseUtil.java

@ -0,0 +1,39 @@
package com.hnac.hzims.safeproduct.utils;
import com.hnac.hzims.common.logs.utils.StringUtils;
/**
* 公用工具类
*
* @author liwen
* @date 2024-01-02
*/
public class BaseUtil {
/**
* 生成编码规则模块首字母 + 日期yyyymm + 编号三位
* @param module 模块首字母
* @param lastCode 已存在的最新编号
* @param currentMonth 日期
* @return 编码
*/
public static String getUniqueCode(String module, String lastCode, String currentMonth) {
// 若不存在,新增编号
String code;
if (StringUtils.isNull(lastCode)) {
code = module + currentMonth + "001";
} else { // 若存在,编号递增
String oldNum = lastCode.substring(lastCode.length() - 3);
int value = Integer.parseInt(oldNum) + 1;
// 根据数位拼接编号
if (value < 10) {
code = module + currentMonth + "00" + value;
} else if (value < 100) {
code = module + currentMonth + "0" + value;
} else {
code = module + currentMonth + value;
}
}
return code;
}
}
Loading…
Cancel
Save