From 5d8bbbb6787813c958b472a1a79272f54b555371 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 27 Dec 2023 09:40:08 +0800 Subject: [PATCH 1/9] =?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/9] =?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 Date: Wed, 27 Dec 2023 14:10:42 +0800 Subject: [PATCH 3/9] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=BC=94?= =?UTF-8?q?=E7=BB=83=E7=AE=A1=E7=90=86=E3=80=81=E5=9F=B9=E8=AE=AD=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/dto/RehearsalExportDTO.java | 55 +++++ .../safeproduct/entity/RehearsalPlanEntity.java | 60 +++++ .../safeproduct/entity/RehearsalRecordEntity.java | 54 +---- .../hzims/safeproduct/entity/TrainPlanEntity.java | 7 +- .../controller/RehearsalRecordController.java | 81 +++++-- .../safeproduct/controller/TrainController.java | 2 +- .../hnac/hzims/safeproduct/jobs/RehearsalJob.java | 10 +- .../safeproduct/mapper/RehearsalPlanMapper.java | 64 +++++ .../safeproduct/mapper/RehearsalPlanMapper.xml | 84 +++++++ .../safeproduct/mapper/RehearsalRecordMapper.java | 38 --- .../safeproduct/mapper/RehearsalRecordMapper.xml | 60 ----- .../safeproduct/service/IRehearsalPlanService.java | 67 ++++++ .../service/IRehearsalRecordService.java | 56 +---- .../safeproduct/service/ITrainPlanService.java | 8 + .../service/impl/RehearsalPlanServiceImpl.java | 259 +++++++++++++++++++++ .../service/impl/RehearsalRecordServiceImpl.java | 213 +++-------------- .../service/impl/TrainPlanServiceImpl.java | 41 ++++ .../safeproduct/src/main/resources/db/1.0.1.sql | 18 +- 18 files changed, 756 insertions(+), 421 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java new file mode 100644 index 0000000..1f2903b --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/RehearsalExportDTO.java @@ -0,0 +1,55 @@ +package com.hnac.hzims.safeproduct.dto; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwen + * @date 2023-12-27 + */ +@Data +@ExcelIgnoreUnannotated +@ApiModel(value = "演练数据导出DTO类") +public class RehearsalExportDTO { + + @ApiModelProperty("单位") + @ExcelProperty(value = "单位", index = 0) + private String unit; + + @ApiModelProperty("演练科目") + @ExcelProperty(value = "演练科目", index = 1) + private String subject; + + @ApiModelProperty("演练计划开始时间") + @ExcelProperty(value = "演练计划开始时间", index = 2) + private Date scheduledStartTime; + + @ApiModelProperty("演练计划结束时间") + @ExcelProperty(value = "演练计划结束时间", index = 3) + private Date scheduledEndTime; + + @ApiModelProperty("演练地点") + @ExcelProperty(value = "演练地点", index = 4) + private String location; + + @ApiModelProperty("参演人数") + @ExcelProperty(value = "参演人数", index = 5) + private Integer peopleNum; + + @ApiModelProperty("演练实际开始时间") + @ExcelProperty(value = "演练实际开始时间", index = 6) + private Date actualStartTime; + + @ApiModelProperty("演练实际结束时间") + @ExcelProperty(value = "演练实际结束时间", index = 7) + private Date actualEndTime; + + @ApiModelProperty("演练状态") + @ExcelProperty(value = "演练状态", index = 8) + private String rehearsalStatus; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java new file mode 100644 index 0000000..bdff1a1 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalPlanEntity.java @@ -0,0 +1,60 @@ +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-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_rehearsal_plan") +@ApiModel(value = "演练计划实体类") +public class RehearsalPlanEntity extends BaseEntity { + + @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; + + @NotNull + @Size(max = 10, message = "总指挥字段长度不能超过10") + @ApiModelProperty("总指挥") + private String commander; + + @Size(max = 20, message = "演练方式字段长度不能超过20") + @ApiModelProperty("演练方式") + private String rehearsalMethod; + + @NotNull + @Size(max = 20, message = "演练状态字段长度不能超过20") + @ApiModelProperty("演练状态") + private String rehearsalStatus; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java index 28d15e8..1bcf594 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/RehearsalRecordEntity.java @@ -1,7 +1,5 @@ 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; @@ -11,7 +9,6 @@ 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; @@ -21,65 +18,30 @@ import java.util.Date; */ @Data @EqualsAndHashCode(callSuper = true) -@ExcelIgnoreUnannotated @TableName("hzims_rehearsal_record") @ApiModel(value = "演练记录实体类") public class RehearsalRecordEntity extends BaseEntity { + @ApiModelProperty("演练计划id") + private Long rehearsalPlanId; + @Size(max = 50, message = "编码字段长度不能超过50") @ApiModelProperty("编码") - @ExcelProperty(value = "编码", index = 0) private String code; - @NotNull - @Size(max = 50, message = "单位字段长度不能超过50") - @ApiModelProperty("单位") - @ExcelProperty(value = "单位", index = 1) - private String unit; - - @NotNull - @Size(max = 50, message = "演练科目字段长度不能超过50") - @ApiModelProperty("演练科目") - @ExcelProperty(value = "演练科目", index = 2) - private String subject; - - @NotNull - @ApiModelProperty("演练计划开始时间") - @ExcelProperty(value = "演练计划开始时间", index = 3) - private Date scheduledStartTime; - - @NotNull - @ApiModelProperty("演练计划结束时间") - @ExcelProperty(value = "演练计划结束时间", index = 4) - private Date scheduledEndTime; - - @NotNull - @Size(max = 255, message = "演练地点字段长度不能超过255") - @ApiModelProperty("演练地点") - @ExcelProperty(value = "演练地点", index = 5) - private String location; - @Min(value = 0, message = "参演人数不能小于0") @Max(value = 1000, message = "参演人数字段长度超出限制范围") @ApiModelProperty("参演人数") - @ExcelProperty(value = "参演人数", index = 6) private Integer peopleNum; @Size(max = 5000, message = "参演人员字段长度超出限制范围") @ApiModelProperty("参演人员") private String peopleName; - @NotNull - @Size(max = 10, message = "总指挥字段长度不能超过10") - @ApiModelProperty("总指挥") - private String commander; - @ApiModelProperty("演练实际开始时间") - @ExcelProperty(value = "演练实际开始时间", index = 7) private Date actualStartTime; @ApiModelProperty("演练实际结束时间") - @ExcelProperty(value = "演练实际结束时间", index = 8) private Date actualEndTime; @Size(max = 250, message = "演练记录字段长度不能超过250") @@ -90,16 +52,6 @@ public class RehearsalRecordEntity extends BaseEntity { @ApiModelProperty("演练评价") private String comment; - @Size(max = 20, message = "演练方式字段长度不能超过20") - @ApiModelProperty("演练方式") - private String rehearsalMethod; - - @NotNull - @Size(max = 20, message = "演练状态字段长度不能超过20") - @ApiModelProperty("演练状态") - @ExcelProperty(value = "演练状态", index = 9) - private String rehearsalStatus; - @Size(max = 1000, message = "演练图片字段长度不能超过1000") @ApiModelProperty("演练图片") private String imgPath; 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 09fe232..9b1b0fb 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 @@ -2,6 +2,7 @@ package com.hnac.hzims.safeproduct.entity; 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 io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -70,6 +71,10 @@ public class TrainPlanEntity extends BaseEntity { @NotNull @ApiModelProperty("关联考试:0-否,1-是") - @ExcelProperty(value = "是否考试", index = 5) private Integer isTest; + + @TableField(exist = false) + @ApiModelProperty("是否考试") + @ExcelProperty(value = "是否考试", index = 5) + private String hasTest; } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java index 71b375f..f80e0fa 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/RehearsalRecordController.java @@ -3,7 +3,9 @@ package com.hnac.hzims.safeproduct.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; +import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; @@ -36,32 +38,34 @@ public class RehearsalRecordController extends BladeController { private final IRehearsalRecordService rehearsalRecordService; + private final IRehearsalPlanService rehearsalPlanService; + @PostMapping("/save") - @ApiOperation(value = "新增") + @ApiOperation(value = "新增演练计划") @ApiOperationSupport(order = 1) - public R save(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.saveRehearsal(rehearsalRecord)); + public R save(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { + return R.status(rehearsalPlanService.save(rehearsalPlan)); } @PostMapping("/update") - @ApiOperation(value = "修改") + @ApiOperation(value = "修改演练计划") @ApiOperationSupport(order = 2) - public R update(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { - return R.status(rehearsalRecordService.updateRehearsal(rehearsalRecord)); + public R update(@Valid @RequestBody RehearsalPlanEntity rehearsalPlan) { + return R.status(rehearsalPlanService.updateById(rehearsalPlan)); } @PostMapping("/remove") - @ApiOperation(value = "删除") + @ApiOperation(value = "删除演练计划") @ApiOperationSupport(order = 3) public R remove(@RequestParam Long id) { - return R.status(rehearsalRecordService.removeById(id)); + return R.status(rehearsalPlanService.removeRehearsalPlan(id)); } @GetMapping("/detail") - @ApiOperation(value = "详情") + @ApiOperation(value = "演练计划详情") @ApiOperationSupport(order = 4) - public R detail(@RequestParam Long id) { - return R.data(rehearsalRecordService.getById(id)); + public R detail(@RequestParam Long id) { + return R.data(rehearsalPlanService.getById(id)); } @GetMapping("/page") @@ -70,9 +74,48 @@ public class RehearsalRecordController extends BladeController { @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) - @ApiOperation(value = "分页") + @ApiOperation(value = "演练计划分页") @ApiOperationSupport(order = 5) - public R> page(@ApiIgnore @RequestParam Map param, Query query) { + public R> page(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = rehearsalPlanService.rehearsalPlanPage(param, query); + return R.data(page); + } + + @PostMapping("/saveRehearsalRecord") + @ApiOperation(value = "新增演练记录") + @ApiOperationSupport(order = 6) + public R saveRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + return R.status(rehearsalRecordService.saveRehearsalRecord(rehearsalRecord)); + } + + @PostMapping("/updateRehearsalRecord") + @ApiOperation(value = "修改演练记录") + @ApiOperationSupport(order = 7) + public R updateRehearsalRecord(@Valid @RequestBody RehearsalRecordEntity rehearsalRecord) { + return R.status(rehearsalRecordService.updateRehearsalRecord(rehearsalRecord)); + } + + @PostMapping("/removeRehearsalRecord") + @ApiOperation(value = "删除演练记录") + @ApiOperationSupport(order = 8) + public R removeRehearsalRecord(@RequestParam Long id) { + return R.status(rehearsalRecordService.removeById(id)); + } + + @GetMapping("/rehearsalRecordDetail") + @ApiOperation(value = "演练记录详情") + @ApiOperationSupport(order = 9) + public R rehearsalRecordDetail(@RequestParam Long id) { + return R.data(rehearsalRecordService.getById(id)); + } + + @GetMapping("/rehearsalRecordPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "rehearsalPlanId", value = "演练计划id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "演练记录分页") + @ApiOperationSupport(order = 10) + public R> rehearsalRecordPage(@ApiIgnore @RequestParam Map param, Query query) { IPage page = rehearsalRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(param, RehearsalRecordEntity.class)); return R.data(page); @@ -80,17 +123,17 @@ public class RehearsalRecordController extends BladeController { @GetMapping("/dataByMonth") @ApiOperation(value = "月度统计表") - @ApiOperationSupport(order = 6) + @ApiOperationSupport(order = 11) public R> dataByMonth(@RequestParam String month, Query query) { - IPage page = rehearsalRecordService.dataByMonth(month, query); + IPage page = rehearsalPlanService.dataByMonth(month, query); return R.data(page); } @GetMapping("/dataByYear") @ApiOperation(value = "年度统计表") - @ApiOperationSupport(order = 7) + @ApiOperationSupport(order = 12) public R> dataByYear(@RequestParam String year, Query query) { - IPage page = rehearsalRecordService.dataByYear(year, query); + IPage page = rehearsalPlanService.dataByYear(year, query); return R.data(page); } @@ -101,8 +144,8 @@ public class RehearsalRecordController extends BladeController { @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "演练数据导出") - @ApiOperationSupport(order = 8) + @ApiOperationSupport(order = 13) public void exportRehearsalData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { - rehearsalRecordService.exportRehearsalData(param, response); + rehearsalPlanService.exportRehearsalPlanData(param, response); } } 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 25fbe27..92d703c 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 @@ -94,7 +94,7 @@ public class TrainController extends BladeController { @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)); + IPage page = trainPlanService.trainPlanPage(param, query); return R.data(page); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/RehearsalJob.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/RehearsalJob.java index 5b69652..44ff7d8 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/RehearsalJob.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/jobs/RehearsalJob.java @@ -1,8 +1,8 @@ package com.hnac.hzims.safeproduct.jobs; -import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; -import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; +import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.handler.annotation.XxlJob; import org.springblade.core.tool.utils.DateUtil; @@ -22,7 +22,7 @@ import java.util.List; public class RehearsalJob { @Autowired - IRehearsalRecordService rehearsalRecordService; + IRehearsalPlanService rehearsalPlanService; @XxlJob("autoChangeRehearsalStatus") public ReturnT autoChangeRehearsalStatus(String param) { @@ -32,12 +32,12 @@ public class RehearsalJob { String today = DateUtil.format(current, "yyyy-mm-dd hh:MM:ss"); String yesterday = DateUtil.format(before, "yyyy-mm-dd hh:MM:ss"); // 查询前一天的超时未完成演练记录 - List list = rehearsalRecordService.getWaitingRehearsalInTimeRange(yesterday, today); + List list = rehearsalPlanService.getWaitingRehearsalInTimeRange(yesterday, today); list.forEach(x -> { x.setRehearsalStatus(RehearsalStatusEnum.UNFINISHED.getValue()); }); // 将状态置为未完成 - boolean flag = rehearsalRecordService.updateBatchById(list); + boolean flag = rehearsalPlanService.updateBatchById(list); return flag ? ReturnT.SUCCESS : ReturnT.FAIL; } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.java new file mode 100644 index 0000000..990793b --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.java @@ -0,0 +1,64 @@ +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.dto.RehearsalExportDTO; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; +import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; +import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 演练计划Mapper类 + * + * @author liwen + * @date 2023-12-27 + */ +@Mapper +public interface RehearsalPlanMapper extends BaseMapper { + + /** + * 查询当月各单位的演练总数 + * @param page 分页类 + * @param month 月份 + * @return 当月的演练总数据 + */ + IPage selectByMonth(IPage page, String month); + + /** + * 查询当月各单位已完成的演练数据 + * @param page 分页类 + * @param month 月份 + * @return 当月的已完成数据 + */ + IPage selectFinishedDataByMonth(IPage page, String month); + + /** + * 查询当年的所有单位 + * @param page 分页类 + * @param year 年份 + * @return 年度单位数据 + */ + IPage selectUnitByYear(IPage page, @Param("year") String year); + + /** + * 查询各单位全年已完成的演练数据 + * @param unitList 单元列表 + * @param year 年份 + * @return 单位各月的数据列表 + */ + List selectFinishedDataByUnit(@Param("unitList") List unitList, @Param("year") String year); + + /** + * 根据单位和计划时间查询演练数据 + * @param unit 单位 + * @param startTime 计划开始时间 + * @param endTime 计划结束时间 + * @return 演练数据列表 + */ + List getRehearsalByUnitAndDate(String unit, String startTime, String endTime); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml new file mode 100644 index 0000000..71519a5 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java index 9d60ecf..1c77f92 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.java @@ -1,15 +1,8 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.hnac.hzims.safeproduct.dto.RehearsalYearDTO; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; -import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; -import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; /** * 演练记录Mapper类 @@ -20,35 +13,4 @@ import java.util.List; @Mapper public interface RehearsalRecordMapper extends BaseMapper { - /** - * 查询当月各单位的演练总数 - * @param page 分页类 - * @param month 月份 - * @return 当月的演练总数据 - */ - IPage selectByMonth(IPage page, @Param("month") String month); - - /** - * 查询当月各单位已完成的演练数据 - * @param page 分页类 - * @param month 月份 - * @return 当月的已完成数据 - */ - IPage selectFinishedDataByMonth(IPage page, @Param("month") String month); - - /** - * 查询当年的所有单位 - * @param page 分页类 - * @param year 年份 - * @return 年度单位数据 - */ - IPage selectUnitByYear(IPage page, @Param("year") String year); - - /** - * 查询各单位全年已完成的演练数据 - * @param unitList 单元列表 - * @param year 年份 - * @return 单位各月的数据列表 - */ - List selectFinishedDataByUnit(@Param("unitList") List unitList, @Param("year") String year); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml index fbe9efc..123fddd 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalRecordMapper.xml @@ -2,64 +2,4 @@ - - - - - - - - \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java new file mode 100644 index 0000000..cc18cfe --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalPlanService.java @@ -0,0 +1,67 @@ +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.RehearsalPlanEntity; +import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; +import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; +import org.springblade.core.mp.support.Query; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + +/** + * 演练计划服务类 + * + * @author liwen + * @date 2023-12-27 + */ +public interface IRehearsalPlanService extends IService { + + /** + * 删除演练计划 + * @param id 演练计划id + * @return true-成功,false-失败 + */ + boolean removeRehearsalPlan(Long id); + + /** + * 演练月度数据 + * @param month 月份 + * @param query 分页类 + * @return 月度统计分页 + */ + IPage dataByMonth(String month, Query query); + + /** + * 演练年度数据 + * @param year 年份 + * @param query 分页类 + * @return 年度统计分页 + */ + IPage dataByYear(String year, Query query); + + /** + * 演练计划数据导出 + * @param param 入参 + * @param response 响应类 + */ + void exportRehearsalPlanData(Map param, HttpServletResponse response); + + /** + * 查询时间范围内未开始的演练数据 + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 演练数据 + */ + List getWaitingRehearsalInTimeRange(String startTime, String endTime); + + /** + * 演练计划分页 + * @param param 入参 + * @param query 分页类 + * @return 演练计划数据 + */ + IPage rehearsalPlanPage(Map param, Query query); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java index 2ee8bbf..0fab88d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IRehearsalRecordService.java @@ -1,15 +1,7 @@ package com.hnac.hzims.safeproduct.service; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; -import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; -import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; -import org.springblade.core.mp.support.Query; - -import javax.servlet.http.HttpServletResponse; -import java.util.List; -import java.util.Map; /** * 演练记录服务类 @@ -20,47 +12,23 @@ import java.util.Map; public interface IRehearsalRecordService 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 rehearsalRecord 演练记录DTO类 - * @return 新增是否成功 - */ - boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord); - - /** - * 修改演练 - * @param rehearsalRecord 演练记录DTO类 - * @return 更新是否成功 + * 新增演练记录 + * @param rehearsalRecord 演练记录实体类 + * @return true-成功,false-失败 */ - boolean updateRehearsal(RehearsalRecordEntity rehearsalRecord); + boolean saveRehearsalRecord(RehearsalRecordEntity rehearsalRecord); /** - * 演练数据导出 - * @param param 入参 - * @param response 响应类 + * 修改演练记录 + * @param rehearsalRecord 演练记录实体类 + * @return true-成功,false-失败 */ - void exportRehearsalData(Map param, HttpServletResponse response); + boolean updateRehearsalRecord(RehearsalRecordEntity rehearsalRecord); /** - * 查询时间范围内未开始的演练数据 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @return 演练数据 + * 删除关联演练记录 + * @param rehearsalPlanId 演练计划id + * @return true-成功,false-失败 */ - List getWaitingRehearsalInTimeRange(String startTime, String endTime); + boolean removeRelativeRehearsalRecord(Long rehearsalPlanId); } 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 bfb31ac..50571cc 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 @@ -56,4 +56,12 @@ public interface ITrainPlanService extends IService { * @return 培训计划数据 */ List getWaitingTrainPlanInTimeRange(String startTime, String endTime); + + /** + * 培训计划分页 + * @param param 入参 + * @param query 分页类 + * @return 培训计划数据 + */ + IPage trainPlanPage(Map param, Query query); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java new file mode 100644 index 0000000..a3db6d5 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -0,0 +1,259 @@ +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.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO; +import com.hnac.hzims.safeproduct.dto.RehearsalExportDTO; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; +import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; +import com.hnac.hzims.safeproduct.mapper.RehearsalPlanMapper; +import com.hnac.hzims.safeproduct.service.IRehearsalPlanService; +import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; +import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; +import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; +import org.springblade.core.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 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-27 + */ +@Service +public class RehearsalPlanServiceImpl extends ServiceImpl + implements IRehearsalPlanService { + + @Autowired + IRehearsalRecordService rehearsalRecordService; + + /** + * 删除演练计划 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removeRehearsalPlan(Long id) { + boolean remove = this.removeById(id); + // 若演练计划删除成功,删除关联演练记录 + if (remove) { + return rehearsalRecordService.removeRelativeRehearsalRecord(id); + } + return false; + } + + /** + * 演练月度数据 + */ + @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 (RehearsalMonthVO unit : unitList) { + Long taskNum = unit.getScheduledTaskNum(); + Optional finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); + Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTaskNum() : 0L; + unit.setFinishedTaskNum(finishedTaskNum); + unit.setUnfinishedTaskNum(taskNum - finishedTaskNum); + BigDecimal taskDecimal = new BigDecimal(taskNum); + BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); + unit.setTaskCompletionRate(finishedDecimal.divide(taskDecimal, 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 (org.springframework.util.CollectionUtils.isEmpty(records)) { + return unitPage; + } + List unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList()); + // 查询各单位全年已完成的演练数据 + List unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); + // 将各单位每个月的演练数据写入统计列表 + unitMonthDataList.forEach(data -> { + RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) + .collect(Collectors.toList()).get(0); + // 根据月份匹配写入对应字段 + switch (data.getDateTime()) { + case "01": + rehearsalYearVO.setJanuaryNum(data.getFinishedNum()); + break; + case "02": + rehearsalYearVO.setFebruaryNum(data.getFinishedNum()); + break; + case "03": + rehearsalYearVO.setMarchNum(data.getFinishedNum()); + break; + case "04": + rehearsalYearVO.setAprilNum(data.getFinishedNum()); + break; + case "05": + rehearsalYearVO.setMayNum(data.getFinishedNum()); + break; + case "06": + rehearsalYearVO.setJuneNum(data.getFinishedNum()); + break; + case "07": + rehearsalYearVO.setJulyNum(data.getFinishedNum()); + break; + case "08": + rehearsalYearVO.setAugustNum(data.getFinishedNum()); + break; + case "09": + rehearsalYearVO.setSeptemberNum(data.getFinishedNum()); + break; + case "10": + rehearsalYearVO.setOctoberNum(data.getFinishedNum()); + break; + case "11": + rehearsalYearVO.setNovemberNum(data.getFinishedNum()); + break; + case "12": + rehearsalYearVO.setDecemberNum(data.getFinishedNum()); + } + }); + unitPage.setRecords(records); + return unitPage; + } + + /** + * 演练计划数据导出 + */ + @Override + public void exportRehearsalPlanData(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 rehearsalList = getRehearsalByUnitAndDate(unit, startTime, endTime); + // 处理演练状态信息 + rehearsalList.forEach(record -> { + String status; + if (record.getRehearsalStatus().equals(RehearsalStatusEnum.WAITING.getValue())) { + status = RehearsalStatusEnum.WAITING.getDesc(); + } else if (record.getRehearsalStatus().equals(RehearsalStatusEnum.UNFINISHED.getValue())) { + status = RehearsalStatusEnum.UNFINISHED.getDesc(); + } else { + status = RehearsalStatusEnum.FINISHED.getDesc(); + } + record.setRehearsalStatus(status); + }); + // 设置响应头 + // 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(RehearsalExportDTO.class) + .build(); + excelWriter.write(rehearsalList, 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 getRehearsalByUnitAndDate(String unit, String startTime, String endTime) { + return baseMapper.getRehearsalByUnitAndDate(unit, startTime, endTime); + } + + /** + * 查询时间范围内未开始的演练数据 + */ + @Override + public List getWaitingRehearsalInTimeRange(String startTime, String endTime) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(RehearsalPlanEntity::getRehearsalStatus, RehearsalStatusEnum.WAITING.getValue()) + .ge(RehearsalPlanEntity::getScheduledEndTime, startTime) + .lt(RehearsalPlanEntity::getScheduledEndTime, endTime); + return this.list(queryWrapper); + } + + /** + * 演练计划分页 + */ + @Override + public IPage rehearsalPlanPage(Map param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("startTime")); + String endTime = String.valueOf((param.get("endTime"))); + if (unit.equals("null") || unit.equals("")) { + queryWrapper.lambda().eq(RehearsalPlanEntity::getUnit, unit); + } + if (startTime.equals("null") || startTime.equals("")) { + queryWrapper.lambda().ge(RehearsalPlanEntity::getScheduledStartTime, startTime); + } + if (endTime.equals("null") || endTime.equals("")) { + queryWrapper.lambda().le(RehearsalPlanEntity::getScheduledEndTime, endTime); + } + return this.page(Condition.getPage(query), queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java index f1aa1e8..b3a6701 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalRecordServiceImpl.java @@ -1,37 +1,21 @@ package com.hnac.hzims.safeproduct.service.impl; import cn.hutool.core.date.DatePattern; -import com.alibaba.druid.support.json.JSONUtils; -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.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.logs.utils.StringUtils; -import com.hnac.hzims.safeproduct.dto.RehearsalYearDTO; +import com.hnac.hzims.safeproduct.constants.SafeProductConstant; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; import com.hnac.hzims.safeproduct.entity.RehearsalRecordEntity; import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; +import com.hnac.hzims.safeproduct.mapper.RehearsalPlanMapper; import com.hnac.hzims.safeproduct.mapper.RehearsalRecordMapper; import com.hnac.hzims.safeproduct.service.IRehearsalRecordService; -import com.hnac.hzims.safeproduct.vo.RehearsalMonthVO; -import com.hnac.hzims.safeproduct.vo.RehearsalYearVO; import lombok.extern.slf4j.Slf4j; -import org.springblade.core.log.exception.ServiceException; -import org.springblade.core.mp.support.Query; import org.springframework.stereotype.Service; -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 javax.annotation.Resource; import java.util.*; import java.util.stream.Collectors; @@ -45,99 +29,14 @@ import java.util.stream.Collectors; @Slf4j public class RehearsalRecordServiceImpl extends ServiceImpl implements IRehearsalRecordService { - /** - * 演练月度数据 - */ - @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 (RehearsalMonthVO unit : unitList) { - Long taskNum = unit.getScheduledTaskNum(); - Optional finishedRehearsal = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); - Long finishedTaskNum = finishedRehearsal.isPresent() ? finishedRehearsal.get().getFinishedTaskNum() : 0L; - unit.setFinishedTaskNum(finishedTaskNum); - unit.setUnfinishedTaskNum(taskNum - finishedTaskNum); - BigDecimal taskDecimal = new BigDecimal(taskNum); - BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); - unit.setTaskCompletionRate(finishedDecimal.divide(taskDecimal, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) - .setScale(2, RoundingMode.HALF_UP)); - } - unitPage.setRecords(unitList); - return unitPage; - } - - /** - * 演练年度数据 - */ - @Override - public IPage dataByYear(String year, Query query) { - IPage page = new Page<>(query.getCurrent(), query.getSize()); - // 查询当年的所有单位 - IPage unitPage = baseMapper.selectUnitByYear(page, year); - List records = unitPage.getRecords(); - List unitList = records.stream().map(RehearsalYearVO::getUnit).collect(Collectors.toList()); - // 查询各单位全年已完成的演练数据 - List unitMonthDataList = baseMapper.selectFinishedDataByUnit(unitList, year); - // 将各单位每个月的演练数据写入统计列表 - unitMonthDataList.forEach(data -> { - RehearsalYearVO rehearsalYearVO = records.stream().filter(x -> x.getUnit().equals(data.getUnit())) - .collect(Collectors.toList()).get(0); - // 根据月份匹配写入对应字段 - switch (data.getDateTime()) { - case "01": - rehearsalYearVO.setJanuaryNum(data.getFinishedNum()); - break; - case "02": - rehearsalYearVO.setFebruaryNum(data.getFinishedNum()); - break; - case "03": - rehearsalYearVO.setMarchNum(data.getFinishedNum()); - break; - case "04": - rehearsalYearVO.setAprilNum(data.getFinishedNum()); - break; - case "05": - rehearsalYearVO.setMayNum(data.getFinishedNum()); - break; - case "06": - rehearsalYearVO.setJuneNum(data.getFinishedNum()); - break; - case "07": - rehearsalYearVO.setJulyNum(data.getFinishedNum()); - break; - case "08": - rehearsalYearVO.setAugustNum(data.getFinishedNum()); - break; - case "09": - rehearsalYearVO.setSeptemberNum(data.getFinishedNum()); - break; - case "10": - rehearsalYearVO.setOctoberNum(data.getFinishedNum()); - break; - case "11": - rehearsalYearVO.setNovemberNum(data.getFinishedNum()); - break; - case "12": - rehearsalYearVO.setDecemberNum(data.getFinishedNum()); - } - }); - unitPage.setRecords(records); - return unitPage; - } + @Resource + RehearsalPlanMapper rehearsalPlanMapper; /** * 新增演练 */ @Override - public boolean saveRehearsal(RehearsalRecordEntity rehearsalRecord) { + public boolean saveRehearsalRecord(RehearsalRecordEntity rehearsalRecord) { // 获取当月时间(yyyymm) String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); // 查询是否存在同月编号 @@ -165,14 +64,21 @@ public class RehearsalRecordServiceImpl extends ServiceImpl 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 = getRehearsalByUnitAndDate(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(RehearsalRecordEntity.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 @@ -255,37 +115,20 @@ public class RehearsalRecordServiceImpl extends ServiceImpl getRehearsalByUnitAndDate(String unit, String startTime, String endTime) { - LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - if (!unit.equals("null")) { - queryWrapper.eq(RehearsalRecordEntity::getUnit, unit); - } - if (!startTime.equals("null")) { - queryWrapper.ge(RehearsalRecordEntity::getScheduledStartTime, startTime); - } - if (!endTime.equals("null")) { - queryWrapper.le(RehearsalRecordEntity::getScheduledEndTime, endTime); - } - queryWrapper.orderByDesc(RehearsalRecordEntity::getScheduledEndTime); - return this.list(queryWrapper); - } - - /** - * 查询时间范围内未开始的演练数据 + * 删除关联演练记录 */ @Override - public List getWaitingRehearsalInTimeRange(String startTime, String endTime) { + public boolean removeRelativeRehearsalRecord(Long rehearsalPlanId) { + // 查询关联演练记录 QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(RehearsalRecordEntity::getRehearsalStatus, RehearsalStatusEnum.WAITING.getValue()) - .ge(RehearsalRecordEntity::getScheduledEndTime, startTime) - .lt(RehearsalRecordEntity::getScheduledEndTime, endTime); - return this.list(queryWrapper); + queryWrapper.lambda().eq(RehearsalRecordEntity::getRehearsalPlanId, rehearsalPlanId); + List rehearsalRecordList = this.list(queryWrapper); + // 若无关联演练记录,直接返回true + if (CollectionUtils.isEmpty(rehearsalRecordList)) { + return true; + } + // 删除关联演练记录 + List ids = rehearsalRecordList.stream().map(RehearsalRecordEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); } - } 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 142b75f..33aec9e 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 @@ -10,8 +10,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO; +import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; +import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.enums.TrainStatusEnum; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.service.ITestService; @@ -170,6 +174,22 @@ public class TrainPlanServiceImpl extends ServiceImpl trainPlanList = getTrainPlanByUnitAndDate(unit, startTime, endTime); + // 处理字段信息 + trainPlanList.forEach(train -> { + // 培训状态 + String status; + if (train.getTrainStatus().equals(TrainStatusEnum.WAITING.getValue())) { + status = TrainStatusEnum.WAITING.getDesc(); + } else if (train.getTrainStatus().equals(TrainStatusEnum.UNFINISHED.getValue())) { + status = TrainStatusEnum.UNFINISHED.getDesc(); + } else { + status = TrainStatusEnum.FINISHED.getDesc(); + } + train.setTrainStatus(status); + // 是否考试 + String isTest = train.getIsTest().equals(SafeProductConstant.TRAIN_PLAN_HAS_TEST) ? "是" : "否"; + train.setHasTest(isTest); + }); // 设置响应头 // URLEncoder.encode防止中文乱码 String fileName = URLEncoder.encode("培训计划表", "UTF-8"); @@ -217,6 +237,27 @@ public class TrainPlanServiceImpl extends ServiceImpl trainPlanPage(Map param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("startTime")); + String endTime = String.valueOf((param.get("endTime"))); + if (unit.equals("null") || unit.equals("")) { + queryWrapper.lambda().eq(TrainPlanEntity::getUnit, unit); + } + if (startTime.equals("null") || startTime.equals("")) { + queryWrapper.lambda().ge(TrainPlanEntity::getScheduledStartTime, startTime); + } + if (endTime.equals("null") || endTime.equals("")) { + queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime); + } + return this.page(Condition.getPage(query), queryWrapper); + } + + /** * 根据单位和计划时间查询培训计划数据 * @param unit 单位 * @param startTime 计划开始时间 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 6d3a340..6bf9836 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 @@ -13,23 +13,14 @@ create table document_management CREATE TABLE `hzims_rehearsal_plan` ( `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 '创建时间', @@ -42,21 +33,14 @@ CREATE TABLE `hzims_rehearsal_plan` ( CREATE TABLE `hzims_rehearsal_record` ( `id` bigint(20) NOT NULL COMMENT '主键id', + `rehearsal_plan_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 '创建人', From 8107228ce50eb552b10a610b571c92242f117a63 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Wed, 27 Dec 2023 14:48:01 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=9C=88=E5=BA=A6=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=A2=9E=E5=8A=A0=E6=9C=BA=E6=9E=84=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../defect/controller/OperDefectController.java | 8 +- .../defect/mapper/OperDefectMapper.java | 8 +- .../operational/defect/mapper/OperDefectMapper.xml | 56 +++++-- .../defect/service/IOperDefectService.java | 4 +- .../defect/service/impl/OperDefectServiceImpl.java | 171 +++++++++++++++------ 5 files changed, 171 insertions(+), 76 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java index addc566..b1d5fac 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectController.java @@ -143,17 +143,17 @@ public class OperDefectController extends BladeController { @OperationAnnotation(moduleName = "生产月报", title = "缺陷月报表", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action = "获取缺陷的统计月报") - public R> getDefectStatistics(@ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month) { - Map defectStatistics = defectService.getDefectStatistics(month); + public R> getDefectStatistics(@ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month, @RequestParam String deptId) { + Map defectStatistics = defectService.getDefectStatistics(month,deptId); return R.data(defectStatistics); } @ApiOperation(value = "缺陷月报表导出-Excel") @RequestMapping(value = "/exportFualtMonthExcel", method = {RequestMethod.GET, RequestMethod.POST}) - public void exportFualtMonthExcel(HttpServletResponse response, @ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month) { + public void exportFualtMonthExcel(HttpServletResponse response, @ApiParam(value = "month 格式:2021-01", required = true) @RequestParam String month,@ApiParam String deptId) { Map result = new HashMap<>(); try { - defectService.exportFualtMonthExcel(response, month); + defectService.exportFualtMonthExcel(response, month, deptId); result.put("success", "true"); } catch (IOException e) { result.put("success", "false"); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.java index 8eb6960..dfe376f 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.java @@ -27,7 +27,7 @@ public interface OperDefectMapper extends UserDataScopeBaseMapper getStatisticByMonth(@Param("month") String month, - @Param("createDept") String createDept); + @Param("createDept") List createDept); /** * 当年1月 - 当前月获取缺陷等级统计数据 @@ -37,13 +37,13 @@ public interface OperDefectMapper extends UserDataScopeBaseMapper getStatisticBySeveralMonth(@Param("firstMonth") String firstMonth, @Param("endMonth") String endMonth, - @Param("createDept") String createDept); + @Param("createDept") List createDept); /** * 获取重复缺陷等级统计数据 * @return */ - List getRepetStatistics(@Param("createDept") String createDept); + List getRepetStatistics(@Param("createDept") List createDept); /** * 获取按月管理指标统计数据 @@ -52,7 +52,7 @@ public interface OperDefectMapper extends UserDataScopeBaseMapper getManageIndex(@Param("month") String month, - @Param("createDept") String createDept); + @Param("createDept") List createDept); List selectDefectList(String emCode,List list); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.xml index 28d1911..35489b3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/mapper/OperDefectMapper.xml @@ -8,8 +8,11 @@ hzims_oper_phenomenon P ON D.DEFECT_CODE = P.DEFECT_CODE WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + GROUP BY P.DEFECT_LEVEL,D.HANDLE_STATUS ORDER BY P.DEFECT_LEVEL @@ -22,8 +25,11 @@ LEFT JOIN hzims_oper_phenomenon P ON D.DEFECT_CODE = P.DEFECT_CODE WHERE D.CREATE_TIME BETWEEN #{firstMonth} AND #{endMonth} - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + GROUP BY P.DEFECT_LEVEL,D.HANDLE_STATUS ORDER BY P.DEFECT_LEVEL @@ -34,8 +40,11 @@ hzims_oper_phenomenon P ON D.DEFECT_CODE = P.DEFECT_CODE WHERE 1=1 - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + GROUP BY P.DEFECT_LEVEL,P.FAULT_CODE @@ -47,8 +56,11 @@ WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} AND D.HANDLE_STATUS = 1 AND D.ACT_END_TIME <= P.PLAN_END_TIME - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + ) UNION ALL @@ -57,8 +69,11 @@ SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} AND D.HANDLE_STATUS = 1 - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + ) UNION ALL @@ -67,8 +82,11 @@ SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} AND D.HANDLE_STATUS = 0 - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + ) UNION ALL @@ -77,8 +95,11 @@ SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') < CONCAT(#{month}, '-01') AND D.HANDLE_STATUS = 0 - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + ) UNION ALL @@ -86,8 +107,11 @@ ( SELECT COUNT(D.ID) AS DEFECT_NUM from hzims_oper_defect D WHERE DATE_FORMAT(D.CREATE_TIME,'%Y-%m') = #{month} - - AND D.CREATE_DEPT = #{createDept} + + and D.CREATE_DEPT in + + #{item} + ) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java index ede6661..98c5c30 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectService.java @@ -43,7 +43,7 @@ public interface IOperDefectService extends BaseService { * 获取缺陷的统计月报 * @param month 格式:"2021-01" */ - Map getDefectStatistics(String month); + Map getDefectStatistics(String month,String deptId); /** * 导出缺陷统计月报报表 @@ -51,7 +51,7 @@ public interface IOperDefectService extends BaseService { * @param month 格式 "2021-01" * @throws IOException */ - void exportFualtMonthExcel(HttpServletResponse response, String month) throws IOException; + void exportFualtMonthExcel(HttpServletResponse response, String month,String deptId) throws IOException; List getDefectList(String emCode,List list); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java index 83a2c6d..859102e 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java @@ -50,6 +50,8 @@ import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.vo.ComleteTask; import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -57,6 +59,7 @@ import org.springframework.stereotype.Service; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; +import javax.xml.ws.WebServiceException; import java.io.IOException; import java.math.BigDecimal; import java.net.URLEncoder; @@ -85,6 +88,8 @@ public class OperDefectServiceImpl extends BaseServiceImpl getQueryWrapper(OperDefectVO defectVO) { LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectEntity(), defectVO); @@ -180,6 +186,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl getDefectStatistics(String month) { + public Map getDefectStatistics(String month, String deptId) { Map re = new HashMap<>(); - re.put("currentMonth", getCurrentMonthStatic(month)); - re.put("severalMonths", getStatisticBySeveralMonth(month)); - re.put("manageIndex", getManageIndexStatistic(month)); - re.put("repeat", getRepeatStatistic(month)); + re.put("currentMonth", getCurrentMonthStatic(month, deptId)); + re.put("severalMonths", getStatisticBySeveralMonth(month, deptId)); + re.put("manageIndex", getManageIndexStatistic(month, deptId)); + re.put("repeat", getRepeatStatistic(deptId)); return re; } @Override - public void exportFualtMonthExcel(HttpServletResponse response, String month) throws IOException { + public void exportFualtMonthExcel(HttpServletResponse response, String month, String deptId) throws IOException { Map re = new HashMap<>(); - re = this.getDefectStatistics(month); + re = this.getDefectStatistics(month, deptId); //获取数据 List currentMonth = (List) re.get("currentMonth"); List severalMonths = (List) re.get("severalMonths"); @@ -785,8 +792,24 @@ public class OperDefectServiceImpl extends BaseServiceImpl getCurrentMonthStatic(String month) { - List statisticByMonth = this.baseMapper.getStatisticByMonth(month, AuthUtil.getDeptId()); + private List getCurrentMonthStatic(String month, String deptId) { + List createDeptList = new ArrayList<>(); + List deptList = new ArrayList<>(); + R> res = sysClient.getDeptByCurrentUser(); + if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { + deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); + } else { + throw new WebServiceException("该用户没有此权限"); + } + if (StringUtil.isNotBlank(deptId)) { + if (deptList.contains(deptId)) { + createDeptList.add(deptId); + } + } else { + //拿到用户当前及其以下的机构 + createDeptList.addAll(deptList); + } + List statisticByMonth = this.baseMapper.getStatisticByMonth(month, createDeptList); return getRatioStatic(statisticByMonth); } @@ -796,7 +819,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl getStatisticBySeveralMonth(String month) { + private List getStatisticBySeveralMonth(String month, String deptId) { Integer intervalMonth = Integer.valueOf(month.split("-")[1]); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date date; @@ -811,8 +834,23 @@ public class OperDefectServiceImpl extends BaseServiceImpl statisticBySeveralMonth = this.baseMapper.getStatisticBySeveralMonth(firstMonth, dateFormat.format(date), createDeptList); return getRatioStatic(statisticBySeveralMonth); } @@ -822,9 +860,25 @@ public class OperDefectServiceImpl extends BaseServiceImpl list = this.baseMapper.getManageIndex(month, AuthUtil.getDeptId()); + List createDeptList = new ArrayList<>(); + List deptList = new ArrayList<>(); + R> res = sysClient.getDeptByCurrentUser(); + if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { + deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); + } else { + throw new WebServiceException("该用户没有此权限"); + } + if (StringUtil.isNotBlank(deptId)) { + if (deptList.contains(deptId)) { + createDeptList.add(deptId); + } + } else { + //拿到用户当前及其以下的机构 + createDeptList.addAll(deptList); + } + List list = this.baseMapper.getManageIndex(month, createDeptList); manageIndex.setInTimeNum(list.get(0)); if (!list.get(1).equals(0)) { manageIndex.setInTimeRatio(list.get(0).equals(0) ? 0.0 : Double.valueOf(list.get(0)) / list.get(1)); @@ -840,50 +894,67 @@ public class OperDefectServiceImpl extends BaseServiceImpl getRepeatStatistic(String month) { + private List getRepeatStatistic(String deptId) { List re = new ArrayList<>(); - - List repetStatistics = this.baseMapper.getRepetStatistics(AuthUtil.getDeptId()); - //总缺陷数 - int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); - //总重复缺陷数 - int totalRepeat = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); - //等级重复统计 - Map repeatList = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); - - OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); - one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); - if (repeatList.get(one.getDefectLevel()) != null) { - one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); - one.setHappenRatio(one.getHappenNum() / Double.valueOf(total)); - one.setRepeatRatio(one.getHappenNum() / Double.valueOf(totalRepeat)); + List createDeptList = new ArrayList<>(); + List deptList ; + R> res = sysClient.getDeptByCurrentUser(); + if (res.isSuccess() && CollectionUtil.isNotEmpty(res.getData())) { + deptList = res.getData().stream().map(Dept::getId).map(s -> s.toString()).collect(Collectors.toList()); + } else { + throw new WebServiceException("该用户没有此权限"); } - - OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); - two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); - if (repeatList.get(two.getDefectLevel()) != null) { - two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); - two.setHappenRatio(two.getHappenNum() / Double.valueOf(total)); - two.setRepeatRatio(two.getHappenNum() / Double.valueOf(totalRepeat)); + if (StringUtil.isNotBlank(deptId)) { + if (deptList.contains(deptId)) { + createDeptList.add(deptId); + } + } else { + //拿到用户当前及其以下的机构 + createDeptList.addAll(deptList); } + if (CollectionUtil.isNotEmpty(createDeptList)) { + List repetStatistics = this.baseMapper.getRepetStatistics(createDeptList); + //总缺陷数 + int total = repetStatistics.stream().mapToInt(OperDefectStatisticsCodeDTO::getDefectNum).sum(); + //总重复缺陷数 + int totalRepeat = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.summingInt(OperDefectStatisticsCodeDTO::getDefectNum)); + //等级重复统计 + Map repeatList = repetStatistics.stream().filter(s -> s.getDefectNum() > 1 && s.getDefectLevel() != null).collect(Collectors.groupingBy(OperDefectStatisticsCodeDTO::getDefectLevel, Collectors.summarizingInt(OperDefectStatisticsCodeDTO::getDefectNum))); + + OperDefectRepeatRatioDTO one = new OperDefectRepeatRatioDTO(); + one.setDefectLevel(DefectConstant.DefectLevelEnum.ONE.getStatus()); + if (repeatList.get(one.getDefectLevel()) != null) { + one.setHappenNum(repeatList.get(one.getDefectLevel()).getSum()); + one.setHappenRatio(one.getHappenNum() / Double.valueOf(total)); + one.setRepeatRatio(one.getHappenNum() / Double.valueOf(totalRepeat)); + } - OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); - three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); - if (repeatList.get(three.getDefectLevel()) != null) { - three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); - three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); - three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); - } + OperDefectRepeatRatioDTO two = new OperDefectRepeatRatioDTO(); + two.setDefectLevel(DefectConstant.DefectLevelEnum.TWO.getStatus()); + if (repeatList.get(two.getDefectLevel()) != null) { + two.setHappenNum(repeatList.get(two.getDefectLevel()).getSum()); + two.setHappenRatio(two.getHappenNum() / Double.valueOf(total)); + two.setRepeatRatio(two.getHappenNum() / Double.valueOf(totalRepeat)); + } - OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder().defectLevel("合计").happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()).happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()).repeatRatio(1.00).build(); - if (addUp.getHappenNum().equals(0L)) { - addUp.setRepeatRatio(0.0); - } + OperDefectRepeatRatioDTO three = new OperDefectRepeatRatioDTO(); + three.setDefectLevel(DefectConstant.DefectLevelEnum.THREE.getStatus()); + if (repeatList.get(three.getDefectLevel()) != null) { + three.setHappenNum(repeatList.get(three.getDefectLevel()).getSum()); + three.setHappenRatio(three.getHappenNum() / Double.valueOf(total)); + three.setRepeatRatio(three.getHappenNum() / Double.valueOf(totalRepeat)); + } - re.addAll(Arrays.asList(one, two, three, addUp)); + OperDefectRepeatRatioDTO addUp = OperDefectRepeatRatioDTO.builder().defectLevel("合计").happenNum(one.getHappenNum() + two.getHappenNum() + three.getHappenNum()).happenRatio(one.getHappenRatio() + two.getHappenRatio() + three.getHappenRatio()).repeatRatio(1.00).build(); + if (addUp.getHappenNum().equals(0L)) { + addUp.setRepeatRatio(0.0); + } + + re.addAll(Arrays.asList(one, two, three, addUp)); + } return re; } From 652f5ea14fa367f0d307cb9292f2fc6f03e17422 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 27 Dec 2023 16:03:22 +0800 Subject: [PATCH 5/9] =?UTF-8?q?add:=20=E4=BC=9A=E8=AE=AE=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 --- .../hzims/safeproduct/dto/ConferenceExportDTO.java | 59 ++++++++ .../safeproduct/entity/ConferencePlanEntity.java | 60 ++++++++ .../safeproduct/entity/ConferenceRecordEntity.java | 55 +++++++ .../safeproduct/enums/ConferenceMethodEnum.java | 31 ++++ .../safeproduct/enums/ConferenceStatusEnum.java | 31 ++++ .../controller/ConferenceController.java | 133 +++++++++++++++++ .../safeproduct/mapper/ConferencePlanMapper.java | 27 ++++ .../safeproduct/mapper/ConferencePlanMapper.xml | 23 +++ .../safeproduct/mapper/ConferenceRecordMapper.java | 16 +++ .../safeproduct/mapper/ConferenceRecordMapper.xml | 4 + .../service/IConferencePlanService.java | 40 ++++++ .../service/IConferenceRecordService.java | 27 ++++ .../service/impl/ConferencePlanServiceImpl.java | 160 +++++++++++++++++++++ .../service/impl/ConferenceRecordServiceImpl.java | 113 +++++++++++++++ 14 files changed, 779 insertions(+) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/ConferenceMethodEnum.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/ConferenceStatusEnum.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferencePlanService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferenceRecordService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java new file mode 100644 index 0000000..3f3e951 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/ConferenceExportDTO.java @@ -0,0 +1,59 @@ +package com.hnac.hzims.safeproduct.dto; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwen + * @date 2023-12-27 + */ +@Data +@ExcelIgnoreUnannotated +@ApiModel(value = "会议数据导出DTO类") +public class ConferenceExportDTO { + + @ApiModelProperty("单位") + @ExcelProperty(value = "单位", index = 0) + private String unit; + + @ApiModelProperty("会议计划开始时间") + @ExcelProperty(value = "会议计划开始时间", index = 1) + private Date scheduledStartTime; + + @ApiModelProperty("会议计划结束时间") + @ExcelProperty(value = "会议计划结束时间", index = 2) + private Date scheduledEndTime; + + @ApiModelProperty("会议主题") + @ExcelProperty(value = "会议主题", index = 3) + private String theme; + + @ApiModelProperty("会议地点") + @ExcelProperty(value = "会议地点", index = 4) + private String location; + + @ApiModelProperty("会议方式") + @ExcelProperty(value = "会议方式", index = 5) + private String conferenceMethod; + + @ApiModelProperty("主持人") + @ExcelProperty(value = "主持人", index = 6) + private String host; + + @ApiModelProperty("会议实际开始时间") + @ExcelProperty(value = "会议实际开始时间", index = 7) + private Date actualStartTime; + + @ApiModelProperty("会议实际结束时间") + @ExcelProperty(value = "会议实际结束时间", index = 8) + private Date actualEndTime; + + @ApiModelProperty("会议状态") + @ExcelProperty(value = "会议状态", index = 9) + private String conferenceStatus; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java new file mode 100644 index 0000000..a7261a9 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferencePlanEntity.java @@ -0,0 +1,60 @@ +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-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_conference_plan") +@ApiModel(value = "会议计划实体类") +public class ConferencePlanEntity extends BaseEntity { + + @NotNull + @Size(max = 50, message = "单位字段长度不能超过50") + @ApiModelProperty("单位") + private String unit; + + @NotNull + @Size(max = 50, message = "会议主题字段长度不能超过50") + @ApiModelProperty("会议主题") + private String theme; + + @NotNull + @ApiModelProperty("会议计划开始时间") + private Date scheduledStartTime; + + @NotNull + @ApiModelProperty("会议计划结束时间") + private Date scheduledEndTime; + + @NotNull + @Size(max = 255, message = "演练地点字段长度不能超过255") + @ApiModelProperty("会议地点") + private String location; + + @NotNull + @Size(max = 10, message = "总指挥字段长度不能超过10") + @ApiModelProperty("主持人") + private String host; + + @Size(max = 20, message = "会议方式字段长度不能超过20") + @ApiModelProperty("会议方式") + private String conferenceMethod; + + @NotNull + @Size(max = 20, message = "会议状态字段长度不能超过20") + @ApiModelProperty("会议状态") + private String conferenceStatus; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java new file mode 100644 index 0000000..42968dd --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java @@ -0,0 +1,55 @@ +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-27 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_conference_record") +@ApiModel(value = "会议记录实体类") +public class ConferenceRecordEntity extends BaseEntity { + + @ApiModelProperty("会议计划id") + private Long conferencePlanId; + + @Size(max = 50, message = "编码字段长度不能超过50") + @ApiModelProperty("编码") + private String code; + + @Size(max = 5000, message = "参会人员字段长度超出限制范围") + @ApiModelProperty("参会人员") + private String peopleName; + + @ApiModelProperty("会议实际开始时间") + private Date actualStartTime; + + @ApiModelProperty("会议实际结束时间") + private Date actualEndTime; + + @Size(max = 250, message = "记录人字段长度不能超过250") + @ApiModelProperty("记录人") + private String recorder; + + @Size(max = 250, message = "会议内容字段长度不能超过250") + @ApiModelProperty("会议内容") + private String content; + + @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/enums/ConferenceMethodEnum.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/ConferenceMethodEnum.java new file mode 100644 index 0000000..b459dde --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/ConferenceMethodEnum.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.safeproduct.enums; + +/** + * 会议方式枚举类 + * + * @author liwen + * @date 2023-12-27 + */ +public enum ConferenceMethodEnum { + + ONLINE("ONLINE", "线上"), + OFFLINE("OFFLINE", "线下"), + MIXED("MIXED", "线上+线下"); + + private final String value; + + private final String desc; + + ConferenceMethodEnum(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/enums/ConferenceStatusEnum.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/ConferenceStatusEnum.java new file mode 100644 index 0000000..ea68dfc --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/enums/ConferenceStatusEnum.java @@ -0,0 +1,31 @@ +package com.hnac.hzims.safeproduct.enums; + +/** + * 会议状态枚举类 + * + * @author liwen + * @date 2023-12-27 + */ +public enum ConferenceStatusEnum { + + WAITING("WAITING", "未开始"), + UNFINISHED("UNFINISHED", "未完成"), + FINISHED("FINISHED", "已完成"); + + private final String value; + + private final String desc; + + ConferenceStatusEnum(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/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java new file mode 100644 index 0000000..aa12908 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/ConferenceController.java @@ -0,0 +1,133 @@ +package com.hnac.hzims.safeproduct.controller; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; +import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; +import com.hnac.hzims.safeproduct.service.IConferencePlanService; +import com.hnac.hzims.safeproduct.service.IConferenceRecordService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.*; +import springfox.documentation.annotations.ApiIgnore; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.util.Map; + +/** + * 会议管理接口类 + * + * @author liwen + * @date 2023-12-27 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/conference") +@Api(value = "会议管理", tags = "会议管理接口") +public class ConferenceController extends BladeController { + + private final IConferencePlanService conferencePlanService; + + private final IConferenceRecordService conferenceRecordService; + + @PostMapping("/savePlan") + @ApiOperation(value = "新增会议计划") + @ApiOperationSupport(order = 1) + public R savePlan(@Valid @RequestBody ConferencePlanEntity conferencePlan) { + return R.status(conferencePlanService.save(conferencePlan)); + } + + @PostMapping("/updatePlan") + @ApiOperation(value = "修改会议计划") + @ApiOperationSupport(order = 2) + public R updatePlan(@Valid @RequestBody ConferencePlanEntity conferencePlan) { + return R.status(conferencePlanService.updateById(conferencePlan)); + } + + @PostMapping("/removePlan") + @ApiOperation(value = "删除会议计划") + @ApiOperationSupport(order = 3) + public R removePlan(@RequestParam Long id) { + return R.status(conferencePlanService.removePlan(id)); + } + + @GetMapping("/planDetail") + @ApiOperation(value = "会议计划详情") + @ApiOperationSupport(order = 4) + public R planDetail(@RequestParam Long id) { + return R.data(conferencePlanService.getById(id)); + } + + @GetMapping("/planPage") + @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> planPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = conferencePlanService.planPage(param, query); + return R.data(page); + } + + @PostMapping("/saveRecord") + @ApiOperation(value = "新增会议记录") + @ApiOperationSupport(order = 6) + public R saveRecord(@Valid @RequestBody ConferenceRecordEntity conferenceRecord) { + return R.status(conferenceRecordService.saveRecord(conferenceRecord)); + } + + @PostMapping("/updateRecord") + @ApiOperation(value = "修改会议记录") + @ApiOperationSupport(order = 7) + public R updateRecord(@Valid @RequestBody ConferenceRecordEntity conferenceRecord) { + return R.status(conferenceRecordService.updateById(conferenceRecord)); + } + + @PostMapping("/removeRecord") + @ApiOperation(value = "删除会议记录") + @ApiOperationSupport(order = 8) + public R removeRecord(@RequestParam Long id) { + return R.status(conferenceRecordService.removeById(id)); + } + + @GetMapping("/recordDetail") + @ApiOperation(value = "会议记录详情") + @ApiOperationSupport(order = 9) + public R recordDetail(@RequestParam Long id) { + return R.data(conferenceRecordService.getById(id)); + } + + @GetMapping("/recordPage") + @ApiImplicitParams({ + @ApiImplicitParam(name = "conferencePlanId", value = "会议计划id", dataType = "query", paramType = "string") + }) + @ApiOperation(value = "会议记录分页") + @ApiOperationSupport(order = 10) + public R> recordPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = conferenceRecordService.page(Condition.getPage(query), + Condition.getQueryWrapper(param, ConferenceRecordEntity.class)); + return R.data(page); + } + + @GetMapping("/exportConferenceData") + @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 = 11) + public void exportConferenceData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { + conferencePlanService.exportConferenceData(param, response); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.java new file mode 100644 index 0000000..6aab066 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.dto.ConferenceExportDTO; +import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 会议计划Mapper类 + * + * @author liwen + * @date 2023-12-27 + */ +@Mapper +public interface ConferencePlanMapper extends BaseMapper { + + /** + * 根据单位和计划时间查询会议记录 + * @param unit 单位 + * @param startTime 计划开始时间 + * @param endTime 计划结束时间 + * @return 会议记录列表 + */ + List getConferenceByUnitAndDate(String unit, String startTime, String endTime); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml new file mode 100644 index 0000000..841cf7c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.java new file mode 100644 index 0000000..eed6c2c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.java @@ -0,0 +1,16 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 会议记录Mapper类 + * + * @author liwen + * @date 2023-12-27 + */ +@Mapper +public interface ConferenceRecordMapper extends BaseMapper { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.xml new file mode 100644 index 0000000..ccb0eac --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferenceRecordMapper.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferencePlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferencePlanService.java new file mode 100644 index 0000000..2c3581d --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferencePlanService.java @@ -0,0 +1,40 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; +import org.springblade.core.mp.support.Query; + +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + +/** + * 会议计划服务类 + * + * @author liwen + * @date 2023-12-27 + */ +public interface IConferencePlanService extends IService { + + /** + * 删除会议计划 + * @param id 会议计划id + * @return true-成功,false-失败 + */ + boolean removePlan(Long id); + + /** + * 会议计划分页 + * @param param 入参 + * @param query 分页类 + * @return 会议计划数据 + */ + IPage planPage(Map param, Query query); + + /** + * 会议数据导出 + * @param param 入参 + * @param response 响应类 + */ + void exportConferenceData(Map param, HttpServletResponse response); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferenceRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferenceRecordService.java new file mode 100644 index 0000000..b7b867d --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IConferenceRecordService.java @@ -0,0 +1,27 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; + +/** + * 会议记录服务类 + * + * @author liwen + * @date 2023-12-27 + */ +public interface IConferenceRecordService extends IService { + + /** + * 删除关联会议记录 + * @param conferencePlanId 会议计划id + * @return true-成功,false-失败 + */ + boolean removeReferenceRecord(Long conferencePlanId); + + /** + * 新增会议记录 + * @param conferenceRecord 会议记录实体类 + * @return true-成功,false-失败 + */ + boolean saveRecord(ConferenceRecordEntity conferenceRecord); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java new file mode 100644 index 0000000..eb8f3af --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java @@ -0,0 +1,160 @@ +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.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.dto.ConferenceExportDTO; +import com.hnac.hzims.safeproduct.dto.RehearsalExportDTO; +import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; +import com.hnac.hzims.safeproduct.enums.ConferenceMethodEnum; +import com.hnac.hzims.safeproduct.enums.ConferenceStatusEnum; +import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; +import com.hnac.hzims.safeproduct.mapper.ConferencePlanMapper; +import com.hnac.hzims.safeproduct.service.IConferencePlanService; +import com.hnac.hzims.safeproduct.service.IConferenceRecordService; +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 javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.List; +import java.util.Map; + +/** + * 会议计划服务实现类 + * + * @author liwen + * @date 2023-12-27 + */ +@Service +public class ConferencePlanServiceImpl extends ServiceImpl implements IConferencePlanService { + + @Autowired + IConferenceRecordService conferenceRecordService; + + /** + * 删除会议计划 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public boolean removePlan(Long id) { + boolean remove = this.removeById(id); + // 若成功删除会议计划,删除关联的会议记录 + if (remove) { + return conferenceRecordService.removeReferenceRecord(id); + } + return false; + } + + /** + * 会议计划分页 + */ + @Override + public IPage planPage(Map param, Query query) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + String unit = String.valueOf(param.get("unit")); + String startTime = String.valueOf(param.get("startTime")); + String endTime = String.valueOf((param.get("endTime"))); + if (!unit.equals("null") && !unit.equals("")) { + queryWrapper.lambda().eq(ConferencePlanEntity::getUnit, unit); + } + if (!startTime.equals("null") && !startTime.equals("")) { + queryWrapper.lambda().ge(ConferencePlanEntity::getScheduledStartTime, startTime); + } + if (!endTime.equals("null") && !endTime.equals("")) { + queryWrapper.lambda().le(ConferencePlanEntity::getScheduledEndTime, endTime); + } + return this.page(Condition.getPage(query), queryWrapper); + } + + /** + * 会议数据导出 + */ + @Override + public void exportConferenceData(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 conferenceList = getConferenceByUnitAndDate(unit, startTime, endTime); + // 处理会议数据信息 + conferenceList.forEach(conference -> { + // 会议方式 + String method; + if (conference.getConferenceMethod().equals(ConferenceMethodEnum.ONLINE.getValue())) { + method = ConferenceMethodEnum.ONLINE.getDesc(); + } else if (conference.getConferenceMethod().equals(ConferenceMethodEnum.OFFLINE.getValue())) { + method = ConferenceMethodEnum.OFFLINE.getDesc(); + } else { + method = ConferenceMethodEnum.MIXED.getDesc(); + } + conference.setConferenceMethod(method); + // 会议状态 + String status; + if (conference.getConferenceStatus().equals(ConferenceStatusEnum.WAITING.getValue())) { + status = ConferenceStatusEnum.WAITING.getDesc(); + } else if (conference.getConferenceStatus().equals(ConferenceStatusEnum.UNFINISHED.getValue())) { + status = ConferenceStatusEnum.UNFINISHED.getDesc(); + } else { + status = ConferenceStatusEnum.FINISHED.getDesc(); + } + conference.setConferenceStatus(status); + }); + // 设置响应头 + // 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(ConferenceExportDTO.class) + .build(); + excelWriter.write(conferenceList, 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 getConferenceByUnitAndDate(String unit, String startTime, String endTime) { + return baseMapper.getConferenceByUnitAndDate(unit, startTime, endTime); + } +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java new file mode 100644 index 0000000..622683c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferenceRecordServiceImpl.java @@ -0,0 +1,113 @@ +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.entity.ConferencePlanEntity; +import com.hnac.hzims.safeproduct.entity.ConferenceRecordEntity; +import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; +import com.hnac.hzims.safeproduct.mapper.ConferencePlanMapper; +import com.hnac.hzims.safeproduct.mapper.ConferenceRecordMapper; +import com.hnac.hzims.safeproduct.service.IConferenceRecordService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 会议记录服务实现类 + * + * @author liwen + * @date 2023-12-27 + */ +@Service +public class ConferenceRecordServiceImpl extends ServiceImpl implements IConferenceRecordService { + + @Resource + ConferencePlanMapper conferencePlanMapper; + + /** + * 删除关联会议记录 + */ + @Override + public boolean removeReferenceRecord(Long conferencePlanId) { + // 查询关联会议记录 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(ConferenceRecordEntity::getConferencePlanId, conferencePlanId); + List rehearsalRecordList = this.list(queryWrapper); + // 若无关联会议记录,直接返回true + if (CollectionUtils.isEmpty(rehearsalRecordList)) { + return true; + } + // 删除关联会议记录 + List ids = rehearsalRecordList.stream().map(ConferenceRecordEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } + + /** + * 新增会议记录 + */ + @Override + public boolean saveRecord(ConferenceRecordEntity conferenceRecord) { + // 获取当月时间(yyyymm) + String currentMonth = DatePattern.SIMPLE_MONTH_FORMAT.format(new Date()); + // 查询是否存在同月编号 + String lastCode = getLastCode(currentMonth); + // 若不存在,新增编号 + String code; + if (StringUtils.isNull(lastCode)) { + code = "HYJL" + currentMonth + "001"; + } else { // 若存在,编号递增 + String oldNum = lastCode.substring(lastCode.length() - 3); + int value = Integer.parseInt(oldNum) + 1; + // 根据数位拼接编号 + if (value < 10) { + code = "HYJL" + currentMonth + "00" + value; + } else if (value < 100) { + code = "HYJL" + currentMonth + "0" + value; + } else { + code = "HYJL" + currentMonth + value; + } + } + conferenceRecord.setCode(code); + boolean save = this.save(conferenceRecord); + // 若会议记录新增成功,修改会议计划状态为已完成 + if (save) { + ConferencePlanEntity conferencePlanEntity = conferencePlanMapper.selectById(conferenceRecord.getConferencePlanId()); + conferencePlanEntity.setConferenceStatus(RehearsalStatusEnum.FINISHED.getValue()); + return conferencePlanMapper.updateById(conferencePlanEntity) == SafeProductConstant.SUCCESS; + } + return false; + } + + /** + * 查询是否存在同月编号 + * @param currentMonth 当月 + * @return 存在则返回上一编号,否则返回null + */ + private String getLastCode(String currentMonth) { + String month = currentMonth.substring(currentMonth.length() - 2); + List list = getConferenceByMonth(month); + if (CollectionUtils.isEmpty(list)) { + return null; + } + return list.get(0).getCode(); + } + + /** + * 查询当月会议记录 + * @param month 当月 + * @return 当月会议数据表 + */ + public List getConferenceByMonth(String month) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().like(ConferenceRecordEntity::getCreateTime, month) + .orderByDesc(ConferenceRecordEntity::getCode); + return this.list(queryWrapper); + } +} From 6b7680b62fc8c95b13a26473aef2ec8cb7ed9bce Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 27 Dec 2023 16:52:12 +0800 Subject: [PATCH 6/9] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=BC=94=E7=BB=83?= =?UTF-8?q?=E3=80=81=E5=9F=B9=E8=AE=AD=E6=A8=A1=E5=9D=97=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=92=8C=E5=88=86=E9=A1=B5=E5=8A=9F=E8=83=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/mapper/RehearsalPlanMapper.xml | 10 +++++----- .../service/impl/RehearsalPlanServiceImpl.java | 16 ++++++++-------- .../safeproduct/service/impl/TrainPlanServiceImpl.java | 14 ++++++-------- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml index 71519a5..66626be 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml @@ -68,16 +68,16 @@ t2.people_num, t2.actual_start_time, t2.actual_end_time, t1.rehearsal_status FROM hzims_rehearsal_plan t1 - LEFT JOIN hzims_rehearsal_record t2 ON t1.id = t2.rehearsal_record_id + LEFT JOIN hzims_rehearsal_record t2 ON t1.id = t2.rehearsal_plan_id WHERE t1.is_deleted = 0 - - AND t1.unit = #{unit} + + AND t1.unit like #{unit} - + AND t1.scheduled_start_time >= #{startTime} - + AND t1.scheduled_end_time < #{endTime} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java index a3db6d5..647fb1f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/RehearsalPlanServiceImpl.java @@ -181,7 +181,7 @@ public class RehearsalPlanServiceImpl extends ServiceImpl rehearsalPlanPage(Map param, Query query) { QueryWrapper queryWrapper = new QueryWrapper<>(); String unit = String.valueOf(param.get("unit")); - String startTime = String.valueOf(param.get("startTime")); - String endTime = String.valueOf((param.get("endTime"))); - if (unit.equals("null") || unit.equals("")) { - queryWrapper.lambda().eq(RehearsalPlanEntity::getUnit, unit); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf((param.get("scheduledEndTime"))); + if (!unit.equals("null") && !unit.equals("")) { + queryWrapper.lambda().like(RehearsalPlanEntity::getUnit, unit); } - if (startTime.equals("null") || startTime.equals("")) { + if (!startTime.equals("null") && !startTime.equals("")) { queryWrapper.lambda().ge(RehearsalPlanEntity::getScheduledStartTime, startTime); } - if (endTime.equals("null") || endTime.equals("")) { + if (!endTime.equals("null") && !endTime.equals("")) { queryWrapper.lambda().le(RehearsalPlanEntity::getScheduledEndTime, endTime); } return this.page(Condition.getPage(query), 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 index 33aec9e..cba9def 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 @@ -13,9 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.AnalysisYearDTO; -import com.hnac.hzims.safeproduct.entity.RehearsalPlanEntity; import com.hnac.hzims.safeproduct.entity.TrainPlanEntity; -import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.enums.TrainStatusEnum; import com.hnac.hzims.safeproduct.mapper.TrainPlanMapper; import com.hnac.hzims.safeproduct.service.ITestService; @@ -243,15 +241,15 @@ public class TrainPlanServiceImpl extends ServiceImpl trainPlanPage(Map param, Query query) { QueryWrapper queryWrapper = new QueryWrapper<>(); String unit = String.valueOf(param.get("unit")); - String startTime = String.valueOf(param.get("startTime")); - String endTime = String.valueOf((param.get("endTime"))); - if (unit.equals("null") || unit.equals("")) { - queryWrapper.lambda().eq(TrainPlanEntity::getUnit, unit); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf((param.get("scheduledEndTime"))); + if (!unit.equals("null") && !unit.equals("")) { + queryWrapper.lambda().like(TrainPlanEntity::getUnit, unit); } - if (startTime.equals("null") || startTime.equals("")) { + if (!startTime.equals("null") && !startTime.equals("")) { queryWrapper.lambda().ge(TrainPlanEntity::getScheduledStartTime, startTime); } - if (endTime.equals("null") || endTime.equals("")) { + if (!endTime.equals("null") && !endTime.equals("")) { queryWrapper.lambda().le(TrainPlanEntity::getScheduledEndTime, endTime); } return this.page(Condition.getPage(query), queryWrapper); From d3e19ed24699ec3a35e535a26933dd7ff3c5f959 Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Thu, 28 Dec 2023 08:41:54 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=B7=A1=E6=A3=80=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=8C=E6=88=90=E7=8E=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java | 3 +++ .../com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java | 7 +++++++ .../operational/defect/service/impl/OperDefectServiceImpl.java | 1 + 3 files changed, 11 insertions(+) diff --git a/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java b/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java index 788f4cd..adbf9b0 100644 --- a/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java +++ b/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java @@ -36,4 +36,7 @@ public class VoteChartVo { @ApiModelProperty(value = "完成id") @ExcelIgnore private List finishIds; + @ApiModelProperty(value = "完成率") + @ExcelProperty(value = "完成率", index = 3) + private Double finishRate; } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index 16b509d..4da0a75 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -54,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -1162,6 +1163,12 @@ public class TaskServiceImpl extends BaseServiceImpl imp voteChartVo.setFinishIds(finishIds); voteChartVo.setUndoneNum(undoneIds.size()); voteChartVo.setUndoneIds(undoneIds); + if (CollectionUtil.isEmpty(list)||CollectionUtil.isEmpty(undoneIds)){ + voteChartVo.setFinishRate(0.00d); + }else { + BigDecimal divide = new BigDecimal(list.size()).divide(new BigDecimal(list.size()),2,BigDecimal.ROUND_UP); + voteChartVo.setFinishRate( divide.doubleValue()); + } return voteChartVo; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java index 859102e..cdcd04c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectServiceImpl.java @@ -799,6 +799,7 @@ public class OperDefectServiceImpl extends BaseServiceImpl s.toString()).collect(Collectors.toList()); } else { + log.error("getCurrentMonthStatic"+"用户权限问题"); throw new WebServiceException("该用户没有此权限"); } if (StringUtil.isNotBlank(deptId)) { From f169e1c657ce85cb5988101f053f42d5645edcc4 Mon Sep 17 00:00:00 2001 From: liwen Date: Thu, 28 Dec 2023 16:46:50 +0800 Subject: [PATCH 8/9] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E6=BC=94?= =?UTF-8?q?=E7=BB=83&=E5=9F=B9=E8=AE=AD&=E4=BC=9A=E8=AE=AE=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=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 | 2 + .../safeproduct/entity/ConferenceRecordEntity.java | 2 +- .../safeproduct/controller/BaseController.java | 56 ++++++++++++++++++++++ .../safeproduct/controller/TrainController.java | 22 +-------- .../safeproduct/mapper/ConferencePlanMapper.xml | 8 ++-- .../safeproduct/mapper/RehearsalPlanMapper.xml | 2 +- .../service/impl/ConferencePlanServiceImpl.java | 4 +- 7 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/BaseController.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 84ae0c6..bcfb2fb 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,8 @@ package com.hnac.hzims.safeproduct.constants; */ public interface SafeProductConstant { + String TENANT_ID = "200000"; + int SUCCESS = 1; int FAILURE = 0; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java index 42968dd..1aa0309 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/ConferenceRecordEntity.java @@ -37,7 +37,7 @@ public class ConferenceRecordEntity extends BaseEntity { @ApiModelProperty("会议实际结束时间") private Date actualEndTime; - @Size(max = 250, message = "记录人字段长度不能超过250") + @Size(max = 20, message = "记录人字段长度不能超过20") @ApiModelProperty("记录人") private String recorder; diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/BaseController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/BaseController.java new file mode 100644 index 0000000..a920746 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/BaseController.java @@ -0,0 +1,56 @@ +package com.hnac.hzims.safeproduct.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.safeproduct.constants.SafeProductConstant; +import io.swagger.annotations.Api; +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.secure.BladeUser; +import org.springblade.core.tool.api.R; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * 公用业务接口类 + * + * @author liwen + * @date 2023-12-28 + */ +@RestController +@AllArgsConstructor +@RequestMapping("/base") +@Api(value = "公用业务", tags = "公用业务接口") +public class BaseController extends BladeController { + + private final ISysClient sysClient; + + private final IUserClient userClient; + + @GetMapping("/getDeptName") + @ApiOperation(value = "获取所属机构名") + @ApiOperationSupport(order = 1) + 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("/getUserList") + @ApiOperation(value = "获取用户列表") + @ApiOperationSupport(order = 2) + public R> getUserList(@RequestParam String name) { + return userClient.userListByCodeAndNameAndAccount(SafeProductConstant.TENANT_ID, null, name, null); + } +} 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 92d703c..d306a47 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 @@ -21,12 +21,9 @@ 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; @@ -55,8 +52,6 @@ public class TrainController extends BladeController { private final ITestScoreService testScoreService; - private final ISysClient sysClient; - @PostMapping("/saveTrainPlan") @ApiOperation(value = "新增培训计划") @ApiOperationSupport(order = 1) @@ -224,18 +219,6 @@ public class TrainController extends BladeController { 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"), @@ -243,7 +226,7 @@ public class TrainController extends BladeController { @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训计划数据导出") - @ApiOperationSupport(order = 23) + @ApiOperationSupport(order = 22) public void exportTrainPlanData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { trainPlanService.exportTrainPlanData(param, response); } @@ -253,9 +236,8 @@ public class TrainController extends BladeController { @ApiImplicitParam(name = "trainPlanId", value = "培训计划id", dataType = "query", paramType = "string") }) @ApiOperation(value = "培训记录数据导出") - @ApiOperationSupport(order = 24) + @ApiOperationSupport(order = 23) 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/ConferencePlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml index 841cf7c..c71d0dc 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/ConferencePlanMapper.xml @@ -10,13 +10,13 @@ LEFT JOIN hzims_conference_record t2 ON t1.id = t2.conference_plan_id WHERE t1.is_deleted = 0 - - AND t1.unit = #{unit} + + AND t1.unit like concat('%', #{unit}, '%') - + AND t1.scheduled_start_time >= #{startTime} - + AND t1.scheduled_end_time < #{endTime} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml index 66626be..e3f1b14 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/RehearsalPlanMapper.xml @@ -72,7 +72,7 @@ WHERE t1.is_deleted = 0 - AND t1.unit like #{unit} + AND t1.unit like concat('%', #{unit}, '%') AND t1.scheduled_start_time >= #{startTime} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java index eb8f3af..2d742ce 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/ConferencePlanServiceImpl.java @@ -10,11 +10,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.hnac.hzims.common.utils.Condition; import com.hnac.hzims.safeproduct.dto.ConferenceExportDTO; -import com.hnac.hzims.safeproduct.dto.RehearsalExportDTO; import com.hnac.hzims.safeproduct.entity.ConferencePlanEntity; import com.hnac.hzims.safeproduct.enums.ConferenceMethodEnum; import com.hnac.hzims.safeproduct.enums.ConferenceStatusEnum; -import com.hnac.hzims.safeproduct.enums.RehearsalStatusEnum; import com.hnac.hzims.safeproduct.mapper.ConferencePlanMapper; import com.hnac.hzims.safeproduct.service.IConferencePlanService; import com.hnac.hzims.safeproduct.service.IConferenceRecordService; @@ -67,7 +65,7 @@ public class ConferencePlanServiceImpl extends ServiceImpl Date: Thu, 28 Dec 2023 20:11:45 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E8=AF=81=E4=B9=A6=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=8A=E8=AF=81=E4=B9=A6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=88=B0=E6=9C=9F=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/basic/entity/CertificatetEntity.java | 12 +- .../basic/entity/CertificatetNoticeEntity.java | 44 +++++++ .../com/hnac/hzims/basic/vo/PersonManagemetVo.java | 5 - .../operational/main/constant/MainConstants.java | 1 + .../com/hnac/hzims/message/MessageConstants.java | 1 + .../controller/CertificatetNoticeController.java | 63 +++++++++ .../basic/mapper/CertificatetNoticeMapper.java | 15 +++ .../basic/mapper/CertificatetNoticeMapper.xml | 6 + .../hzims/basic/mapper/PersonManagemetMapper.xml | 7 +- .../service/IImsCertificatetNoticeService.java | 13 ++ .../impl/CertificatetNoticeServiceImpl.java | 20 +++ hzims-service/hzims-scheduled/pom.xml | 4 + .../scheduled/mapper/basic/CertificatetMapper.java | 15 +++ .../scheduled/mapper/basic/CertificatetMapper.xml | 6 + .../mapper/basic/CertificatetNoticeMapper.java | 15 +++ .../mapper/basic/CertificatetNoticeMapper.xml | 6 + .../mapper/basic/PersonManagemetMapper.java | 29 +++++ .../mapper/basic/PersonManagemetMapper.xml | 97 ++++++++++++++ .../scheduled/scheduled/basicScheduledTask.java | 141 +++++++++++++++++++++ .../basic/IImsCertificatetNoticeService.java | 13 ++ .../service/basic/IImsCertificatetService.java | 13 ++ .../basic/impl/CertificatetNoticeServiceImpl.java | 21 +++ .../basic/impl/CertificatetServiceImpl.java | 21 +++ 23 files changed, 556 insertions(+), 12 deletions(-) create mode 100644 hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetNoticeEntity.java create mode 100644 hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/CertificatetNoticeController.java create mode 100644 hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.java create mode 100644 hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.xml create mode 100644 hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/IImsCertificatetNoticeService.java create mode 100644 hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/impl/CertificatetNoticeServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.xml create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/basicScheduledTask.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetNoticeService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetService.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetNoticeServiceImpl.java create mode 100644 hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetServiceImpl.java diff --git a/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetEntity.java b/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetEntity.java index 79b29ce..be0f26a 100644 --- a/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetEntity.java +++ b/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetEntity.java @@ -1,6 +1,7 @@ package com.hnac.hzims.basic.entity; import com.baomidou.mybatisplus.annotation.SqlCondition; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; @@ -21,7 +22,7 @@ import java.util.Date; @Data @TableName("hzims_certificatet") @EqualsAndHashCode(callSuper = true) -@ApiModel(value = "档案管理表", description = "档案管理表") +@ApiModel(value = "证书管理表", description = "证书管理表") public class CertificatetEntity extends TenantEntity { private static final long serialVersionUID = 1L; @@ -35,7 +36,7 @@ public class CertificatetEntity extends TenantEntity { /** * 档案类型 */ - @ApiModelProperty(value = "档案类型") + @ApiModelProperty(value = "证书类型") @QueryField(condition = SqlCondition.LIKE) private String type; /** @@ -54,6 +55,11 @@ public class CertificatetEntity extends TenantEntity { */ @ApiModelProperty(value = "图片地址") private String pic; - + /** + * 是否过期 + */ + @TableField(exist = false) + @ApiModelProperty(value = "是否过期") + private String isDead; } diff --git a/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetNoticeEntity.java b/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetNoticeEntity.java new file mode 100644 index 0000000..056acc8 --- /dev/null +++ b/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/entity/CertificatetNoticeEntity.java @@ -0,0 +1,44 @@ +package com.hnac.hzims.basic.entity; + +import com.baomidou.mybatisplus.annotation.SqlCondition; +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.support.QueryField; +import org.springblade.core.tenant.mp.TenantEntity; + + + +/** + * 实体类 + * @author Chill + */ +@Data +@TableName("hzims_certificatet_notice") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "证书通知配置表", description = "证书通知配置表") +public class CertificatetNoticeEntity extends TenantEntity { + + private static final long serialVersionUID = 1L; + + /** + * 通知类型 + */ + @ApiModelProperty(value = "通知类型") + @QueryField(condition = SqlCondition.EQUAL) + private String sendType; + /** + * 距离过期前几天通知 + */ + @ApiModelProperty(value = "距离过期前几天通知") + @QueryField(condition = SqlCondition.EQUAL) + private Integer safeTime; + /** + * 通知用户 + */ + @ApiModelProperty(value = "通知用户") + @QueryField(condition = SqlCondition.LIKE) + private String noticeUsers; +} diff --git a/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/vo/PersonManagemetVo.java b/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/vo/PersonManagemetVo.java index ef5fdef..6a32ae0 100644 --- a/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/vo/PersonManagemetVo.java +++ b/hzims-service-api/basic-api/src/main/java/com/hnac/hzims/basic/vo/PersonManagemetVo.java @@ -62,11 +62,6 @@ public class PersonManagemetVo extends PersonManagemetEntity { ) @ApiModelProperty(value = "到期时间") private Date deadTime; - /** - * 图片地址 - */ - @ApiModelProperty(value = "图片地址") - private String pic; /** * 档案编号 diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java index 1edaf29..5e1572d 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/main/constant/MainConstants.java @@ -87,6 +87,7 @@ public interface MainConstants { String LOAD_PHOTOVOLTAIC_REAL = "loadPhotovoltaicReal"; String DUTY_NOTICE = "dutyNotice"; + String CERTIFICATET_DEAD_LINE_NOTICE = "certificatetDeadLineNotice"; String PROJECT_MANAGER = "projectManager"; diff --git a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java index 0f0f9a1..86b931f 100644 --- a/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java +++ b/hzims-service-api/message-api/src/main/java/com/hnac/hzims/message/MessageConstants.java @@ -60,6 +60,7 @@ public class MessageConstants { OPERATIONTICKETMESSAGE("operation-ticket-message","操作票消息"), ROUTINEMAINTENANCE("operation-maintenance-message","日常维护消息"), OPERATIONDEFECTMESSAGE("operation-defect-message","消缺消息"), + CERTIFICATETNOTICE("certificatet-notice-message","证书消息"), OVERHAUL_PLAN("overhaul-plan","检修计划"), diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/CertificatetNoticeController.java b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/CertificatetNoticeController.java new file mode 100644 index 0000000..90cd677 --- /dev/null +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/controller/CertificatetNoticeController.java @@ -0,0 +1,63 @@ +package com.hnac.hzims.basic.controller; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; +import com.hnac.hzims.basic.service.IImsCertificatetNoticeService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springframework.web.bind.annotation.*; + + +/** + * 控制器 + * + * @author Chill + */ +@RestController +@AllArgsConstructor +@RequestMapping("/certificatetNotice") +@Api(value = "档案通知配置页面", tags = "档案通知配置页面") +public class CertificatetNoticeController extends BladeController { + + + private final IImsCertificatetNoticeService iImsCertificatetNoticeService; + + + /** + * 新增或修改 + */ + @PostMapping("/submit") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "增加", notes = "传入imsDutyClass") + public R submit(@RequestBody CertificatetNoticeEntity certificatetNoticeEntity) { + Boolean submit = iImsCertificatetNoticeService.saveOrUpdate(certificatetNoticeEntity); + if (submit) { + return R.success("保存成功"); + } + return R.fail("保存失败"); + + } + + /** + * 新增或修改 + */ + @PostMapping("/getCertificatetNotice") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "增加", notes = "传入imsDutyClass") + public R getCertificatetNotice() { + CertificatetNoticeEntity res = iImsCertificatetNoticeService.getOne(Wrappers.lambdaQuery() + .eq(CertificatetNoticeEntity::getIsDeleted, 0) + .last("limit 1;")); + if (ObjectUtil.isNotEmpty(res)) { + return R.data(res); + } + return R.data(""); + + } + +} diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.java b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.java new file mode 100644 index 0000000..fb767da --- /dev/null +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.basic.mapper; + +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * Mapper 接口 + * + * @author Chill + */ +@Mapper +public interface CertificatetNoticeMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.xml b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.xml new file mode 100644 index 0000000..e75a8ab --- /dev/null +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/CertificatetNoticeMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml index 3a4091e..da2837d 100644 --- a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/mapper/PersonManagemetMapper.xml @@ -20,13 +20,15 @@ + diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/IImsCertificatetNoticeService.java b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/IImsCertificatetNoticeService.java new file mode 100644 index 0000000..121419a --- /dev/null +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/IImsCertificatetNoticeService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.basic.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; + +/** + * 服务类 + * + * @author Chill + */ +public interface IImsCertificatetNoticeService extends IService { +} diff --git a/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/impl/CertificatetNoticeServiceImpl.java b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/impl/CertificatetNoticeServiceImpl.java new file mode 100644 index 0000000..d31c2f2 --- /dev/null +++ b/hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/service/impl/CertificatetNoticeServiceImpl.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.basic.service.impl; + +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; +import com.hnac.hzims.basic.mapper.CertificatetNoticeMapper; +import com.hnac.hzims.basic.service.IImsCertificatetNoticeService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + + +/** + * 证书实现类 + * @author ty + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class CertificatetNoticeServiceImpl extends BaseServiceImpl implements IImsCertificatetNoticeService { +} diff --git a/hzims-service/hzims-scheduled/pom.xml b/hzims-service/hzims-scheduled/pom.xml index 3e004f3..f28251e 100644 --- a/hzims-service/hzims-scheduled/pom.xml +++ b/hzims-service/hzims-scheduled/pom.xml @@ -167,6 +167,10 @@ weather-api + com.hnac.hzims + basic-api + + com.alibaba fastjson diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.java new file mode 100644 index 0000000..40f4273 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.mapper.basic; + +import com.hnac.hzims.basic.entity.CertificatetEntity; +import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * Mapper 接口 + * + * @author Chill + */ +@Mapper +public interface CertificatetMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.xml b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.xml new file mode 100644 index 0000000..6941d55 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.java new file mode 100644 index 0000000..a2286ae --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.scheduled.mapper.basic; + +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +/** + * Mapper 接口 + * + * @author Chill + */ +@Mapper +public interface CertificatetNoticeMapper extends UserDataScopeBaseMapper { + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.xml b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.xml new file mode 100644 index 0000000..c951079 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/CertificatetNoticeMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.java new file mode 100644 index 0000000..b44102a --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.scheduled.mapper.basic; + +import com.hnac.hzims.basic.entity.PersonManagemetEntity; +import com.hnac.hzims.basic.vo.PersonManagemetVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springblade.core.datascope.mapper.UserDataScopeBaseMapper; + +import java.util.Date; +import java.util.List; + +/** + * Mapper 接口 + * + * @author Chill + */ +@Mapper +public interface PersonManagemetMapper extends UserDataScopeBaseMapper { + + List getPersonManagemetEntity( + @Param(value = "type")String type, @Param(value = "deadStartTime") Date deadStartTime, @Param(value = "deadTime")Date deadTime, + @Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job, + @Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status, @Param(value = "current")Integer current, @Param(value = "size")Integer size) ; + Integer getCountByPersonManagemetEntity( + @Param(value = "type")String type, @Param(value = "deadStartTime") Date deadStartTime, @Param(value = "deadTime")Date deadTime, + @Param(value = "name")String name, @Param(value = "unitName")String unitName, @Param(value = "sex")String sex, @Param(value = "job")String job, + @Param(value = "academicTitle")String academicTitle, @Param(value = "status")Integer status, @Param(value = "current")Integer current, @Param(value = "size")Integer size) ; + +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.xml b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.xml new file mode 100644 index 0000000..409cbfb --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/mapper/basic/PersonManagemetMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/basicScheduledTask.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/basicScheduledTask.java new file mode 100644 index 0000000..9b72730 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/basicScheduledTask.java @@ -0,0 +1,141 @@ +package com.hnac.hzims.scheduled.scheduled; + +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.hnac.hzims.basic.entity.CertificatetEntity; +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; +import com.hnac.hzims.basic.entity.PersonManagemetEntity; +import com.hnac.hzims.message.MessageConstants; +import com.hnac.hzims.message.dto.BusinessMessageDTO; +import com.hnac.hzims.message.entity.config.SmsConfigEntity; +import com.hnac.hzims.message.fegin.IMessageClient; +import com.hnac.hzims.message.fegin.IMessageConfigClient; +import com.hnac.hzims.scheduled.mapper.basic.PersonManagemetMapper; +import com.hnac.hzims.scheduled.service.basic.IImsCertificatetNoticeService; +import com.hnac.hzims.scheduled.service.basic.IImsCertificatetService; +import com.xxl.job.core.biz.model.ReturnT; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; +import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.cache.UserCache; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +import static com.hnac.hzims.operational.main.constant.MainConstants.*; + + +/** + * 排班到期定时任务通知 + * + * @author ty + */ +@Slf4j +@Component +public class basicScheduledTask { + + @Autowired + private IImsCertificatetService iImsCertificatetService; + @Autowired + private IImsCertificatetNoticeService iImsCertificatetNoticeService; + @Autowired + private ISysClient sysClient; + @Autowired + private IUserClient userClient; + @Autowired + private IMessageClient messageClient; + @Autowired + private PersonManagemetMapper personManagemetMapper; + @Autowired + private IMessageConfigClient messageConfigClient; + + /** + * realId刷新 + */ + @XxlJob(CERTIFICATET_DEAD_LINE_NOTICE) +// @Scheduled(cron = "0 */1 * * * ? ") + public ReturnT certificatetDeadLineNotice(String param) throws ParseException { + Date endTime = new Date(); + if (Func.isBlank(param)) { + endTime = new SimpleDateFormat("yyyy-MM-dd").parse(param); + } + CertificatetNoticeEntity noticeEntity = iImsCertificatetNoticeService.getOne(Wrappers.lambdaQuery() + .eq(CertificatetNoticeEntity::getIsDeleted, 0) + .last("limit 1;")); + //用户档案过期截止时间 + Date date = DateUtil.plusDays(endTime, noticeEntity.getSafeTime()); + List list = iImsCertificatetService.list(Wrappers.lambdaQuery() + .le(CertificatetEntity::getDeadTime, date)); + String noticeUsers = noticeEntity.getNoticeUsers(); + List userList = Arrays.asList(noticeUsers.split(",")); + if (CollectionUtil.isNotEmpty(userList) && CollectionUtil.isNotEmpty(list)) { + List personIds = list.stream().map(CertificatetEntity::getPersonId).collect(Collectors.toList()); + List personManagemetEntities = personManagemetMapper.selectList(Wrappers.query().lambda().in(PersonManagemetEntity::getId, personIds)); + String personNotice=""; + if (CollectionUtil.isNotEmpty(personManagemetEntities)) { + personNotice = personManagemetEntities.stream().map(PersonManagemetEntity::getName).collect(Collectors.joining(",")); + } + if ("1".equals(noticeEntity.getSendType())) { + sendSmsByUserList(userList, date,personNotice); + } + sendMessage(list.get(0), noticeEntity.getSafeTime(), noticeEntity.getNoticeUsers(),personNotice); + } + return new ReturnT<>("SUCCESS"); + } + + private void sendSmsByUserList(List userList, Date date,String personNotice) { + //区分用户 + for (String s : userList) { + User user = UserCache.getUser(Long.valueOf(s)); + String phone = ""; + if (ObjectUtil.isNotEmpty(user)) { + phone = user.getPhone(); + } + //短信推送 + String code = "certificatetNotice"; + SmsConfigEntity smsConfigEntity = messageConfigClient.getSmsConfigByBusinessKey(code); + Map contentParams = new HashMap<>(2); + contentParams.put("one", personNotice); + String deadLine = DateUtil.format(date, "yyyy-MM-dd"); + contentParams.put("two", deadLine); + smsConfigEntity.setTemplateParam(JSONObject.toJSONString(contentParams)); + smsConfigEntity.setPhones(phone); + messageConfigClient.pushSmsMessageByConfig(smsConfigEntity); + } + } + + private void sendMessage(CertificatetEntity certificatetEntity, Integer date, String users,String personNotice) { +// //注意:通知人是创建人所在机构 + BusinessMessageDTO message = new BusinessMessageDTO(); + message.setBusinessClassify("system"); + message.setBusinessKey(MessageConstants.BusinessClassifyEnum.CERTIFICATETNOTICE.getKey()); + message.setSubject(MessageConstants.BusinessClassifyEnum.CERTIFICATETNOTICE.getDescription()); + message.setTaskId(System.currentTimeMillis()); + message.setTenantId("200000"); + String countent = + personNotice + "的证书即将到期,请提交新的证书资料"; + message.setContent(countent); + message.setDeptId(certificatetEntity.getCreateDept()); + R deptName = sysClient.getDeptName(certificatetEntity.getCreateDept()); + if (deptName.isSuccess()) { + message.setDeptName(deptName.getData()); + } + message.setUserIds(users); + User admin = userClient.userByAccount("200000", "admin").getData(); + message.setCreateUser(admin.getId()); + messageClient.sendAppAndWsMsgByUsers(message); + } + + +} \ No newline at end of file diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetNoticeService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetNoticeService.java new file mode 100644 index 0000000..4b3503b --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetNoticeService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.service.basic; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; + +/** + * 服务类 + * + * @author Chill + */ +public interface IImsCertificatetNoticeService extends IService { +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetService.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetService.java new file mode 100644 index 0000000..bba5428 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/IImsCertificatetService.java @@ -0,0 +1,13 @@ +package com.hnac.hzims.scheduled.service.basic; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.basic.entity.CertificatetEntity; + +/** + * 服务类 + * + * @author Chill + */ +public interface IImsCertificatetService extends IService { +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetNoticeServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetNoticeServiceImpl.java new file mode 100644 index 0000000..b4e956d --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetNoticeServiceImpl.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.basic.impl; + +import com.hnac.hzims.basic.entity.CertificatetNoticeEntity; +import com.hnac.hzims.scheduled.mapper.basic.CertificatetNoticeMapper; +import com.hnac.hzims.scheduled.service.basic.IImsCertificatetNoticeService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + + +/** + * 证书实现类 + * @author ty + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class CertificatetNoticeServiceImpl extends BaseServiceImpl implements IImsCertificatetNoticeService { +} diff --git a/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetServiceImpl.java b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetServiceImpl.java new file mode 100644 index 0000000..8849e80 --- /dev/null +++ b/hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/basic/impl/CertificatetServiceImpl.java @@ -0,0 +1,21 @@ +package com.hnac.hzims.scheduled.service.basic.impl; + +import com.hnac.hzims.basic.entity.CertificatetEntity; +import com.hnac.hzims.scheduled.mapper.basic.CertificatetMapper; +import com.hnac.hzims.scheduled.service.basic.IImsCertificatetService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + + + +/** + * 证书实现类 + * @author ty + */ +@Service +@Slf4j +@RequiredArgsConstructor +public class CertificatetServiceImpl extends BaseServiceImpl implements IImsCertificatetService { +}