Commit 608288eb authored by suhuiguang's avatar suhuiguang

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

1.压力管道管道长度调整为字符串/分隔开
parent e59e14c5
......@@ -72,7 +72,7 @@ public class MetaHandler implements MetaObjectHandler {
// 示例:针对pipeLength的特殊处理
if ("pipeLengthText".equals(pipeLengthField.sourceField())) {
return Arrays.stream(sourceValue.toString().split("/")).filter(Objects::nonNull)
.map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, RoundingMode.HALF_UP).toPlainString();
.map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(3, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
}
// 可扩展其他转换规则
return sourceValue;
......
......@@ -98,7 +98,7 @@ public class TechParamUtil {
return subClass;
}
}
throw new RuntimeException("not found equListCode " + equListCode + "clazz");
throw new RuntimeException("not found equListCode:{ " + equListCode + "} clazz");
}
}
......@@ -398,4 +398,11 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(dataHandlerService.equDefineChangeFix());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@PutMapping(value = "/fixPipeLen")
@ApiOperation(httpMethod = "PUT", value = "压力管道单据的管道长度补充", notes = "压力管道单据的管道长度补充")
public ResponseModel<Long> pipeLenFix(){
return ResponseHelper.buildResponse(dataHandlerService.pipeLenFix());
}
}
\ No newline at end of file
......@@ -44,6 +44,7 @@ import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEdit
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.jg.biz.utils.PipLenCalUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
......@@ -681,6 +682,7 @@ public class DataDockServiceImpl {
equipTechParamPipeline.setTemperature(String.valueOf(equ.get("temperature_YLGD")));
equipTechParamPipeline.setDeviceLevel(String.valueOf(equ.get("deviceLevel_YLGD")));
equipTechParamPipeline.setWorkTemperature(String.valueOf(equ.get("workTemperature_YLGD")));
equipTechParamPipeline.setPipeLengthText(equipTechParamPipeline.getPipeLength());
equipTechParamPipeline.setRecord(record);
equipTechParamPipeline.setRecDate(new Date());
iIdxBizJgTechParamsPipelineService.saveOrUpdateData(equipTechParamPipeline);
......@@ -1251,6 +1253,12 @@ public class DataDockServiceImpl {
* @param errorMessage 错误内容
* @param rowError 错误集
*/
private void checkIsSpiltFormatNumber(String date, String errorMessage, StringBuffer rowError) {
if (!com.yeejoin.amos.boot.module.jg.biz.utils.StringUtils.isValidMultiSlash(date)) {
rowError.append(errorMessage);
}
}
private void checkDateFormatNumber(String date, String errorMessage, StringBuffer rowError) {
if (!NumberUtils.isCreatable(date)) {
rowError.append(errorMessage);
......@@ -1570,7 +1578,7 @@ public class DataDockServiceImpl {
.collect(Collectors.groupingBy(
e -> Objects.toString(e.getProjectContraptionNo(), "").trim(),
Collectors.mapping(
e -> new BigDecimal(Objects.toString(e.getPipeLength(), "0")),
e -> PipLenCalUtils.calBigDecimal(e.getPipeLength()),
Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)
)
));
......@@ -1751,7 +1759,7 @@ public class DataDockServiceImpl {
//checkNotBlank(data.getNominalDiameter(), "公称直径不能为空;", rowError);
//Optional.ofNullable(data.getNominalDiameter()).ifPresent(item -> checkPipeSpecifications(item, "公称直径请输入数字或者/分割的范围,如2/6;", rowError));
checkNotBlank(data.getPipeLength(), "管道长度不能为空;", rowError);
Optional.ofNullable(data.getPipeLength()).ifPresent(item -> checkDateFormatNumber(item, "管道长度必须为数字", rowError));
Optional.ofNullable(data.getPipeLength()).ifPresent(item -> checkIsSpiltFormatNumber(item, "请输入数字或者/分割的数字,如2.1/6.3", rowError));
//checkNotBlank(data.getPressure(), "设计-压力不能为空;", rowError);
//checkNotBlank(data.getMedium(), "设计-介质不能为空;", rowError);
//checkNotBlank(data.getTemperature(), "设计-温度不能为空;", rowError);
......@@ -2044,18 +2052,7 @@ public class DataDockServiceImpl {
.setProductPhoto(toJSONString(equipInfo.get("PRODUCT_PHOTO")))
.setProductQualificationCertificate(toJSONString(equipInfo.get("PRODUCT_QUALIFICATION_CERTIFICATE")))
.setOtherAccessories(ValidationUtil.isEmpty(equipInfo.get("OTHER_ACCESSORIES")) ? null : toJSONString(equipInfo.get("OTHER_ACCESSORIES")))
.setPipelineLength(
Optional.ofNullable(equLists)
.orElse(Collections.emptyList())
.stream()
.filter(Objects::nonNull)
.map(PipingExcelDto::getPipeLength)
.filter(Objects::nonNull)
.map(String::trim)
.filter(s -> !s.isEmpty())
.mapToDouble(Double::parseDouble)
.sum()
)
.setPipelineLength(PipLenCalUtils.getPipLen(equLists))
.setInspectUnitCreditCode(inspectUnitCreditCode)
.setInspectUnitName(inspectUnitName)
.setStartLatitudeLongitude(toJSONString(equipInfo.get("startLatitudeLongitude")))
......@@ -2226,6 +2223,7 @@ public class DataDockServiceImpl {
pipelineInfo.setRecord(record);
pipelineInfo.setRecDate(new Date());
pipelineInfo.setSequenceNbr(null);
pipelineInfo.setPipeLengthText(pipelineInfo.getPipeLength());
// 字典name -》 字典code
pipelineInfo.setDeviceLevel(DictParamsConverter.dictMap.get(pipelineInfo.getDeviceLevel()));
paramsPipelineList.add(pipelineInfo);
......
......@@ -54,6 +54,7 @@ import com.yeejoin.amos.boot.module.ymt.api.dto.ProjectWaitRefreshDataQualitySco
import com.yeejoin.amos.boot.module.ymt.api.dto.RefreshDataDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import lombok.RequiredArgsConstructor;
......@@ -102,7 +103,7 @@ import static com.yeejoin.amos.boot.module.jg.biz.service.impl.JgInstallationNot
@Slf4j
@Service
@RequiredArgsConstructor
public class DataHandlerServiceImpl {
public class DataHandlerServiceImpl {
public static final String IDX_BIZ_VIEW_JG_ALL = "idx_biz_view_jg_all";
public static final String IDX_BIZ_EQUIPMENT_INFO = "idx_biz_equipment_info";
public static final String STATUS = "STATUS";
......@@ -145,6 +146,9 @@ public class DataHandlerServiceImpl {
private final JgChangeVehicleRegistrationUnitMapper jgChangeVehicleRegistrationUnitMapper;
private final JgChangeRegistrationTransferMapper jgChangeRegistrationTransferMapper;
private final JgUseRegistrationManageServiceImpl jgUseRegistrationManageServiceImpl;
private final JgChangeRegistrationReformMapper jgChangeRegistrationReformMapper;
private final JgReformNoticeMapper jgReformNoticeMapper;
private final EsBaseEnterpriseInfoDao enterpriseInfoDao;
......@@ -185,6 +189,8 @@ public class DataHandlerServiceImpl {
private EventPublisher eventPublisher;
@Autowired
private JgUseRegistrationManageMapper jgUseRegistrationManageMapper;
@Autowired
private CommonServiceImpl commonServiceImpl;
/**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
......@@ -2515,4 +2521,120 @@ public class DataHandlerServiceImpl {
});
return Boolean.TRUE;
}
/**
* 压力管道-已完成及作废状态的单据的历史数据管道长度补充
* @return 是否成功
*/
public Long pipeLenFix() {
cn.hutool.core.date.StopWatch watch = new cn.hutool.core.date.StopWatch();
// 1.已完成及作废状态的安装告知
List<JgInstallationNotice> notices = installationNoticeService.list(new LambdaQueryWrapper<JgInstallationNotice>()
.and(w->w.eq(JgInstallationNotice::getNoticeStatus, FlowStatusEnum.TO_BE_FINISHED.getCode() + "")
.or().eq(JgInstallationNotice::getNoticeStatus, FlowStatusEnum.TO_BE_DISCARD.getCode() +""))
.eq(JgInstallationNotice::getEquListCode, EquipmentClassifityEnum.YLGD.getCode())
.select(BaseEntity::getSequenceNbr)
);
watch.start("安装告知" + notices.size());
notices.parallelStream().forEach(n->{
JSONObject jsonObject = commonServiceImpl.queryHistoryData(n.getSequenceNbr());
if(jsonObject != null){
JSONArray jsonArray = jsonObject.getJSONArray("deviceList");
List<JSONObject> pipelines = jsonArray.stream().map(e->{
JSONObject pipeline = JSONObject.parseObject(e.toString());
if(!pipeline.containsKey("pipeLengthText")){
pipeline.put("pipeLengthText", pipeline.get("pipeLength"));
}
return pipeline;
}).collect(Collectors.toList());
jsonObject.put("deviceList", pipelines);
commonServiceImpl.saveOrUpdateHistory(null, jsonObject, null, n.getSequenceNbr() + "" );
}
});
watch.stop();
// 2.已完成及作废状态的使用登记
List<JgUseRegistration> useRegistrations = useRegistrationService.list(new LambdaQueryWrapper<JgUseRegistration>()
.and(w->w.eq(JgUseRegistration::getStatus, FlowStatusEnum.TO_BE_FINISHED.getName()).or()
.eq(JgUseRegistration::getStatus, FlowStatusEnum.TO_BE_DISCARD.getName()))
.ne(JgUseRegistration::getProjectContraptionId, "")
.select(BaseEntity::getSequenceNbr));
watch.start("使用登记" + useRegistrations.size() );
useRegistrations.parallelStream().forEach(u->{
JSONObject jsonObject = commonServiceImpl.queryHistoryData(u.getSequenceNbr());
if(jsonObject != null){
String pipelistKey;
if(jsonObject.containsKey("equipmentLists")){
pipelistKey = "equipmentLists";
} else {
pipelistKey = "pipelineList";
}
JSONArray jsonArray = jsonObject.getJSONArray(pipelistKey);
Optional.ofNullable(jsonArray).ifPresent(d->{
List<JSONObject> pipelines = d.stream().map(e->{
JSONObject pipeline = JSONObject.parseObject(e.toString());
if(!pipeline.containsKey("pipeLengthText")){
pipeline.put("pipeLengthText", pipeline.get("pipeLength"));
}
return pipeline;
}).collect(Collectors.toList());
jsonObject.put(pipelistKey, pipelines);
commonServiceImpl.saveOrUpdateHistory(null, jsonObject, null, u.getSequenceNbr() + "" );
});
}
});
watch.stop();
// 3.已完成及作废状态的改造变更登记
List<JgChangeRegistrationReform> changeRegistrationReforms = jgChangeRegistrationReformMapper.selectList(new LambdaQueryWrapper<JgChangeRegistrationReform>()
.and(w->w.eq(JgChangeRegistrationReform::getStatus, FlowStatusEnum.TO_BE_FINISHED.getName()).or()
.eq(JgChangeRegistrationReform::getStatus, FlowStatusEnum.TO_BE_DISCARD.getName()))
.ne(JgChangeRegistrationReform::getProjectContraptionId, "")
.select(JgChangeRegistrationReform::getApplyNo));
watch.start("改造变更登记" + changeRegistrationReforms.size());
changeRegistrationReforms.parallelStream().forEach(u->{
JSONObject jsonObject = commonServiceImpl.queryHistoryData(u.getApplyNo());
if(jsonObject != null){
JSONArray jsonArray = jsonObject.getJSONArray("equipmentLists");
Optional.ofNullable(jsonArray).ifPresent(d->{
List<JSONObject> pipelines = d.stream().map(e->{
JSONObject pipeline = JSONObject.parseObject(e.toString());
if(!pipeline.containsKey("pipeLengthText")){
pipeline.put("pipeLengthText", pipeline.get("pipeLength"));
}
return pipeline;
}).collect(Collectors.toList());
jsonObject.put("equipmentLists", pipelines);
commonServiceImpl.saveOrUpdateHistory(null, jsonObject, null, u.getApplyNo());
});
}
});
watch.stop();
// 4.已完成及作废状态的改造告知
List<JgReformNotice> reformNotices = jgReformNoticeMapper.selectList(new LambdaQueryWrapper<JgReformNotice>()
.and(w->w.eq(JgReformNotice::getNoticeStatus, FlowStatusEnum.TO_BE_FINISHED.getCode() + "").or()
.eq(JgReformNotice::getNoticeStatus, FlowStatusEnum.TO_BE_DISCARD.getCode() + ""))
.ne(JgReformNotice::getProjectContraptionId, "")
.select(BaseEntity::getSequenceNbr));
watch.start("改造告知" + reformNotices.size());
reformNotices.parallelStream().forEach(u->{
JSONObject jsonObject = commonServiceImpl.queryHistoryData(u.getSequenceNbr());
if(jsonObject != null){
JSONArray jsonArray = jsonObject.getJSONArray("deviceList");
Optional.ofNullable(jsonArray).ifPresent(d->{
List<JSONObject> pipelines = d.stream().map(e->{
JSONObject pipeline = JSONObject.parseObject(e.toString());
if(!pipeline.containsKey("pipeLengthText")){
pipeline.put("pipeLengthText", pipeline.get("pipeLength"));
}
return pipeline;
}).collect(Collectors.toList());
jsonObject.put("deviceList", pipelines);
commonServiceImpl.saveOrUpdateHistory(null, jsonObject, null, u.getSequenceNbr() + "" );
});
}
});
watch.stop();
int num = notices.size() + useRegistrations.size() + reformNotices.size() + changeRegistrationReforms.size();
log.info("压力管道业务单据补充字段pipeLengthText,总处理数量:{}, 耗时信息:{}",num, watch.prettyPrint(TimeUnit.SECONDS));
return (long) (num);
}
}
......@@ -3,10 +3,13 @@ package com.yeejoin.amos.boot.module.jg.biz.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.util.StringUtil;
import com.yeejoin.amos.boot.module.jg.api.dto.PipingExcelDto;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import static com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant.PIPE_LENGTH;
......@@ -26,11 +29,30 @@ public final class PipLenCalUtils {
.map(BigDecimal::new) // 转 BigDecimal
.reduce(BigDecimal.ZERO, BigDecimal::add) // 分段求和
)
.reduce(BigDecimal.ZERO, BigDecimal::add) // 全局求和
.reduce(BigDecimal.ZERO, BigDecimal::add).stripTrailingZeros() // 全局求和
.doubleValue();
}
public static double getPipLen(List<PipingExcelDto> equLists) {
return equLists.stream()
.map(PipingExcelDto::getPipeLength)
.filter(StringUtil::isNotEmpty)
.map(d ->
Arrays.stream(d.split(PIPE_LENGTH_SPILT)) // 分割字符串
.map(BigDecimal::new) // 转 BigDecimal
.reduce(BigDecimal.ZERO, BigDecimal::add) // 分段求和
)
.reduce(BigDecimal.ZERO, BigDecimal::add).stripTrailingZeros() // 全局求和
.doubleValue();
}
public static String cal(String pipeLengthText) {
return Optional.ofNullable(pipeLengthText).filter(StringUtils::isNotEmpty).map(l -> Arrays.stream(l.split(PIPE_LENGTH_SPILT)).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add)).orElse(new BigDecimal("0")).stripTrailingZeros().toPlainString();
return Optional.ofNullable(pipeLengthText).filter(StringUtils::isNotEmpty).map(l -> Arrays.stream(l.split(PIPE_LENGTH_SPILT)).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add)).orElse(BigDecimal.ZERO).stripTrailingZeros().toPlainString();
}
public static BigDecimal calBigDecimal(String pipeLengthText) {
return Optional.ofNullable(pipeLengthText).filter(StringUtils::isNotEmpty).map(l -> Arrays.stream(l.split(PIPE_LENGTH_SPILT)).map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add)).orElse(BigDecimal.ZERO).setScale(3, RoundingMode.HALF_UP);
}
}
......@@ -11,6 +11,8 @@ import java.util.regex.Pattern;
* @Date: 2022/8/4 9:08
*/
public class StringUtils {
private final static String regex = "^(?:[1-9]\\d*(?:\\.\\d*)?|0(?:\\.\\d+)?)(?:/(?:[1-9]\\d*(?:\\.\\d*)?|0(?:\\.\\d+)?))*$";
public static StringJoiner getWhereSql(String operator, Map<String, String> map){
StringJoiner stringJoiner = new StringJoiner(" " + operator +" ");
......@@ -31,4 +33,11 @@ public class StringUtils {
}
return "";
}
public static Boolean isValidMultiSlash(String str){
if (str == null) {
return false;
}
return Pattern.compile(regex).matcher(str).matches();
}
}
......@@ -3,7 +3,6 @@ package com.yeejoin.amos.boot.module.ymt.api.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.annotation.Group;
import com.yeejoin.amos.boot.biz.common.annotation.PipeLengthField;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import lombok.Data;
......@@ -127,7 +126,7 @@ public class IdxBizJgTechParamsPipeline extends TzsBaseEntity {
private String temperature;
/**
* 设计-介质
* 设计-介质
*/
@TableField("\"MEDIUM\"")
private String medium;
......
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