yang_shj
12 months ago
12 changed files with 701 additions and 1 deletions
@ -0,0 +1,23 @@
|
||||
package com.hnac.hzims.safeproduct.dto; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2023-12-14 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "演练年度统计DTO类") |
||||
public class RehearsalYearDTO { |
||||
|
||||
@ApiModelProperty("单位") |
||||
private String unit; |
||||
|
||||
@ApiModelProperty("日期") |
||||
private String dateTime; |
||||
|
||||
@ApiModelProperty("完成数") |
||||
private Long finishedNum; |
||||
} |
@ -0,0 +1,93 @@
|
||||
package com.hnac.hzims.safeproduct.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
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-13 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@TableName("hzims_rehearsal_record") |
||||
@ApiModel(value = "演练记录实体类") |
||||
public class RehearsalRecordEntity 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 = 1000000000, message = "参演人数超出限制范围") |
||||
@ApiModelProperty("参演人数") |
||||
private Integer peopleNum; |
||||
|
||||
@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 imgPath; |
||||
|
||||
@Size(max = 1000, message = "演练附件字段长度不能超过1000") |
||||
@ApiModelProperty("演练附件") |
||||
private String filePath; |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.hnac.hzims.safeproduct.enums; |
||||
|
||||
/** |
||||
* 演练状态枚举类 |
||||
* |
||||
* @author liwen |
||||
* @date 2023-12-14 |
||||
*/ |
||||
public enum RehearsalStatusEnum { |
||||
|
||||
WAITING("WAITING", "未开始"), |
||||
UNFINISHED("UNFINISHED", "未完成"), |
||||
FINISHED("FINISHED", "已完成"); |
||||
|
||||
private final String value; |
||||
|
||||
private final String desc; |
||||
|
||||
RehearsalStatusEnum(String value, String desc) { |
||||
this.value = value; |
||||
this.desc = desc; |
||||
} |
||||
|
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
public String getDesc() { |
||||
return desc; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.hnac.hzims.safeproduct.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2023-12-14 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "演练月度统计VO类") |
||||
public class RehearsalMonthVO { |
||||
|
||||
@ApiModelProperty("单位") |
||||
private String unit; |
||||
|
||||
@ApiModelProperty("计划任务总数") |
||||
private Long scheduledTaskNum; |
||||
|
||||
@ApiModelProperty("已完成任务/次") |
||||
private Long finishedTaskNum; |
||||
|
||||
@ApiModelProperty("未完成任务/次") |
||||
private Long unfinishedTaskNum; |
||||
|
||||
@ApiModelProperty("任务完成率") |
||||
private BigDecimal taskCompletionRate; |
||||
} |
@ -0,0 +1,53 @@
|
||||
package com.hnac.hzims.safeproduct.vo; |
||||
|
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @author liwen |
||||
* @date 2023-12-14 |
||||
*/ |
||||
@Data |
||||
@ApiModel(value = "演练年度统计VO类") |
||||
public class RehearsalYearVO { |
||||
|
||||
@ApiModelProperty("单位") |
||||
private String unit; |
||||
|
||||
@ApiModelProperty("1月完成数") |
||||
private Long januaryNum; |
||||
|
||||
@ApiModelProperty("2月完成数") |
||||
private Long februaryNum; |
||||
|
||||
@ApiModelProperty("3月完成数") |
||||
private Long marchNum; |
||||
|
||||
@ApiModelProperty("4月完成数") |
||||
private Long aprilNum; |
||||
|
||||
@ApiModelProperty("5月完成数") |
||||
private Long mayNum; |
||||
|
||||
@ApiModelProperty("6月完成数") |
||||
private Long juneNum; |
||||
|
||||
@ApiModelProperty("7月完成数") |
||||
private Long julyNum; |
||||
|
||||
@ApiModelProperty("8月完成数") |
||||
private Long augustNum; |
||||
|
||||
@ApiModelProperty("9月完成数") |
||||
private Long septemberNum; |
||||
|
||||
@ApiModelProperty("10月完成数") |
||||
private Long octoberNum; |
||||
|
||||
@ApiModelProperty("11月完成数") |
||||
private Long novemberNum; |
||||
|
||||
@ApiModelProperty("12月完成数") |
||||
private Long decemberNum; |
||||
} |
@ -0,0 +1,93 @@
|
||||
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.RehearsalRecordEntity; |
||||
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.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; |
||||
|
||||
@PostMapping("/save") |
||||
@ApiOperation(value = "新增") |
||||
@ApiOperationSupport(order = 1) |
||||
public R save(@Valid @RequestBody RehearsalRecordEntity 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)); |
||||
} |
||||
|
||||
@PostMapping("/remove") |
||||
@ApiOperation(value = "删除") |
||||
@ApiOperationSupport(order = 3) |
||||
public R remove(@RequestParam Long id) { |
||||
return R.status(rehearsalRecordService.removeById(id)); |
||||
} |
||||
|
||||
@GetMapping("/detail") |
||||
@ApiOperation(value = "详情") |
||||
@ApiOperationSupport(order = 4) |
||||
public R<RehearsalRecordEntity> detail(@RequestParam Long id) { |
||||
return R.data(rehearsalRecordService.getById(id)); |
||||
} |
||||
|
||||
@GetMapping("/page") |
||||
@ApiImplicitParams({ |
||||
@ApiImplicitParam() |
||||
}) |
||||
@ApiOperation(value = "分页") |
||||
@ApiOperationSupport(order = 5) |
||||
public R<IPage<RehearsalRecordEntity>> page(@ApiIgnore @RequestParam Map<String, Object> param, Query query) { |
||||
IPage<RehearsalRecordEntity> page = rehearsalRecordService.page(Condition.getPage(query), |
||||
Condition.getQueryWrapper(param, RehearsalRecordEntity.class)); |
||||
return R.data(page); |
||||
} |
||||
|
||||
@GetMapping("/dataByMonth") |
||||
@ApiOperation(value = "月度统计表") |
||||
@ApiOperationSupport(order = 6) |
||||
public R<IPage<RehearsalMonthVO>> dataByMonth(@RequestParam String month, Query query) { |
||||
IPage<RehearsalMonthVO> page = rehearsalRecordService.dataByMonth(month, query); |
||||
return R.data(page); |
||||
} |
||||
|
||||
@GetMapping("/dataByYear") |
||||
@ApiOperation(value = "年度统计表") |
||||
@ApiOperationSupport(order = 7) |
||||
public R<IPage<RehearsalYearVO>> dataByYear(@RequestParam String year, Query query) { |
||||
IPage<RehearsalYearVO> page = rehearsalRecordService.dataByYear(year, query); |
||||
return R.data(page); |
||||
} |
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.hnac.hzims.safeproduct.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.hnac.hzims.safeproduct.dto.RehearsalYearDTO; |
||||
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; |
||||
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; |
||||
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 演练记录Mapper类 |
||||
* |
||||
* @author liwen |
||||
* @date 2023-12-13 |
||||
*/ |
||||
@Mapper |
||||
public interface RehearsalRecordMapper extends BaseMapper<RehearsalRecordEntity> { |
||||
|
||||
/** |
||||
* 查询当月各单位的演练总数 |
||||
* @param page 分页类 |
||||
* @param month 月份 |
||||
* @return 当月的演练总数据 |
||||
*/ |
||||
IPage<RehearsalMonthVO> selectByMonth(IPage<RehearsalMonthVO> page, @Param("month") String month); |
||||
|
||||
/** |
||||
* 查询当月各单位已完成的演练数据 |
||||
* @param page 分页类 |
||||
* @param month 月份 |
||||
* @return 当月的已完成数据 |
||||
*/ |
||||
IPage<RehearsalMonthVO> selectFinishedDataByMonth(IPage<RehearsalMonthVO> page, @Param("month") String month); |
||||
|
||||
/** |
||||
* 查询当年的所有单位 |
||||
* @param page 分页类 |
||||
* @param year 年份 |
||||
* @return 年度单位数据 |
||||
*/ |
||||
IPage<RehearsalYearVO> selectUnitByYear(IPage<RehearsalYearVO> page, @Param("year") String year); |
||||
|
||||
/** |
||||
* 查询各单位全年已完成的演练数据 |
||||
* @param unitList 单元列表 |
||||
* @param year 年份 |
||||
* @return 单位各月的数据列表 |
||||
*/ |
||||
List<RehearsalYearDTO> selectFinishedDataByUnit(@Param("unitList") List<String> unitList, @Param("year") String year); |
||||
} |
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper"> |
||||
|
||||
<select id="selectByMonth" resultType="com.hnac.hzims.safeproduct.vo.RehearsalMonthVO"> |
||||
SELECT |
||||
unit, count(1) as scheduled_task_num |
||||
FROM |
||||
hzims_rehearsal_record |
||||
WHERE |
||||
is_deleted = 0 |
||||
AND scheduled_end_time like concat('%', #{month}, '%') |
||||
GROUP BY |
||||
unit |
||||
ORDER BY |
||||
unit |
||||
</select> |
||||
|
||||
<select id="selectFinishedDataByMonth" resultType="com.hnac.hzims.safeproduct.vo.RehearsalMonthVO"> |
||||
SELECT |
||||
unit, count(1) as finished_task_num |
||||
FROM |
||||
hzims_rehearsal_record |
||||
WHERE |
||||
is_deleted = 0 |
||||
AND scheduled_end_time like concat('%', #{month}, '%') |
||||
AND rehearsal_status = 'FINISHED' |
||||
GROUP BY |
||||
unit |
||||
ORDER BY |
||||
unit |
||||
</select> |
||||
|
||||
<select id="selectUnitByYear" resultType="com.hnac.hzims.safeproduct.vo.RehearsalYearVO"> |
||||
SELECT |
||||
distinct unit |
||||
FROM |
||||
hzims_rehearsal_record |
||||
WHERE |
||||
is_deleted = 0 |
||||
AND actual_end_time like concat('%', #{year}, '%') |
||||
ORDER BY |
||||
unit |
||||
</select> |
||||
|
||||
<select id="selectFinishedDataByUnit" resultType="com.hnac.hzims.safeproduct.dto.RehearsalYearDTO"> |
||||
SELECT |
||||
unit, DATE_FORMAT(actual_end_time, '%m') as dateTime, count(1) as finished_num |
||||
FROM |
||||
hzims_rehearsal_record |
||||
WHERE |
||||
is_deleted = 0 |
||||
AND actual_end_time like concat('%', #{year}, '%') |
||||
AND rehearsal_status = 'FINISHED' |
||||
AND unit in |
||||
<foreach collection="unitList" item="unit" open="(" close=")" separator=","> |
||||
#{unit} |
||||
</foreach> |
||||
GROUP BY |
||||
unit, DATE_FORMAT(actual_end_time, '%m') |
||||
ORDER BY |
||||
unit |
||||
</select> |
||||
|
||||
</mapper> |
@ -0,0 +1,40 @@
|
||||
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.entity.RehearsalRecordEntity; |
||||
import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; |
||||
import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; |
||||
import org.springblade.core.mp.support.Query; |
||||
|
||||
/** |
||||
* 演练记录服务类 |
||||
* |
||||
* @author liwen |
||||
* @date 2023-12-13 |
||||
*/ |
||||
public interface IRehearsalRecordService extends IService<RehearsalRecordEntity> { |
||||
|
||||
/** |
||||
* 演练月度数据 |
||||
* @param month 月份 |
||||
* @param query 分页类 |
||||
* @return 月度统计分页 |
||||
*/ |
||||
IPage<RehearsalMonthVO> dataByMonth(String month, Query query); |
||||
|
||||
/** |
||||
* 演练年度数据 |
||||
* @param year 年份 |
||||
* @param query 分页类 |
||||
* @return 年度统计分页 |
||||
*/ |
||||
IPage<RehearsalYearVO> dataByYear(String year, Query query); |
||||
|
||||
/** |
||||
* 新增演练 |
||||
* @param rehearsalRecord 演练记录实体类 |
||||
* @return 新增是否成功 |
||||
*/ |
||||
boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord); |
||||
} |
@ -0,0 +1,178 @@
|
||||
package com.hnac.hzims.safeproduct.service.impl; |
||||
|
||||
import cn.hutool.core.date.DatePattern; |
||||
import com.alibaba.excel.util.CollectionUtils; |
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
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.RehearsalYearDTO; |
||||
import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; |
||||
import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; |
||||
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.stereotype.Service; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.math.RoundingMode; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Optional; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 演练记录服务实现类 |
||||
* |
||||
* @author liwen |
||||
* @date 2023-12-13 |
||||
*/ |
||||
@Service |
||||
public class RehearsalRecordServiceImpl extends ServiceImpl<RehearsalRecordMapper, RehearsalRecordEntity> implements IRehearsalRecordService { |
||||
|
||||
/** |
||||
* 演练月度数据 |
||||
*/ |
||||
@Override |
||||
public IPage<RehearsalMonthVO> dataByMonth(String month, Query query) { |
||||
IPage<RehearsalMonthVO> page = new Page<>(query.getCurrent(), query.getSize()); |
||||
// 查询当月各单位的演练总数
|
||||
IPage<RehearsalMonthVO> unitPage = baseMapper.selectByMonth(page, month); |
||||
List<RehearsalMonthVO> unitList = unitPage.getRecords(); |
||||
// 查询当月各单位已完成的演练数据
|
||||
IPage<RehearsalMonthVO> finishedPage = baseMapper.selectFinishedDataByMonth(page, month); |
||||
List<RehearsalMonthVO> finishedList = finishedPage.getRecords(); |
||||
// 处理统计数据
|
||||
for (RehearsalMonthVO unit : unitList) { |
||||
Long taskNum = unit.getScheduledTaskNum(); |
||||
Optional<RehearsalMonthVO> finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); |
||||
Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTaskNum() : 0L; |
||||
unit.setFinishedTaskNum(finishedTaskNum); |
||||
unit.setUnfinishedTaskNum(taskNum - finishedTaskNum); |
||||
BigDecimal taskDecimal = new BigDecimal(taskNum); |
||||
BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); |
||||
unit.setTaskCompletionRate(finishedDecimal.divide(taskDecimal, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) |
||||
.setScale(2, RoundingMode.HALF_UP)); |
||||
} |
||||
unitPage.setRecords(unitList); |
||||
return unitPage; |
||||
} |
||||
|
||||
/** |
||||
* 演练年度数据 |
||||
*/ |
||||
@Override |
||||
public IPage<RehearsalYearVO> dataByYear(String year, Query query) { |
||||
IPage<RehearsalYearVO> page = new Page<>(query.getCurrent(), query.getSize()); |
||||
// 查询当年的所有单位
|
||||
IPage<RehearsalYearVO> unitPage = baseMapper.selectUnitByYear(page, year); |
||||
List<RehearsalYearVO> records = unitPage.getRecords(); |
||||
List<String> unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList()); |
||||
// 查询各单位全年已完成的演练数据
|
||||
List<RehearsalYearDTO> unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); |
||||
// 将各单位每个月的演练数据写入统计列表
|
||||
unitMonthDataList.forEach(data -> { |
||||
RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) |
||||
.collect(Collectors.toList()).get(0); |
||||
// 根据月份匹配写入对应字段
|
||||
switch (data.getDateTime()) { |
||||
case "01": |
||||
rehearsalYearVO.setJanuaryNum(data.getFinishedNum()); |
||||
break; |
||||
case "02": |
||||
rehearsalYearVO.setFebruaryNum(data.getFinishedNum()); |
||||
break; |
||||
case "03": |
||||
rehearsalYearVO.setMarchNum(data.getFinishedNum()); |
||||
break; |
||||
case "04": |
||||
rehearsalYearVO.setAprilNum(data.getFinishedNum()); |
||||
break; |
||||
case "05": |
||||
rehearsalYearVO.setMayNum(data.getFinishedNum()); |
||||
break; |
||||
case "06": |
||||
rehearsalYearVO.setJuneNum(data.getFinishedNum()); |
||||
break; |
||||
case "07": |
||||
rehearsalYearVO.setJulyNum(data.getFinishedNum()); |
||||
break; |
||||
case "08": |
||||
rehearsalYearVO.setAugustNum(data.getFinishedNum()); |
||||
break; |
||||
case "09": |
||||
rehearsalYearVO.setSeptemberNum(data.getFinishedNum()); |
||||
break; |
||||
case "10": |
||||
rehearsalYearVO.setOctoberNum(data.getFinishedNum()); |
||||
break; |
||||
case "11": |
||||
rehearsalYearVO.setNovemberNum(data.getFinishedNum()); |
||||
break; |
||||
case "12": |
||||
rehearsalYearVO.setDecemberNum(data.getFinishedNum()); |
||||
} |
||||
}); |
||||
unitPage.setRecords(records); |
||||
return unitPage; |
||||
} |
||||
|
||||
/** |
||||
* 新增演练 |
||||
*/ |
||||
@Override |
||||
public boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord) { |
||||
// 获取当月时间(yyyymm)
|
||||
String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); |
||||
// 查询是否存在同月编号
|
||||
String lastCode = getLastCode(currentMonth); |
||||
// 若不存在,新增编号
|
||||
if (StringUtils.isNull(lastCode)) { |
||||
String code = "YLJL" + currentMonth + "001"; |
||||
rehearsalRecord.setCode(code); |
||||
return this.save(rehearsalRecord); |
||||
} |
||||
// 若存在,编号递增
|
||||
String oldNum = lastCode.substring(lastCode.length() - 3); |
||||
int value = Integer.parseInt(oldNum) + 1; |
||||
String code; |
||||
// 根据数位拼接编号
|
||||
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); |
||||
return this.save(rehearsalRecord); |
||||
} |
||||
|
||||
/** |
||||
* 查询是否存在同月编号 |
||||
* @param currentMonth 当月 |
||||
* @return 存在则返回上一编号,否则返回null |
||||
*/ |
||||
private String getLastCode(String currentMonth) { |
||||
String month = currentMonth.substring(currentMonth.length() - 2); |
||||
List<RehearsalRecordEntity> list = getRehearsalByMonth(month); |
||||
if (CollectionUtils.isEmpty(list)) { |
||||
return null; |
||||
} |
||||
return list.get(0).getCode(); |
||||
} |
||||
|
||||
/** |
||||
* 查询当月演练记录 |
||||
* @param month 当月 |
||||
* @return 当月演练数据表 |
||||
*/ |
||||
public List<RehearsalRecordEntity> getRehearsalByMonth(String month) { |
||||
QueryWrapper<RehearsalRecordEntity> queryWrapper = new QueryWrapper<>(); |
||||
queryWrapper.lambda().like(RehearsalRecordEntity::getCreateTime, month) |
||||
.orderByDesc(RehearsalRecordEntity::getCode); |
||||
return this.list(queryWrapper); |
||||
} |
||||
} |
Loading…
Reference in new issue