|
|
@@ -42,6 +42,7 @@ import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 研发项目固定资产表 服务实现类
|
|
|
@@ -84,11 +85,11 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
}
|
|
|
Date lastDate = DateUtil.minusMonths(DateUtil.parse(yearAndMonth, DateUtil.PATTERN_YYYYMM), 1);
|
|
|
//获取上个月数据
|
|
|
-
|
|
|
List<XmFixedAsset> lastMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(DateUtil.format(lastDate, DateUtil.PATTERN_YYYYMM), type.getCode());
|
|
|
//获取本月数据
|
|
|
List<XmFixedAsset> thisMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(yearAndMonth, type.getCode());
|
|
|
- List<String> zcbmList = thisMonthList.stream().map(XmFixedAsset::getZcbm).toList();
|
|
|
+
|
|
|
+ Map<Long, List<String>> map = thisMonthList.stream().collect(Collectors.groupingBy(XmFixedAsset::getXmId, Collectors.mapping(XmFixedAsset::getZcbm, Collectors.toList())));
|
|
|
|
|
|
//已结题项目列表
|
|
|
List<Long> jtXmIdList = new ArrayList<>();
|
|
|
@@ -97,10 +98,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
if (!CollectionUtil.isEmpty(lastMonthList)) {
|
|
|
//复制上个月数据到本月
|
|
|
for (XmFixedAsset dbAsset : lastMonthList) {
|
|
|
- //dbAsset已存在,则跳过
|
|
|
- if (zcbmList.contains(dbAsset.getZcbm())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+
|
|
|
if (jtXmIdList.contains(dbAsset.getXmId())) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -111,6 +109,18 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
if (dbAsset.getAsset() != null && !Func.equals(dbAsset.getAsset().getStatus(), AssetStatusEnum.正常.getCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ //dbAsset已存在,则跳过
|
|
|
+ List<String> thisMonthZcbmList = map.get(dbAsset.getXmId());
|
|
|
+ if(Func.isNull(thisMonthZcbmList)){
|
|
|
+ thisMonthZcbmList = new ArrayList<>();
|
|
|
+ map.put(dbAsset.getXmId(), thisMonthZcbmList);
|
|
|
+ }
|
|
|
+ if (thisMonthZcbmList.contains(dbAsset.getZcbm())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ thisMonthZcbmList.add(dbAsset.getZcbm());
|
|
|
+
|
|
|
XmFixedAsset asset = new XmFixedAsset();
|
|
|
asset.setYearAndMonth(yearAndMonth);
|
|
|
asset.setXmId(dbAsset.getXmId());
|
|
|
@@ -125,9 +135,7 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
throw new ServiceException("项目预算表中无数据");
|
|
|
}
|
|
|
for (YsZjfyycqdtfyEntity ys : ysList) {
|
|
|
- if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(ys.getZcbm())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+
|
|
|
if (jtXmIdList.contains(ys.getXmId())) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -138,6 +146,17 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
if (!Func.equals(ys.getAssetStatus(), AssetStatusEnum.正常.getCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ List<String> thisMonthZcbmList = map.get(ys.getXmId());
|
|
|
+ if(Func.isNull(thisMonthZcbmList)){
|
|
|
+ thisMonthZcbmList = new ArrayList<>();
|
|
|
+ map.put(ys.getXmId(), thisMonthZcbmList);
|
|
|
+ }
|
|
|
+ if (thisMonthZcbmList.contains(ys.getZcbm())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ thisMonthZcbmList.add(ys.getZcbm());
|
|
|
+
|
|
|
XmFixedAsset asset = new XmFixedAsset();
|
|
|
asset.setYearAndMonth(yearAndMonth);
|
|
|
asset.setXmId(ys.getXmId());
|
|
|
@@ -164,15 +183,13 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
}
|
|
|
//获取本月数据
|
|
|
List<XmFixedAsset> thisMonthList = baseMapper.selectXmFixedAssetByYearAndMonth(yearAndMonth, type.getCode());
|
|
|
- List<String> zcbmList = thisMonthList.stream().map(XmFixedAsset::getZcbm).toList();
|
|
|
+ Map<Long, List<String>> map = thisMonthList.stream().collect(Collectors.groupingBy(XmFixedAsset::getXmId, Collectors.mapping(XmFixedAsset::getZcbm, Collectors.toList())));
|
|
|
|
|
|
List<XmFixedAsset> insertList = new ArrayList<>();
|
|
|
Map<String, Long> xmIdMap = new HashMap<>();
|
|
|
Map<String, AssetEntity> assetIdMap = new HashMap<>();
|
|
|
for (XmFixedAssetExcel excel : data) {
|
|
|
- if (CollectionUtil.isNotEmpty(zcbmList) && zcbmList.contains(excel.getZcbm())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+
|
|
|
if (Func.isBlank(excel.getXmbh())) {
|
|
|
throw new ServiceException("序号为[" + excel.getXh() + "]的项目研发编号为空");
|
|
|
}
|
|
|
@@ -206,6 +223,17 @@ public class XmFixedAssetServiceImpl extends BaseServiceImpl<XmFixedAssetMapper,
|
|
|
}
|
|
|
assetIdMap.put(assetkey, dbAsset);
|
|
|
|
|
|
+ List<String> zcbmList = map.get(xmId);
|
|
|
+ if(Func.isNull(zcbmList)){
|
|
|
+ zcbmList = new ArrayList<>();
|
|
|
+ map.put(xmId, zcbmList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (zcbmList.contains(excel.getZcbm())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ zcbmList.add(excel.getZcbm());
|
|
|
+
|
|
|
XmFixedAsset xmAsset = new XmFixedAsset();
|
|
|
xmAsset.setYearAndMonth(yearAndMonth);
|
|
|
xmAsset.setXmId(xmId);
|