From fd587bcf18d1ef0ec1e17a128bc118dbeeb9d2c9 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 3 Jan 2024 13:41:24 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E5=8D=AB=E7=94=9F=E8=87=AA=E6=9F=A5?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E9=80=BB=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hzims/safeproduct/dto/HygieneExportDTO.java | 21 --- .../hnac/hzims/safeproduct/dto/HygienePlanDTO.java | 42 +++++ .../hzims/safeproduct/dto/HygieneRecordDTO.java | 58 ++++++ .../safeproduct/entity/HygienePlanEntity.java | 18 +- .../safeproduct/entity/HygieneRecordEntity.java | 12 +- .../safeproduct/entity/HygieneZoneEntity.java | 34 ++++ .../hnac/hzims/safeproduct/vo/HygieneMonthVO.java | 8 + .../hzims/safeproduct/vo/HygienePlanDetailVO.java | 39 ++++ .../safeproduct/vo/HygieneRecordDetailVO.java | 31 +-- .../hzims/safeproduct/vo/HygieneRecordPageVO.java | 34 ++++ .../hzims/safeproduct/vo/HygieneZoneDetailVO.java | 41 ++++ .../safeproduct/controller/HygieneController.java | 55 +++--- .../safeproduct/mapper/HygienePlanMapper.java | 17 +- .../hzims/safeproduct/mapper/HygienePlanMapper.xml | 26 +-- .../safeproduct/mapper/HygieneRecordMapper.java | 12 ++ .../safeproduct/mapper/HygieneRecordMapper.xml | 23 ++- .../safeproduct/mapper/HygieneZoneMapper.java | 10 + .../hzims/safeproduct/mapper/HygieneZoneMapper.xml | 4 + .../safeproduct/service/IHygienePlanService.java | 33 +++- .../safeproduct/service/IHygieneRecordService.java | 32 +++- .../safeproduct/service/IHygieneZoneService.java | 23 +++ .../service/impl/HygienePlanServiceImpl.java | 207 +++++++++++++-------- .../service/impl/HygieneRecordServiceImpl.java | 148 ++++++++++++--- .../service/impl/HygieneZoneServiceImpl.java | 42 +++++ .../safeproduct/src/main/resources/db/1.0.1.sql | 31 ++- 25 files changed, 760 insertions(+), 241 deletions(-) delete mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneExportDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygienePlanDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneRecordDTO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneZoneEntity.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygienePlanDetailVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordPageVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneZoneDetailVO.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.xml create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java create mode 100644 hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneExportDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneExportDTO.java deleted file mode 100644 index 4e8298e..0000000 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneExportDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -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; - -/** - * @author liwen - * @date 2023-12-27 - */ -@Data -@ExcelIgnoreUnannotated -@ApiModel(value = "卫生自查数据导出DTO类") -public class HygieneExportDTO { - - @ApiModelProperty("卫生自查状态") - @ExcelProperty(value = "卫生自查状态", index = 8) - private String hygieneStatus; -} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygienePlanDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygienePlanDTO.java new file mode 100644 index 0000000..9332d2f --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygienePlanDTO.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.safeproduct.dto; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; +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 java.util.Date; +import java.util.List; + +/** + * @author liwen + * @date 2024-01-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "卫生自查计划DTO类") +public class HygienePlanDTO extends BaseEntity { + + @ApiModelProperty("编码") + private String code; + + @ApiModelProperty("标准总分值") + private Integer standardScore; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划开始时间") + private Date scheduledStartTime; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划结束时间") + private Date scheduledEndTime; + + @ApiModelProperty("责任区数据列表") + private List zoneList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneRecordDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneRecordDTO.java new file mode 100644 index 0000000..442e76b --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/dto/HygieneRecordDTO.java @@ -0,0 +1,58 @@ +package com.hnac.hzims.safeproduct.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.mp.base.BaseEntity; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; + +/** + * @author liwen + * @date 2024-01-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "卫生自查记录DTO类") +public class HygieneRecordDTO extends BaseEntity { + + @ApiModelProperty("卫生自查计划id") + private Long hygienePlanId; + + @NotNull + @Size(max = 50, message = "单位字段长度不能超过50") + @ApiModelProperty("单位") + private String unit; + + @Size(max = 50, message = "编码字段长度不能超过50") + @ApiModelProperty("编码") + private String code; + + @ApiModelProperty("实际开始时间") + private Date actualStartTime; + + @ApiModelProperty("实际结束时间") + private Date actualEndTime; + + @ApiModelProperty("检查人") + private String checkUser; + + @ApiModelProperty("责任区id") + private String hygieneZoneIds; + + @ApiModelProperty("检查结果") + private String checkResult; + + @ApiModelProperty("综合评分") + private String comprehensiveScore; + + @ApiModelProperty("周数") + private Integer weekNum; + + @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/HygienePlanEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygienePlanEntity.java index 84d558f..0379406 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygienePlanEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygienePlanEntity.java @@ -22,22 +22,8 @@ import java.util.Date; @ApiModel(value = "卫生自查计划实体类") public class HygienePlanEntity extends BaseEntity { - @NotNull - @Size(max = 50, message = "单位字段长度不能超过50") - @ApiModelProperty("单位") - private String unit; - - @ApiModelProperty("责任区") - private String zone; - - @ApiModelProperty("责任人") - private String principal; - - @ApiModelProperty("检查项") - private String checkItem; - - @ApiModelProperty("检查项分值") - private String checkItemScore; + @ApiModelProperty("编码") + private String code; @ApiModelProperty("标准总分值") private Integer standardScore; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java index 9122e7e..25d7842 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneRecordEntity.java @@ -7,6 +7,7 @@ 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; @@ -23,6 +24,11 @@ public class HygieneRecordEntity extends BaseEntity { @ApiModelProperty("卫生自查计划id") private Long hygienePlanId; + @NotNull + @Size(max = 50, message = "单位字段长度不能超过50") + @ApiModelProperty("单位") + private String unit; + @Size(max = 50, message = "编码字段长度不能超过50") @ApiModelProperty("编码") private String code; @@ -36,11 +42,15 @@ public class HygieneRecordEntity extends BaseEntity { @ApiModelProperty("检查人") private String checkUser; + @ApiModelProperty("责任区id") + private String hygieneZoneIds; + @ApiModelProperty("检查结果") private String checkResult; + @NotNull @ApiModelProperty("综合评分") - private Integer comprehensiveScore; + private String comprehensiveScore; @ApiModelProperty("周数") private Integer weekNum; diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneZoneEntity.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneZoneEntity.java new file mode 100644 index 0000000..415e47b --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/HygieneZoneEntity.java @@ -0,0 +1,34 @@ +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; + +/** + * @author liwen + * @date 2024-01-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("hzims_hygiene_zone") +@ApiModel(value = "卫生自查区域实体类") +public class HygieneZoneEntity extends BaseEntity { + + @ApiModelProperty("卫生自查计划id") + private Long hygienePlanId; + + @ApiModelProperty("责任区") + private String zone; + + @ApiModelProperty("责任人") + private String principal; + + @ApiModelProperty("检查项") + private String checkItem; + + @ApiModelProperty("检查项分值") + private String checkItemScore; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneMonthVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneMonthVO.java index 62b1c2b..8fdd1cc 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneMonthVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneMonthVO.java @@ -1,5 +1,7 @@ package com.hnac.hzims.safeproduct.vo; +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; @@ -11,21 +13,27 @@ import java.math.BigDecimal; * @date 2023-12-27 */ @Data +@ExcelIgnoreUnannotated @ApiModel(value = "卫生自查月度统计VO类") public class HygieneMonthVO { @ApiModelProperty("单位") + @ExcelProperty(value = "单位", index = 0) private String unit; @ApiModelProperty("应检查次数") + @ExcelProperty(value = "应检查次数", index = 1) private Long scheduledCheckNum; @ApiModelProperty("已检查次数") + @ExcelProperty(value = "已检查次数", index = 2) private Long finishedCheckNum; @ApiModelProperty("未检查次数") + @ExcelProperty(value = "未检查次数", index = 3) private Long unfinishedCheckNum; @ApiModelProperty("完成率") + @ExcelProperty(value = "完成率/%", index = 4) private BigDecimal completionRate; } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygienePlanDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygienePlanDetailVO.java new file mode 100644 index 0000000..a41e72e --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygienePlanDetailVO.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.safeproduct.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; +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 java.util.Date; +import java.util.List; + +/** + * @author liwen + * @date 2024-01-02 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "卫生自查计划详情VO类") +public class HygienePlanDetailVO extends BaseEntity { + + @ApiModelProperty("标准总分值") + private Integer standardScore; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划开始时间") + private Date scheduledStartTime; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd") + @ApiModelProperty("计划结束时间") + private Date scheduledEndTime; + + @ApiModelProperty("责任区数据列表") + private List zoneList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java index 341b402..da9328f 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordDetailVO.java @@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.util.Date; +import java.util.List; /** * @author liwen @@ -14,33 +15,33 @@ import java.util.Date; @ApiModel(value = "卫生自查记录详情VO类") public class HygieneRecordDetailVO { - @ApiModelProperty("责任区") - private String zone; - - @ApiModelProperty("责任人") - private String principal; - - @ApiModelProperty("检查项") - private String checkItem; - - @ApiModelProperty("检查项分值") - private String checkItemScore; - @ApiModelProperty("编码") private String code; - @ApiModelProperty("检查时间") - private Date checkTime; + @ApiModelProperty("实际结束时间") + private Date actualEndTime; @ApiModelProperty("检查人") private String checkUser; + @ApiModelProperty("责任区id") + private String hygieneZoneIds; + @ApiModelProperty("检查结果") private String checkResult; @ApiModelProperty("综合评分") - private Integer comprehensiveScore; + private String comprehensiveScore; @ApiModelProperty("周数") private Integer weekNum; + + @ApiModelProperty("检查图片") + private String imgPath; + + @ApiModelProperty("卫生自查计划id") + private Long hygienePlanId; + + @ApiModelProperty("检查信息列表") + private List checkList; } diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordPageVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordPageVO.java new file mode 100644 index 0000000..9cc2f9a --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneRecordPageVO.java @@ -0,0 +1,34 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +/** + * @author liwen + * @date 2024-01-03 + */ +@Data +@ApiModel(value = "卫生自查记录页面VO类") +public class HygieneRecordPageVO { + + @ApiModelProperty("卫生自查记录id") + private Long id; + + @ApiModelProperty("单位") + private String unit; + + @ApiModelProperty("实际开始时间") + private Date actualStartTime; + + @ApiModelProperty("实际结束时间") + private Date actualEndTime; + + @ApiModelProperty("检查人") + private String checkUser; + + @ApiModelProperty("周数") + private Integer weekNum; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneZoneDetailVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneZoneDetailVO.java new file mode 100644 index 0000000..a2b8574 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneZoneDetailVO.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.safeproduct.vo; + +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; + +/** + * @author liwen + * @date 2024-01-02 + */ +@Data +@ExcelIgnoreUnannotated +@ApiModel(value = "卫生自查详情VO类") +public class HygieneZoneDetailVO { + + @ApiModelProperty("责任区") + @ExcelProperty(value = "责任区", index = 0) + private String zone; + + @ApiModelProperty("责任人") + @ExcelProperty(value = "责任人", index = 1) + private String principal; + + @ApiModelProperty("检查项") + @ExcelProperty(value = "检查项", index = 2) + private String checkItem; + + @ApiModelProperty("检查项分值") + @ExcelProperty(value = "检查项分值", index = 3) + private String checkItemScore; + + @ApiModelProperty("检查结果") + @ExcelProperty(value = "检查结果", index = 4) + private String result; + + @ApiModelProperty("综合评分") + @ExcelProperty(value = "综合评分", index = 5) + private Integer score; +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java index ce00552..f73fc03 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java @@ -3,12 +3,16 @@ package com.hnac.hzims.safeproduct.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.utils.Condition; +import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; +import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.service.IHygienePlanService; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; +import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -43,15 +47,15 @@ public class HygieneController extends BladeController { @PostMapping("/savePlan") @ApiOperation(value = "新增卫生自查计划") @ApiOperationSupport(order = 1) - public R savePlan(@Valid @RequestBody HygienePlanEntity hygienePlanEntity) { - return hygienePlanService.savePlan(hygienePlanEntity); + public R savePlan(@Valid @RequestBody HygienePlanDTO hygienePlanDTO) { + return hygienePlanService.savePlan(hygienePlanDTO); } @PostMapping("/updatePlan") @ApiOperation(value = "修改卫生自查计划") @ApiOperationSupport(order = 2) - public R updatePlan(@Valid @RequestBody HygienePlanEntity hygienePlanEntity) { - return hygienePlanService.updatePlan(hygienePlanEntity); + public R updatePlan(@Valid @RequestBody HygienePlanDTO hygienePlanDTO) { + return hygienePlanService.updatePlan(hygienePlanDTO); } @PostMapping("/removePlan") @@ -64,14 +68,14 @@ public class HygieneController extends BladeController { @GetMapping("/planDetail") @ApiOperation(value = "卫生自查计划详情") @ApiOperationSupport(order = 4) - public R planDetail(@RequestParam Long id) { - return R.data(hygienePlanService.getById(id)); + public R planDetail(@RequestParam Long id) { + return R.data(hygienePlanService.getPlan(id)); } @GetMapping("/planPage") @ApiImplicitParams({ - @ApiImplicitParam(name = "zone", value = "责任区", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "principal", 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) @@ -83,15 +87,15 @@ public class HygieneController extends BladeController { @PostMapping("/saveRecord") @ApiOperation(value = "新增卫生自查记录") @ApiOperationSupport(order = 6) - public R saveRecord(@Valid @RequestBody HygieneRecordEntity hygieneRecordEntity) { - return hygieneRecordService.saveRecord(hygieneRecordEntity); + public R saveRecord(@Valid @RequestBody HygieneRecordDTO hygieneRecordDTO) { + return hygieneRecordService.saveRecord(hygieneRecordDTO); } @PostMapping("/updateRecord") @ApiOperation(value = "修改卫生自查记录") @ApiOperationSupport(order = 7) - public R updateRecord(@Valid @RequestBody HygieneRecordEntity hygieneRecordEntity) { - return hygieneRecordService.updateRecord(hygieneRecordEntity); + public R updateRecord(@Valid @RequestBody HygieneRecordDTO hygieneRecordDTO) { + return hygieneRecordService.updateRecord(hygieneRecordDTO); } @PostMapping("/removeRecord") @@ -114,29 +118,34 @@ public class HygieneController extends BladeController { }) @ApiOperation(value = "卫生自查记录分页") @ApiOperationSupport(order = 10) - public R> recordPage(@ApiIgnore @RequestParam Map param, Query query) { - IPage page = hygieneRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(param, - HygieneRecordEntity.class)); + public R> recordPage(@ApiIgnore @RequestParam Map param, Query query) { + IPage page = hygieneRecordService.recordPage(param, query); return R.data(page); } @GetMapping("/dataByMonth") @ApiOperation(value = "月度统计表") @ApiOperationSupport(order = 11) - public R> dataByMonth(@RequestParam String month, Query query) { - IPage page = hygienePlanService.dataByMonth(month, query); + public R> dataByMonth(@RequestParam String month, String unit, Query query) { + IPage page = hygienePlanService.dataByMonth(month, unit, query); return R.data(page); } @GetMapping("/exportHygieneData") + @ApiOperation(value = "卫生自查数据导出") + @ApiOperationSupport(order = 12) + public void exportHygieneData(@RequestParam Long hygieneRecordId, HttpServletResponse response) { + hygieneRecordService.exportHygieneData(hygieneRecordId, response); + } + + @GetMapping("/exportMonthData") @ApiImplicitParams({ - @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledStartTime", value = "计划开始时间", dataType = "query", paramType = "string"), - @ApiImplicitParam(name = "scheduledEndTime", value = "计划结束时间", dataType = "query", paramType = "string") + @ApiImplicitParam(name = "month", value = "月份", dataType = "query", paramType = "string"), + @ApiImplicitParam(name = "unit", value = "单位", dataType = "query", paramType = "string") }) - @ApiOperation(value = "卫生自查数据导出") + @ApiOperation(value = "月度数据导出") @ApiOperationSupport(order = 13) - public void exportHygieneData(@ApiIgnore @RequestParam Map param, HttpServletResponse response) { - hygienePlanService.exportHygieneData(param, response); + public void exportMonthData(@ApiIgnore @RequestParam Map param, Query query, HttpServletResponse response) { + hygienePlanService.exportMonthData(param, query, response); } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java index a17a2da..324d14f 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.java @@ -2,12 +2,10 @@ 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.HygieneExportDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.apache.ibatis.annotations.Mapper; -import java.util.List; /** * 卫生自查计划Mapper类 @@ -21,25 +19,18 @@ public interface HygienePlanMapper extends BaseMapper { /** * 查询当月各单位的卫生自查总数 * @param page 分页类 + * @param unit 单位 * @param month 月份 * @return 当月的卫生自查总数据 */ - IPage selectByMonth(IPage page, String month); + IPage selectByMonth(IPage page, String unit, String month); /** * 查询当月各单位已完成的卫生自查数据 * @param page 分页类 + * @param unit 单位 * @param month 月份 * @return 当月的已完成数据 */ - IPage selectFinishedDataByMonth(IPage page, String month); - - /** - * 根据单位和计划时间查询卫生自查记录 - * @param unit 单位 - * @param startTime 计划开始时间 - * @param endTime 计划结束时间 - * @return 卫生自查记录 - */ - List getHygieneByUnitAndDate(String unit, String startTime, String endTime); + IPage selectFinishedDataByMonth(IPage page, String unit, String month); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.xml index a47decf..18fdba8 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygienePlanMapper.xml @@ -9,6 +9,9 @@ WHERE is_deleted = 0 AND scheduled_end_time like concat('%', #{month}, '%') + + AND unit like concat('%', #{unit}, '%') + GROUP BY unit ORDER BY @@ -24,29 +27,12 @@ is_deleted = 0 AND scheduled_end_time like concat('%', #{month}, '%') AND hygiene_status = 'FINISHED' + + AND unit like concat('%', #{unit}, '%') + GROUP BY unit ORDER BY unit - - \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java index 96ac415..b888c54 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java @@ -1,10 +1,14 @@ 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.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import org.apache.ibatis.annotations.Mapper; +import java.util.Map; + /** * 卫生自查记录Mapper类 * @@ -20,4 +24,12 @@ public interface HygieneRecordMapper extends BaseMapper { * @return 卫生自查记录详情VO类 */ HygieneRecordDetailVO getRecordDetail(Long id); + + /** + * 卫生自查记录页面 + * @param param 入参 + * @param page 分页类 + * @return 记录数据页 + */ + IPage recordPage(IPage page, Map param); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml index 9913b1a..68efbe5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml @@ -3,13 +3,24 @@ + + \ No newline at end of file diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java new file mode 100644 index 0000000..b3d0e5c --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.java @@ -0,0 +1,10 @@ +package com.hnac.hzims.safeproduct.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface HygieneZoneMapper extends BaseMapper { + +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.xml b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.xml new file mode 100644 index 0000000..8113ac8 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneZoneMapper.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/IHygienePlanService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java index 6b62e72..6d3e98d 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygienePlanService.java @@ -2,7 +2,9 @@ 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.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; +import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -35,30 +37,43 @@ public interface IHygienePlanService extends IService { /** * 新增卫生自查计划 - * @param hygienePlanEntity 卫生自查计划实体类 + * @param hygienePlanDTO 卫生自查DTO类 * @return 结果封装类 */ - R savePlan(HygienePlanEntity hygienePlanEntity); + R savePlan(HygienePlanDTO hygienePlanDTO); /** * 修改卫生自查计划 - * @param hygienePlanEntity 卫生自查计划实体类 + * @param hygienePlanDTO 卫生自查DTO类 * @return 结果封装类 */ - R updatePlan(HygienePlanEntity hygienePlanEntity); + R updatePlan(HygienePlanDTO hygienePlanDTO); /** * 卫生自查月度数据 * @param month 月份 + * @param unit 单位 * @param query 分页类 * @return 月度统计分页 */ - IPage dataByMonth(String month, Query query); + IPage dataByMonth(String month, String unit, Query query); /** - * 卫生自查数据导出 - * @param param 入参 - * @param response 响应类 + * 卫生自查计划数据详情 + * @param id 卫生自查计划id + * @return 卫生自查计划详情VO类 + */ + HygienePlanDetailVO getPlan(Long id); + + /** + * 根据编码查询卫生自查计划 + * @param code 编码 + * @return 卫生自查计划实体类 + */ + HygienePlanEntity getPlanByCode(String code); + + /** + * 月度数据导出 */ - void exportHygieneData(Map param, HttpServletResponse response); + void exportMonthData(Map param, Query query, HttpServletResponse response); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java index 93ac01e..d717ad5 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java @@ -1,10 +1,17 @@ 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.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import javax.servlet.http.HttpServletResponse; +import java.util.Map; + /** * 卫生自查记录服务类 * @@ -22,17 +29,17 @@ public interface IHygieneRecordService extends IService { /** * 新增卫生自查记录 - * @param hygieneRecordEntity 卫生自查记录实体类 + * @param hygieneRecordDTO 卫生自查记录DTO类 * @return 封装结果类 */ - R saveRecord(HygieneRecordEntity hygieneRecordEntity); + R saveRecord(HygieneRecordDTO hygieneRecordDTO); /** * 修改卫生自查记录 - * @param hygieneRecordEntity 卫生自查记录实体类 - * @return true-成功,false-失败 + * @param hygieneRecordDTO 卫生自查记录DTO类 + * @return 封装结果类 */ - R updateRecord(HygieneRecordEntity hygieneRecordEntity); + R updateRecord(HygieneRecordDTO hygieneRecordDTO); /** * 查询卫生自查记录详情 @@ -40,4 +47,19 @@ public interface IHygieneRecordService extends IService { * @return 卫生自查记录详情VO类 */ HygieneRecordDetailVO getRecordDetail(Long id); + + /** + * 卫生自查记录页面 + * @param param 入参 + * @param query 分页类 + * @return 记录数据页 + */ + IPage recordPage(Map param, Query query); + + /** + * 卫生自查记录数据导出 + * @param hygieneRecordId 卫生自查记录id + * @param response 响应类 + */ + void exportHygieneData(Long hygieneRecordId, HttpServletResponse response); } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java new file mode 100644 index 0000000..3c62284 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneZoneService.java @@ -0,0 +1,23 @@ +package com.hnac.hzims.safeproduct.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; + +import java.util.List; + +public interface IHygieneZoneService extends IService { + + /** + * 删除关联责任区数据 + * @param hygienePlanId 卫生自查计划id + * @return true-成功,false-失败 + */ + boolean removeReferenceZone(Long hygienePlanId); + + /** + * 查询关联责任区数据 + * @param hygienePlanId 卫生自查计划id + * @return 关联责任区数据 + */ + List getReferenceZone(Long hygienePlanId); +} diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java index 4ca5f3c..659fc88 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygienePlanServiceImpl.java @@ -10,18 +10,22 @@ 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.HygieneExportDTO; +import com.hnac.hzims.safeproduct.dto.HygienePlanDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; -import com.hnac.hzims.safeproduct.enums.HygieneStatusEnum; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.service.IHygienePlanService; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; +import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import com.hnac.hzims.safeproduct.vo.HygienePlanDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneMonthVO; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springframework.beans.BeanUtils; 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; @@ -45,14 +49,24 @@ public class HygienePlanServiceImpl extends ServiceImpl planPage(Map param, Query query) { QueryWrapper queryWrapper = new QueryWrapper<>(); - String zone = String.valueOf(param.get("zone")); - String principal = String.valueOf(param.get("principal")); - if (!zone.equals("null") && !zone.equals("")) { - queryWrapper.lambda().like(HygienePlanEntity::getZone, zone); + String startTime = String.valueOf(param.get("scheduledStartTime")); + String endTime = String.valueOf(param.get("scheduledEndTime")); + if (!startTime.equals("null") && !startTime.equals("")) { + queryWrapper.lambda().ge(HygienePlanEntity::getScheduledStartTime, startTime); } - if (!principal.equals("null") && !principal.equals("")) { - queryWrapper.lambda().ge(HygienePlanEntity::getPrincipal, principal); + if (!endTime.equals("null") && !endTime.equals("")) { + queryWrapper.lambda().le(HygienePlanEntity::getScheduledEndTime, endTime); } return this.page(Condition.getPage(query), queryWrapper); } @@ -77,48 +91,84 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygienePlanDTO.getZoneList(); + // 若计划新增成功,新增关联责任区数据 + if (savePlan) { + HygienePlanEntity hygienePlan = getPlanByCode(hygienePlanDTO.getCode()); + for (HygieneZoneEntity zone : zoneList) { + // 传计划id + if (hygienePlan != null) { + zone.setHygienePlanId(hygienePlan.getId()); + } + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + R res = getSumScore(scores, hygienePlanDTO.getStandardScore()); + if (!res.isSuccess()) { + return res; + } + } + // 校验通过则批量新增责任区数据 + return R.status(hygieneZoneService.saveBatch(zoneList)); + } + return R.status(Boolean.FALSE); } /** * 修改卫生自查计划 */ @Override - public R updatePlan(HygienePlanEntity hygienePlanEntity) { - String[] scores = hygienePlanEntity.getCheckItemScore().split(",|,"); - Integer standardScore = hygienePlanEntity.getStandardScore(); - R res = getSumScore(scores, standardScore); - return res.isSuccess() ? R.status(this.updateById(hygienePlanEntity)) : res; + public R updatePlan(HygienePlanDTO hygienePlanDTO) { + // 修改卫生自查计划 + HygienePlanEntity hygienePlanEntity = new HygienePlanEntity(); + BeanUtils.copyProperties(hygienePlanDTO, hygienePlanEntity); + boolean updatePlan = this.updateById(hygienePlanEntity); + List zoneList = hygienePlanDTO.getZoneList(); + // 若计划修改成功,修改关联责任区数据 + if (updatePlan) { + for (HygieneZoneEntity zone : zoneList) { + String[] scores = zone.getCheckItemScore().split(",|,"); + // 校验检查项总成绩是否为标准总成绩 + R res = getSumScore(scores, hygienePlanDTO.getStandardScore()); + if (!res.isSuccess()) { + return res; + } + } + // 校验通过则批量修改责任区数据 + return R.status(hygieneZoneService.updateBatchById(zoneList)); + } + return R.status(Boolean.FALSE); } /** * 卫生自查月度数据 */ @Override - public IPage dataByMonth(String month, Query query) { + public IPage dataByMonth(String month, String unit, Query query) { // 查询当月各单位的卫生自查总数 IPage page = new Page<>(query.getCurrent(), query.getSize()); - IPage unitPage = baseMapper.selectByMonth(page, month); + IPage unitPage = baseMapper.selectByMonth(page, unit, month); List unitList = unitPage.getRecords(); // 查询当月各单位已完成的卫生自查数据 IPage page1 = new Page<>(query.getCurrent(), query.getSize()); - IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, month); + IPage finishedPage = baseMapper.selectFinishedDataByMonth(page1, unit, month); List finishedList = finishedPage.getRecords(); // 处理统计数据 - for (HygieneMonthVO unit : unitList) { - Long taskNum = unit.getScheduledCheckNum(); - Optional finishedHygiene = finishedList.stream().filter(x -> x.getUnit().equals(unit.getUnit())).findFirst(); + for (HygieneMonthVO u : unitList) { + Long taskNum = u.getScheduledCheckNum(); + Optional finishedHygiene = finishedList.stream().filter(x -> x.getUnit().equals(u.getUnit())).findFirst(); Long finishedTaskNum = finishedHygiene.isPresent() ? finishedHygiene.get().getFinishedCheckNum() : 0L; - unit.setFinishedCheckNum(finishedTaskNum); - unit.setUnfinishedCheckNum(taskNum - finishedTaskNum); + u.setFinishedCheckNum(finishedTaskNum); + u.setUnfinishedCheckNum(taskNum - finishedTaskNum); BigDecimal taskDecimal = new BigDecimal(taskNum); BigDecimal finishedDecimal = new BigDecimal(finishedTaskNum); - unit.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) + u.setCompletionRate(finishedDecimal.divide(taskDecimal, 4, RoundingMode.HALF_UP).multiply(new BigDecimal("100")) .setScale(2, RoundingMode.HALF_UP)); } unitPage.setRecords(unitList); @@ -126,32 +176,61 @@ public class HygienePlanServiceImpl extends ServiceImpl zoneList = hygieneZoneService.getReferenceZone(id); + hygienePlanDetailVO.setZoneList(zoneList); + return hygienePlanDetailVO; + } + + /** + * 计算累计分值 + * @param scores 各项分值 + * @param standardScore 标准总分值 + * @return 累计分值等于标准总分值时,返回数据,否则返回错误信息 + */ + private R getSumScore(String[] scores, Integer standardScore) { + int sum = 0; + for (String score : scores) { + sum += Integer.parseInt(score); + if (sum > standardScore) { + return R.fail("累计分值已超过标准总分值"); + } + } + return sum < standardScore ? R.fail("标准总分值未全部分配") : R.data(sum); + } + + /** + * 根据编码查询卫生自查计划 + */ + @Override + public HygienePlanEntity getPlanByCode(String code) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygienePlanEntity::getCode, code); + return this.getOne(queryWrapper); + } + + /** + * 月度数据导出 */ @Override - public void exportHygieneData(Map param, HttpServletResponse response) { + public void exportMonthData(Map param, Query query, 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 = getHygieneByUnitAndDate(unit, startTime, endTime); - // 处理卫生自查状态信息 - rehearsalList.forEach(record -> { - String status; - if (record.getHygieneStatus().equals(HygieneStatusEnum.WAITING.getValue())) { - status = HygieneStatusEnum.WAITING.getDesc(); - } else if (record.getHygieneStatus().equals(HygieneStatusEnum.UNFINISHED.getValue())) { - status = HygieneStatusEnum.UNFINISHED.getDesc(); - } else { - status = HygieneStatusEnum.FINISHED.getDesc(); - } - record.setHygieneStatus(status); - }); + String month = String.valueOf(param.get("month")); + IPage monthPage = dataByMonth(month, unit, query); + List records = monthPage.getRecords(); // 设置响应头 // URLEncoder.encode防止中文乱码 - String fileName = URLEncoder.encode("卫生自查数据表", "UTF-8"); + String fileName = URLEncoder.encode("卫生自查月度统计表", "UTF-8"); response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("UTF-8"); @@ -162,52 +241,24 @@ public class HygienePlanServiceImpl extends ServiceImpl standardScore) { - return R.fail("累计分值已超过标准总分值"); - } - } - return sum < standardScore ? R.fail("标准总分值未全部分配") : R.data(sum); - } - - /** - * 根据单位和计划时间查询卫生自查记录 - * @param unit 单位 - * @param startTime 计划开始时间 - * @param endTime 计划结束时间 - * @return 卫生自查记录 - */ - public List getHygieneByUnitAndDate(String unit, String startTime, String endTime) { - return baseMapper.getHygieneByUnitAndDate(unit, startTime, endTime); - } } diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java index 321078c..469d5fa 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java @@ -1,26 +1,48 @@ package com.hnac.hzims.safeproduct.service.impl; import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateUtil; +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.merge.LoopMergeStrategy; +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.logs.utils.StringUtils; +import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.mapper.HygienePlanMapper; import com.hnac.hzims.safeproduct.mapper.HygieneRecordMapper; import com.hnac.hzims.safeproduct.service.IHygieneRecordService; +import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import com.hnac.hzims.safeproduct.utils.BaseUtil; +import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; +import com.hnac.hzims.safeproduct.vo.HygieneZoneDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.ss.usermodel.CellStyle; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; import java.time.LocalDate; import java.time.ZoneId; import java.time.temporal.WeekFields; -import java.util.Date; -import java.util.List; -import java.util.Locale; +import java.util.*; import java.util.stream.Collectors; /** @@ -35,6 +57,9 @@ public class HygieneRecordServiceImpl extends ServiceImpl 0) { - return R.fail("评分不能大于标准总分值"); + String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",|,"); + for (String score : scores) { + int sc = Integer.parseInt(score); + if (sc > hygienePlanEntity.getStandardScore()) { + return R.fail("评分不能大于标准总分值"); + } } return R.status(this.save(hygieneRecordEntity)); } @@ -94,14 +111,20 @@ public class HygieneRecordServiceImpl extends ServiceImpl 0) { - return R.fail("评分不能大于标准总分值"); + String[] scores = hygieneRecordEntity.getComprehensiveScore().split(",|,"); + for (String score : scores) { + int sc = Integer.parseInt(score); + if (sc > hygienePlanEntity.getStandardScore()) { + return R.fail("评分不能大于标准总分值"); + } } return R.status(this.updateById(hygieneRecordEntity)); } @@ -111,7 +134,80 @@ public class HygieneRecordServiceImpl extends ServiceImpl checkDetailVOList = new ArrayList<>(); + for (int i = 0; i < zoneIds.length ; i++) { + HygieneZoneDetailVO zoneDetailVO = new HygieneZoneDetailVO(); + HygieneZoneEntity hygieneZoneEntity = hygieneZoneService.getById(zoneIds[i]); + BeanUtils.copyProperties(hygieneZoneEntity, zoneDetailVO); + zoneDetailVO.setResult(results[i]); + zoneDetailVO.setScore(Integer.parseInt(scores[i])); + checkDetailVOList.add(zoneDetailVO); + } + recordDetailVO.setCheckList(checkDetailVOList); + return recordDetailVO; + } + + /** + * 卫生自查记录页面 + */ + @Override + public IPage recordPage(Map param, Query query) { + IPage page = new Page<>(query.getCurrent(), query.getSize()); + return baseMapper.recordPage(page, param); + } + + /** + * 卫生自查数据导出 + */ + @Override + public void exportHygieneData(Long hygieneRecordId, HttpServletResponse response) { + ServletOutputStream outputStream = null; + try { + outputStream = response.getOutputStream(); + HygieneRecordDetailVO recordDetailVO = getRecordDetail(hygieneRecordId); + List records = recordDetailVO.getCheckList(); + // 设置响应头 + // 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(); + Date endTime = recordDetailVO.getActualEndTime(); + String name = DateUtil.format(endTime, "yyyy年mm月") + "第" + recordDetailVO.getWeekNum() + "周卫生自查表"; + List head = new ArrayList<>(); + head.add(name); + WriteSheet writeSheet = EasyExcel.writerSheet(1, "卫生自查记录数据表") + .head(Collections.singletonList(head)) + .head(HygieneZoneDetailVO.class) + .build(); + excelWriter.write(records, 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()); + } + } + } } /** diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java new file mode 100644 index 0000000..2cedf06 --- /dev/null +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneZoneServiceImpl.java @@ -0,0 +1,42 @@ +package com.hnac.hzims.safeproduct.service.impl; + +import com.alibaba.excel.util.CollectionUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; +import com.hnac.hzims.safeproduct.mapper.HygieneZoneMapper; +import com.hnac.hzims.safeproduct.service.IHygieneZoneService; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class HygieneZoneServiceImpl extends ServiceImpl implements IHygieneZoneService { + + /** + * 删除关联责任区数据 + */ + @Override + public boolean removeReferenceZone(Long hygienePlanId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneZoneEntity::getHygienePlanId, hygienePlanId); + List zoneList = this.list(queryWrapper); + // 若无关联卫生自查责任区,直接返回true + if (CollectionUtils.isEmpty(zoneList)) { + return true; + } + List ids = zoneList.stream().map(HygieneZoneEntity::getId).collect(Collectors.toList()); + return this.removeByIds(ids); + } + + /** + * 查询关联责任区数据 + */ + @Override + public List getReferenceZone(Long hygienePlanId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(HygieneZoneEntity::getHygienePlanId, hygienePlanId); + return this.list(queryWrapper); + } +} diff --git a/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql b/hzims-service/safeproduct/src/main/resources/db/1.0.1.sql index 57e4455..419e469 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 @@ -80,7 +80,7 @@ CREATE TABLE `hzims_train_record` ( `train_record_name` varchar(50) NOT NULL DEFAULT '' COMMENT '培训记录名称', `code` varchar(50) NOT NULL COMMENT '编号', `people_name` varchar(5000) DEFAULT '' COMMENT '培训学员', - `content` varchar(5000) DEFAULT '' COMMENT '培训内容', + `content` mediumtext DEFAULT '' COMMENT '培训内容', `actual_start_time` datetime DEFAULT NULL COMMENT '实际培训开始时间', `actual_end_time` datetime DEFAULT NULL COMMENT '实际培训结束时间', `command` varchar(250) DEFAULT NULL COMMENT '培训评价', @@ -164,7 +164,7 @@ CREATE TABLE `hzims_conference_record` ( `actual_start_time` datetime DEFAULT NULL COMMENT '会议实际开始时间', `actual_end_time` datetime DEFAULT NULL COMMENT '会议实际结束时间', `recorder` varchar(20) DEFAULT '' COMMENT '记录人', - `content` varchar(250) DEFAULT '' DEFAULT '' COMMENT '会议内容', + `content` mediumtext DEFAULT '' DEFAULT '' COMMENT '会议内容', `img_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '会议图片', `file_path` varchar(1000) NOT NULL DEFAULT '' COMMENT '会议附件', `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', @@ -179,15 +179,27 @@ CREATE TABLE `hzims_conference_record` ( CREATE TABLE `hzims_hygiene_plan` ( `id` bigint(20) NOT NULL COMMENT '主键id', - `unit` varchar(50) NOT NULL COMMENT '单位', + `code` varchar(50) NOT NULL COMMENT '编码', + `standard_score` int(10) NOT NULL DEFAULT '100' COMMENT '标准总分值', + `scheduled_start_time` date NOT NULL COMMENT '计划开始时间', + `scheduled_end_time` date NOT NULL COMMENT '计划结束时间', + `create_user` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建人', + `create_dept` bigint(20) NOT NULL DEFAULT '-1' COMMENT '创建部门', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_user` bigint(20) DEFAULT '-1' COMMENT '更新人', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', + `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='卫生自查计划表' ROW_FORMAT=Dynamic; + +CREATE TABLE `hzims_hygiene_zone` ( + `id` bigint(20) NOT NULL COMMENT '主键id', + `hygiene_plan_id` bigint(20) NOT NULL COMMENT '卫生自查计划id', `zone` varchar(50) NOT NULL COMMENT '责任区', `principal` varchar(20) NOT NULL COMMENT '责任人', `check_item` mediumtext NOT NULL COMMENT '检查项', `check_item_score` varchar(255) NOT NULL COMMENT '检查项分值', - `standard_score` int(10) NOT NULL DEFAULT '100' COMMENT '标准总分值', - `scheduled_start_time` date NOT NULL COMMENT '计划开始时间', - `scheduled_end_time` date NOT NULL COMMENT '计划结束时间', - `hygiene_status` varchar(20) NOT NULL DEFAULT 'WAITING' 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 '创建时间', @@ -196,14 +208,17 @@ CREATE TABLE `hzims_hygiene_plan` ( `status` int(2) NOT NULL DEFAULT '1' COMMENT '状态', `is_deleted` int(2) NOT NULL DEFAULT '0' COMMENT '逻辑删除状态:0-未删除,1-删除', PRIMARY KEY (`id`) USING BTREE -) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='卫生自查表' ROW_FORMAT=Dynamic; +) ENGINE=INNODB CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='卫生自查区域表' ROW_FORMAT=Dynamic; CREATE TABLE `hzims_hygiene_record` ( `id` bigint(20) NOT NULL COMMENT '主键id', + `hygiene_plan_id` bigint(20) NOT NULL COMMENT '卫生自查计划id', + `unit` varchar(50) NOT NULL COMMENT '单位', `code` varchar(50) NOT NULL COMMENT '编号', `actual_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际开始时间', `actual_end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '实际结束时间', `check_user` varchar(20) NOT NULL DEFAULT '' COMMENT '检查人', + `hygiene_zone_ids` varchar(1000) NOT NULL COMMENT '卫生自查区域id', `check_result` mediumtext NOT NULL COMMENT '检查结果', `comprehensive_score` int(10) NOT NULL COMMENT '综合评分', `week_num` int(10) NOT NULL COMMENT '周数',