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;
@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("演练地点")

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;
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;

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;
/**
* 演练记录接口类
* 演练管理接口类
*
* @author liwen
* @date 2023-12-13
@ -33,8 +33,8 @@ import java.util.Map;
@RestController
@AllArgsConstructor
@RequestMapping("/rehearsal")
@Api(value = "演练记录", tags = "演练记录接口")
public class RehearsalRecordController extends BladeController {
@Api(value = "演练管理", tags = "演练管理接口")
public class RehearsalController extends BladeController {
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.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<RehearsalPlanMapper, R
IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize());
IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, month);
List<RehearsalMonthVO> unitList = unitPage.getRecords();
// 若无数据,返回空页面
if (CollectionUtils.isEmpty(unitList)) {
return unitPage;
}
// 查询当月各单位已完成的演练数据
IPage<RehearsalMonthVO> page1 = new Page<>(query.getCurrent(), query.getSize());
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);
List<RehearsalYearVO> records = unitPage.getRecords();
// 若无数据,返回空页面
if (org.springframework.util.CollectionUtils.isEmpty(records)) {
if (CollectionUtils.isEmpty(records)) {
return unitPage;
}
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.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<RehearsalRecordMappe
// 查询是否存在同月编号
String lastCode = getLastCode(currentMonth);
// 若不存在,新增编号
String code;
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;
}
}
String code = BaseUtil.getUniqueCode("YLJL", lastCode, currentMonth);
rehearsalRecord.setCode(code);
// 参演人数
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