package com.gkhy.safePlatform.specialWork.service.impl;
|
|
import cn.hutool.core.util.IdUtil;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
|
import com.gkhy.safePlatform.commons.enums.E;
|
import com.gkhy.safePlatform.commons.enums.ResultCodes;
|
import com.gkhy.safePlatform.commons.exception.AusinessException;
|
import com.gkhy.safePlatform.commons.exception.BusinessException;
|
import com.gkhy.safePlatform.commons.query.PageQuery;
|
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
|
import com.gkhy.safePlatform.commons.utils.StringUtils;
|
import com.gkhy.safePlatform.commons.vo.ResultVO;
|
import com.gkhy.safePlatform.commons.vo.SearchResultVO;
|
import com.gkhy.safePlatform.equipment.rpc.api.EquipmentRpcAPi;
|
import com.gkhy.safePlatform.specialWork.entity.*;
|
import com.gkhy.safePlatform.specialWork.enums.*;
|
import com.gkhy.safePlatform.specialWork.model.dto.req.WorkProcessCheckReqDTO;
|
import com.gkhy.safePlatform.specialWork.model.dto.req.WorkProcessDetectionReqDTO;
|
import com.gkhy.safePlatform.specialWork.model.dto.resp.*;
|
import com.gkhy.safePlatform.specialWork.model.query.WorkProcessCheckPageQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.WorkProcessDetectionPageQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.WorkProcessWarningPageQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.WorkProcessWorkApplyQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.db.WorkProcessCheckPageDBQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.db.WorkProcessDetectionPageDBQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.db.WorkProcessWarningPageDBQuery;
|
import com.gkhy.safePlatform.specialWork.model.query.db.WorkProcessWorkApplyDBQuery;
|
import com.gkhy.safePlatform.specialWork.service.SpecialWorkMinoService;
|
import com.gkhy.safePlatform.specialWork.service.WorkProcessService;
|
import com.gkhy.safePlatform.specialWork.service.baseService.*;
|
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.math.BigDecimal;
|
import java.time.LocalDateTime;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
@Service("workProcessService")
|
public class WorkProcessServiceImpl implements WorkProcessService {
|
|
@Autowired
|
private WorkApplyInfoService workApplyInfoService;
|
@Autowired
|
private WorkProcessDetectionInfoService workProcessDetectionInfoService;
|
@Autowired
|
private WorkProcessCheckInfoService workProcessCheckInfoService;
|
@Autowired
|
private WorkProcessWarningInfoService workProcessWarningInfoService;
|
@Autowired
|
private WorkProcessCheckImgInfoService workProcessCheckImgInfoService;
|
@Autowired
|
private SpecialWorkMinoService specialWorkMinoService;
|
@Autowired
|
private MaterialDetailInfoService materialDetailInfoService;
|
@Autowired
|
private WorkMaterialInfoService workMaterialInfoService;
|
@Autowired
|
private WorkMaterialCheckService workMaterialCheckService;
|
@DubboReference(check = false)
|
private EquipmentRpcAPi equipmentRpcAPi;
|
|
@Autowired
|
private WorkMaterialRecordsInfoService workMaterialRecordsInfoService;
|
|
|
@Override
|
public void detectionReport(ContextCacheUser currentUser, WorkProcessDetectionReqDTO reqDTO) {
|
if (StringUtils.isBlank(reqDTO.getWorkPermitNo())) {
|
throw new AusinessException(E.DATA_PARAM_NULL,"作业编号为空");
|
}
|
if (reqDTO.getOxygen() == null &&
|
reqDTO.getCarbonMonoxide() == null &&
|
reqDTO.getCombustible() == null &&
|
reqDTO.getHydrogenSulfide() == null) {
|
throw new AusinessException(E.DATA_PARAM_NULL,"至少传入一个数据");
|
}
|
if (WorkReportSourceEnum.parse(reqDTO.getSource()) == null) {
|
throw new AusinessException(E.DATA_STATUS_CHECK_INVALID, "数据状态非法");
|
}
|
|
StringBuffer sb = new StringBuffer();
|
// 数据异常状态判断
|
WorkProcessDetectionResultEnum detectionResult = WorkProcessDetectionResultEnum.NORMAL;
|
// 氧气
|
if (reqDTO.getOxygen() != null && reqDTO.getOxygen().compareTo(new BigDecimal("18")) < 0) {
|
detectionResult = WorkProcessDetectionResultEnum.ABNORMAL;
|
sb.append("氧气浓度低于");
|
sb.append("18");
|
sb.append(",");
|
}
|
// 可燃气
|
if (reqDTO.getCombustible() != null && reqDTO.getCombustible().compareTo(new BigDecimal("1")) > 0) {
|
detectionResult = WorkProcessDetectionResultEnum.ABNORMAL;
|
sb.append("可燃气浓度超过");
|
sb.append("18");
|
sb.append(",");
|
}
|
// 一氧化碳
|
if (reqDTO.getCarbonMonoxide() != null && reqDTO.getCarbonMonoxide().compareTo(new BigDecimal("24")) > 0) {
|
detectionResult = WorkProcessDetectionResultEnum.ABNORMAL;
|
sb.append("一氧化碳浓度超过");
|
sb.append("24");
|
sb.append(",");
|
}
|
// 硫化氢
|
if (reqDTO.getHydrogenSulfide() != null && reqDTO.getHydrogenSulfide().compareTo(new BigDecimal("10")) > 0) {
|
detectionResult = WorkProcessDetectionResultEnum.ABNORMAL;
|
sb.append("硫化氢浓度超过");
|
sb.append("10");
|
sb.append(",");
|
}
|
if (sb.length() > 0) {
|
sb.deleteCharAt(sb.length() - 1);
|
}
|
|
String workPermitNo = reqDTO.getWorkPermitNo().trim();
|
WorkApplyInfo workApplyInfo = workApplyInfoService.getApplyInfoByWorkPermitNo(workPermitNo);
|
if (workApplyInfo == null) {
|
throw new AusinessException(E.DATA_PARAM_CHECK_INVALID, "作业编号不存在");
|
}
|
// 审批结束
|
if (!workApplyInfo.getStatus().equals(WorkApplyStatusEnum.STATU_FINISH.getStatus())) {
|
throw new AusinessException(E.DATA_STATUS_CHECK_INVALID, "未结束审批作业状态无法上报");
|
}
|
LocalDateTime operationTime = LocalDateTime.now();
|
// 时间校验
|
if (operationTime.isBefore(workApplyInfo.getExpStartTime()) ||
|
operationTime.isAfter(workApplyInfo.getExpEndTime())) {
|
throw new AusinessException(E.DATA_PARAM_CHECK_INVALID, "上报时间不在作业时间内");
|
}
|
// exc
|
WorkProcessDetectionInfo detectionEntity = new WorkProcessDetectionInfo();
|
detectionEntity.setId(IdUtil.getSnowflake(0,0).nextId());
|
detectionEntity.setWorkApplyId(workApplyInfo.getId());
|
detectionEntity.setWorkPermitNo(workPermitNo);
|
detectionEntity.setWorkType(workApplyInfo.getWorkType());
|
detectionEntity.setWorkLevel(workApplyInfo.getWorkLevel());
|
detectionEntity.setOperationTime(operationTime);
|
detectionEntity.setOperatorUid(currentUser.getUid());
|
detectionEntity.setOperatorUname(currentUser.getRealName());
|
detectionEntity.setOperationTime(operationTime);
|
detectionEntity.setInfo(reqDTO.getInfo());
|
detectionEntity.setCombustible(reqDTO.getCombustible());
|
detectionEntity.setOxygen(reqDTO.getOxygen());
|
detectionEntity.setCarbonMonoxide(reqDTO.getCarbonMonoxide());
|
detectionEntity.setHydrogenSulfide(reqDTO.getHydrogenSulfide());
|
detectionEntity.setStatus(WorkProcessDetectionStatusEnum.VALID.code);
|
detectionEntity.setSource(reqDTO.getSource());
|
detectionEntity.setResult(detectionResult.code);
|
workProcessDetectionInfoService.saveWorkProcessDetectionInfo(detectionEntity);
|
|
// 异常 => 预警
|
if (detectionResult == WorkProcessDetectionResultEnum.ABNORMAL) {
|
WorkProcessWarningInfo warningInfo = new WorkProcessWarningInfo();
|
warningInfo.setId(IdUtil.getSnowflake(0,0).nextId());
|
warningInfo.setWorkApplyId(workApplyInfo.getId());
|
warningInfo.setWorkPermitNo(workApplyInfo.getWorkPermitNo());
|
warningInfo.setWarningContent(sb.toString());
|
warningInfo.setWarningType(WorkProcessWarningTypeEnum.CHECK.code);
|
warningInfo.setWarningInfo(detectionEntity.getInfo());
|
warningInfo.setOperatorUid(currentUser.getUid());
|
warningInfo.setOperatorUname(currentUser.getRealName());
|
warningInfo.setOperationTime(operationTime);
|
warningInfo.setStatus(WorkProcessWarningStatusEnum.VALID.code);
|
warningInfo.setSource(reqDTO.getSource());
|
warningInfo.setWorkType(workApplyInfo.getWorkType());
|
warningInfo.setWorkLevel(workApplyInfo.getWorkLevel());
|
warningInfo.setOriginalId(detectionEntity.getId());
|
workProcessWarningInfoService.saveWorkProcessWarningInfo(warningInfo);
|
}
|
}
|
|
@Override
|
public SearchResultVO<List<WorkProcessDetectionInfoRespDTO>> listDetectionByPage(ContextCacheUser currentUser, PageQuery<WorkProcessDetectionPageQuery> pageQuery) {
|
|
WorkProcessDetectionPageDBQuery dbQuery = new WorkProcessDetectionPageDBQuery();
|
if (pageQuery.getSearchParams() != null) {
|
dbQuery.setResult(pageQuery.getSearchParams().getResult());
|
dbQuery.setWorkPermitNo(pageQuery.getSearchParams().getWorkPermitNo());
|
dbQuery.setWorkType(pageQuery.getSearchParams().getWorkType());
|
}
|
Page<WorkProcessDetectionInfo> page = new Page<>(pageQuery.getPageIndex(), pageQuery.getPageSize());
|
List<WorkProcessDetectionInfo> dbData = workProcessDetectionInfoService.listWorkDetectionInfoByPage(page, dbQuery);
|
List<WorkProcessDetectionInfoRespDTO> result = new ArrayList<>(dbData.size());
|
if (dbData.size() > 0) {
|
WorkProcessDetectionInfoRespDTO respDTO;
|
WorkTypeEnum workTypeEnum;
|
WorkLevelEnum workLevelEnum;
|
WorkProcessDetectionStatusEnum statusEnum;
|
WorkProcessDetectionResultEnum resultEnum;
|
WorkReportSourceEnum sourceEnum;
|
for (WorkProcessDetectionInfo detectionInfo : dbData) {
|
respDTO = new WorkProcessDetectionInfoRespDTO();
|
respDTO.setWorkProcessDetectionId(detectionInfo.getId());
|
respDTO.setWorkApplyId(detectionInfo.getWorkApplyId());
|
respDTO.setWorkPermitNo(detectionInfo.getWorkPermitNo());
|
respDTO.setWorkType(detectionInfo.getWorkType());
|
workTypeEnum = WorkTypeEnum.parse(detectionInfo.getWorkType());
|
if (workTypeEnum != null) {
|
respDTO.setWorkTypeDesc(workTypeEnum.getName());
|
}
|
respDTO.setWorkLevel(detectionInfo.getWorkLevel());
|
workLevelEnum = WorkLevelEnum.parse(detectionInfo.getWorkLevel());
|
if (workLevelEnum != null) {
|
respDTO.setWorkLevelDesc(workLevelEnum.getTitle());
|
}
|
respDTO.setOperationTime(detectionInfo.getOperationTime());
|
respDTO.setOperatorUname(detectionInfo.getOperatorUname());
|
respDTO.setOperatorUid(detectionInfo.getOperatorUid());
|
respDTO.setInfo(detectionInfo.getInfo());
|
respDTO.setCombustible(detectionInfo.getCombustible());
|
respDTO.setOxygen(detectionInfo.getOxygen());
|
respDTO.setCarbonMonoxide(detectionInfo.getCarbonMonoxide());
|
respDTO.setHydrogenSulfide(detectionInfo.getHydrogenSulfide());
|
respDTO.setStatus(detectionInfo.getStatus());
|
statusEnum = WorkProcessDetectionStatusEnum.parse(detectionInfo.getStatus());
|
if (statusEnum != null) {
|
respDTO.setStatusDesc(statusEnum.value);
|
}
|
respDTO.setResult(detectionInfo.getResult());
|
resultEnum = WorkProcessDetectionResultEnum.parse(detectionInfo.getResult());
|
if (resultEnum != null) {
|
respDTO.setResultDesc(resultEnum.value);
|
}
|
respDTO.setSource(detectionInfo.getSource());
|
sourceEnum = WorkReportSourceEnum.parse(detectionInfo.getSource());
|
if (sourceEnum != null) {
|
respDTO.setSourceDesc(sourceEnum.value);
|
}
|
|
result.add(respDTO);
|
|
}
|
}
|
return new SearchResultVO<>(
|
true,
|
page.getCurrent(),
|
page.getSize(),
|
page.getPages(),
|
page.getTotal(),
|
result,
|
ResultCodes.OK);
|
}
|
|
@Override
|
@Transactional
|
public void checkReport(ContextCacheUser currentUser, WorkProcessCheckReqDTO reqDTO) {
|
if (StringUtils.isBlank(reqDTO.getCheckContent())) {
|
throw new AusinessException(E.DATA_PARAM_NULL, "检查上报内容为空");
|
}
|
if (StringUtils.isBlank(reqDTO.getWorkPermitNo())) {
|
throw new AusinessException(E.DATA_PARAM_NULL,"作业编号为空");
|
}
|
String workPermitNo = reqDTO.getWorkPermitNo().trim();
|
WorkApplyInfo workApplyInfo = workApplyInfoService.getApplyInfoByWorkPermitNo(workPermitNo);
|
if (workApplyInfo == null) {
|
throw new AusinessException(E.DATA_PARAM_CHECK_INVALID, "作业编号不存在");
|
}
|
// 审批结束
|
if (!workApplyInfo.getStatus().equals(WorkApplyStatusEnum.STATU_FINISH.getStatus())) {
|
throw new AusinessException(E.DATA_STATUS_CHECK_INVALID, "未结束审批作业状态无法上报");
|
}
|
LocalDateTime operationTime = LocalDateTime.now();
|
// 时间校验
|
if (operationTime.isBefore(workApplyInfo.getExpStartTime()) ||
|
operationTime.isAfter(workApplyInfo.getExpEndTime())) {
|
throw new AusinessException(E.DATA_PARAM_CHECK_INVALID, "上报时间不在作业时间内");
|
}
|
if (reqDTO.getCheckResult() == null) {
|
throw new AusinessException(E.DATA_PARAM_NULL, "检查上报结果为空");
|
}
|
WorkProcessCheckResultEnum resultEnum = WorkProcessCheckResultEnum.parse(reqDTO.getCheckResult());
|
if (resultEnum == null) {
|
throw new AusinessException(E.DATA_STATUS_CHECK_INVALID, "检查上报结果参数非法");
|
}
|
if (WorkReportSourceEnum.parse(reqDTO.getSource()) == null) {
|
throw new AusinessException(E.DATA_STATUS_CHECK_INVALID, "数据状态非法");
|
}
|
List<WorkMaterialRecordsInfo> listByRfids = null;
|
if (!CollectionUtils.isEmpty(reqDTO.getRfids())) {
|
listByRfids = workMaterialRecordsInfoService.listByRfids(reqDTO.getRfids());
|
}
|
Byte mcResult = -1;
|
if(workApplyInfo.getMaBaseId() != null){
|
mcResult = getMcResult(workApplyInfo.getId(),listByRfids);
|
}
|
|
// exc
|
WorkProcessCheckInfo checkEntity = new WorkProcessCheckInfo();
|
checkEntity.setId(IdUtil.getSnowflake(0,0).nextId());
|
checkEntity.setWorkApplyId(workApplyInfo.getId());
|
checkEntity.setWorkPermitNo(workApplyInfo.getWorkPermitNo());
|
checkEntity.setCheckContent(reqDTO.getCheckContent());
|
checkEntity.setCheckResult(reqDTO.getCheckResult());
|
checkEntity.setOperatorUname(currentUser.getRealName());
|
checkEntity.setOperatorUid(currentUser.getUid());
|
checkEntity.setOperationTime(operationTime);
|
checkEntity.setStatus(WorkProcessCheckStatusEnum.VALID.code);
|
checkEntity.setSource(reqDTO.getSource());
|
checkEntity.setWorkType(workApplyInfo.getWorkType());
|
checkEntity.setWorkLevel(workApplyInfo.getWorkLevel());
|
checkEntity.setInfo(reqDTO.getInfo());
|
checkEntity.setMcResult(mcResult);
|
workProcessCheckInfoService.saveWorkProcessCheckInfo(checkEntity);
|
// img
|
if (reqDTO.getImagePaths() != null && reqDTO.getImagePaths().size() > 0) {
|
List<WorkProcessCheckImgInfo> checkImages = new ArrayList<>();
|
WorkProcessCheckImgInfo checkImg;
|
for (String path : reqDTO.getImagePaths()) {
|
checkImg = new WorkProcessCheckImgInfo();
|
checkImg.setId(IdUtil.getSnowflake(0, 0).nextId());
|
checkImg.setWorkProcessCheckId(checkEntity.getId());
|
checkImg.setPath(path);
|
checkImages.add(checkImg);
|
}
|
workProcessCheckImgInfoService.saveCheckImages(checkImages);
|
}
|
/* //物资检查
|
List<WorkMaterialCheckInfo> materialCheckInfoList = new ArrayList<>();
|
if (!CollectionUtils.isEmpty(reqDTO.getWorkMaterialList())) {
|
for(WorkMaterialCheckReqDTO material:reqDTO.getWorkMaterialList()){
|
WorkMaterialCheckInfo materialCheckInfo = new WorkMaterialCheckInfo();
|
materialCheckInfo.setId(IdUtil.getSnowflake(0,0).nextId());
|
materialCheckInfo.setMaterialName(material.getMaterialName());
|
materialCheckInfo.setSceneCount(material.getSceneCount());
|
materialCheckInfo.setWorkApplyId(workApplyInfo.getId());
|
materialCheckInfo.setUseCount(material.getUseCount());
|
materialCheckInfo.setWpcId(checkEntity.getId());
|
materialCheckInfoList.add(materialCheckInfo);
|
}
|
workMaterialCheckService.saveMaterialCheckBatch(materialCheckInfoList);
|
}*/
|
|
|
// 异常 => 同步存入预警信息
|
if (resultEnum == WorkProcessCheckResultEnum.ABNORMAL) {
|
WorkProcessWarningInfo warningInfo = new WorkProcessWarningInfo();
|
warningInfo.setId(IdUtil.getSnowflake(0,0).nextId());
|
warningInfo.setWorkApplyId(workApplyInfo.getId());
|
warningInfo.setWorkPermitNo(workApplyInfo.getWorkPermitNo());
|
warningInfo.setWarningContent(checkEntity.getCheckContent());
|
warningInfo.setWarningType(WorkProcessWarningTypeEnum.CHECK.code);
|
warningInfo.setWarningInfo(checkEntity.getInfo());
|
warningInfo.setOperatorUid(currentUser.getUid());
|
warningInfo.setOperatorUname(currentUser.getRealName());
|
warningInfo.setOperationTime(operationTime);
|
warningInfo.setStatus(WorkProcessWarningStatusEnum.VALID.code);
|
warningInfo.setSource(reqDTO.getSource());
|
warningInfo.setWorkType(workApplyInfo.getWorkType());
|
warningInfo.setWorkLevel(workApplyInfo.getWorkLevel());
|
warningInfo.setOriginalId(checkEntity.getId());
|
workProcessWarningInfoService.saveWorkProcessWarningInfo(warningInfo);
|
|
}
|
|
}
|
private Byte getMcResult(Long workApplyId, List<WorkMaterialRecordsInfo> list){
|
Byte mcResult = -1;
|
if(!CollectionUtils.isEmpty(list)){
|
List<WorkMaterialInfo> workMaterialInfoList = workMaterialInfoService.listByWorkApplyId(workApplyId);
|
//过滤出必修
|
List<WorkMaterialInfo> selectList = workMaterialInfoList
|
.stream()
|
.filter(wm -> wm.getConfigurationLevel().equals(ConfigurationLevelEnum.MANDATORY.getCode()))
|
.collect(Collectors.toList());
|
if(selectList.size()>0){
|
for(WorkMaterialInfo materialInfo:selectList){
|
//根据部门或者仓库过滤出物资
|
List<WorkMaterialRecordsInfo> collect = list
|
.stream()
|
.filter(cl -> cl.getWorkMaterialId().equals(materialInfo.getId()))
|
.collect(Collectors.toList());
|
if(mcResult != WorkMaterialCheckEnum.UNQUALIFIED.getType()){
|
if(collect.size()>=materialInfo.getUseCount()){
|
mcResult = WorkMaterialCheckEnum.QUALIFIED.getType();
|
}else {
|
mcResult = WorkMaterialCheckEnum.UNQUALIFIED.getType();
|
}
|
}
|
|
}
|
}else{
|
mcResult = WorkMaterialCheckEnum.UNQUALIFIED.getType();
|
}
|
}
|
return mcResult;
|
}
|
|
@Override
|
public SearchResultVO<List<WorkProcessCheckInfoRespDTO>> listCheckByPage(ContextCacheUser currentUser, PageQuery<WorkProcessCheckPageQuery> pageQuery) {
|
WorkProcessCheckPageDBQuery dbQuery = new WorkProcessCheckPageDBQuery();
|
if (pageQuery.getSearchParams() != null) {
|
dbQuery.setCheckResult(pageQuery.getSearchParams().getCheckResult());
|
dbQuery.setWorkPermitNo(pageQuery.getSearchParams().getWorkPermitNo());
|
dbQuery.setWorkType(pageQuery.getSearchParams().getWorkType());
|
}
|
|
Page<WorkProcessCheckInfo> page = new Page<>(pageQuery.getPageIndex(), pageQuery.getPageSize());
|
List<WorkProcessCheckInfo> dbData = workProcessCheckInfoService.listWorkProcessCheckInfoByPage(page, dbQuery);
|
List<WorkMaterialCheckInfo> materialCheckInfoList = new ArrayList<>();
|
if(!CollectionUtils.isEmpty(dbData)){
|
List<Long> idList = dbData.stream().map(WorkProcessCheckInfo::getId).collect(Collectors.toList());
|
materialCheckInfoList = workMaterialCheckService.getListByWpcIds(idList);
|
}
|
List<WorkProcessCheckInfoRespDTO> result = new ArrayList<>(dbData.size());
|
if (dbData.size() > 0) {
|
WorkProcessCheckInfoRespDTO respDTO;
|
WorkTypeEnum workTypeEnum;
|
WorkLevelEnum workLevelEnum;
|
WorkReportSourceEnum sourceEnum;
|
WorkProcessCheckStatusEnum statusEnum;
|
WorkProcessCheckResultEnum resultEnum;
|
for (WorkProcessCheckInfo checkInfo : dbData) {
|
respDTO = new WorkProcessCheckInfoRespDTO();
|
respDTO.setWorkProcessCheckId(checkInfo.getId());
|
respDTO.setWorkApplyId(checkInfo.getWorkApplyId());
|
respDTO.setWorkPermitNo(checkInfo.getWorkPermitNo());
|
respDTO.setWorkType(checkInfo.getWorkType());
|
workTypeEnum = WorkTypeEnum.parse(checkInfo.getWorkType());
|
if (workTypeEnum != null) {
|
respDTO.setWorkTypeDesc(workTypeEnum.getName());
|
}
|
respDTO.setWorkLevel(checkInfo.getWorkLevel());
|
workLevelEnum = WorkLevelEnum.parse(checkInfo.getWorkLevel());
|
if (workLevelEnum != null) {
|
respDTO.setWorkLevelDesc(workLevelEnum.getTitle());
|
}
|
respDTO.setOperationTime(checkInfo.getOperationTime());
|
respDTO.setOperatorUname(checkInfo.getOperatorUname());
|
respDTO.setOperatorUid(checkInfo.getOperatorUid());
|
respDTO.setInfo(checkInfo.getInfo());
|
respDTO.setStatus(checkInfo.getStatus());
|
respDTO.setSource(checkInfo.getSource());
|
respDTO.setMcResult(checkInfo.getMcResult());
|
sourceEnum = WorkReportSourceEnum.parse(checkInfo.getSource());
|
if (sourceEnum != null) {
|
respDTO.setSourceDesc(sourceEnum.value);
|
}
|
statusEnum = WorkProcessCheckStatusEnum.parse(checkInfo.getStatus());
|
if (statusEnum != null) {
|
respDTO.setStatusDesc(statusEnum.value);
|
}
|
WorkMaterialCheckEnum materialCheckEnum = WorkMaterialCheckEnum.parse(checkInfo.getMcResult());
|
if(materialCheckEnum != null){
|
respDTO.setMcResultName(materialCheckEnum.getDesc());
|
}
|
respDTO.setCheckContent(checkInfo.getCheckContent());
|
respDTO.setCheckResult(checkInfo.getCheckResult());
|
resultEnum = WorkProcessCheckResultEnum.parse(checkInfo.getCheckResult());
|
if (resultEnum != null) {
|
respDTO.setCheckResultDesc(resultEnum.value);
|
}
|
List<WorkProcessCheckImgInfo> images = workProcessCheckImgInfoService.listImagesByCheckId(checkInfo.getId());
|
respDTO.setImagePaths(images.stream().map(item -> specialWorkMinoService.viewFiles(item.getPath())).collect(Collectors.toList()));
|
//获取对应物资检查的数据
|
List<WorkMaterialCheckInfo> selectList = materialCheckInfoList
|
.stream()
|
.filter(mc -> mc.getWpcId().equals(checkInfo.getId()))
|
.collect(Collectors.toList());
|
List<WorkMaterialCheckRespDTO> list = new ArrayList<>();
|
if(selectList.size()>0){
|
list = BeanCopyUtils.copyBeanList(selectList, WorkMaterialCheckRespDTO.class);
|
}
|
respDTO.setWorkMaterialCheckList(list);
|
result.add(respDTO);
|
|
}
|
}
|
return new SearchResultVO<>(
|
true,
|
page.getCurrent(),
|
page.getSize(),
|
page.getPages(),
|
page.getTotal(),
|
result,
|
ResultCodes.OK);
|
}
|
|
@Override
|
public SearchResultVO<List<WorkProcessWarningInfoRespDTO>> listWarningByPage(ContextCacheUser currentUser, PageQuery<WorkProcessWarningPageQuery> pageQuery) {
|
WorkProcessWarningPageDBQuery dbQuery = new WorkProcessWarningPageDBQuery();
|
if (pageQuery.getSearchParams() != null) {
|
dbQuery.setWarningType(pageQuery.getSearchParams().getWarningType());
|
dbQuery.setWorkPermitNo(pageQuery.getSearchParams().getWorkPermitNo());
|
dbQuery.setWorkType(pageQuery.getSearchParams().getWorkType());
|
}
|
Page<WorkProcessWarningInfo> page = new Page<>(pageQuery.getPageIndex(), pageQuery.getPageSize());
|
List<WorkProcessWarningInfo> dbData = workProcessWarningInfoService.listWorkProcessWarningInfoByPage(page, dbQuery);
|
List<WorkProcessWarningInfoRespDTO> result = new ArrayList<>(dbData.size());
|
if (dbData.size() > 0) {
|
WorkProcessWarningInfoRespDTO respDTO;
|
WorkProcessWarningTypeEnum warningTypeEnum;
|
WorkProcessWarningStatusEnum statusEnum;
|
WorkReportSourceEnum sourceEnum;
|
WorkTypeEnum workTypeEnum;
|
WorkLevelEnum workLevelEnum;
|
for (WorkProcessWarningInfo warningInfo : dbData) {
|
respDTO = new WorkProcessWarningInfoRespDTO();
|
respDTO.setWorkProcessWarningId(warningInfo.getId());
|
respDTO.setWorkApplyId(warningInfo.getWorkApplyId());
|
respDTO.setWorkPermitNo(warningInfo.getWorkPermitNo());
|
respDTO.setWarningContent(warningInfo.getWarningContent());
|
respDTO.setWarningType(warningInfo.getWarningType());
|
warningTypeEnum = WorkProcessWarningTypeEnum.parse(warningInfo.getWarningType());
|
if (warningTypeEnum != null) {
|
respDTO.setWarningTypeDesc(warningTypeEnum.value);
|
}
|
respDTO.setWarningInfo(warningInfo.getWarningInfo());
|
respDTO.setOperatorUid(warningInfo.getOperatorUid());
|
respDTO.setOperatorUname(warningInfo.getOperatorUname());
|
respDTO.setOperationTime(warningInfo.getOperationTime());
|
respDTO.setStatus(warningInfo.getStatus());
|
statusEnum = WorkProcessWarningStatusEnum.parse(warningInfo.getStatus());
|
if (statusEnum != null) {
|
respDTO.setStatusDesc(statusEnum.value);
|
}
|
respDTO.setSource(warningInfo.getSource());
|
sourceEnum = WorkReportSourceEnum.parse(warningInfo.getSource());
|
respDTO.setSourceDesc(sourceEnum.value);
|
respDTO.setWorkType(warningInfo.getWorkType());
|
workTypeEnum = WorkTypeEnum.parse(warningInfo.getWorkType());
|
if (workTypeEnum != null) {
|
respDTO.setWorkTypeDesc(workTypeEnum.getName());
|
}
|
respDTO.setWorkLevel(warningInfo.getWorkLevel());
|
workLevelEnum = WorkLevelEnum.parse(warningInfo.getWorkLevel());
|
if (workLevelEnum != null) {
|
respDTO.setWorkLevelDesc(workLevelEnum.getTitle());
|
}
|
if (warningTypeEnum == WorkProcessWarningTypeEnum.CHECK) {
|
List<WorkProcessCheckImgInfo> images = workProcessCheckImgInfoService.listImagesByCheckId(warningInfo.getOriginalId());
|
respDTO.setImagePaths(images.stream().map(item -> specialWorkMinoService.viewFiles(item.getPath())).collect(Collectors.toList()));
|
}
|
result.add(respDTO);
|
}
|
}
|
return new SearchResultVO<>(
|
true,
|
page.getCurrent(),
|
page.getSize(),
|
page.getPages(),
|
page.getTotal(),
|
result,
|
ResultCodes.OK);
|
}
|
|
@Override
|
public List<WorkApplyReportableRespDTO> listReportableWorkApply(ContextCacheUser currentUser, WorkProcessWorkApplyQuery query) {
|
|
|
WorkProcessWorkApplyDBQuery dbQuery = new WorkProcessWorkApplyDBQuery();
|
dbQuery.setWorkPermitNo(query.getWorkPermitNo());
|
dbQuery.setWorkType(query.getWorkType());
|
dbQuery.setNow(LocalDateTime.now());
|
dbQuery.setStatus(WorkApplyStatusEnum.STATU_FINISH.getStatus());
|
List<WorkApplyReportableDO> dbData = workApplyInfoService.listReportableWorkApply(dbQuery);
|
List<WorkApplyReportableRespDTO> result = new ArrayList<>(dbData.size());
|
if (dbData.size() > 0) {
|
WorkApplyReportableRespDTO respDTO;
|
WorkTypeEnum typeEnum;
|
WorkLevelEnum levelEnum;
|
WorkApplyStatusEnum statusEnum;
|
for (WorkApplyReportableDO workApplyInfo : dbData) {
|
respDTO = new WorkApplyReportableRespDTO();
|
respDTO.setWorkApplyId(workApplyInfo.getId());
|
respDTO.setWorkType(workApplyInfo.getWorkType());
|
respDTO.setWorkLevel(workApplyInfo.getWorkLevel());
|
respDTO.setWorkPermitNo(workApplyInfo.getWorkPermitNo());
|
respDTO.setWorkContent(workApplyInfo.getWorkContent());
|
respDTO.setWorkLocation(workApplyInfo.getWorkLocation());
|
respDTO.setHazardIdentification(workApplyInfo.getHazardIdentification());
|
respDTO.setStatus(workApplyInfo.getStatus());
|
typeEnum = WorkTypeEnum.parse(workApplyInfo.getWorkType());
|
if (typeEnum != null) {
|
respDTO.setWorkTypeDesc(typeEnum.getName());
|
}
|
levelEnum = WorkLevelEnum.parse(workApplyInfo.getWorkLevel());
|
if (levelEnum != null) {
|
respDTO.setWorkLevelDesc(levelEnum.getTitle());
|
}
|
statusEnum = WorkApplyStatusEnum.parse(workApplyInfo.getStatus());
|
if (statusEnum != null) {
|
respDTO.setStatusDesc(statusEnum.getDesc());
|
}
|
respDTO.setExpStartTime(workApplyInfo.getExpStartTime());
|
respDTO.setExpEndTime(workApplyInfo.getExpEndTime());
|
result.add(respDTO);
|
}
|
}
|
return result;
|
}
|
|
@Override
|
public ResultVO<List<ConfigurationLevelCheckRespDTO>> chekMaterialList(ContextCacheUser currentUser, String workPermitNo) {
|
if(StringUtils.isBlank(workPermitNo)){
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
WorkApplyInfo workApplyInfo = workApplyInfoService.getApplyInfoByWorkPermitNo(workPermitNo.trim());
|
if (workApplyInfo == null) {
|
throw new AusinessException(E.DATA_PARAM_CHECK_INVALID, "作业编号不存在");
|
}
|
List<ConfigurationLevelCheckRespDTO> list = new ArrayList<>();
|
if(null != workApplyInfo.getMaBaseId()) {
|
//获取
|
List<WorkMaterialInfo> workMaterialInfoList = workMaterialInfoService.listByWorkApplyId(workApplyInfo.getId());
|
//循环配置级别
|
for (ConfigurationLevelEnum levelEnum : ConfigurationLevelEnum.values()) {
|
ConfigurationLevelCheckRespDTO levelCheckRespDTO = new ConfigurationLevelCheckRespDTO();
|
levelCheckRespDTO.setConfigurationLevel(levelEnum.getCode());
|
levelCheckRespDTO.setConfigurationLevelName(levelEnum.getValue());
|
List<WorkMaterialInfo> selectList = workMaterialInfoList
|
.stream().filter(wm -> wm.getConfigurationLevel().equals(levelEnum.getCode()))
|
.collect(Collectors.toList());
|
if (selectList.size() > 0) {
|
List<MaterialCheckRespDTO> materialList = new ArrayList<>();
|
for (WorkMaterialInfo materialInfo : selectList) {
|
MaterialCheckRespDTO materialCheckRespDTO = new MaterialCheckRespDTO();
|
materialCheckRespDTO.setMaterialName(materialInfo.getMaterialName());
|
materialCheckRespDTO.setConfigurationLevel(materialInfo.getConfigurationLevel());
|
materialCheckRespDTO.setUseCount(materialInfo.getUseCount());
|
materialList.add(materialCheckRespDTO);
|
}
|
levelCheckRespDTO.setMdList(materialList);
|
list.add(levelCheckRespDTO);
|
}
|
}
|
}
|
return new ResultVO<>(ResultCodes.OK,list);
|
}
|
|
public List<WorkMaterialRecordsRespDTO> getListByRfids(List<String> rfids){
|
if(CollectionUtils.isEmpty(rfids)){
|
throw new BusinessException(ResultCodes.SERVER_PARAM_NULL);
|
}
|
List<WorkMaterialRecordsRespDTO> list = new ArrayList<>();
|
List<WorkMaterialRecordsInfo> workMaterialRecordsInfoList = workMaterialRecordsInfoService.listByRfids(rfids);
|
if(!CollectionUtils.isEmpty(workMaterialRecordsInfoList)){
|
list = BeanCopyUtils.copyBeanList(workMaterialRecordsInfoList,WorkMaterialRecordsRespDTO.class);
|
}
|
return list;
|
}
|
|
}
|