From 72e783c7bbadf2f2f5f37c3d852cfa9b5d8760cb Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 26 Dec 2023 17:36:51 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E5=9F=B9=E8=AE=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/constants/SafeProductConstant.java | 13 + .../hzims/safeproduct/dto/AnalysisYearDTO.java | 23 ++ .../hzims/safeproduct/dto/RehearsalRecordDTO.java | 95 -------- .../hzims/safeproduct/dto/RehearsalYearDTO.java | 23 -- .../com/hnac/hzims/safeproduct/dto/TestDTO.java | 20 ++ .../hnac/hzims/safeproduct/dto/TestScoreDTO.java | 23 ++ .../hnac/hzims/safeproduct/dto/TrainRecordDTO.java | 20 ++ .../hnac/hzims/safeproduct/entity/TestEntity.java | 77 ++++++ .../hzims/safeproduct/entity/TestScoreEntity.java | 37 +++ .../hzims/safeproduct/entity/TrainPlanEntity.java | 64 +++++ .../safeproduct/entity/TrainRecordEntity.java | 59 +++++ .../com/hnac/hzims/safeproduct/vo/TestScoreVO.java | 20 ++ .../hnac/hzims/safeproduct/vo/TrainMonthVO.java | 31 +++ .../com/hnac/hzims/safeproduct/vo/TrainYearVO.java | 53 +++++ .../safeproduct/controller/TrainController.java | 261 +++++++++++++++++++++ .../hnac/hzims/safeproduct/mapper/TestMapper.java | 25 ++ .../hnac/hzims/safeproduct/mapper/TestMapper.xml | 14 ++ .../hzims/safeproduct/mapper/TestScoreMapper.java | 25 ++ .../hzims/safeproduct/mapper/TestScoreMapper.xml | 18 ++ .../hzims/safeproduct/mapper/TrainPlanMapper.java | 53 +++++ .../hzims/safeproduct/mapper/TrainPlanMapper.xml | 64 +++++ .../safeproduct/mapper/TrainRecordMapper.java | 25 ++ .../hzims/safeproduct/mapper/TrainRecordMapper.xml | 18 ++ .../safeproduct/service/ITestScoreService.java | 45 ++++ .../hzims/safeproduct/service/ITestService.java | 66 ++++++ .../safeproduct/service/ITrainPlanService.java | 50 ++++ .../safeproduct/service/ITrainRecordService.java | 60 +++++ .../service/impl/TestScoreServiceImpl.java | 75 ++++++ .../safeproduct/service/impl/TestServiceImpl.java | 220 +++++++++++++++++ .../service/impl/TrainPlanServiceImpl.java | 228 ++++++++++++++++++ .../service/impl/TrainRecordServiceImpl.java | 217 +++++++++++++++++ .../safeproduct/src/main/resources/db/1.0.1.sql | 116 ++++++++- 32 files changed, 2018 insertions(+), 120 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/AnalysisYearDTO.java delete mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java delete mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalYearDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestScoreDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TrainRecordDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestScoreEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainMonthVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainYearVO.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestScoreService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainRecordService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java new file mode 100644 index 0000000..af9d10a --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/constants/SafeProductConstant.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.safeproduct.constants; + +/** + * safeproduct 常量类 + * + * @author liwen + * @date 2023-12-25 + */ +public interface SafeProductConstant { + + int TRAIN_PLAN_HAS_TEST = 1; + int TRAIN_PLAN_HAS_NO_TEST = 0; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/AnalysisYearDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/AnalysisYearDTO.java new file mode 100644 index 0000000..3c09840 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/AnalysisYearDTO.java @@ -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 AnalysisYearDTO { + + @ApiModelProperty("单位") + private String unit; + + @ApiModelProperty("日期") + private String dateTime; + + @ApiModelProperty("完成数") + private Long finishedNum; +} 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 deleted file mode 100644 index 4500ea5..0000000 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalRecordDTO.java +++ /dev/null @@ -1,95 +0,0 @@ -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/dto/RehearsalYearDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalYearDTO.java deleted file mode 100644 index 6ce369d..0000000 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalYearDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -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; -} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestDTO.java new file mode 100644 index 0000000..6b55684 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestDTO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.safeproduct.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@ApiModel(value = "考试记录DTO类") +public class TestDTO { + + @ApiModelProperty("考试记录id") + private Long id; + + @ApiModelProperty("考试记录名称") + private String testName; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestScoreDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestScoreDTO.java new file mode 100644 index 0000000..ab7b651 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TestScoreDTO.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.safeproduct.dto; + +import com.hnac.hzims.safeproduct.vo.TestScoreVO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@ApiModel(value = "考试成绩DTO类") +public class TestScoreDTO { + + @ApiModelProperty("考试记录id") + private Long testId; + + @ApiModelProperty("考试成绩列表") + private List scoreList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TrainRecordDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TrainRecordDTO.java new file mode 100644 index 0000000..f077f0c --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/TrainRecordDTO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.safeproduct.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@ApiModel(value = "培训记录DTO类") +public class TrainRecordDTO { + + @ApiModelProperty("培训记录id") + private Long id; + + @ApiModelProperty("培训记录名称") + private String trainRecordName; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java new file mode 100644 index 0000000..0736f88 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestEntity.java @@ -0,0 +1,77 @@ +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.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_test") +@ApiModel(value = "考试记录实体类") +public class TestEntity extends BaseEntity { + + @ApiModelProperty("培训计划id") + private Long trainPlanId; + + @ApiModelProperty("培训记录id") + private Long trainRecordId; + + @Size(max = 50, message = "名称字段长度不能超过50") + @ApiModelProperty("考试记录名称") + private String testName; + + @Size(max = 50, message = "编码字段长度不能超过50") + @ApiModelProperty("编码") + private String code; + + @NotNull + @Size(max = 50, message = "单位字段长度不能超过50") + @ApiModelProperty("单位") + private String unit; + + @NotNull + @ApiModelProperty("考试开始时间") + private Date testStartTime; + + @NotNull + @ApiModelProperty("考试结束时间") + private Date testEndTime; + + @NotNull + @Size(max = 255, message = "考试地点字段长度不能超过255") + @ApiModelProperty("考试地点") + private String location; + + @NotNull + @Size(max = 50, message = "考试科目字段长度不能超过50") + @ApiModelProperty("考试科目") + private String subject; + + @NotNull + @Size(max = 20, message = "监考人字段长度不能超过20") + @ApiModelProperty("监考人") + private String proctor; + + @Size(max = 1000, message = "参考人员字段长度超出限制范围") + @ApiModelProperty("参考人员") + private String peopleName; + + @Size(max = 1000, message = "考试图片字段长度不能超过1000") + @ApiModelProperty("考试图片") + private String imgPath; + + @Size(max = 1000, message = "考试附件字段长度不能超过1000") + @ApiModelProperty("考试附件") + private String filePath; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestScoreEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestScoreEntity.java new file mode 100644 index 0000000..a95020e --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TestScoreEntity.java @@ -0,0 +1,37 @@ +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; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_test_score") +@ApiModel(value = "考试记录实体类") +public class TestScoreEntity extends BaseEntity { + + @ApiModelProperty("考试记录id") + private Long testId; + + @Size(max = 50, message = "姓名字段长度不能超过50") + @ApiModelProperty("姓名") + private String name; + + @NotNull + @Min(value = 0, message = "成绩必须大于等于0") + @Max(value = 100, message = "成绩必须小于等于100") + @ApiModelProperty("成绩") + private Integer score; +} 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 new file mode 100644 index 0000000..f6a5d4c --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainPlanEntity.java @@ -0,0 +1,64 @@ +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.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_train_plan") +@ApiModel(value = "培训计划实体类") +public class TrainPlanEntity extends BaseEntity { + + @NotNull + @Size(max = 50, message = "单位字段长度不能超过50") + @ApiModelProperty("单位") + private String unit; + + @NotNull + @ApiModelProperty("计划培训开始时间") + private Date scheduledStartTime; + + @NotNull + @ApiModelProperty("计划培训结束时间") + private Date scheduledEndTime; + + @NotNull + @Size(max = 255, message = "单位字段长度不能超过255") + @ApiModelProperty("培训课程") + private String lesson; + + @NotNull + @Size(max = 255, message = "培训地点字段长度不能超过255") + @ApiModelProperty("培训地点") + private String location; + + @Size(max = 20, message = "培训方式字段长度不能超过20") + @ApiModelProperty("培训方式") + private String trainMethod; + + @NotNull + @Size(max = 20, message = "培训讲师字段长度不能超过20") + @ApiModelProperty("培训讲师") + private String teacher; + + @NotNull + @Size(max = 20, message = "培训状态字段长度不能超过20") + @ApiModelProperty("培训状态") + private String trainStatus; + + @NotNull + @ApiModelProperty("关联考试:0-否,1-是") + private Integer isTest; +} 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 new file mode 100644 index 0000000..f92ae58 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/TrainRecordEntity.java @@ -0,0 +1,59 @@ +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.Size; +import java.util.Date; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_train_record") +@ApiModel(value = "培训记录实体类") +public class TrainRecordEntity extends BaseEntity { + + @ApiModelProperty("培训计划id") + private Long trainPlanId; + + @Size(max = 50, message = "名称字段长度不能超过50") + @ApiModelProperty("培训记录名称") + private String trainRecordName; + + @Size(max = 50, message = "编码字段长度不能超过50") + @ApiModelProperty("编码") + private String code; + + @Size(max = 5000, message = "培训学员字段长度超出限制范围") + @ApiModelProperty("培训学员") + private String peopleName; + + @Size(max = 5000, message = "培训内容字段长度超出限制范围") + @ApiModelProperty("培训内容") + private String content; + + @ApiModelProperty("实际培训开始时间") + private Date actualStartTime; + + @ApiModelProperty("实际培训结束时间") + private Date actualEndTime; + + @Size(max = 250, message = "培训评价字段长度不能超过250") + @ApiModelProperty("培训评价") + private String command; + + @Size(max = 1000, message = "培训图片字段长度不能超过1000") + @ApiModelProperty("培训图片") + private String imgPath; + + @Size(max = 1000, message = "培训附件字段长度不能超过1000") + @ApiModelProperty("培训附件") + private String filePath; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java new file mode 100644 index 0000000..2e33809 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TestScoreVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwen + * @date 2023-12-25 + */ +@Data +@ApiModel(value = "考试成绩VO类") +public class TestScoreVO { + + @ApiModelProperty("姓名") + private String name; + + @ApiModelProperty("成绩") + private Integer score; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainMonthVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainMonthVO.java new file mode 100644 index 0000000..e121988 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainMonthVO.java @@ -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-25 + */ +@Data +@ApiModel(value = "培训月度统计VO类") +public class TrainMonthVO { + + @ApiModelProperty("单位") + private String unit; + + @ApiModelProperty("应完成次数") + private Long scheduledTrainNum; + + @ApiModelProperty("已完成次数") + private Long finishedTrainNum; + + @ApiModelProperty("未完成次数") + private Long unfinishedTrainNum; + + @ApiModelProperty("完成率") + private BigDecimal completionRate; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainYearVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainYearVO.java new file mode 100644 index 0000000..227b355 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/TrainYearVO.java @@ -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-25 + */ +@Data +@ApiModel(value = "培训年度统计VO类") +public class TrainYearVO { + + @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; +} 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 new file mode 100644 index 0000000..1dd2f50 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/TrainController.java @@ -0,0 +1,261 @@ +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.TestDTO; +import com.hnac.hzims.safeproduct.dto.TestScoreDTO; +import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; +import com.hnac.hzims.safeproduct.entity.TestEntity; +import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +import com.hnac.hzims.safeproduct.entity.TrainRecordEntity; +import com.hnac.hzims.safeproduct.service.ITestScoreService; +import com.hnac.hzims.safeproduct.service.ITestService; +import com.hnac.hzims.safeproduct.service.ITrainPlanService; +import com.hnac.hzims.safeproduct.service.ITrainRecordService; +import com.hnac.hzims.safeproduct.vo.TestScoreVO; +import com.hnac.hzims.safeproduct.vo.TrainMonthVO; +import com.hnac.hzims.safeproduct.vo.TrainYearVO; +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.apache.commons.lang3.StringUtils; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Query; +import org.springblade.core.secure.BladeUser; +import org.springblade.core.tool.api.R; +import org.springblade.system.feign.ISysClient; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.List; +import java.util.Map; + +/** + * 培训管理接口类 + * + * @author liwen + * @date 2023-12-25 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/train") +@Api(value = "培训管理", tags = "培训管理接口") +public class TrainController extends BladeController { + + private final ITrainPlanService trainPlanService; + + private final ITrainRecordService trainRecordService; + + private final ITestService testService; + + private final ITestScoreService testScoreService; + + private final ISysClient sysClient; + + @PostMapping("/saveTrainPlan") + @ApiOperation(value = "新增培训计划") + @ApiOperationSupport(order = 1) + public R saveTrainPlan(@Valid @RequestBody TrainPlanEntity trainPlanEntity) { + return R.status(trainPlanService.save(trainPlanEntity)); + } + + @PostMapping("/updateTrainPlan") + @ApiOperation(value = "修改培训计划") + @ApiOperationSupport(order = 2) + public R updateTrainPlan(@Valid @RequestBody TrainPlanEntity trainPlanEntity) { + return R.status(trainPlanService.updateById(trainPlanEntity)); + } + + @PostMapping("/removeTrainPlan") + @ApiOperation(value = "删除培训计划") + @ApiOperationSupport(order = 3) + public R removeTrainPlan(@RequestParam Long id) { + return R.status(trainPlanService.removeTrainPlan(id)); + } + + @GetMapping("/trainPlanDetail") + @ApiOperation(value = "培训计划详情") + @ApiOperationSupport(order = 4) + public R trainPlanDetail(@RequestParam Long id) { + return R.data(trainPlanService.getById(id)); + } + + @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") + }) + @ApiOperation(value = "培训计划分页") + @ApiOperationSupport(order = 5) + public R> trainPlanPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = trainPlanService.page(Condition.getPage(query), Condition.getQueryWrapper(param, TrainPlanEntity.class)); + return R.data(page); + } + + @PostMapping("/saveTrainRecord") + @ApiOperation(value = "新增培训记录") + @ApiOperationSupport(order = 6) + public R saveTrainRecord(@Valid @RequestBody TrainRecordEntity trainRecordEntity) { + return R.status(trainRecordService.saveTrainRecord(trainRecordEntity)); + } + + @PostMapping("/updateTrainRecord") + @ApiOperation(value = "修改培训记录") + @ApiOperationSupport(order = 7) + public R updateTrainRecord(@Valid @RequestBody TrainRecordEntity trainRecordEntity) { + return R.status(trainRecordService.updateById(trainRecordEntity)); + } + + @PostMapping("/removeTrainRecord") + @ApiOperation(value = "删除培训记录") + @ApiOperationSupport(order = 8) + public R removeTrainRecord(@RequestParam Long id) { + return R.status(trainRecordService.removeTrainRecord(id)); + } + + @GetMapping("/trainRecordDetail") + @ApiOperation(value = "培训记录详情") + @ApiOperationSupport(order = 9) + public R trainRecordDetail(@RequestParam Long id) { + return R.data(trainRecordService.getById(id)); + } + + @GetMapping("/trainRecordPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "trainPlanId", value = "培训计划id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "培训记录分页") + @ApiOperationSupport(order = 10) + public R> trainRecordPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = trainRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(param, TrainRecordEntity.class)); + return R.data(page); + } + + @GetMapping("/getTrainRecordNameList") + @ApiOperation(value = "培训记录名称列表") + @ApiOperationSupport(order = 11) + public R> getTrainRecordNameList(@RequestParam String trainPlanId) { + List list = trainRecordService.getTrainRecordNameList(trainPlanId); + return R.data(list); + } + + @PostMapping("/saveTest") + @ApiOperation(value = "新增考试") + @ApiOperationSupport(order = 12) + public R saveTest(@Valid @RequestBody TestEntity testEntity) { + return testService.saveTest(testEntity); + } + + @PostMapping("/updateTest") + @ApiOperation(value = "修改考试") + @ApiOperationSupport(order = 13) + public R updateTest(@Valid @RequestBody TestEntity testEntity) { + return R.status(testService.updateTest(testEntity)); + } + + @PostMapping("/removeTest") + @ApiOperation(value = "删除考试") + @ApiOperationSupport(order = 14) + public R removeTest(@RequestParam Long id) { + return R.status(testService.removeTest(id)); + } + + @GetMapping("/testDetail") + @ApiOperation(value = "考试详情") + @ApiOperationSupport(order = 15) + public R testDetail(@RequestParam Long id) { + return R.data(testService.getById(id)); + } + + @GetMapping("/testPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "trainRecordId", value = "培训记录id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "考试记录分页") + @ApiOperationSupport(order = 16) + public R> testPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = testService.page(Condition.getPage(query), Condition.getQueryWrapper(param, TestEntity.class)); + return R.data(page); + } + + @GetMapping("/getTestNameList") + @ApiOperation(value = "考试记录名称列表") + @ApiOperationSupport(order = 17) + public R> getTestNameList(@RequestParam String trainPlanId) { + List list = testService.getTestNameList(trainPlanId); + return R.data(list); + } + + @GetMapping("/testScoreList") + @ApiOperation(value = "考试成绩列表") + @ApiOperationSupport(order = 18) + public R> testScoreList(@RequestParam Long testId) { + List list = testScoreService.testScoreList(testId); + return R.data(list); + } + + @PostMapping("/updateBatchScore") + @ApiOperation(value = "批量填写分数") + @ApiOperationSupport(order = 19) + public R updateBatchScore(TestScoreDTO testScoreDTO) { + return R.status(testScoreService.updateBatchScore(testScoreDTO)); + } + + @GetMapping("/trainDataByMonth") + @ApiOperation(value = "培训月度统计表") + @ApiOperationSupport(order = 20) + public R> trainDataByMonth(@RequestParam String month, Query query) { + IPage page = trainPlanService.dataByMonth(month, query); + return R.data(page); + } + + @GetMapping("/trainDataByYear") + @ApiOperation(value = "培训年度统计表") + @ApiOperationSupport(order = 21) + public R> trainDataByYear(@RequestParam String year, Query query) { + IPage page = trainPlanService.dataByYear(year, query); + return R.data(page); + } + + @GetMapping("/getDeptName") + @ApiOperation(value = "获取所属机构名") + @ApiOperationSupport(order = 22) + public R getDeptName() { + BladeUser bladeUser = getUser(); + String deptId = bladeUser.getDeptId(); + if (StringUtils.isNotBlank(deptId)) { + return sysClient.getDeptName(Long.valueOf(deptId)); + } + return R.data(null, "所属机构为空"); + } + + @GetMapping("/exportTrainPlanData") + @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 = 23) + public void exportTrainPlanData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { + trainPlanService.exportTrainPlanData(param, response); + } + + @GetMapping("/exportTrainRecordData") + @ApiImplicitParams({ + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "培训记录数据导出") + @ApiOperationSupport(order = 24) + public void exportTrainRecordData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { + trainRecordService.exportTrainRecordData(param, response); + } + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.java new file mode 100644 index 0000000..6d65b66 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.dto.TestDTO; +import com.hnac.hzims.safeproduct.entity.TestEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 考试记录Mapper类 + * + * @author liwen + * @date 2023-12-25 + */ +@Mapper +public interface TestMapper extends BaseMapper { + + /** + * 查询考试记录名称列表 + * @param trainPlanId 培训计划id + * @return 考试记录名称列表 + */ + List getTestNameList(String trainPlanId); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.xml new file mode 100644 index 0000000..f6ded92 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestMapper.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.java new file mode 100644 index 0000000..8497c60 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.TestScoreEntity; +import com.hnac.hzims.safeproduct.vo.TestScoreVO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 考试成绩Mapper类 + * + * @author liwen + * @date 2023-12-25 + */ +@Mapper +public interface TestScoreMapper extends BaseMapper { + + /** + * 查询考试成绩列表 + * @param testId 考试记录id + * @return 考试成绩列表 + */ + List testScoreList(Long testId); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.xml new file mode 100644 index 0000000..53333d0 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TestScoreMapper.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.java new file mode 100644 index 0000000..38eaa5b --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.java @@ -0,0 +1,53 @@ +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.AnalysisYearDTO; +import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +import com.hnac.hzims.safeproduct.vo.TrainMonthVO; +import com.hnac.hzims.safeproduct.vo.TrainYearVO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 培训计划Mapper类 + * + * @author liwen + * @date 2023-12-25 + */ +@Mapper +public interface TrainPlanMapper extends BaseMapper { + + /** + * 查询当月各单位的培训计划总数 + * @param page 分页类 + * @param month 月份 + * @return 当月培训计划总数 + */ + IPage selectByMonth(IPage page, String month); + + /** + * 查询当月各单位已完成的培训计划数据 + * @param page1 分页类 + * @param month 月份 + * @return 当月已完成培训计划数 + */ + IPage selectFinishedDataByMonth(IPage page1, String month); + + /** + * 查询当年的所有单位 + * @param page 分页类 + * @param year 年份 + * @return 年度单位数据 + */ + IPage selectUnitByYear(IPage page, String year); + + /** + * 查询各单位全年已完成的培训计划数 + * @param unitList 单元列表 + * @param year 年份 + * @return 单位各月的培训计划数 + */ + List selectFinishedDataByUnit(List unitList, String year); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml new file mode 100644 index 0000000..81fe776 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainPlanMapper.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.java new file mode 100644 index 0000000..2e170c9 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; +import com.hnac.hzims.safeproduct.entity.TrainRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 培训记录Mapper类 + * + * @author liwen + * @date 2023-12-25 + */ +@Mapper +public interface TrainRecordMapper extends BaseMapper { + + /** + * 查询培训记录名称列表 + * @param trainPlanId 培训计划id + * @return 培训记录名称列表 + */ + List getTrainRecordNameList(String trainPlanId); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.xml new file mode 100644 index 0000000..01f1e58 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/TrainRecordMapper.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestScoreService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestScoreService.java new file mode 100644 index 0000000..802e6ea --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestScoreService.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.TestScoreDTO; +import com.hnac.hzims.safeproduct.entity.TestScoreEntity; +import com.hnac.hzims.safeproduct.vo.TestScoreVO; + +import java.util.List; + +/** + * 考试成绩服务类 + * + * @author liwen + * @date 2023-12-25 + */ +public interface ITestScoreService extends IService { + + /** + * 查询考试成绩列表 + * @param testId 考试记录id + * @return 考试成绩列表 + */ + List testScoreList(Long testId); + + /** + * 批量填写分数 + * @param testScoreDTO 考试成绩DTO类 + * @return true-成功,false-失败 + */ + boolean updateBatchScore(TestScoreDTO testScoreDTO); + + /** + * 删除关联考试成绩 + * @param testId 考试记录id + * @return true-成功,false-失败 + */ + boolean removeRelativeTestScore(Long testId); + + /** + * 查询关联考试成绩 + * @param testId 考试记录id + * @return 考试成绩列表 + */ + List getRelativeTestScore(Long testId); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestService.java new file mode 100644 index 0000000..83eeeeb --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITestService.java @@ -0,0 +1,66 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.TestDTO; +import com.hnac.hzims.safeproduct.entity.TestEntity; +import org.springblade.core.tool.api.R; + +import java.util.List; + +/** + * 考试记录服务类 + * + * @author liwen + * @date 2023-12-25 + */ +public interface ITestService extends IService { + + /** + * 新增考试记录 + * @param testEntity 考试记录实体类 + * @return 返回结果封装类 + */ + R saveTest(TestEntity testEntity); + + /** + * 根据编码查询考试记录 + * @param code 编码 + * @return 考试记录实体类 + */ + TestEntity getTestByCode(String code); + + /** + * 删除关联考试记录 + * @param trainRecordId 培训记录id + * @return true-成功,false-失败 + */ + boolean removeRelativeTest(Long trainRecordId); + + /** + * 查询关联考试记录 + * @param trainRecordId 培训记录id + * @return 考试记录列表 + */ + List getRelativeTest(Long trainRecordId); + + /** + * 删除考试记录 + * @param id 考试记录id + * @return true-成功,false-失败 + */ + boolean removeTest(Long id); + + /** + * 查询考试记录名称列表 + * @param trainPlanId 培训计划id + * @return 考试记录名称列表 + */ + List getTestNameList(String trainPlanId); + + /** + * 修改考试记录 + * @param testEntity 考试记录实体类 + * @return true-成功,false-失败 + */ + boolean updateTest(TestEntity testEntity); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java new file mode 100644 index 0000000..3c88648 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainPlanService.java @@ -0,0 +1,50 @@ +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.TrainPlanEntity; +import com.hnac.hzims.safeproduct.vo.TrainMonthVO; +import com.hnac.hzims.safeproduct.vo.TrainYearVO; +import org.springblade.core.mp.support.Query; + +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 培训计划服务类 + * + * @author liwen + * @date 2023-12-25 + */ +public interface ITrainPlanService extends IService { + + /** + * 月度培训数据 + * @param month 月份 + * @param query 分页类 + * @return 月度培训分页 + */ + IPage dataByMonth(String month, Query query); + + /** + * 年度培训数据 + * @param year 年份 + * @param query 分页类 + * @return 年度培训分页 + */ + IPage dataByYear(String year, Query query); + + /** + * 删除培训计划 + * @param id 培训计划id + * @return true-成功,false-失败 + */ + boolean removeTrainPlan(Long id); + + /** + * 培训计划数据导出 + * @param param 入参 + * @param response 响应类 + */ + void exportTrainPlanData(Map param, HttpServletResponse response); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainRecordService.java new file mode 100644 index 0000000..bd89033 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ITrainRecordService.java @@ -0,0 +1,60 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; +import com.hnac.hzims.safeproduct.entity.TrainRecordEntity; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 培训记录服务类 + * + * @author liwen + * @date 2023-12-25 + */ +public interface ITrainRecordService extends IService { + + /** + * 新增培训记录 + * @param trainRecordEntity 培训记录实体类 + * @return true-成功,false-失败 + */ + boolean saveTrainRecord(TrainRecordEntity trainRecordEntity); + + /** + * 删除关联培训记录 + * @param trainPlanId 培训计划id + * @return true-成功,false-失败 + */ + boolean removeRelativeTrainRecord(Long trainPlanId); + + /** + * 查询关联培训记录 + * @param trainPlanId 培训计划id + * @return 培训记录列表 + */ + List getRelativeTrainRecord(Long trainPlanId); + + /** + * 删除培训记录 + * @param id 培训记录id + * @return true-成功,false-失败 + */ + boolean removeTrainRecord(Long id); + + /** + * 查询培训记录名称列表 + * @param trainPlanId 培训计划id + * @return 培训记录名称列表 + */ + List getTrainRecordNameList(String trainPlanId); + + /** + * 培训记录数据导出 + * @param param 入参 + * @param response 响应类 + */ + void exportTrainRecordData(Map param, HttpServletResponse response); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java new file mode 100644 index 0000000..11b47ce --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestScoreServiceImpl.java @@ -0,0 +1,75 @@ +package com.hnac.hzims.safeproduct.service.impl; + +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.safeproduct.dto.TestScoreDTO; +import com.hnac.hzims.safeproduct.entity.TestScoreEntity; +import com.hnac.hzims.safeproduct.mapper.TestScoreMapper; +import com.hnac.hzims.safeproduct.service.ITestScoreService; +import com.hnac.hzims.safeproduct.vo.TestScoreVO; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * 考试成绩服务实现类 + * + * @author liwen + * @date 2023-12-25 + */ +@Service +public class TestScoreServiceImpl extends ServiceImpl implements ITestScoreService { + + /** + * 查询考试成绩列表 + */ + @Override + public List testScoreList(Long testId) { + return baseMapper.testScoreList(testId); + } + + /** + * 批量填写分数 + */ + @Override + public boolean updateBatchScore(TestScoreDTO testScoreDTO) { + List scoreList = testScoreDTO.getScoreList(); + List testScoreEntities = new ArrayList<>(); + scoreList.forEach(score -> { + TestScoreEntity testScoreEntity = new TestScoreEntity(); + BeanUtils.copyProperties(score, testScoreEntity); + testScoreEntities.add(testScoreEntity); + }); + return this.updateBatchById(testScoreEntities); + } + + /** + * 删除关联考试成绩 + */ + @Override + public boolean removeRelativeTestScore(Long testId) { + // 查询关联考试成绩 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(TestScoreEntity::getTestId, testId); + List testScoreList = this.list(queryWrapper); + // 若无关联考试成绩,直接返回true + if (CollectionUtils.isEmpty(testScoreList)) { + return true; + } + // 删除关联考试成绩 + return this.removeByIds(testScoreList); + } + + /** + * 查询关联考试成绩 + */ + @Override + public List getRelativeTestScore(Long testId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(TestScoreEntity::getTestId, testId); + return this.list(queryWrapper); + } +} 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 new file mode 100644 index 0000000..8325630 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TestServiceImpl.java @@ -0,0 +1,220 @@ +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.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; +import com.hnac.hzims.safeproduct.entity.TestScoreEntity; +import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +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.vo.TestScoreVO; +import org.springblade.core.tool.api.R; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 考试记录服务实现类 + * + * @author liwen + * @date 2023-12-25 + */ +@Service +public class TestServiceImpl extends ServiceImpl implements ITestService { + + @Autowired + ITestScoreService testScoreService; + + @Resource + TrainPlanMapper trainPlanMapper; + + /** + * 新增考试记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public R saveTest(TestEntity testEntity) { + // 判断培训计划是否需要考试,若不需要,则无法新增考试记录 + TrainPlanEntity trainPlanEntity = trainPlanMapper.selectById(testEntity.getTrainPlanId()); + if (trainPlanEntity.getIsTest().equals(SafeProductConstant.TRAIN_PLAN_HAS_NO_TEST)) { + return R.fail("该培训计划无法新增考试"); + } + // 获取当月时间(yyyymm) + String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); + // 查询是否存在同月编号 + 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; + } + } + testEntity.setCode(code); + boolean saveTest = this.save(testEntity); + // 若新增考试记录成功,添加相关的参考人员数据 + if (saveTest) { + // 查询考试记录 + TestEntity test = getTestByCode(testEntity.getCode()); + // 获取姓名数组 + 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); + } + return R.status(testScoreService.saveBatch(scoreList)); + } + return R.fail("新增考试记录失败"); + } + + /** + * 根据编码查询考试记录 + */ + @Override + public TestEntity getTestByCode(String code) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(TestEntity::getCode, code); + return this.getOne(queryWrapper); + } + + /** + * 删除关联考试记录 + */ + @Override + public boolean removeRelativeTest(Long trainRecordId) { + // 查询关联考试记录 + List testList = getRelativeTest(trainRecordId); + // 若无关联考试记录,直接返回true + if (CollectionUtils.isEmpty(testList)) { + return true; + } + // 删除关联考试记录 + boolean remove = this.removeByIds(testList); + // 若删除考试记录成功,删除关联考试成绩 + if (remove) { + for (TestEntity test : testList) { + boolean removeTestScore = testScoreService.removeRelativeTestScore(test.getId()); + if (!removeTestScore) { + return false; + } + } + return true; + } + return false; + } + + /** + * 查询关联考试记录 + */ + @Override + public List getRelativeTest(Long trainRecordId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(TestEntity::getTrainRecordId, trainRecordId); + return this.list(queryWrapper); + } + + /** + * 删除考试记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeTest(Long id) { + boolean remove = this.removeById(id); + // 若考试记录删除成功,删除关联考试成绩 + if (remove) { + return testScoreService.removeRelativeTestScore(id); + } + return false; + } + + /** + * 查询考试记录名称列表 + */ + @Override + public List getTestNameList(String trainPlanId) { + return baseMapper.getTestNameList(trainPlanId); + } + + /** + * 修改考试记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateTest(TestEntity testEntity) { + // 判断考试人员是否有变化 + TestEntity oldTest = getTestByCode(testEntity.getCode()); + // 若不存在变化,更新考试记录 + if (oldTest.getPeopleName().equals(testEntity.getPeopleName())) { + return this.updateById(testEntity); + } + // 若存在变化,查询并删除关联考试成绩 + List testScoreList = testScoreService.getRelativeTestScore(testEntity.getId()); + boolean removeByIds = testScoreService.removeByIds(testScoreList); + // 若删除成功,新增新的考试成绩数据 + 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); + } + return false; + } + + /** + * 查询是否存在同月编号 + * @param currentMonth 当月 + * @return 存在则返回上一编号,否则返回null + */ + private String getLastCode(String currentMonth) { + String month = currentMonth.substring(currentMonth.length() - 2); + List list = getTestByMonth(month); + if (CollectionUtils.isEmpty(list)) { + return null; + } + return list.get(0).getCode(); + } + + /** + * 查询当月考试记录 + * @param month 当月 + * @return 当月考试记录 + */ + public List getTestByMonth(String month) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().like(TestEntity::getCreateTime, month) + .orderByDesc(TestEntity::getCode); + return this.list(queryWrapper); + } +} 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 new file mode 100644 index 0000000..6d9840a --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainPlanServiceImpl.java @@ -0,0 +1,228 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.converters.longconverter.LongStringConverter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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.safeproduct.dto.AnalysisYearDTO; +import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; +import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +import com.hnac.hzims.safeproduct.entity.TrainRecordEntity; +import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; +import com.hnac.hzims.safeproduct.service.ITestService; +import com.hnac.hzims.safeproduct.service.ITrainPlanService; +import com.hnac.hzims.safeproduct.service.ITrainRecordService; +import com.hnac.hzims.safeproduct.vo.TrainMonthVO; +import com.hnac.hzims.safeproduct.vo.TrainYearVO; +import org.springblade.core.log.exception.ServiceException; +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; +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.net.URLEncoder; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * 培训计划服务实现类 + * + * @author liwen + * @date 2023-12-25 + */ +@Service +public class TrainPlanServiceImpl extends ServiceImpl implements ITrainPlanService { + + @Autowired + ITrainRecordService trainRecordService; + + @Autowired + ITestService testService; + + /** + * 月度培训数据 + */ + @Override + public IPage dataByMonth(String month, Query query) { + // 查询当月各单位的培训计划总数 + IPage page = new Page<>(query.getCurrent(), query.getSize()); + IPage unitPage = baseMapper.selectByMonth(page, month); + List unitList = unitPage.getRecords(); + // 查询当月各单位已完成的培训数据 + IPage page1 = new Page<>(query.getCurrent(), query.getSize()); + IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); + List finishedList = finishedPage.getRecords(); + // 处理统计数据 + for (TrainMonthVO unit : unitList) { + Long taskNum = unit.getScheduledTrainNum(); + Optional finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); + Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTrainNum() : 0L; + unit.setFinishedTrainNum(finishedTaskNum); + unit.setUnfinishedTrainNum(taskNum - finishedTaskNum); + BigDecimal taskDecimal = new BigDecimal(taskNum); + BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); + unit.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) + .setScale(2, RoundingMode.HALF_UP)); + } + unitPage.setRecords(unitList); + return unitPage; + } + + /** + * 年度培训数据 + */ + @Override + public IPage dataByYear(String year, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + // 查询当年的所有单位 + IPage unitPage = baseMapper.selectUnitByYear(page, year); + List records = unitPage.getRecords(); + // 若无数据,返回空页面 + if (CollectionUtils.isEmpty(records)) { + return unitPage; + } + List unitList = records.stream().map(TrainYearVO::getUnit).collect(Collectors.toList()); + // 查询各单位全年已完成的培训计划数 + List unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); + // 将各单位每个月的培训计划数据写入统计列表 + unitMonthDataList.forEach(data -> { + TrainYearVO trainYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) + .collect(Collectors.toList()).get(0); + // 根据月份匹配写入对应字段 + switch (data.getDateTime()) { + case "01": + trainYearVO.setJanuaryNum(data.getFinishedNum()); + break; + case "02": + trainYearVO.setFebruaryNum(data.getFinishedNum()); + break; + case "03": + trainYearVO.setMarchNum(data.getFinishedNum()); + break; + case "04": + trainYearVO.setAprilNum(data.getFinishedNum()); + break; + case "05": + trainYearVO.setMayNum(data.getFinishedNum()); + break; + case "06": + trainYearVO.setJuneNum(data.getFinishedNum()); + break; + case "07": + trainYearVO.setJulyNum(data.getFinishedNum()); + break; + case "08": + trainYearVO.setAugustNum(data.getFinishedNum()); + break; + case "09": + trainYearVO.setSeptemberNum(data.getFinishedNum()); + break; + case "10": + trainYearVO.setOctoberNum(data.getFinishedNum()); + break; + case "11": + trainYearVO.setNovemberNum(data.getFinishedNum()); + break; + case "12": + trainYearVO.setDecemberNum(data.getFinishedNum()); + } + }); + unitPage.setRecords(records); + return unitPage; + } + + /** + * 删除培训计划 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeTrainPlan(Long id) { + boolean remove = this.removeById(id); + // 若培训计划删除成功,删除关联培训记录 + if (remove) { + return trainRecordService.removeRelativeTrainRecord(id); + } + return false; + } + + /** + * 培训计划数据导出 + */ + @Override + public void exportTrainPlanData(Map param, HttpServletResponse response) { + ServletOutputStream outputStream = null; + try { + outputStream = response.getOutputStream(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf(param.get("scheduledEndTime")); + List rehearsalRecordList = getTrainPlanByUnitAndDate(unit, startTime, endTime); + // 设置响应头 + // URLEncoder.encode防止中文乱码 + String fileName = URLEncoder.encode("培训计划表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // ExcelWriter初始化 + ExcelWriter excelWriter = EasyExcel + .write(response.getOutputStream()) + .autoCloseStream(Boolean.TRUE) + .registerConverter(new LongStringConverter()) + .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) + .build(); + WriteSheet writeSheet = EasyExcel.writerSheet(1, "培训计划表").head(TrainPlanEntity.class) + .build(); + excelWriter.write(rehearsalRecordList, writeSheet); + excelWriter.finish(); + } catch (Exception e) { + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + throw new ServiceException("培训计划数据导出异常: " + e.getMessage()); + } finally { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error("培训计划导出响应头输出流关闭异常: " + e.getMessage()); + } + } + } + } + + /** + * 根据单位和计划时间查询培训计划数据 + * @param unit 单位 + * @param startTime 计划开始时间 + * @param endTime 计划结束时间 + * @return 培训计划列表 + */ + public List getTrainPlanByUnitAndDate(String unit, String startTime, String endTime) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (!unit.equals("null")) { + queryWrapper.eq(TrainPlanEntity::getUnit, unit); + } + if (!startTime.equals("null")) { + queryWrapper.ge(TrainPlanEntity::getScheduledStartTime, startTime); + } + if (!endTime.equals("null")) { + queryWrapper.lt(TrainPlanEntity::getScheduledEndTime, endTime); + } + queryWrapper.orderByDesc(TrainPlanEntity::getScheduledEndTime); + return this.list(queryWrapper); + } +} 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 new file mode 100644 index 0000000..be310d4 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/TrainRecordServiceImpl.java @@ -0,0 +1,217 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import cn.hutool.core.date.DatePattern; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.converters.longconverter.LongStringConverter; +import com.alibaba.excel.util.CollectionUtils; +import com.alibaba.excel.write.metadata.WriteSheet; +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.dto.TrainRecordDTO; +import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; +import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +import com.hnac.hzims.safeproduct.entity.TrainRecordEntity; +import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper; +import com.hnac.hzims.safeproduct.service.ITestService; +import com.hnac.hzims.safeproduct.service.ITrainRecordService; +import org.springblade.core.log.exception.ServiceException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 培训记录服务实现类 + * + * @author liwen + * @date 2023-12-25 + */ +@Service +public class TrainRecordServiceImpl extends ServiceImpl implements ITrainRecordService { + + @Autowired + ITestService testService; + + /** + * 新增培训记录 + */ + @Override + public boolean saveTrainRecord(TrainRecordEntity trainRecordEntity) { + // 获取当月时间(yyyymm) + String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); + // 查询是否存在同月编号 + String lastCode = getLastCode(currentMonth); + // 若不存在,新增编号 + String code; + if (StringUtils.isNull(lastCode)) { + code = "PXJL" + currentMonth + "001"; + } else { // 若存在,编号递增 + String oldNum = lastCode.substring(lastCode.length() - 3); + int value = Integer.parseInt(oldNum) + 1; + // 根据数位拼接编号 + if (value < 10) { + code = "PXJL" + currentMonth + "00" + value; + } else if (value < 100) { + code = "PXJL" + currentMonth + "0" + value; + } else { + code = "PXJL" + currentMonth + value; + } + } + trainRecordEntity.setCode(code); + return this.save(trainRecordEntity); + } + + /** + * 删除关联培训记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeRelativeTrainRecord(Long trainPlanId) { + // 查询关联培训记录 + List trainRecordList = getRelativeTrainRecord(trainPlanId); + // 若无关联培训记录,直接返回true + if (CollectionUtils.isEmpty(trainRecordList)) { + return true; + } + // 删除关联培训记录 + boolean remove = this.removeByIds(trainRecordList); + // 若删除培训记录成功,则删除关联考试记录 + if (remove) { + for (TrainRecordEntity trainRecord : trainRecordList) { + boolean removeTest = testService.removeRelativeTest(trainRecord.getId()); + if (!removeTest) { + return false; + } + } + return true; + } + return false; + } + + /** + * 查询关联培训记录 + */ + @Override + public List getRelativeTrainRecord(Long trainPlanId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(TrainRecordEntity::getTrainPlanId, trainPlanId); + return this.list(queryWrapper); + } + + /** + * 删除培训记录 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeTrainRecord(Long id) { + boolean remove = this.removeById(id); + // 若培训记录删除成功,删除关联考试记录 + if (remove) { + return testService.removeRelativeTest(id); + } + return false; + } + + /** + * 查询培训记录名称列表 + */ + @Override + public List getTrainRecordNameList(String trainPlanId) { + return baseMapper.getTrainRecordNameList(trainPlanId); + } + + /** + * 培训记录数据导出 + */ + @Override + public void exportTrainRecordData(Map param, HttpServletResponse response) { + ServletOutputStream outputStream = null; + try { + outputStream = response.getOutputStream(); + String trainPlanId = String.valueOf(param.get("trainPlanId")); + List rehearsalRecordList = getTrainRecordByTrainPlanId(trainPlanId); + // 设置响应头 + // URLEncoder.encode防止中文乱码 + String fileName = URLEncoder.encode("培训记录表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // ExcelWriter初始化 + ExcelWriter excelWriter = EasyExcel + .write(response.getOutputStream()) + .autoCloseStream(Boolean.TRUE) + .registerConverter(new LongStringConverter()) + .registerWriteHandler(new SimpleColumnWidthStyleStrategy(25)) + .build(); + WriteSheet writeSheet = EasyExcel.writerSheet(1, "培训记录表").head(TrainRecordEntity.class) + .build(); + excelWriter.write(rehearsalRecordList, writeSheet); + excelWriter.finish(); + } catch (Exception e) { + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + throw new ServiceException("培训记录数据导出异常: " + e.getMessage()); + } finally { + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + log.error("培训记录导出响应头输出流关闭异常: " + e.getMessage()); + } + } + } + } + + /** + * 查询是否存在同月编号 + * @param currentMonth 当月 + * @return 存在则返回上一编号,否则返回null + */ + private String getLastCode(String currentMonth) { + String month = currentMonth.substring(currentMonth.length() - 2); + List list = getTrainByMonth(month); + if (CollectionUtils.isEmpty(list)) { + return null; + } + return list.get(0).getCode(); + } + + /** + * 查询当月培训记录 + * @param month 当月 + * @return 当月培训记录 + */ + public List getTrainByMonth(String month) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().like(TrainRecordEntity::getCreateTime, month) + .orderByDesc(TrainRecordEntity::getCode); + return this.list(queryWrapper); + } + + /** + * 根据培训计划id查询培训记录数据 + * @param trainPlanId 培训计划id + * @return 培训记录列表 + */ + public List getTrainRecordByTrainPlanId(String trainPlanId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + if (!trainPlanId.equals("null")) { + queryWrapper.ge(TrainRecordEntity::getTrainPlanId, trainPlanId); + } + queryWrapper.orderByDesc(TrainRecordEntity::getActualEndTime); + return this.list(queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql index d729081..6d3a340 100644 --- a/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql +++ b/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql @@ -11,7 +11,7 @@ create table document_management ) comment '文档管理'; -CREATE TABLE `hzims`.`hzims_rehearsal_record` ( +CREATE TABLE `hzims_rehearsal_plan` ( `id` bigint(20) NOT NULL COMMENT '主键id', `code` varchar(50) NOT NULL COMMENT '编号', `unit` varchar(50) NOT NULL COMMENT '单位', @@ -38,4 +38,116 @@ CREATE TABLE `hzims`.`hzims_rehearsal_record` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='演练记录表' ROW_FORMAT=Dynamic; \ No newline at end of file +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='演练计划表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_rehearsal_record` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `code` varchar(50) NOT NULL COMMENT '编号', + `unit` varchar(50) NOT NULL COMMENT '单位', + `subject` varchar(50) NOT NULL COMMENT '演练科目', + `scheduled_start_time` datetime NOT NULL COMMENT '演练计划开始时间', + `scheduled_end_time` datetime NOT NULL COMMENT '演练计划结束时间', + `location` varchar(255) NOT NULL COMMENT '演练地点', + `people_num` int(10) NOT NULL DEFAULT '0' COMMENT '参演人数', + `people_name` varchar(5000) DEFAULT '' COMMENT '参演人员', + `commander` varchar(10) NOT NULL COMMENT '总指挥', + `actual_start_time` datetime DEFAULT NULL COMMENT '演练实际开始时间', + `actual_end_time` datetime DEFAULT NULL COMMENT '演练实际结束时间', + `record` varchar(250) DEFAULT '' COMMENT '演练记录', + `comment` varchar(250) DEFAULT '' DEFAULT '' COMMENT '演练评价', + `rehearsal_method` varchar(20) DEFAULT '' COMMENT '演练方式', + `rehearsal_status` varchar(20) NOT NULL DEFAULT 'WAITING' COMMENT '演练状态', + `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '演练图片', + `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '演练附件', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='演练记录表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_train_plan` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `unit` varchar(50) NOT NULL COMMENT '单位', + `scheduled_start_time` datetime NOT NULL COMMENT '计划培训开始时间', + `scheduled_end_time` datetime NOT NULL COMMENT '计划培训结束时间', + `lesson` varchar(255) NOT NULL COMMENT '培训课程', + `location` varchar(255) NOT NULL COMMENT '培训地点', + `train_method` varchar(20) DEFAULT '' COMMENT '培训方式', + `teacher` varchar(20) NOT NULL DEFAULT '' COMMENT '培训讲师', + `train_status` varchar(20) NOT NULL DEFAULT 'WAITING' COMMENT '培训状态', + `is_test` int(2) NOT NULL DEFAULT '0' COMMENT '关联考试:0-否,1-是', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='培训计划表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_train_record` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `train_plan_id` bigint(20) DEFAULT NULL COMMENT '培训计划id', + `train_record_name` varchar(50) NOT NULL DEFAULT '' COMMENT '培训记录名称', + `code` varchar(50) NOT NULL COMMENT '编号', + `people_name` varchar(5000) DEFAULT '' COMMENT '培训学员', + `content` varchar(5000) DEFAULT '' COMMENT '培训内容', + `actual_start_time` datetime DEFAULT NULL COMMENT '实际培训开始时间', + `actual_end_time` datetime DEFAULT NULL COMMENT '实际培训结束时间', + `command` varchar(250) DEFAULT NULL COMMENT '培训评价', + `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '培训图片', + `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '培训附件', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='培训记录表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_test` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `train_plan_id` bigint(20) DEFAULT NULL COMMENT '培训计划id', + `train_record_id` bigint(20) DEFAULT NULL COMMENT '培训记录id', + `test_name` varchar(50) NOT NULL DEFAULT '' COMMENT '考试记录名称', + `code` varchar(50) NOT NULL COMMENT '编号', + `unit` varchar(50) NOT NULL COMMENT '单位', + `test_start_time` datetime NOT NULL COMMENT '考试开始时间', + `test_end_time` datetime NOT NULL COMMENT '考试结束时间', + `location` varchar(255) NOT NULL COMMENT '考试地点', + `subject` varchar(50) NOT NULL COMMENT '考试科目', + `proctor` varchar(20) NOT NULL COMMENT '监考人', + `people_name` varchar(1000) DEFAULT '' COMMENT '参考人员', + `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '考试图片', + `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '考试附件', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='考试记录表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_test_score` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `test_id` bigint(20) DEFAULT NULL COMMENT '考试记录id', + `name` varchar(50) NOT NULL COMMENT '姓名', + `score` int(10) DEFAULT NULL COMMENT '成绩', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='考试成绩表' ROW_FORMAT=Dynamic; \ No newline at end of file