From f8cb1f7cd23b4607620984cde24a787d29686991 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 2 Jan 2024 10:52:03 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=9F=B9=E8=AE=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/entity/TrainPlanEntity.java | 7 ++- .../safeproduct/entity/TrainRecordEntity.java | 1 - .../safeproduct/controller/TrainController.java | 4 +- .../safeproduct/service/impl/TestServiceImpl.java | 53 +++++++++------------- .../service/impl/TrainPlanServiceImpl.java | 4 ++ .../service/impl/TrainRecordServiceImpl.java | 18 +------- 6 files changed, 35 insertions(+), 52 deletions(-) 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 9b1b0fb..93db233 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 @@ -4,6 +4,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -32,12 +33,14 @@ public class TrainPlanEntity extends BaseEntity { private String unit; @NotNull - @ApiModelProperty("计划培训开始时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划开始时间") @ExcelProperty(value = "计划开始时间", index = 6) private Date scheduledStartTime; @NotNull - @ApiModelProperty("计划培训结束时间") + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划结束时间") @ExcelProperty(value = "计划结束时间", index = 7) private Date scheduledEndTime; 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 24f2e2f..b8728dc 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 @@ -41,7 +41,6 @@ public class TrainRecordEntity extends BaseEntity { @ExcelProperty(value = "培训学员", index = 3) private String peopleName; - @Size(max = 5000, message = "培训内容字段长度超出限制范围") @ApiModelProperty("培训内容") @ExcelProperty(value = "培训内容", index = 2) private String content; 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 d306a47..172a59b 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 @@ -83,8 +83,8 @@ public class TrainController extends BladeController { @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") + @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划分页") @ApiOperationSupport(order = 5) 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 8ab1dfa..9df05c4 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 @@ -4,7 +4,6 @@ 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; @@ -14,6 +13,7 @@ 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.utils.BaseUtil; import org.springblade.core.tool.api.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -56,21 +56,7 @@ public class TestServiceImpl extends ServiceImpl impleme // 查询是否存在同月编号 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; - } - } + String code = BaseUtil.getUniqueCode("KSJL", lastCode, currentMonth); testEntity.setCode(code); boolean saveTest = this.save(testEntity); // 若新增考试记录成功,添加相关的参考人员数据 @@ -81,13 +67,7 @@ public class TestServiceImpl extends ServiceImpl impleme 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); - } + List scoreList = getReferenceTestScore(test, person); return R.status(testScoreService.saveBatch(scoreList)); } return R.fail("新增考试记录失败"); @@ -185,20 +165,31 @@ public class TestServiceImpl extends ServiceImpl impleme 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); + List scoreList = getReferenceTestScore(testEntity, person); + return testScoreService.saveBatch(scoreList); } } return false; } /** + * 获取成绩列表 + * @param testEntity 考试记录实体类 + * @param person 参考人员 + * @return 成绩列表 + */ + private List getReferenceTestScore(TestEntity testEntity, String[] person) { + List res = new ArrayList<>(); + for (String name : person) { + TestScoreEntity testScoreEntity = new TestScoreEntity(); + testScoreEntity.setTestId(testEntity.getId()); + testScoreEntity.setName(name); + res.add(testScoreEntity); + } + return res; + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null 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 cba9def..27a8d8e 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 @@ -63,6 +63,10 @@ public class TrainPlanServiceImpl extends ServiceImpl page = new Page<>(query.getCurrent(), query.getSize()); IPage unitPage = baseMapper.selectByMonth(page, month); List unitList = unitPage.getRecords(); + // 若无数据,返回空页面 + if (CollectionUtils.isEmpty(unitList)) { + return unitPage; + } // 查询当月各单位已完成的培训数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); 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 230a4d2..79d9c05 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 @@ -10,7 +10,6 @@ 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.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.TrainRecordDTO; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; @@ -20,6 +19,7 @@ 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; +import com.hnac.hzims.safeproduct.utils.BaseUtil; import org.springblade.core.log.exception.ServiceException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -61,21 +61,7 @@ public class TrainRecordServiceImpl extends ServiceImpl