diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java index 70b38697ce..2ea0aa08d0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java @@ -1,10 +1,12 @@ package com.epmet.service.evaluationindex.indexcoll.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.LockConstants; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.OrgTypeConstant; @@ -29,6 +31,7 @@ import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -200,7 +203,17 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { } while (deleteNum > NumConstant.ZERO); } if (!CollectionUtils.isEmpty(formDTO.getDataList())) { - factIndexGovrnAblityDeptMonthlyDao.batchInsertFactIndexGovrnAblityDeptMonthly(formDTO.getDataList(), customerId); + List dataList = formDTO.getDataList(); + // 有 deptId字段为空时,报错提示 + List deptIsNull = dataList.stream().filter(d -> null == d.getDeptId() || d.getDeptId().equals("")).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(deptIsNull)){ + throw new RenException("治理能力-部门相关指标计算【deptId为空】的客户ID为:"+customerId+",具体信息信息为:"+ JSON.toJSONString(deptIsNull)); + } + // 改成分批插入 + List> partition = ListUtils.partition(dataList, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + factIndexGovrnAblityDeptMonthlyDao.batchInsertFactIndexGovrnAblityDeptMonthly(p, customerId); + }); } }