|
@@ -4,20 +4,24 @@ import com.github.pagehelper.PageHelper;
|
|
|
import com.platform.common.bean.AbstractPageResultBean;
|
|
|
import com.platform.common.exception.BusinessException;
|
|
|
import com.platform.common.exception.DeniedException;
|
|
|
+import com.platform.common.util.BigDecimalUtil;
|
|
|
import com.platform.common.util.DateUtils;
|
|
|
import com.platform.common.util.ListUtils;
|
|
|
import com.platform.common.util.StringUtils;
|
|
|
import com.platform.dao.bean.MyPage;
|
|
|
+import com.platform.dao.dto.check.CheckJobDTO;
|
|
|
import com.platform.dao.dto.sb.SbMeasureLogDTO;
|
|
|
import com.platform.dao.entity.check.CheckProjectStandardRelation;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
import com.platform.dao.entity.sb.SbMeasureLog;
|
|
|
import com.platform.dao.entity.upms.SysFile;
|
|
|
-import com.platform.dao.enums.SbUseType;
|
|
|
-import com.platform.dao.enums.SysFileTypeEnum;
|
|
|
+import com.platform.dao.enums.*;
|
|
|
import com.platform.dao.mapper.sb.SbInfoMapper;
|
|
|
import com.platform.dao.mapper.sb.SbMeasureLogMapper;
|
|
|
+import com.platform.dao.vo.query.check.CheckJobVO;
|
|
|
import com.platform.dao.vo.query.sb.SbMeasureLogVO;
|
|
|
+import com.platform.dao.vo.report.CheckJobReportVO;
|
|
|
+import com.platform.dao.vo.report.MeasureLogReportVO;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import com.platform.service.sb.SbMeasureLogService;
|
|
|
import com.platform.service.upms.SysFileService;
|
|
@@ -26,9 +30,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import tk.mybatis.mapper.weekend.Weekend;
|
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @Description 点检标准 service 实现类
|
|
@@ -88,6 +94,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
updInfo.setNextCheckDate(model.getLastDate().minusMonths(-sbInfo.getCheckPeriod()).minusDays(1));
|
|
|
updInfo.setZaiz(model.getName());// 检定单位
|
|
|
updInfo.setSbdh(serialNo);// 检定编号
|
|
|
+ updInfo.setMeasureStatus(YesNoEnum.NO.getValue());// 每次检定后, 检定状态改为正常
|
|
|
updInfo.setRemark(model.getRemark());// 备注
|
|
|
updInfo.setDph(model.getRequirement());// 检定人
|
|
|
sbInfoMapper.updateByPrimaryKeySelective(updInfo);
|
|
@@ -149,6 +156,7 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
sbInfo.setSbdh(model.getNo());// 检定编号
|
|
|
sbInfo.setRemark(model.getRemark());// 备注
|
|
|
sbInfo.setDph(model.getRequirement());// 检定人
|
|
|
+ sbInfo.setMeasureStatus(YesNoEnum.NO.getValue());// 每次检定后, 检定状态改为正常
|
|
|
// sbInfo.setStatus(model.getSbStatus());// 每次检定后,状态变更也要更新
|
|
|
sbInfoMapper.updateByPrimaryKey(sbInfo);
|
|
|
|
|
@@ -239,4 +247,65 @@ public class SbMeasureLogServiceImpl extends BaseServiceImpl<SbMeasureLogMapper,
|
|
|
sbMeasureLog.setCheckFileList(checkFileList);
|
|
|
return sbMeasureLog;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<MeasureLogReportVO> getMonthReport(SbMeasureLogDTO sbMeasureLogDTO, Integer searchYear , LocalDate startMonth, LocalDate endMonth) {
|
|
|
+ List<Map<String, LocalDateTime>> monthStartAndEndList = new ArrayList<Map<String, LocalDateTime>>();
|
|
|
+ LocalDateTime searchStartTime = null;
|
|
|
+ LocalDateTime searchEndTime = null;
|
|
|
+ if(searchYear != null){
|
|
|
+ LocalDate localDate = LocalDate.now();
|
|
|
+ int year = localDate.getYear();
|
|
|
+ // 如2021-10-15号码,则month=10,需要计算到11月份,需要加1
|
|
|
+ int month = localDate.getMonthValue();
|
|
|
+ if(searchYear<year){
|
|
|
+ month = 12;
|
|
|
+ year = searchYear;
|
|
|
+ }
|
|
|
+ monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(year, month);
|
|
|
+ // 当前年份只统计到当前月,历史年份统计全年
|
|
|
+ searchStartTime = DateUtils.getFirstDayOfThisYear(year);
|
|
|
+ searchEndTime = DateUtils.getLastDayOfMonth(year, month);
|
|
|
+ }else{
|
|
|
+ monthStartAndEndList = DateUtils.getMonthStartAndEndByYear(startMonth, endMonth);
|
|
|
+ searchStartTime = DateUtils.getFirstDayOfMonth(startMonth);
|
|
|
+ searchEndTime = DateUtils.getLastDayOfMonth(endMonth);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 总数
|
|
|
+ sbMeasureLogDTO.setSearchStartTime(searchStartTime);
|
|
|
+ sbMeasureLogDTO.setSearchEndTime(searchEndTime);
|
|
|
+ List<SbMeasureLogVO> list = mapper.selectList(sbMeasureLogDTO);
|
|
|
+
|
|
|
+ List<MeasureLogReportVO> result = new ArrayList<>();
|
|
|
+ for(Map<String, LocalDateTime> map: monthStartAndEndList){
|
|
|
+ MeasureLogReportVO vo = new MeasureLogReportVO();
|
|
|
+ List<SbMeasureLogVO> detailList = new ArrayList<>();
|
|
|
+ vo.setYear(map.get("searchStartTimeMonth").getYear());
|
|
|
+ vo.setMonth(map.get("searchStartTimeMonth").getMonthValue());
|
|
|
+ int totalNum = 0;
|
|
|
+ int totalFinishNum = 0;
|
|
|
+ int totalWaitNum = 0;
|
|
|
+ double finishRate = 0;
|
|
|
+ for(SbMeasureLogVO sbMeasureLogVO: list){
|
|
|
+ if(sbMeasureLogVO.getLastDate().isAfter(map.get("searchStartTimeMonth").toLocalDate()) && sbMeasureLogVO.getLastDate().isBefore(map.get("searchEndTimeMonth").toLocalDate())){
|
|
|
+ totalNum ++;
|
|
|
+ totalFinishNum ++;
|
|
|
+ detailList.add(sbMeasureLogVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(totalNum != 0){
|
|
|
+ totalWaitNum = totalNum - totalFinishNum;
|
|
|
+ finishRate = BigDecimalUtil.decimal(BigDecimalUtil.div(totalFinishNum*100, totalNum),2);
|
|
|
+ }
|
|
|
+ vo.setTotalNum(totalNum);
|
|
|
+ vo.setTotalFinishNum(totalFinishNum);
|
|
|
+ // vo.setTotalWaitNum(totalWaitNum);
|
|
|
+ // vo.setFinishRate(finishRate+"%");
|
|
|
+ vo.setDetailList(detailList);
|
|
|
+ result.add(vo);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|