From 5d8bbbb6787813c958b472a1a79272f54b555371 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 27 Dec 2023 09:40:08 +0800 Subject: [PATCH 1/2] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E5=9F=B9?= =?UTF-8?q?=E8=AE=AD=E7=AE=A1=E7=90=86=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/constants/SafeProductConstant.java | 3 +++ .../hzims/safeproduct/enums/TrainStatusEnum.java | 31 ++++++++++++++++++++++ .../com/hnac/hzims/safeproduct/vo/TestScoreVO.java | 3 +++ .../safeproduct/controller/TrainController.java | 3 ++- .../hzims/safeproduct/mapper/TestScoreMapper.xml | 2 +- .../hzims/safeproduct/mapper/TrainPlanMapper.xml | 12 ++++----- .../service/impl/TestScoreServiceImpl.java | 1 + .../safeproduct/service/impl/TestServiceImpl.java | 5 ++-- .../service/impl/TrainRecordServiceImpl.java | 18 +++++++++++-- 9 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/TrainStatusEnum.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 index af9d10a..84ae0c6 100644 --- 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 @@ -8,6 +8,9 @@ package com.hnac.hzims.safeproduct.constants; */ public interface SafeProductConstant { + int SUCCESS = 1; + int FAILURE = 0; + 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/enums/TrainStatusEnum.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/TrainStatusEnum.java new file mode 100644 index 0000000..bb156f0 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/TrainStatusEnum.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.safeproduct.enums; + +/** + * 培训计划状态枚举类 + * + * @author liwen + * @date 2023-12-27 + */ +public enum TrainStatusEnum { + + WAITING("WAITING", "未开始"), + UNFINISHED("UNFINISHED", "未完成"), + FINISHED("FINISHED", "已完成"); + + private final String value; + + private final String desc; + + TrainStatusEnum(String value, String desc) { + this.value = value; + this.desc = desc; + } + + public String getValue() { + return value; + } + + public String getDesc() { + return desc; + } +} diff --git a/hzims-service-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 index 2e33809..019d7b0 100644 --- 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 @@ -12,6 +12,9 @@ import lombok.Data; @ApiModel(value = "考试成绩VO类") public class TestScoreVO { + @ApiModelProperty("考试成绩id") + private Long id; + @ApiModelProperty("姓名") private String name; 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 index 1dd2f50..70ec717 100644 --- 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 @@ -175,6 +175,7 @@ public class TrainController extends BladeController { @GetMapping("/testPage") @ApiImplicitParams({ + @ApiImplicitParam(name = "trainPlanId", value = "培训计划id", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "trainRecordId", value = "培训记录id", dataType = "query", paramType = "string") }) @ApiOperation(value = "考试记录分页") @@ -203,7 +204,7 @@ public class TrainController extends BladeController { @PostMapping("/updateBatchScore") @ApiOperation(value = "批量填写分数") @ApiOperationSupport(order = 19) - public R updateBatchScore(TestScoreDTO testScoreDTO) { + public R updateBatchScore(@RequestBody TestScoreDTO testScoreDTO) { return R.status(testScoreService.updateBatchScore(testScoreDTO)); } 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 index 53333d0..cf6795a 100644 --- 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 @@ -4,7 +4,7 @@ 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 index 11b47ce..2607bc8 100644 --- 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 @@ -41,6 +41,7 @@ public class TestScoreServiceImpl extends ServiceImpl { TestScoreEntity testScoreEntity = new TestScoreEntity(); BeanUtils.copyProperties(score, testScoreEntity); + testScoreEntity.setTestId(testScoreDTO.getTestId()); testScoreEntities.add(testScoreEntity); }); return this.updateBatchById(testScoreEntities); 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 index 8325630..f9d1d66 100644 --- 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 @@ -14,7 +14,6 @@ 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; @@ -24,6 +23,7 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 考试记录服务实现类 @@ -175,7 +175,8 @@ public class TestServiceImpl extends ServiceImpl impleme } // 若存在变化,查询并删除关联考试成绩 List testScoreList = testScoreService.getRelativeTestScore(testEntity.getId()); - boolean removeByIds = testScoreService.removeByIds(testScoreList); + List scoreIds = testScoreList.stream().map(TestScoreEntity::getId).collect(Collectors.toList()); + boolean removeByIds = testScoreService.removeByIds(scoreIds); // 若删除成功,新增新的考试成绩数据 if (removeByIds) { String[] person = testEntity.getPeopleName().split(",|,"); 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 index be310d4..ae3e85f 100644 --- 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 @@ -11,10 +11,12 @@ 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.constants.SafeProductConstant; 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.enums.TrainStatusEnum; +import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.mapper.TrainRecordMapper; import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITrainRecordService; @@ -23,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -43,9 +46,13 @@ public class TrainRecordServiceImpl extends ServiceImpl Date: Wed, 27 Dec 2023 10:38:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E5=9F=B9?= =?UTF-8?q?=E8=AE=AD=E7=AE=A1=E7=90=86=E9=83=A8=E5=88=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/TrainPlanEntity.java | 11 ++++++ .../safeproduct/entity/TrainRecordEntity.java | 10 +++++ .../safeproduct/controller/TrainController.java | 3 +- .../com/hnac/hzims/safeproduct/jobs/TrainJob.java | 43 +++++++++++++++++++++ .../safeproduct/service/ITrainPlanService.java | 9 +++++ .../service/impl/TestScoreServiceImpl.java | 4 +- .../safeproduct/service/impl/TestServiceImpl.java | 45 ++++++++++++---------- .../service/impl/TrainPlanServiceImpl.java | 20 ++++++++-- .../service/impl/TrainRecordServiceImpl.java | 8 ++-- 9 files changed, 123 insertions(+), 30 deletions(-) create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/TrainJob.java 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 index f6a5d4c..09fe232 100644 --- 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 @@ -1,5 +1,7 @@ package com.hnac.hzims.safeproduct.entity; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,6 +19,7 @@ import java.util.Date; */ @Data @EqualsAndHashCode(callSuper = true) +@ExcelIgnoreUnannotated @TableName("hzims_train_plan") @ApiModel(value = "培训计划实体类") public class TrainPlanEntity extends BaseEntity { @@ -24,24 +27,29 @@ public class TrainPlanEntity extends BaseEntity { @NotNull @Size(max = 50, message = "单位字段长度不能超过50") @ApiModelProperty("单位") + @ExcelProperty(value = "单位", index = 0) private String unit; @NotNull @ApiModelProperty("计划培训开始时间") + @ExcelProperty(value = "计划开始时间", index = 6) private Date scheduledStartTime; @NotNull @ApiModelProperty("计划培训结束时间") + @ExcelProperty(value = "计划结束时间", index = 7) private Date scheduledEndTime; @NotNull @Size(max = 255, message = "单位字段长度不能超过255") @ApiModelProperty("培训课程") + @ExcelProperty(value = "培训课程", index = 1) private String lesson; @NotNull @Size(max = 255, message = "培训地点字段长度不能超过255") @ApiModelProperty("培训地点") + @ExcelProperty(value = "培训地点", index = 2) private String location; @Size(max = 20, message = "培训方式字段长度不能超过20") @@ -51,14 +59,17 @@ public class TrainPlanEntity extends BaseEntity { @NotNull @Size(max = 20, message = "培训讲师字段长度不能超过20") @ApiModelProperty("培训讲师") + @ExcelProperty(value = "培训讲师", index = 4) private String teacher; @NotNull @Size(max = 20, message = "培训状态字段长度不能超过20") @ApiModelProperty("培训状态") + @ExcelProperty(value = "培训状态", index = 3) private String trainStatus; @NotNull @ApiModelProperty("关联考试:0-否,1-是") + @ExcelProperty(value = "是否考试", index = 5) 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 index f92ae58..24f2e2f 100644 --- 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 @@ -1,5 +1,7 @@ package com.hnac.hzims.safeproduct.entity; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -16,6 +18,7 @@ import java.util.Date; */ @Data @EqualsAndHashCode(callSuper = true) +@ExcelIgnoreUnannotated @TableName("hzims_train_record") @ApiModel(value = "培训记录实体类") public class TrainRecordEntity extends BaseEntity { @@ -25,28 +28,35 @@ public class TrainRecordEntity extends BaseEntity { @Size(max = 50, message = "名称字段长度不能超过50") @ApiModelProperty("培训记录名称") + @ExcelProperty(value = "培训记录名称", index = 1) private String trainRecordName; @Size(max = 50, message = "编码字段长度不能超过50") @ApiModelProperty("编码") + @ExcelProperty(value = "编码", index = 0) private String code; @Size(max = 5000, message = "培训学员字段长度超出限制范围") @ApiModelProperty("培训学员") + @ExcelProperty(value = "培训学员", index = 3) private String peopleName; @Size(max = 5000, message = "培训内容字段长度超出限制范围") @ApiModelProperty("培训内容") + @ExcelProperty(value = "培训内容", index = 2) private String content; @ApiModelProperty("实际培训开始时间") + @ExcelProperty(value = "实际开始时间", index = 5) private Date actualStartTime; @ApiModelProperty("实际培训结束时间") + @ExcelProperty(value = "实际结束时间", index = 6) private Date actualEndTime; @Size(max = 250, message = "培训评价字段长度不能超过250") @ApiModelProperty("培训评价") + @ExcelProperty(value = "培训评价", index = 4) private String command; @Size(max = 1000, message = "培训图片字段长度不能超过1000") 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 index 70ec717..25fbe27 100644 --- 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 @@ -250,8 +250,7 @@ public class TrainController extends BladeController { @GetMapping("/exportTrainRecordData") @ApiImplicitParams({ - @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "trainPlanId", value = "培训计划id", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训记录数据导出") @ApiOperationSupport(order = 24) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/TrainJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/TrainJob.java new file mode 100644 index 0000000..6ed0f71 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/TrainJob.java @@ -0,0 +1,43 @@ +package com.hnac.hzims.safeproduct.jobs; + +import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +import com.hnac.hzims.safeproduct.enums.TrainStatusEnum; +import com.hnac.hzims.safeproduct.service.ITrainPlanService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import org.springblade.core.tool.utils.DateUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.List; + +/** + * 演练模块定时任务 + * + * @author liwen + * @date 2023-12-27 + */ +@Component +public class TrainJob { + + @Autowired + ITrainPlanService trainPlanService; + + @XxlJob("autoChangeTrainPlanStatus") + public ReturnT autoChangeTrainPlanStatus(String param) { + // 获取时间范围 + Date current = DateUtil.now(); + Date before = DateUtil.minusDays(current, 1); + String today = DateUtil.format(current, "yyyy-mm-dd hh:MM:ss"); + String yesterday = DateUtil.format(before, "yyyy-mm-dd hh:MM:ss"); + // 查询前一天的超时未完成培训计划 + List list = trainPlanService.getWaitingTrainPlanInTimeRange(yesterday, today); + list.forEach(x -> { + x.setTrainStatus(TrainStatusEnum.UNFINISHED.getValue()); + }); + // 将状态置为未完成 + boolean flag = trainPlanService.updateBatchById(list); + return flag ? ReturnT.SUCCESS : ReturnT.FAIL; + } +} 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 index 3c88648..bfb31ac 100644 --- 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 @@ -8,6 +8,7 @@ import com.hnac.hzims.safeproduct.vo.TrainYearVO; import org.springblade.core.mp.support.Query; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; /** @@ -47,4 +48,12 @@ public interface ITrainPlanService extends IService { * @param response 响应类 */ void exportTrainPlanData(Map param, HttpServletResponse response); + + /** + * 查询时间范围内未开始的培训计划数据 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 培训计划数据 + */ + List getWaitingTrainPlanInTimeRange(String startTime, String endTime); } 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 index 2607bc8..ed346aa 100644 --- 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 @@ -13,6 +13,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * 考试成绩服务实现类 @@ -61,7 +62,8 @@ public class TestScoreServiceImpl extends ServiceImpl ids = testScoreList.stream().map(TestScoreEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); } /** 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 index f9d1d66..8ab1dfa 100644 --- 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 @@ -115,7 +115,8 @@ public class TestServiceImpl extends ServiceImpl impleme return true; } // 删除关联考试记录 - boolean remove = this.removeByIds(testList); + List ids = testList.stream().map(TestEntity::getId).collect(Collectors.toList()); + boolean remove = this.removeByIds(ids); // 若删除考试记录成功,删除关联考试成绩 if (remove) { for (TestEntity test : testList) { @@ -169,26 +170,30 @@ public class TestServiceImpl extends ServiceImpl impleme 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()); - List scoreIds = testScoreList.stream().map(TestScoreEntity::getId).collect(Collectors.toList()); - boolean removeByIds = testScoreService.removeByIds(scoreIds); - // 若删除成功,新增新的考试成绩数据 - 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); + // 更新考试记录 + boolean update = this.updateById(testEntity); + if (update) { + // 若不存在人员变化,返回true + if (oldTest.getPeopleName().equals(testEntity.getPeopleName())) { + return true; + } + // 若存在变化,查询并删除关联考试成绩 + List testScoreList = testScoreService.getRelativeTestScore(testEntity.getId()); + List scoreIds = testScoreList.stream().map(TestScoreEntity::getId).collect(Collectors.toList()); + boolean removeByIds = testScoreService.removeByIds(scoreIds); + // 若删除成功,新增新的考试成绩数据 + 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 testScoreService.saveBatch(res); } return false; } 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 index 6d9840a..142b75f 100644 --- 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 @@ -6,13 +6,13 @@ 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.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.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.enums.TrainStatusEnum; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.service.ITestService; import com.hnac.hzims.safeproduct.service.ITrainPlanService; @@ -169,7 +169,7 @@ public class TrainPlanServiceImpl extends ServiceImpl rehearsalRecordList = getTrainPlanByUnitAndDate(unit, startTime, endTime); + List trainPlanList = getTrainPlanByUnitAndDate(unit, startTime, endTime); // 设置响应头 // URLEncoder.encode防止中文乱码 String fileName = URLEncoder.encode("培训计划表", "UTF-8"); @@ -185,7 +185,7 @@ public class TrainPlanServiceImpl extends ServiceImpl getWaitingTrainPlanInTimeRange(String startTime, String endTime) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(TrainPlanEntity::getTrainStatus, TrainStatusEnum.WAITING.getValue()) + .ge(TrainPlanEntity::getScheduledEndTime, startTime) + .lt(TrainPlanEntity::getScheduledEndTime, endTime); + return this.list(queryWrapper); + } + + /** * 根据单位和计划时间查询培训计划数据 * @param unit 单位 * @param startTime 计划开始时间 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 index ae3e85f..230a4d2 100644 --- 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 @@ -33,6 +33,7 @@ import java.net.URLEncoder; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 培训记录服务实现类 @@ -99,7 +100,8 @@ public class TrainRecordServiceImpl extends ServiceImpl ids = trainRecordList.stream().map(TrainRecordEntity::getId).collect(Collectors.toList()); + boolean remove = this.removeByIds(ids); // 若删除培训记录成功,则删除关联考试记录 if (remove) { for (TrainRecordEntity trainRecord : trainRecordList) { @@ -154,7 +156,7 @@ public class TrainRecordServiceImpl extends ServiceImpl rehearsalRecordList = getTrainRecordByTrainPlanId(trainPlanId); + List trainRecordList = getTrainRecordByTrainPlanId(trainPlanId); // 设置响应头 // URLEncoder.encode防止中文乱码 String fileName = URLEncoder.encode("培训记录表", "UTF-8"); @@ -170,7 +172,7 @@ public class TrainRecordServiceImpl extends ServiceImpl