Commit 0f9103d4 authored by suhuiguang's avatar suhuiguang

reafact(jyjc): 压力管道管道长度

1.压力管道管道长度调整为字符串/分隔开 2.手工录入结果适配调整 3.系统对接时管道长度适配
parent 608288eb
package com.yeejoin.amos.boot.module.jyjc.biz.result.processor;
import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -114,33 +115,33 @@ public class BatchEquipResultDataProcessor implements SupportableResultDataProce
throw new RuntimeException(e);
}
// 5.新计算管道长度
calAndWriteTotalPipelineLength(jyjcInspectionResult);
inspectionResultService.calAndWriteTotalPipelineLength(jyjcInspectionResult.getEquipUnicode());
// 6.发送数据刷新消息
inspectionResultService.sendDataRefreshMsg(records);
}
}
private void calAndWriteTotalPipelineLength(JyjcInspectionResult jyjcInspectionResult) {
List<IdxBizJgTechParamsPipeline> allPipeLines = idxBizJgProjectContraptionMapper.selectPipelineListByProjectContraptionId(jyjcInspectionResult.getEquipUnicode());
Double totalPipelineLength = allPipeLines.stream().map(IdxBizJgTechParamsPipeline::getPipeLength).filter(Objects::nonNull).map(this::parseToBigDecimal)
.reduce(BigDecimal.ZERO, BigDecimal::add)
.setScale(3, RoundingMode.HALF_UP).doubleValue();
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BaseEntity::getSequenceNbr, jyjcInspectionResult.getEquipUnicode());
updateWrapper.set(IdxBizJgProjectContraption::getPipelineLength, totalPipelineLength);
idxBizJgProjectContraptionMapper.update(null, updateWrapper);
}
private BigDecimal parseToBigDecimal(String value) {
try {
return new BigDecimal(value);
} catch (NumberFormatException e) {
return BigDecimal.ZERO;
}
private void updateTechParams(Map<String, Object> e, String record) {
this.doUpdatePipelineTechParams(e, record, techParamPipelineMapper);
}
private void updateTechParams(Map<String, Object> e, String record) {
JyjcInspectionResultServiceImpl.doUpdatePipelineTechParams(e, record, techParamPipelineMapper);
private void doUpdatePipelineTechParams(Map<String, Object> e, String record, IdxBizJgTechParamsPipelineMapper techParamPipelineMapper) {
IdxBizJgTechParamsPipeline techParamPipeline = new IdxBizJgTechParamsPipeline();
BeanUtil.copyProperties(e, techParamPipeline, true);
LambdaUpdateWrapper<IdxBizJgTechParamsPipeline> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgTechParamsPipeline::getRecord, record);
updateWrapper.set(IdxBizJgTechParamsPipeline::getNominalDiameter, techParamPipeline.getNominalDiameter());
updateWrapper.set(IdxBizJgTechParamsPipeline::getWallThickness, techParamPipeline.getWallThickness());
// TODO 此处注意由于pipeLength字段在检验对接时使用,未不修改对接文档字段,只修改数据类型由之前的浮点型调整为文本型,减少对接文档的调整,故如此
updateWrapper.set(IdxBizJgTechParamsPipeline::getPipeLengthText, techParamPipeline.getPipeLength());
updateWrapper.set(IdxBizJgTechParamsPipeline::getPressure, techParamPipeline.getPressure());
updateWrapper.set(IdxBizJgTechParamsPipeline::getTemperature, techParamPipeline.getTemperature());
updateWrapper.set(IdxBizJgTechParamsPipeline::getMedium, techParamPipeline.getMedium());
updateWrapper.set(IdxBizJgTechParamsPipeline::getWorkMedium, techParamPipeline.getWorkMedium());
updateWrapper.set(IdxBizJgTechParamsPipeline::getWorkPressure, techParamPipeline.getWorkPressure());
updateWrapper.set(IdxBizJgTechParamsPipeline::getWorkTemperature, techParamPipeline.getWorkTemperature());
updateWrapper.set(IdxBizJgTechParamsPipeline::getRemarks, techParamPipeline.getRemarks());
techParamPipelineMapper.update(null, updateWrapper);
}
}
......@@ -46,14 +46,12 @@ import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jyjc.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jyjc.biz.util.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgInspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgTechParamsPipeline;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgInspectionDetectionInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgTechParamsPipelineMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.TzsUserInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.UseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.feign.systemctl.model.DictionarieModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
......@@ -77,6 +75,8 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -141,10 +141,6 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
BizEmqPublisher bizEmqPublisher;
@Autowired
@Lazy
JyjcInspectionApplicationServiceImpl inspectionApplicationService;
@Autowired
private CommonMapper jgCommonMapper;
@Autowired
......@@ -168,6 +164,9 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
@Autowired
private EmqKeeper emqKeeper;
@javax.annotation.Resource
private IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
/**
* 检验检测单位分页查询
......@@ -373,6 +372,8 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
// 4.更新es下次检验日期
commonService.updateEquipNextInspectDate(model, record);
});
// 更新装置的汇总的管道长度
calAndWriteTotalPipelineLength(model.getEquipUnicode());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
......@@ -408,6 +409,26 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
return records;
}
public void calAndWriteTotalPipelineLength(String projectContraptionId) {
List<IdxBizJgTechParamsPipeline> allPipeLines = idxBizJgProjectContraptionMapper.selectPipelineListByProjectContraptionId(projectContraptionId);
Double totalPipelineLength = allPipeLines.stream().map(IdxBizJgTechParamsPipeline::getPipeLength).filter(Objects::nonNull).map(this::parseToBigDecimal)
.reduce(BigDecimal.ZERO, BigDecimal::add)
.setScale(3, RoundingMode.HALF_UP).stripTrailingZeros().doubleValue();
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(com.yeejoin.amos.boot.biz.common.entity.BaseEntity::getSequenceNbr, projectContraptionId);
updateWrapper.set(IdxBizJgProjectContraption::getPipelineLength, totalPipelineLength);
idxBizJgProjectContraptionMapper.update(null, updateWrapper);
}
private BigDecimal parseToBigDecimal(String value) {
try {
return new BigDecimal(value);
} catch (NumberFormatException e) {
return BigDecimal.ZERO;
}
}
public void updateTechParam(Long resultSeq, String record) {
List<DynamicColumnDto> columns = new ArrayList<>();
JyjcInspectionResultParam param = iJyjcInspectionResultParamService.getOneParamByResultSeq(resultSeq);
......@@ -1071,7 +1092,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
updateWrapper.eq(IdxBizJgTechParamsPipeline::getRecord, record);
updateWrapper.set(IdxBizJgTechParamsPipeline::getNominalDiameter, techParamPipeline.getNominalDiameter());
updateWrapper.set(IdxBizJgTechParamsPipeline::getWallThickness, techParamPipeline.getWallThickness());
updateWrapper.set(IdxBizJgTechParamsPipeline::getPipeLength, techParamPipeline.getPipeLength());
updateWrapper.set(IdxBizJgTechParamsPipeline::getPipeLengthText, techParamPipeline.getPipeLengthText());
updateWrapper.set(IdxBizJgTechParamsPipeline::getPressure, techParamPipeline.getPressure());
updateWrapper.set(IdxBizJgTechParamsPipeline::getTemperature, techParamPipeline.getTemperature());
updateWrapper.set(IdxBizJgTechParamsPipeline::getMedium, techParamPipeline.getMedium());
......
......@@ -170,7 +170,7 @@ public class IdxBizJgTechParamsPipeline extends TzsBaseEntity {
private String workRemarks;
/**
* 管道长度斜线分隔多段表示用
* 管道长度斜线分隔多段表示用:数字或者 / 分割的数字,如2.1/6.3
*/
@TableField("\"PIPE_LENGTH_TEXT\"")
private String pipeLengthText;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment