From 652f5ea14fa367f0d307cb9292f2fc6f03e17422 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 27 Dec 2023 16:03:22 +0800 Subject: [PATCH] =?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); + } +}