|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -77,15 +78,15 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
@Override
|
|
|
public List<WbsTreeVO2> tree(String wbsId, String tenantId, String type) {
|
|
|
boolean fi;
|
|
|
- do{
|
|
|
- WbsTreePrivate wbsTreePrivate= this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId,wbsId));
|
|
|
- if(wbsTreePrivate!=null){
|
|
|
- fi=true;
|
|
|
- wbsId=wbsTreePrivate.getWbsId();
|
|
|
- }else{
|
|
|
- fi=false;
|
|
|
+ do {
|
|
|
+ WbsTreePrivate wbsTreePrivate = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, wbsId));
|
|
|
+ if (wbsTreePrivate != null) {
|
|
|
+ fi = true;
|
|
|
+ wbsId = wbsTreePrivate.getWbsId();
|
|
|
+ } else {
|
|
|
+ fi = false;
|
|
|
}
|
|
|
- }while (fi);
|
|
|
+ } while (fi);
|
|
|
List<WbsTreeVO2> wbsTreeVO2s = baseMapper.tree2(wbsId, tenantId, type);
|
|
|
if (wbsTreeVO2s.size() > 0) {
|
|
|
return buildWbsTreeByStream(wbsTreeVO2s);
|
|
@@ -322,7 +323,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
|
|
|
@Override
|
|
|
public List<WbsFormElementVO> selectFormElements(String id, Long nodeId) {
|
|
|
- List<WbsFormElementVO> wbsFormElements = wbsTreeMapper.selectFormElements(id);;
|
|
|
+ List<WbsFormElementVO> wbsFormElements = wbsTreeMapper.selectFormElements(id);
|
|
|
+ ;
|
|
|
if (Func.isEmpty(wbsFormElements)) {
|
|
|
wbsFormElements = wbsTreeMapper.selectFormElements4TableId(id);
|
|
|
}
|
|
@@ -333,7 +335,7 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
if (escapeChar != null) {
|
|
|
elements.setEAllowDeviation(escapeChar);
|
|
|
}
|
|
|
- if (nodeId != null &&elements.getNodeId()!=null&& com.mixsmart.utils.StringUtils.isNotEquals(nodeId, elements.getNodeId())) {
|
|
|
+ if (nodeId != null && elements.getNodeId() != null && com.mixsmart.utils.StringUtils.isNotEquals(nodeId, elements.getNodeId())) {
|
|
|
/*与当前节点不相同,则认为是跨节点取数,当然跨节点位置的标记不仅有绑定节点id一种方式*/
|
|
|
elements.setTableElementKey(elements.getNodeId() + StringPool.COLON + elements.getTableElementKey());
|
|
|
}
|
|
@@ -498,30 +500,32 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
|
|
|
if (pawDTO.getReferenceType().equals("private")) {
|
|
|
+
|
|
|
//同步独立表单库数据
|
|
|
this.insertDLTabAsync(pawDTO);
|
|
|
|
|
|
- //获取私有引用项目的wbs树的所有节点、元素表
|
|
|
+ //获取私有引用项目的wbs树的所有节点、元素表、独立表(type=10)
|
|
|
WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getPKeyId, pawDTO.getPrimaryKeyId()));
|
|
|
List<WbsTreePrivate> wbsTreePrivateAllOld = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
.eq(WbsTreePrivate::getProjectId, Long.parseLong(wbsTreePrivate.getProjectId()))
|
|
|
.eq(WbsTreePrivate::getStatus, 1)
|
|
|
- .and(obj -> obj.eq(WbsTreePrivate::getWbsId, Long.parseLong(wbsTreePrivate.getWbsId())).or().eq(WbsTreePrivate::getWbsId, null))
|
|
|
+ .and(obj -> obj.eq(WbsTreePrivate::getWbsId, Long.parseLong(wbsTreePrivate.getWbsId())).or().isNull(WbsTreePrivate::getWbsId))
|
|
|
);
|
|
|
List<WbsTreePrivate> WbsTreePrivateTables = wbsTreePrivateAllOld.stream().filter(f -> f.getType() == 2 || f.getType() == 10).collect(Collectors.toList());
|
|
|
|
|
|
- //获取当前项目私有wbs树下当前所有节点、元素表(type=10,独立库引用元素库)
|
|
|
+ //获取当前项目私有wbs树下当前所有节点、元素表、独立表(type=10)
|
|
|
List<WbsTreePrivate> wbsTreePrivatesAllNow = wbsTreePrivateMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
.eq(WbsTreePrivate::getProjectId, Long.parseLong(pawDTO.getProjectId()))
|
|
|
- .and(obj -> obj.eq(WbsTreePrivate::getWbsId, Long.parseLong(pawDTO.getPrimaryKeyId())).or().eq(WbsTreePrivate::getWbsId, null))
|
|
|
+ .and(obj -> obj.eq(WbsTreePrivate::getWbsId, Long.parseLong(pawDTO.getPrimaryKeyId())).or().isNull(WbsTreePrivate::getWbsId))
|
|
|
);
|
|
|
List<WbsTreePrivate> wbsTreePrivateNowTables = wbsTreePrivatesAllNow.stream().filter(f -> f.getType() == 2 || f.getType() == 10).collect(Collectors.toList());
|
|
|
|
|
|
+ //同步私有-电签匹配数据、默认信息数据
|
|
|
+ this.insertTextDictInfoAsync(WbsTreePrivateTables, wbsTreePrivateNowTables);
|
|
|
+
|
|
|
//同步私有wbs节点信息、元素表基础信息到项目级wbs、合同段wbs
|
|
|
this.updateWbsInfoContractAsync(wbsTreePrivateAllOld, wbsTreePrivatesAllNow, pawDTO.getProjectId(), pawDTO.getPrimaryKeyId());
|
|
|
|
|
|
- //同步私有-电签匹配数据、默认信息数据
|
|
|
- this.insertTextDictInfoAsync(WbsTreePrivateTables, wbsTreePrivateNowTables);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
@@ -545,6 +549,15 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
baseMapper.deleteBatch(ids1, pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
baseMapper.deleteBatch2(ids1, pawDTO.getWbsId(), pawDTO.getProjectId());
|
|
|
+ //全部删除时,需要删除该项目独立库表,且只能是删除质检的wbsType=1,质量的无法删除
|
|
|
+ Long rows = wbsTreePrivateMapper.selectCount(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getWbsId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 1)
|
|
|
+ );
|
|
|
+ if (rows == 0L && pawDTO.getWbsType() == 1) {
|
|
|
+ baseMapper.deleteBatch3(pawDTO.getProjectId());
|
|
|
+ }
|
|
|
|
|
|
} else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
List<Long> ids2 = delIds.stream().map(Long::parseLong).collect(Collectors.toList());
|
|
@@ -564,6 +577,15 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
}
|
|
|
baseMapper.deleteBatch(ids2, pawDTO.getPrimaryKeyId(), pawDTO.getProjectId());
|
|
|
baseMapper.deleteBatch2(ids2, pawDTO.getPrimaryKeyId(), pawDTO.getProjectId());
|
|
|
+ //全部删除时,需要删除该项目独立库表,且只能是删除质检的wbsType=1,质量的无法删除
|
|
|
+ Long rows = wbsTreePrivateMapper.selectCount(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
+ .eq(WbsTreePrivate::getWbsId, pawDTO.getPrimaryKeyId())
|
|
|
+ .eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
+ .eq(WbsTreePrivate::getType, 1)
|
|
|
+ );
|
|
|
+ if (rows == 0L && pawDTO.getWbsType() == 1) {
|
|
|
+ baseMapper.deleteBatch3(pawDTO.getProjectId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -582,6 +604,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
List<WbsTreePrivate> insertData2 = new ArrayList<>();
|
|
|
//私有-电签匹配数据、默认信息数据
|
|
|
List<TextdictInfo> insertData3 = new ArrayList<>();
|
|
|
+ //电签缓存数据
|
|
|
+ List<TextdictInfo> textDictInfosAll = null;
|
|
|
|
|
|
if (pawDTO.getReferenceType().equals("public")) {
|
|
|
List<WbsTree> addListData = new ArrayList<>();
|
|
@@ -628,7 +652,19 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
);
|
|
|
|
|
|
//查询所有电签位置配置信息
|
|
|
- List<TextdictInfo> textDictInfosAll = textdictInfoMapper.selectList(Wrappers.<TextdictInfo>query().lambda());
|
|
|
+ //List<TextdictInfo> textDictInfosAll = textdictInfoMapper.selectList(Wrappers.<TextdictInfo>query().lambda());
|
|
|
+ textDictInfosAll = bladeRedis.get("textDictInfos:");
|
|
|
+ if (ObjectUtils.isEmpty(textDictInfosAll)) {
|
|
|
+ //获取所有电签配置信息
|
|
|
+ textDictInfosAll = textdictInfoMapper.selectList(Wrappers.<TextdictInfo>query().lambda());
|
|
|
+
|
|
|
+ if (textDictInfosAll.size() > 0) {
|
|
|
+ //存入Redis
|
|
|
+ bladeRedis.set("textDictInfos:", textDictInfosAll);
|
|
|
+ //过期时间
|
|
|
+ bladeRedis.expire("textDictInfos:", 3600);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
if (wbsTreePrivate.getType() == 1 || wbsTreePrivate.getType() == 2) {
|
|
@@ -704,26 +740,34 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
|
|
|
this.insertBatch(insertData1, 1000);
|
|
|
|
|
|
- if (pawDTO.getWbsType() == 1) { //修改质检关联信息
|
|
|
+ //修改质检关联信息
|
|
|
+ if (pawDTO.getWbsType() == 1) {
|
|
|
projectInfoMapper.updateTemplateInfoQuality(pawDTO.getProjectId(), pawDTO.getWbsId(), "public");
|
|
|
}
|
|
|
- if (pawDTO.getWbsType() == 2) { //修改试验关联信息
|
|
|
+ //修改试验关联信息
|
|
|
+ if (pawDTO.getWbsType() == 2) {
|
|
|
projectInfoMapper.updateTemplateInfoTrial(pawDTO.getProjectId(), pawDTO.getWbsId(), "public");
|
|
|
}
|
|
|
+
|
|
|
} else if (pawDTO.getReferenceType().equals("private")) {
|
|
|
|
|
|
this.insertBatch(insertData2, 1000);
|
|
|
|
|
|
//电签
|
|
|
textDictInfoService.saveBatch(insertData3, 1000);
|
|
|
-
|
|
|
- if (pawDTO.getWbsType() == 1) { //修改质检关联信息
|
|
|
+ assert textDictInfosAll != null;
|
|
|
+ textDictInfosAll.addAll(insertData3);
|
|
|
+ //更新Redis
|
|
|
+ bladeRedis.set("textDictInfos:", textDictInfosAll);
|
|
|
+ //更新过期时间
|
|
|
+ bladeRedis.expire("textDictInfos:", 3600);
|
|
|
+
|
|
|
+ //修改质检关联信息
|
|
|
+ if (pawDTO.getWbsType() == 1) {
|
|
|
projectInfoMapper.updateTemplateInfoQuality(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");
|
|
|
-
|
|
|
- //新增独立表单库数据
|
|
|
- //wbsTreePrivateService.insertDLTab(pawDTO);
|
|
|
}
|
|
|
- if (pawDTO.getWbsType() == 2) { //修改试验关联信息
|
|
|
+ //修改试验关联信息
|
|
|
+ if (pawDTO.getWbsType() == 2) {
|
|
|
projectInfoMapper.updateTemplateInfoTrial(pawDTO.getProjectId(), pawDTO.getPrimaryKeyId(), "private");
|
|
|
}
|
|
|
}
|
|
@@ -776,12 +820,15 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
return wbsTreePrivateService.updateBatchByIds2(wbsTreePrivates, wbsTreePrivatesAllNow, projectId, primaryKeyId);
|
|
|
}
|
|
|
|
|
|
- //@Async
|
|
|
- public boolean insertDLTabAsync(WbsTreeContractDTO pawDTO) {
|
|
|
+ //同步独立表单库数据
|
|
|
+ private void insertDLTabAsync(WbsTreeContractDTO pawDTO) {
|
|
|
+ //获取当前引用项目的独立表
|
|
|
List<WbsTreePrivate> wbsTreePrivates = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
.eq(WbsTreePrivate::getProjectId, pawDTO.getReferencePrivateWbsProjectId())
|
|
|
.eq(WbsTreePrivate::getType, 10)
|
|
|
);
|
|
|
+
|
|
|
+ //获取当前项目独立表
|
|
|
List<WbsTreePrivate> wbsTreePrivatesNew = wbsTreePrivateService.getBaseMapper().selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
.eq(WbsTreePrivate::getProjectId, pawDTO.getProjectId())
|
|
|
.eq(WbsTreePrivate::getType, 10)
|
|
@@ -792,41 +839,56 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
WbsTreePrivate next = iterator.next();
|
|
|
for (WbsTreePrivate wbsTreePrivate : wbsTreePrivatesNew) {
|
|
|
if (next.getNodeName().equals(wbsTreePrivate.getNodeName()) && next.getTableType().equals(wbsTreePrivate.getTableType())) {
|
|
|
+ //去重,获取新增的独立表
|
|
|
iterator.remove();
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //新增的独立表
|
|
|
List<WbsTreePrivate> wbsTreePrivatesNewAdd = new ArrayList<>();
|
|
|
for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
|
|
|
WbsTreePrivate wbsTreePrivateNew = BeanUtil.copyProperties(wbsTreePrivate, WbsTreePrivate.class);
|
|
|
if (wbsTreePrivateNew != null) {
|
|
|
Long id = SnowFlakeUtil.getId();
|
|
|
wbsTreePrivateNew.setPKeyId(id);
|
|
|
- wbsTreePrivateNew.setId(id);
|
|
|
wbsTreePrivateNew.setProjectId(pawDTO.getProjectId());
|
|
|
wbsTreePrivatesNewAdd.add(wbsTreePrivateNew);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (wbsTreePrivatesNewAdd.size() > 0) {
|
|
|
+ //新增独立表
|
|
|
wbsTreePrivateService.saveBatch(wbsTreePrivatesNewAdd, 1000);
|
|
|
}
|
|
|
- return true;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
public boolean insertTextDictInfoAsync(List<WbsTreePrivate> wbsTreePrivateOldTables, List<WbsTreePrivate> wbsTreePrivateNewTables) {
|
|
|
- //获取所有电签配置信息
|
|
|
- List<TextdictInfo> textDictInfos = textdictInfoMapper.selectList(Wrappers.<TextdictInfo>query().lambda());
|
|
|
+ List<TextdictInfo> redisValue = bladeRedis.get("textDictInfos:");
|
|
|
+ if (ObjectUtils.isEmpty(redisValue)) {
|
|
|
+ //获取所有电签配置信息
|
|
|
+ redisValue = textdictInfoMapper.selectList(Wrappers.<TextdictInfo>query().lambda());
|
|
|
+
|
|
|
+ if (redisValue.size() > 0) {
|
|
|
+ //存入Redis
|
|
|
+ bladeRedis.set("textDictInfos:", redisValue);
|
|
|
+ //过期时间
|
|
|
+ bladeRedis.expire("textDictInfos:", 3600);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //wbsTreePrivateOldTables=原始引用的元素表 wbsTreePrivateNewTables=现在项目树的元素表
|
|
|
+ //wbsTreePrivateOldTables=原始引用的元素表+独立表 wbsTreePrivateNewTables=现在项目树的元素表+独立表
|
|
|
Map<Long, List<TextdictInfo>> textDictInfoData = new HashMap<>();
|
|
|
if (wbsTreePrivateOldTables.size() > 0) {
|
|
|
for (WbsTreePrivate wbsTreePrivate : wbsTreePrivateOldTables) {
|
|
|
//私有引用-电签匹配数据、默认信息数据,根据元素表pKeyId,获取电签位置匹配信息、编辑默认信息
|
|
|
- List<TextdictInfo> collect = textDictInfos.stream().filter(f -> f.getTabId().equals(String.valueOf(wbsTreePrivate.getPKeyId()))).collect(Collectors.toList());
|
|
|
+ //List<TextdictInfo> collect = redisValue.stream().filter(f -> f.getTabId().equals(String.valueOf(wbsTreePrivate.getPKeyId()))).collect(Collectors.toList());
|
|
|
+ //不清楚为什么上面走内存,无法判断,所以直接查询
|
|
|
+ List<TextdictInfo> collect = textdictInfoMapper.selectList(Wrappers.<TextdictInfo>lambdaQuery().eq(TextdictInfo::getTabId, String.valueOf(wbsTreePrivate.getPKeyId())));
|
|
|
+
|
|
|
if (collect.size() > 0) {
|
|
|
textDictInfoData.put(wbsTreePrivate.getId(), collect);
|
|
|
}
|
|
@@ -842,8 +904,8 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
for (TextdictInfo textdictInfo : v) {
|
|
|
textdictInfo.setTabId(String.valueOf(wbsTreePrivateNewTable.getPKeyId()));
|
|
|
textdictInfo.setId(SnowFlakeUtil.getId());
|
|
|
+ insertData.add(textdictInfo);
|
|
|
}
|
|
|
- insertData.addAll(v);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -852,16 +914,26 @@ public class WbsTreeServiceImpl extends BaseServiceImpl<WbsTreeMapper, WbsTree>
|
|
|
Iterator<TextdictInfo> iterator = insertData.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
TextdictInfo textDictInfo = iterator.next();
|
|
|
- textDictInfos.stream().filter(f ->
|
|
|
+ redisValue.stream().filter(f ->
|
|
|
+ //判断每张表TabId的每个位置ColKey、类型Type唯一
|
|
|
f.getColKey().equals(textDictInfo.getColKey())
|
|
|
- && f.getTabId().equals(textDictInfo.getTabId())
|
|
|
&& f.getType().equals(textDictInfo.getType())
|
|
|
+ && f.getTabId().equals(textDictInfo.getTabId())
|
|
|
).findAny().ifPresent(textDict -> iterator.remove());
|
|
|
}
|
|
|
- textDictInfoService.saveBatch(insertData, 1000);
|
|
|
+
|
|
|
+ if (insertData.size() > 0) {
|
|
|
+ textDictInfoService.saveBatch(insertData, 1000);
|
|
|
+
|
|
|
+ //更新Redis
|
|
|
+ redisValue.addAll(insertData);
|
|
|
+ bladeRedis.set("textDictInfos:", redisValue);
|
|
|
+ //更新过期时间
|
|
|
+ bladeRedis.expire("textDictInfos:", 3600);
|
|
|
+ }
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
return false;
|
|
|
}
|
|
|
|