From d7dfb9d957a6749b982c8bd00f9a1571953fde57 Mon Sep 17 00:00:00 2001 From: luyie Date: Tue, 20 Aug 2024 14:52:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=E6=96=87=E4=BB=B6=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java | 2 +- .../operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java index f3ce2b7..ec21858 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricDeviceVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java index a2aae0e..2fcb5e3 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/homePage/hydroelectric/vo/HydroelectricPowerRainVo.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.operational.homePage.Hydroelectric.vo; +package com.hnac.hzims.operational.homePage.hydroelectric.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; From 7292d8a4decb6bdc1a0ba916637f372d97fc9211 Mon Sep 17 00:00:00 2001 From: liwen Date: Tue, 20 Aug 2024 14:55:55 +0800 Subject: [PATCH 2/2] =?UTF-8?q?add:=20=E5=8D=AB=E7=94=9F=E8=80=83=E6=A0=B8?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../safeproduct/vo/HygieneEvaluationPageVO.java | 28 ++++++ .../safeproduct/vo/HygieneEvaluationPeopleVO.java | 28 ++++++ .../safeproduct/vo/HygieneEvaluationScoreVO.java | 20 ++++ .../hnac/hzims/safeproduct/vo/HygieneWeekVO.java | 25 +++++ .../safeproduct/controller/HygieneController.java | 9 ++ .../safeproduct/mapper/HygieneRecordMapper.java | 8 ++ .../safeproduct/mapper/HygieneRecordMapper.xml | 13 +++ .../safeproduct/service/IHygieneRecordService.java | 8 ++ .../service/impl/HygieneRecordServiceImpl.java | 108 ++++++++++++++++++++- 9 files changed, 244 insertions(+), 3 deletions(-) create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java create mode 100644 hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java new file mode 100644 index 0000000..6138a0f --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生考核表VO类") +public class HygieneEvaluationPageVO { + + @ApiModelProperty(value = "总分") + private Long totalScore; + + @ApiModelProperty(value = "备注") + private String remark; + + @ApiModelProperty(value = "周数据列表") + private List weekList; + + @ApiModelProperty(value = "考核人员列表") + private List evaluationList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java new file mode 100644 index 0000000..def489e --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java @@ -0,0 +1,28 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生考核分数VO类") +public class HygieneEvaluationPeopleVO { + + @ApiModelProperty(value = "单位") + private String unit; + + @ApiModelProperty(value = "负责人") + private String principal; + + @ApiModelProperty(value = "合计分") + private Long sumScore; + + @ApiModelProperty(value = "考核分列表") + private List scoreList; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java new file mode 100644 index 0000000..f7729dc --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.safeproduct.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author liwen + * @date 2024-08-16 + */ +@Data +@ApiModel(value = "卫生考核分VO类") +public class HygieneEvaluationScoreVO { + + @ApiModelProperty(value = "周数") + private Integer weekNum; + + @ApiModelProperty(value = "考核分") + private Long score; +} diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java new file mode 100644 index 0000000..49a56f3 --- /dev/null +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java @@ -0,0 +1,25 @@ +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-08-16 + */ +@Data +@ApiModel(value = "卫生周数据VO类") +public class HygieneWeekVO { + + @ApiModelProperty(value = "周数") + private Integer weekNum; + + @ApiModelProperty(value = "周开始日") + private Date startDate; + + @ApiModelProperty(value = "周结束日") + private Date endDate; +} 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 1c4de51..1119951 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 @@ -245,4 +245,13 @@ public class HygieneController extends BladeController { IPage page = hygienePlanService.getDetailListByMonth(param, query); return R.data(page); } + + @GetMapping("/evaluationPage") + @ApiOperation(value = "卫生考核表") + @ApiOperationSupport(order = 21) + @Operate(label = "卫生考核表", type = BusinessType.QUERY) + public R evaluationPage(@RequestParam String month) { + HygieneEvaluationPageVO page = hygieneRecordService.getEvaluationPage(month); + return R.data(page); + } } 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 b364016..34e0c05 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 @@ -2,6 +2,7 @@ package com.hnac.hzims.safeproduct.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.safeproduct.entity.HygieneRecordEntity; +import com.hnac.hzims.safeproduct.entity.HygieneZoneEntity; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import org.apache.ibatis.annotations.Mapper; @@ -43,4 +44,11 @@ public interface HygieneRecordMapper extends UserDataScopeBaseMapper selectHygieneByMonth(@Param("month") String month); + + /** + * 根据id列表查询责任区对应负责人数据 + * @param idList id列表 + * @return 负责人名称列表 + */ + List selectHygieneZoneByIds(@Param("idList") List idList); } 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 d012ec4..6543db5 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 @@ -46,4 +46,17 @@ ORDER BY code DESC + + \ No newline at end of file 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 7d050d0..59152e5 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 @@ -4,6 +4,7 @@ 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.HygieneEvaluationPageVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordDetailVO; import com.hnac.hzims.safeproduct.vo.HygieneRecordPageVO; import org.springblade.core.mp.support.Query; @@ -70,4 +71,11 @@ public interface IHygieneRecordService extends IService { * @return 记录列表 */ List getReferenceRecord(Long planId); + + /** + * 查询卫生考核表 + * @param month 当前月份 + * @return 考核记录表VO类 + */ + HygieneEvaluationPageVO getEvaluationPage(String month); } 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 61b6449..755daf7 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 @@ -5,6 +5,7 @@ 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.DateUtil; import com.hnac.hzims.safeproduct.constants.SafeProductConstant; import com.hnac.hzims.safeproduct.dto.HygieneRecordDTO; import com.hnac.hzims.safeproduct.entity.HygienePlanEntity; @@ -16,12 +17,13 @@ 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 com.hnac.hzims.safeproduct.vo.*; +import com.hnac.hzinfo.exception.HzServiceException; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.api.ResultCode; +import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -31,8 +33,10 @@ import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; +import java.time.DayOfWeek; import java.time.LocalDate; import java.time.ZoneId; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.WeekFields; import java.util.*; import java.util.stream.Collectors; @@ -210,6 +214,104 @@ public class HygieneRecordServiceImpl extends ServiceImpl weekList = new ArrayList<>(); + // 获取周开始日 + LocalDate firstWeekDay = DateUtil.getFirstDayByYearMonth(month); + Date weekStart = DateUtil.toDate(firstWeekDay); + // 获取当月最后一天 + LocalDate lastDay = DateUtil.getLastDayByYearMonth(month); + Date lastDate = DateUtil.toDate(lastDay); + // 循环更新周数、周开始日、周结束日 + int weekNum = 1; + while (weekStart.before(lastDate)) { + // 周结束日 + LocalDate lastWeekDay = firstWeekDay.with(TemporalAdjusters.next(DayOfWeek.SATURDAY)); + Date weekEnd = DateUtil.toDate(lastWeekDay); + // 存储周数据 + HygieneWeekVO weekVO = new HygieneWeekVO(); + weekVO.setWeekNum(weekNum++); + weekVO.setStartDate(weekStart); + weekVO.setEndDate(weekEnd); + weekList.add(weekVO); + // 更新周开始日 + firstWeekDay = firstWeekDay.with(TemporalAdjusters.next(DayOfWeek.SUNDAY)); + weekStart = DateUtil.toDate(firstWeekDay); + } + pageVO.setWeekList(weekList); + + // 计算总分(总分 = 周数 * 100) + long totalScore = weekList.size() * 100L; + pageVO.setTotalScore(totalScore); + // 备注 + pageVO.setRemark("已按标准执行,本月总分" + totalScore + "分(每周100分)"); + + // 查询月度卫生自查数据 + List recordList = baseMapper.selectHygieneByMonth(month); + if (CollectionUtil.isEmpty(recordList)) { + throw new HzServiceException(ResultCode.FAILURE, "本月度无卫生自查数据"); + } + // 整理月度考核人员数据 + // 查询所有责任区id和对应综合评分 + List zoneIdList = recordList.stream().map(HygieneRecordEntity::getHygieneZoneIds).collect(Collectors.toList()); + List comprehensiveScoreList = recordList.stream().map(HygieneRecordEntity::getComprehensiveScore).collect(Collectors.toList()); + // 考核表数据 + List evaluationList = new ArrayList<>(); + for (int i = 0; i < recordList.size(); i++) { + HygieneRecordEntity hygieneRecordEntity = recordList.get(i); + String[] zoneIds = zoneIdList.get(i).split(","); + String[] scores = comprehensiveScoreList.get(i).split(","); + // 查询责任区对应的负责人名称 + List peopleNameList = baseMapper.selectHygieneZoneByIds(Arrays.asList(zoneIds)); + + // 遍历责任区数据 + for (int j = 0; j < zoneIds.length; j++) { + List scoreList = new ArrayList<>(); + HygieneEvaluationPeopleVO peopleVO = new HygieneEvaluationPeopleVO(); + String zoneId = zoneIds[j]; + Optional zoneOptional = peopleNameList.stream().filter(x -> x.getId().equals(Long.valueOf(zoneId))).findFirst(); + if (zoneOptional.isPresent()) { + Integer weekNo = hygieneRecordEntity.getWeekNum(); + // 考核人名称 + String principal = zoneOptional.get().getPrincipal(); + // 判断单位内该名称是否已存在 + Optional checkPeople = evaluationList.stream().filter(x -> x.getPrincipal().equals(principal) && + x.getUnit().equals(hygieneRecordEntity.getUnit())).findFirst(); + + if (checkPeople.isPresent()) { + peopleVO = checkPeople.get(); + scoreList = peopleVO.getScoreList(); + HygieneEvaluationScoreVO scoreVO = new HygieneEvaluationScoreVO(); + scoreVO.setWeekNum(weekNo); + scoreVO.setScore(Long.valueOf(scores[j])); + scoreList.add(scoreVO); + } else { + peopleVO.setUnit(hygieneRecordEntity.getUnit()); + peopleVO.setPrincipal(principal); + HygieneEvaluationScoreVO scoreVO = new HygieneEvaluationScoreVO(); + scoreVO.setWeekNum(weekNo); + scoreVO.setScore(Long.valueOf(scores[j])); + scoreList.add(scoreVO); + peopleVO.setScoreList(scoreList); + } + } + // 合计分 + List peopleScoreList = scoreList.stream().map(HygieneEvaluationScoreVO::getScore).collect(Collectors.toList()); + long sum = peopleScoreList.stream().mapToLong(Long::longValue).sum(); + peopleVO.setSumScore(sum); + evaluationList.add(peopleVO); + } + } + pageVO.setEvaluationList(evaluationList); + return pageVO; + } + + /** * 查询是否存在同月编号 * @param currentMonth 当月 * @return 存在则返回上一编号,否则返回null