Commit 257079eb authored by suhuiguang's avatar suhuiguang

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

1.压力管道管道长度调整为字符串/分隔开
parent 1beaf2dc
...@@ -8,9 +8,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -8,9 +8,7 @@ import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.Optional;
import static com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant.PIPE_LENGTH; import static com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant.PIPE_LENGTH;
import static com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant.PIPE_LENGTH_SPILT; import static com.yeejoin.amos.boot.module.jg.api.common.BizCommonConstant.PIPE_LENGTH_SPILT;
...@@ -34,7 +32,6 @@ public final class PipLenCalUtils { ...@@ -34,7 +32,6 @@ public final class PipLenCalUtils {
} }
public static double getPipLen(List<PipingExcelDto> equLists) { public static double getPipLen(List<PipingExcelDto> equLists) {
return equLists.stream() return equLists.stream()
.map(PipingExcelDto::getPipeLength) .map(PipingExcelDto::getPipeLength)
...@@ -53,6 +50,21 @@ public final class PipLenCalUtils { ...@@ -53,6 +50,21 @@ public final class PipLenCalUtils {
} }
public static BigDecimal calBigDecimal(String pipeLengthText) { 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); 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);
}
public static double getPipLenMap(List<Map<String, Object>> equLists) {
return equLists.stream()
.map(r -> r.get("pipeLengthText"))
.filter(Objects::nonNull)
.map(String::valueOf)
.filter(s -> !"null".equals(s) && StringUtil.isNotEmpty(s))
.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();
} }
} }
...@@ -1267,7 +1267,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1267,7 +1267,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private String getTipMsgString(String record) { private String getTipMsgString(String record) {
IdxBizJgRegisterInfo registerInfo = this.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", record)); IdxBizJgRegisterInfo registerInfo = this.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", record));
return String.format("存在被引用的设备,设备代码:%s", registerInfo.getEquCode()); return String.format("存在业务办理中的设备,设备代码:%s", registerInfo.getEquCode());
} }
/** /**
......
...@@ -635,7 +635,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR ...@@ -635,7 +635,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
} }
}); });
// 管道长度更新为最新的 // 管道长度更新为最新的
paramObj.put("pipelineLength", JyjcInspectionApplicationServiceImpl.calTotalLength(equips)); paramObj.put("pipelineLength", PipLenCalUtils.getPipLenMap(equips));
paramObj.put("equip", equips); paramObj.put("equip", equips);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
......
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