|
|
@@ -103,13 +103,13 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
|
|
|
@Override
|
|
|
public Long approval(XmDTO xm) {
|
|
|
- if(Func.equals(xm.getStatus(), XmStatusEnum.暂存.getCode())){
|
|
|
+ if (Func.equals(xm.getStatus(), XmStatusEnum.暂存.getCode())) {
|
|
|
//检查项目名称是否重复(xm);
|
|
|
Long xmIdByXmmc = baseMapper.getXmIdByXmmcOrXmbh(null, xm.getXmmc(), null);
|
|
|
if (xmIdByXmmc != null && !xmIdByXmmc.equals(xm.getId())) {
|
|
|
throw new ServiceException("研发项目名称已存在");
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
List<String> validate = ValidationUtils.validate(xm);
|
|
|
if (Func.isNotEmpty(validate)) {
|
|
|
throw new ServiceException(String.join(",", validate));
|
|
|
@@ -131,11 +131,9 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
|
|
|
if (xm.getXmyszemx() != null) {
|
|
|
List<JSONObject> list = JSONObject.parseArray(xm.getXmyszemx(), JSONObject.class);
|
|
|
- if (CollectionUtil.isNotEmpty(list)) {
|
|
|
- double total = list.stream().mapToDouble(t -> t.getDouble("amount")).sum();
|
|
|
- if (total != xm.getXmysze().doubleValue()) {
|
|
|
- throw new ServiceException("项目预算总额明细不对");
|
|
|
- }
|
|
|
+ BigDecimal total = list.stream().map(item -> item.getBigDecimal("amount")).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.UP);
|
|
|
+ if (total.compareTo(xm.getXmysze()) != 0) {
|
|
|
+ throw new ServiceException("项目预算总额明细不对");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -213,7 +211,7 @@ public class XmServiceImpl extends BaseServiceImpl<XmMapper, XmEntity> implement
|
|
|
|
|
|
List<JSONObject> xmysmx = JSON.parseArray(xmVO.getXmyszemx(), JSONObject.class);
|
|
|
//预算总额
|
|
|
- xmVO.setXmysze(xmysmx.stream().map(item -> item.getBigDecimal("amount")).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.UP));
|
|
|
+ xmVO.setXmysze(xmysmx.stream().map(item -> item.getBigDecimal("amount")).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.UP));
|
|
|
|
|
|
//本年度预算
|
|
|
for (JSONObject o : xmysmx) {
|