Browse Source

add: 卫生考核表

zhongwei
liwen 3 months ago
parent
commit
7292d8a4de
  1. 28
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPageVO.java
  2. 28
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationPeopleVO.java
  3. 20
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneEvaluationScoreVO.java
  4. 25
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/vo/HygieneWeekVO.java
  5. 9
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java
  6. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.java
  7. 13
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml
  8. 8
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/IHygieneRecordService.java
  9. 108
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/HygieneRecordServiceImpl.java

28
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<HygieneWeekVO> weekList;
@ApiModelProperty(value = "考核人员列表")
private List<HygieneEvaluationPeopleVO> evaluationList;
}

28
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<HygieneEvaluationScoreVO> scoreList;
}

20
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;
}

25
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;
}

9
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/HygieneController.java

@ -245,4 +245,13 @@ public class HygieneController extends BladeController {
IPage<HygienePlanEntity> page = hygienePlanService.getDetailListByMonth(param, query);
return R.data(page);
}
@GetMapping("/evaluationPage")
@ApiOperation(value = "卫生考核表")
@ApiOperationSupport(order = 21)
@Operate(label = "卫生考核表", type = BusinessType.QUERY)
public R<HygieneEvaluationPageVO> evaluationPage(@RequestParam String month) {
HygieneEvaluationPageVO page = hygieneRecordService.getEvaluationPage(month);
return R.data(page);
}
}

8
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<HygieneReco
* @return 当月卫生自查数据表
*/
List<HygieneRecordEntity> selectHygieneByMonth(@Param("month") String month);
/**
* 根据id列表查询责任区对应负责人数据
* @param idList id列表
* @return 负责人名称列表
*/
List<HygieneZoneEntity> selectHygieneZoneByIds(@Param("idList") List<String> idList);
}

13
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/mapper/HygieneRecordMapper.xml

@ -46,4 +46,17 @@
ORDER BY
code DESC
</select>
<select id="selectHygieneZoneByIds" resultType="com.hnac.hzims.safeproduct.entity.HygieneZoneEntity">
SELECT
id, principal
FROM
hzims_hygiene_zone
WHERE
is_deleted = 0
AND id IN
<foreach collection="idList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

8
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<HygieneRecordEntity> {
* @return 记录列表
*/
List<HygieneRecordEntity> getReferenceRecord(Long planId);
/**
* 查询卫生考核表
* @param month 当前月份
* @return 考核记录表VO类
*/
HygieneEvaluationPageVO getEvaluationPage(String month);
}

108
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<HygieneRecordMapper, H
}
/**
* 查询卫生考核表
*/
@Override
public HygieneEvaluationPageVO getEvaluationPage(String month) {
HygieneEvaluationPageVO pageVO = new HygieneEvaluationPageVO();
// 获取月度周数据列表
List<HygieneWeekVO> 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<HygieneRecordEntity> recordList = baseMapper.selectHygieneByMonth(month);
if (CollectionUtil.isEmpty(recordList)) {
throw new HzServiceException(ResultCode.FAILURE, "本月度无卫生自查数据");
}
// 整理月度考核人员数据
// 查询所有责任区id和对应综合评分
List<String> zoneIdList = recordList.stream().map(HygieneRecordEntity::getHygieneZoneIds).collect(Collectors.toList());
List<String> comprehensiveScoreList = recordList.stream().map(HygieneRecordEntity::getComprehensiveScore).collect(Collectors.toList());
// 考核表数据
List<HygieneEvaluationPeopleVO> 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<HygieneZoneEntity> peopleNameList = baseMapper.selectHygieneZoneByIds(Arrays.asList(zoneIds));
// 遍历责任区数据
for (int j = 0; j < zoneIds.length; j++) {
List<HygieneEvaluationScoreVO> scoreList = new ArrayList<>();
HygieneEvaluationPeopleVO peopleVO = new HygieneEvaluationPeopleVO();
String zoneId = zoneIds[j];
Optional<HygieneZoneEntity> 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<HygieneEvaluationPeopleVO> 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<Long> 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

Loading…
Cancel
Save