|
|
|
@ -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 |
|
|
|
|