|
@@ -13,6 +13,9 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.ibatis.session.ExecutorType;
|
|
|
+import org.apache.ibatis.session.SqlSession;
|
|
|
+import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.nodes.Document;
|
|
|
import org.jsoup.nodes.Element;
|
|
@@ -44,6 +47,7 @@ import org.springblade.manager.utils.FileUtils;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
@@ -95,14 +99,14 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
// parentId=1;
|
|
|
// }
|
|
|
if (wbsInfo != null) {
|
|
|
- List<WbsTreePrivateVO> tree = baseMapper.tree(wbsId, projectId, wbsInfo.getWbsType(),parentId);
|
|
|
+ List<WbsTreePrivateVO> tree = baseMapper.tree(wbsId, projectId, wbsInfo.getWbsType(), parentId);
|
|
|
//公有引用
|
|
|
return ForestNodeMerger.merge(tree);
|
|
|
} else {
|
|
|
//私有引用`
|
|
|
WbsTreePrivate nodeRoot = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>query().lambda().eq(WbsTreePrivate::getWbsId, wbsId).eq(WbsTreePrivate::getProjectId, projectId).eq(WbsTreePrivate::getParentId, 0L));
|
|
|
if (nodeRoot != null) {
|
|
|
- return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, Integer.valueOf(nodeRoot.getWbsType()),parentId));
|
|
|
+ return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId, Integer.valueOf(nodeRoot.getWbsType()), parentId));
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
@@ -131,19 +135,19 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
if (wbsTreePrivate.getPKeyId() != null) {
|
|
|
Long pKeyId = wbsTreePrivate.getPKeyId();
|
|
|
wbsTreePrivate.setFullName(wbsTreePrivate.getNodeName());
|
|
|
- //选择了一个,必须选择另一个
|
|
|
- if((wbsTreePrivate.getClassName()!=null&&wbsTreePrivate.getUnitName()==null)||(wbsTreePrivate.getClassName()==null&&wbsTreePrivate.getUnitName()!=null)){
|
|
|
+ //选择了一个,必须选择另一个
|
|
|
+ if ((wbsTreePrivate.getClassName() != null && wbsTreePrivate.getUnitName() == null) || (wbsTreePrivate.getClassName() == null && wbsTreePrivate.getUnitName() != null)) {
|
|
|
throw new ServiceException("标准分类,单元名称不能为空");
|
|
|
}
|
|
|
//如果className,unitName不为空,则要判断该节点是否是最小节点
|
|
|
- if(ObjectUtil.isNotEmpty(wbsTreePrivate.getClassName())&&ObjectUtil.isNotEmpty(wbsTreePrivate.getUnitName())){
|
|
|
- QueryWrapper<WbsTreePrivate>wrapper=new QueryWrapper<>();
|
|
|
- wrapper.eq("parent_id",wbsTreePrivate.getId()).eq("is_deleted",0);
|
|
|
- //查出当前节点所有子节点。如果子节点中没有节点,说明是最小节点
|
|
|
+ if (ObjectUtil.isNotEmpty(wbsTreePrivate.getClassName()) && ObjectUtil.isNotEmpty(wbsTreePrivate.getUnitName())) {
|
|
|
+ QueryWrapper<WbsTreePrivate> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("parent_id", wbsTreePrivate.getId()).eq("is_deleted", 0);
|
|
|
+ //查出当前节点所有子节点。如果子节点中没有节点,说明是最小节点
|
|
|
List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectList(wrapper);
|
|
|
- if(wbsTreePrivates.size()>0){
|
|
|
+ if (wbsTreePrivates.size() > 0) {
|
|
|
//过滤出所有不为表单的节点,大于0,则不是最小节点
|
|
|
- if(wbsTreePrivates.stream().filter(o->o.getType()==Integer.valueOf(1)).collect(Collectors.toList()).size()>0){
|
|
|
+ if (wbsTreePrivates.stream().filter(o -> o.getType() == Integer.valueOf(1)).collect(Collectors.toList()).size() > 0) {
|
|
|
throw new ServiceException("该节点不是最小节点不能设置标准分类和单元名称");
|
|
|
}
|
|
|
}
|
|
@@ -151,17 +155,17 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
/** 同步当前节点下所有节点的新增是否隐藏*/
|
|
|
//如果父节点为隐藏,则子节点不能修改为显示
|
|
|
- if (wbsTreePrivate.getIsAddConceal() == 0){
|
|
|
+ if (wbsTreePrivate.getIsAddConceal() == 0) {
|
|
|
WbsTreePrivate parent = this.getOne(new LambdaQueryWrapper<WbsTreePrivate>()
|
|
|
.eq(WbsTreePrivate::getId, wbsTreePrivate.getParentId())
|
|
|
.eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId()));
|
|
|
- if (parent.getIsAddConceal() == 1){
|
|
|
+ if (parent.getIsAddConceal() == 1) {
|
|
|
throw new ServiceException("修改失败:父节点为新增隐藏,子节点不能改为显示");
|
|
|
}
|
|
|
}
|
|
|
int row = baseMapper.updateByPKeyId(pKeyId, wbsTreePrivate);
|
|
|
Long pId = baseMapper.getByPKeyId(wbsTreePrivate.getPKeyId()).getPId();
|
|
|
- baseMapper.batchUpdateIsAddConceal(wbsTreePrivate,pId);
|
|
|
+ baseMapper.batchUpdateIsAddConceal(wbsTreePrivate, pId);
|
|
|
if (row > 0) {
|
|
|
WbsTreePrivate wbsTreePrivate1 = baseMapper.getByPKeyId(pKeyId);
|
|
|
wbsTreePrivate1.setFullName(wbsTreePrivate1.getNodeName());
|
|
@@ -250,13 +254,13 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
public List<WbsTreePrivateVO> lazyTree(String wbsId, String wbsType, Long parentId, String projectId) {
|
|
|
//获取请求头中的authorization
|
|
|
String headerAuthorization = getHeaderAuthorization();
|
|
|
- List<WbsTreePrivateVO> wbsTreePrivateVOS = baseMapper.lazyTree(wbsId, Integer.valueOf(wbsType), parentId, projectId);
|
|
|
+ List<WbsTreePrivateVO> wbsTreePrivateVOS = baseMapper.lazyTree(wbsId, Integer.valueOf(wbsType), parentId, projectId);
|
|
|
//判断如果是客户端就进入分支 把包含委托单的节点删除
|
|
|
- if(headerAuthorization != null && !"".equals(headerAuthorization) && headerAuthorization.contains("client_secret") && wbsTreePrivateVOS.size()>0){
|
|
|
+ if (headerAuthorization != null && !"".equals(headerAuthorization) && headerAuthorization.contains("client_secret") && wbsTreePrivateVOS.size() > 0) {
|
|
|
JSONArray objects = JSONUtil.parseArray(wbsTreePrivateVOS);
|
|
|
List<TreeNodeVO> treeNodeVOS = JSONUtil.toList(objects, TreeNodeVO.class);
|
|
|
for (int i = 0; i < treeNodeVOS.size(); i++) {
|
|
|
- if(treeNodeVOS.get(i).getTitle().contains("委托单")){
|
|
|
+ if (treeNodeVOS.get(i).getTitle().contains("委托单")) {
|
|
|
wbsTreePrivateVOS.remove(i);
|
|
|
}
|
|
|
}
|
|
@@ -264,7 +268,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
return ForestNodeMerger.merge(wbsTreePrivateVOS);
|
|
|
}
|
|
|
|
|
|
- private static String getHeaderAuthorization() {
|
|
|
+ private static String getHeaderAuthorization() {
|
|
|
//获取请求头中的authorization
|
|
|
String authorization = WebUtil.getRequest().getHeader(CommonConstant.HEADER_AUTHORIZATION);
|
|
|
//解析获取请求头中的authorization
|
|
@@ -286,7 +290,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
@Override
|
|
|
public IPage<TreeNodeVOByTabType> tabTypeLazyTreeAll(IPage<TreeNodeVOByTabType> page, Long parentId, String titleName, Boolean hasPartFormula) {
|
|
|
- if (parentId == null){
|
|
|
+ if (parentId == null) {
|
|
|
throw new ServiceException("请先选择左边表类型再搜索");
|
|
|
}
|
|
|
boolean base = false;
|
|
@@ -295,7 +299,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
base = true;
|
|
|
}
|
|
|
List<TreeNodeVOByTabType> data;
|
|
|
- if (SelectorModel.ID<=parentId&&parentId<=SelectorModel.MAX_ID) {
|
|
|
+ if (SelectorModel.ID <= parentId && parentId <= SelectorModel.MAX_ID) {
|
|
|
data = this.baseList(titleName);
|
|
|
} else {
|
|
|
data = baseMapper.tabTypeLazyTreeAll(page, parentId, titleName);
|
|
@@ -319,39 +323,40 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
data.add(baseInfo);
|
|
|
}
|
|
|
}
|
|
|
- /* public static final List<TreeNodeVOByTabType> TN_TAB_LIST;
|
|
|
- static {
|
|
|
- TN_TAB_LIST=DataModel.getTreeNodeList();
|
|
|
- Map<String, String[]> titleMap = new LinkedHashMap<>();
|
|
|
- titleMap.put(BaseInfo.TBN_CH, new String[]{BaseInfo.TBN, BaseInfo.ID});
|
|
|
- titleMap.put(AdvancePaymentCertificate.TBN_CH, new String[]{AdvancePaymentCertificate.TBN, AdvancePaymentCertificate.ID});
|
|
|
- titleMap.put(MaterialAdvancePayment.TBN_CH, new String[]{MaterialAdvancePayment.TBN, MaterialAdvancePayment.ID});
|
|
|
- titleMap.put(MeterPeriodInfo.TBN_CH, new String[]{MeterPeriodInfo.TBN, MeterPeriodInfo.ID});
|
|
|
- titleMap.put(InterimPaymentCertificate.TBN_CH, new String[]{InterimPaymentCertificate.TBN, InterimPaymentCertificate.ID});
|
|
|
- titleMap.put(InterimPaymentSummary.TBN_CH, new String[]{InterimPaymentSummary.TBN, InterimPaymentSummary.ID});
|
|
|
- titleMap.put(SubprojectInterimPaymentSummary.TBN_CH, new String[]{SubprojectInterimPaymentSummary.TBN, SubprojectInterimPaymentSummary.ID});
|
|
|
- titleMap.put(ConstructionSchedule.TBN_CH, new String[]{ConstructionSchedule.TBN, ConstructionSchedule.ID});
|
|
|
- titleMap.put(SubInterimMeterPaySummary.TBN_CH, new String[]{SubInterimMeterPaySummary.TBN, SubInterimMeterPaySummary.ID});
|
|
|
- titleMap.put(InterimMeterPaySummary.TBN_CH, new String[]{InterimMeterPaySummary.TBN, InterimMeterPaySummary.ID});
|
|
|
- titleMap.put(InterimMeter.TBN_CH, new String[]{InterimMeter.TBN, InterimMeter.ID});
|
|
|
- titleMap.put(MaterialPriceDifferential.TBN_CH, new String[]{MaterialPriceDifferential.TBN, MaterialPriceDifferential.ID});
|
|
|
- TN_TAB_LIST=titleMap.entrySet().stream().map(kv -> {
|
|
|
- TreeNodeVOByTabType tn = new TreeNodeVOByTabType();
|
|
|
- tn.setTitle(kv.getKey());
|
|
|
- tn.setTabType(SelectorModel.NODE_NAME);
|
|
|
- tn.setParentId(SelectorModel.ID);
|
|
|
- tn.setId(Long.parseLong(kv.getValue()[1]));
|
|
|
- tn.setPrimaryKeyId(kv.getValue()[1]);
|
|
|
- tn.setInitTableId(kv.getValue()[1]);
|
|
|
- tn.setHasChildren(false);
|
|
|
- tn.setInitTableName(kv.getValue()[0]);
|
|
|
- return tn;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- }
|
|
|
-*/
|
|
|
+
|
|
|
+ /* public static final List<TreeNodeVOByTabType> TN_TAB_LIST;
|
|
|
+ static {
|
|
|
+ TN_TAB_LIST=DataModel.getTreeNodeList();
|
|
|
+ Map<String, String[]> titleMap = new LinkedHashMap<>();
|
|
|
+ titleMap.put(BaseInfo.TBN_CH, new String[]{BaseInfo.TBN, BaseInfo.ID});
|
|
|
+ titleMap.put(AdvancePaymentCertificate.TBN_CH, new String[]{AdvancePaymentCertificate.TBN, AdvancePaymentCertificate.ID});
|
|
|
+ titleMap.put(MaterialAdvancePayment.TBN_CH, new String[]{MaterialAdvancePayment.TBN, MaterialAdvancePayment.ID});
|
|
|
+ titleMap.put(MeterPeriodInfo.TBN_CH, new String[]{MeterPeriodInfo.TBN, MeterPeriodInfo.ID});
|
|
|
+ titleMap.put(InterimPaymentCertificate.TBN_CH, new String[]{InterimPaymentCertificate.TBN, InterimPaymentCertificate.ID});
|
|
|
+ titleMap.put(InterimPaymentSummary.TBN_CH, new String[]{InterimPaymentSummary.TBN, InterimPaymentSummary.ID});
|
|
|
+ titleMap.put(SubprojectInterimPaymentSummary.TBN_CH, new String[]{SubprojectInterimPaymentSummary.TBN, SubprojectInterimPaymentSummary.ID});
|
|
|
+ titleMap.put(ConstructionSchedule.TBN_CH, new String[]{ConstructionSchedule.TBN, ConstructionSchedule.ID});
|
|
|
+ titleMap.put(SubInterimMeterPaySummary.TBN_CH, new String[]{SubInterimMeterPaySummary.TBN, SubInterimMeterPaySummary.ID});
|
|
|
+ titleMap.put(InterimMeterPaySummary.TBN_CH, new String[]{InterimMeterPaySummary.TBN, InterimMeterPaySummary.ID});
|
|
|
+ titleMap.put(InterimMeter.TBN_CH, new String[]{InterimMeter.TBN, InterimMeter.ID});
|
|
|
+ titleMap.put(MaterialPriceDifferential.TBN_CH, new String[]{MaterialPriceDifferential.TBN, MaterialPriceDifferential.ID});
|
|
|
+ TN_TAB_LIST=titleMap.entrySet().stream().map(kv -> {
|
|
|
+ TreeNodeVOByTabType tn = new TreeNodeVOByTabType();
|
|
|
+ tn.setTitle(kv.getKey());
|
|
|
+ tn.setTabType(SelectorModel.NODE_NAME);
|
|
|
+ tn.setParentId(SelectorModel.ID);
|
|
|
+ tn.setId(Long.parseLong(kv.getValue()[1]));
|
|
|
+ tn.setPrimaryKeyId(kv.getValue()[1]);
|
|
|
+ tn.setInitTableId(kv.getValue()[1]);
|
|
|
+ tn.setHasChildren(false);
|
|
|
+ tn.setInitTableName(kv.getValue()[0]);
|
|
|
+ return tn;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ */
|
|
|
public List<TreeNodeVOByTabType> baseList(String name) {
|
|
|
- if(Func.isNotEmpty(name)) {
|
|
|
- return DataModel.getTreeNodeList().stream().filter(e->e.getTitle().contains(name)).collect(Collectors.toList());
|
|
|
+ if (Func.isNotEmpty(name)) {
|
|
|
+ return DataModel.getTreeNodeList().stream().filter(e -> e.getTitle().contains(name)).collect(Collectors.toList());
|
|
|
}
|
|
|
return DataModel.getTreeNodeList();
|
|
|
}
|
|
@@ -677,7 +682,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
wbsTreePrivate.setHtmlUrl(htmlUrl);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
throw new ServiceException("复制html时出错");
|
|
|
}
|
|
@@ -900,10 +905,10 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
//TODO ---------公有引用同步---------
|
|
|
//获取对应公有树节点
|
|
|
Map<Long, WbsTree> treePublicNodeAll = wbsTreeMapper.selectList(Wrappers.<WbsTree>query().lambda()
|
|
|
- .select(WbsTree::getId)
|
|
|
- .in(WbsTree::getId, privateNodeIds)
|
|
|
- .eq(WbsTree::getStatus, 1)
|
|
|
- .eq(WbsTree::getType, 1))
|
|
|
+ .select(WbsTree::getId)
|
|
|
+ .in(WbsTree::getId, privateNodeIds)
|
|
|
+ .eq(WbsTree::getStatus, 1)
|
|
|
+ .eq(WbsTree::getType, 1))
|
|
|
.stream().collect(Collectors.toMap(WbsTree::getId, Function.identity()));
|
|
|
|
|
|
Map<String, Long> map = new HashMap<>();
|
|
@@ -1539,10 +1544,10 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
/*-------------------------------------质检公有引用同步--------------------------------------------*/
|
|
|
//获取当前节点对应的公有引用树下的元素表
|
|
|
List<WbsTree> wbsTrees = wbsTreeMapper.selectList(Wrappers.<WbsTree>lambdaQuery()
|
|
|
- .select(WbsTree::getAncestors, WbsTree::getWbsId, WbsTree::getId)
|
|
|
- .and(wq -> wq.eq(WbsTree::getId, wbsTreePrivate.getId())
|
|
|
- .or()
|
|
|
- .eq(WbsTree::getId, wbsTreePrivate.getTreePId()))
|
|
|
+ .select(WbsTree::getAncestors, WbsTree::getWbsId, WbsTree::getId)
|
|
|
+ .and(wq -> wq.eq(WbsTree::getId, wbsTreePrivate.getId())
|
|
|
+ .or()
|
|
|
+ .eq(WbsTree::getId, wbsTreePrivate.getTreePId()))
|
|
|
);
|
|
|
List<WbsTree> wbsTreesPublicTables;
|
|
|
WbsTree wbsTree = wbsTrees.get(0);
|
|
@@ -1564,7 +1569,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
//获取当前项目树下的元素表 节点
|
|
|
List<WbsTreePrivate> wbsTreePrivatesProjectAll = baseMapper.selectList(Wrappers.<WbsTreePrivate>query().lambda()
|
|
|
- .select(WbsTreePrivate::getType, WbsTreePrivate::getId, WbsTreePrivate::getAncestors,WbsTreePrivate::getTreePId)
|
|
|
+ .select(WbsTreePrivate::getType, WbsTreePrivate::getId, WbsTreePrivate::getAncestors, WbsTreePrivate::getTreePId)
|
|
|
.eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId())
|
|
|
.eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
|
|
|
/*.eq(WbsTreePrivate::getStatus, 1)*/
|
|
@@ -1583,16 +1588,16 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
// List<WbsTree> addPublicTable = wbsTreesPublicTables.stream().filter(f ->
|
|
|
// !wbsTreePrivatesProjectTables.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(f.getId())).collect(Collectors.toList());
|
|
|
Set<Long> privateIdsAndPids = wbsTreePrivatesProjectTables.stream()
|
|
|
- .flatMap(p -> Stream.of(p.getId(), p.getTreePId()))
|
|
|
- .collect(Collectors.toSet());
|
|
|
+ .flatMap(p -> Stream.of(p.getId(), p.getTreePId()))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
|
- // 过滤 wbsTreesPublicTables
|
|
|
+ // 过滤 wbsTreesPublicTables
|
|
|
List<WbsTree> addPublicTable = wbsTreesPublicTables.stream()
|
|
|
- .filter(f -> !privateIdsAndPids.contains(f.getId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
+ .filter(f -> !privateIdsAndPids.contains(f.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
//判断当前新增的表在项目的wbs树中是否存在上级节点,存在表示可以新增,不存在表示不新增
|
|
|
- // List<WbsTree> addPublicTables = addPublicTable.stream().filter(node ->
|
|
|
- // wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
|
+ // List<WbsTree> addPublicTables = addPublicTable.stream().filter(node ->
|
|
|
+ // wbsTreePrivatesProjectNodes.stream().map(WbsTreePrivate::getId).collect(Collectors.toList()).contains(node.getParentId())).collect(Collectors.toList());
|
|
|
|
|
|
//构造
|
|
|
List<Long> ids = addPublicTable.stream().map(WbsTree::getId).collect(Collectors.toList());
|
|
@@ -1638,7 +1643,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
//获取当前项目选择的节点下的所有元素表 节点
|
|
|
List<WbsTreePrivate> wbsTreePrivatesProjectAll = baseMapper.selectList(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
- .select(WbsTreePrivate::getType, WbsTreePrivate::getId, WbsTreePrivate::getAncestors,WbsTreePrivate::getPKeyId)
|
|
|
+ .select(WbsTreePrivate::getType, WbsTreePrivate::getId, WbsTreePrivate::getAncestors, WbsTreePrivate::getPKeyId)
|
|
|
.eq(WbsTreePrivate::getProjectId, wbsTreePrivate.getProjectId()).eq(WbsTreePrivate::getWbsId, wbsTreePrivate.getWbsId())
|
|
|
/*.eq(WbsTreePrivate::getStatus, 1)*/
|
|
|
);
|
|
@@ -1960,7 +1965,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
tree.setHtmlUrl(htmlUrl);
|
|
|
}
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
throw new ServiceException("重置表单路径错误");
|
|
|
}
|
|
|
}
|
|
@@ -1976,7 +1981,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
//同步到合同段(合同段中可能不存在原始节点(那么分配wsb处就同步不成功),但合同段存在新增、复制的节点,所以单独处理)
|
|
|
if (!insertDataPrivateList.isEmpty()) {
|
|
|
//
|
|
|
- for (WbsTreePrivate treePrivate :insertDataPrivateList){
|
|
|
+ for (WbsTreePrivate treePrivate : insertDataPrivateList) {
|
|
|
WbsTreePrivate treePrivateP = wbsTreePrivateMapper.selectOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getId, treePrivate.getParentId()).eq(WbsTreePrivate::getProjectId, treePrivate.getProjectId()).eq(WbsTreePrivate::getWbsId, treePrivate.getWbsId()));
|
|
|
List<WbsTreeContract> addOrCo = wbsTreeContractMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery()
|
|
|
.eq(WbsTreeContract::getProjectId, wbsTreePrivate.getProjectId())
|
|
@@ -1985,15 +1990,15 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
);
|
|
|
if (addOrCo.size() > 0) {
|
|
|
- for(WbsTreeContract addwbsTreeC : addOrCo){
|
|
|
- WbsTreeContract wbsTreeContract= BeanUtil.copyProperties(treePrivate, WbsTreeContract.class);
|
|
|
- wbsTreeContract.setIsBussShow(1);
|
|
|
- wbsTreeContract.setIsDeleted(0);
|
|
|
- wbsTreeContract.setStatus(1);
|
|
|
- wbsTreeContract.setIsTypePrivatePid(treePrivate.getPKeyId()); //记录原始表的pKeyId
|
|
|
- wbsTreeContract.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- wbsTreeContract.setParentId(addwbsTreeC.getId());
|
|
|
- wbsTreeContract.setContractId(addwbsTreeC.getContractId());
|
|
|
+ for (WbsTreeContract addwbsTreeC : addOrCo) {
|
|
|
+ WbsTreeContract wbsTreeContract = BeanUtil.copyProperties(treePrivate, WbsTreeContract.class);
|
|
|
+ wbsTreeContract.setIsBussShow(1);
|
|
|
+ wbsTreeContract.setIsDeleted(0);
|
|
|
+ wbsTreeContract.setStatus(1);
|
|
|
+ wbsTreeContract.setIsTypePrivatePid(treePrivate.getPKeyId()); //记录原始表的pKeyId
|
|
|
+ wbsTreeContract.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ wbsTreeContract.setParentId(addwbsTreeC.getId());
|
|
|
+ wbsTreeContract.setContractId(addwbsTreeC.getContractId());
|
|
|
insertDataContractList.add(wbsTreeContract);
|
|
|
}
|
|
|
}
|
|
@@ -2116,24 +2121,24 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
if (wbsTreePrivateList != null) {
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
String projectId = wbsTreePrivateList.get(0).getProjectId();
|
|
|
- String dir = file_path + "privateUrlCopy/" +projectId;
|
|
|
+ String dir = file_path + "privateUrlCopy/" + projectId;
|
|
|
File directory = new File(dir);
|
|
|
- if (!directory.exists()){
|
|
|
+ if (!directory.exists()) {
|
|
|
directory.mkdir();
|
|
|
}
|
|
|
//存在htmlUrl才重新保存
|
|
|
- System.out.println("copyHtml-去除空路径之前:"+wbsTreePrivateList.size());
|
|
|
+ System.out.println("copyHtml-去除空路径之前:" + wbsTreePrivateList.size());
|
|
|
wbsTreePrivateList = wbsTreePrivateList.stream().filter(wtp -> StringUtils.isNotBlank(wtp.getHtmlUrl())).collect(Collectors.toList());
|
|
|
- System.out.println("copyHtml-去除重复路径之前:"+wbsTreePrivateList.size());
|
|
|
- List<WbsTreePrivate> wbsTreePrivateList2 = wbsTreePrivateList.stream().collect(Collectors.toMap(WbsTreePrivate::getHtmlUrl,wbs->wbs,(w1,w2)->w1))
|
|
|
- .values().stream().collect(Collectors.toList());
|
|
|
- System.out.println("copyHtml-去除重复路径之后:"+wbsTreePrivateList2.size());
|
|
|
+ System.out.println("copyHtml-去除重复路径之前:" + wbsTreePrivateList.size());
|
|
|
+ List<WbsTreePrivate> wbsTreePrivateList2 = wbsTreePrivateList.stream().collect(Collectors.toMap(WbsTreePrivate::getHtmlUrl, wbs -> wbs, (w1, w2) -> w1))
|
|
|
+ .values().stream().collect(Collectors.toList());
|
|
|
+ System.out.println("copyHtml-去除重复路径之后:" + wbsTreePrivateList2.size());
|
|
|
Set<String> urls = new HashSet<>();
|
|
|
//批量复制保存html
|
|
|
for (WbsTreePrivate tree : wbsTreePrivateList) {
|
|
|
String[] split = tree.getHtmlUrl().split("/");
|
|
|
- String htmlUrl = file_path + "privateUrlCopy/" +projectId+"/"+ split[split.length - 1];
|
|
|
- if (!urls.contains(tree.getHtmlUrl())){
|
|
|
+ String htmlUrl = file_path + "privateUrlCopy/" + projectId + "/" + split[split.length - 1];
|
|
|
+ if (!urls.contains(tree.getHtmlUrl())) {
|
|
|
urls.add(tree.getHtmlUrl());
|
|
|
File file_in = ResourceUtil.getFile(tree.getHtmlUrl());
|
|
|
// File file_in = ResourceUtil.getFile("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\"+split[split.length-1]);
|
|
@@ -2319,35 +2324,35 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
@Transactional
|
|
|
public void syncFormToContractNode(Long projectId, String nodeIds, Long primaryKeyId) {
|
|
|
try {
|
|
|
- if (projectId == null || StringUtils.isBlank(nodeIds) || primaryKeyId == null){
|
|
|
+ if (projectId == null || StringUtils.isBlank(nodeIds) || primaryKeyId == null) {
|
|
|
throw new ServiceException("参数不能为空,请检查参数");
|
|
|
}
|
|
|
//找到当前项目级的节点信息,已经挂载表单数量
|
|
|
List<Long> longs = Func.toLongList(nodeIds);
|
|
|
- List<WbsTreePrivateVO6> privates = baseMapper.getSelectNodes(longs,projectId);
|
|
|
- if (privates.size() == 0 || privates.size() != longs.size()){
|
|
|
+ List<WbsTreePrivateVO6> privates = baseMapper.getSelectNodes(longs, projectId);
|
|
|
+ if (privates.size() == 0 || privates.size() != longs.size()) {
|
|
|
throw new ServiceException("未找到当前项目的节点信息,是确认是否选择节点");
|
|
|
}
|
|
|
//找到当前独立库表单信息
|
|
|
WbsTreePrivate form = this.getOne(new LambdaQueryWrapper<WbsTreePrivate>()
|
|
|
- .eq(WbsTreePrivate::getPKeyId,primaryKeyId));
|
|
|
- if (form == null){
|
|
|
+ .eq(WbsTreePrivate::getPKeyId, primaryKeyId));
|
|
|
+ if (form == null) {
|
|
|
throw new ServiceException("未找到当前表单信息,请联系管理员");
|
|
|
}
|
|
|
List<WbsTreePrivate> projectInsertForm = new ArrayList<>();
|
|
|
List<WbsTreeContract> contractInsertForm = new ArrayList<>();
|
|
|
//找到项目所有合同段下当前节点
|
|
|
- List<WbsTreeContractVO7> list = baseMapper.getSelectContractNodes(longs,projectId);
|
|
|
+ List<WbsTreeContractVO7> list = baseMapper.getSelectContractNodes(longs, projectId);
|
|
|
Map<Long, List<WbsTreeContractVO7>> map = list.stream().collect(Collectors.groupingBy(WbsTreeContractVO7::getIsTypePrivatePid));
|
|
|
//构造项目级节点的表单 && 构造项目级节点对应合同节点的表单
|
|
|
for (WbsTreePrivateVO6 aPrivate : privates) {
|
|
|
WbsTreePrivate pri = new WbsTreePrivate();
|
|
|
//判断项目级节点下是否存在这样表单,如果项目级下存在这张表单,则项目级就不新增这样表单,但是合同段需要新增
|
|
|
- if (aPrivate.getFormCount()>0 && aPrivate.getFormIds().contains(form.getId()+"")) {
|
|
|
+ if (aPrivate.getFormCount() > 0 && aPrivate.getFormIds().contains(form.getId() + "")) {
|
|
|
//存在这张表单,则取出,为项目级信息赋值
|
|
|
- WbsTreePrivate wtp = baseMapper.getThisForm(aPrivate.getProjectId(),aPrivate.getId(),form.getId());
|
|
|
- BeanUtils.copyProperties(wtp,pri);
|
|
|
- }else {
|
|
|
+ WbsTreePrivate wtp = baseMapper.getThisForm(aPrivate.getProjectId(), aPrivate.getId(), form.getId());
|
|
|
+ BeanUtils.copyProperties(wtp, pri);
|
|
|
+ } else {
|
|
|
pri.setPKeyId(SnowFlakeUtil.getId());
|
|
|
pri.setId(form.getId());
|
|
|
pri.setWbsId(aPrivate.getWbsId());
|
|
@@ -2381,13 +2386,13 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
//获取合同段对应节点
|
|
|
List<WbsTreeContractVO7> contracts = map.get(aPrivate.getPKeyId());
|
|
|
- if (contracts == null || contracts.size() == 0){
|
|
|
+ if (contracts == null || contracts.size() == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
//构造项目级节点对应合同节点的表单
|
|
|
for (WbsTreeContractVO7 contract : contracts) {
|
|
|
//忽略已经存在的表单
|
|
|
- if (contract.getFormCount()>0 && contract.getFormIds().contains(form.getId()+"")) {
|
|
|
+ if (contract.getFormCount() > 0 && contract.getFormIds().contains(form.getId() + "")) {
|
|
|
continue;
|
|
|
}
|
|
|
WbsTreeContract con = new WbsTreeContract();
|
|
@@ -2400,11 +2405,11 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
con.setContractId(contract.getContractId());
|
|
|
con.setTenantId(pri.getTenantId());
|
|
|
con.setParentId(contract.getId());
|
|
|
- con.setAncestors(contract.getAncestors()+","+contract.getId());
|
|
|
+ con.setAncestors(contract.getAncestors() + "," + contract.getId());
|
|
|
con.setNodeType(pri.getNodeType());
|
|
|
con.setNodeName(pri.getNodeName());
|
|
|
con.setFullName(pri.getFullName());
|
|
|
- con.setSort(contract.getFormCount()+1);
|
|
|
+ con.setSort(contract.getFormCount() + 1);
|
|
|
con.setType(2);
|
|
|
con.setTableType(pri.getTableType());
|
|
|
con.setIsLinkTable(pri.getIsLinkTable());
|
|
@@ -2426,22 +2431,22 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
List<TextdictInfo> Infos = textDictInfoService.list(new LambdaQueryWrapper<TextdictInfo>()
|
|
|
.eq(TextdictInfo::getTabId, primaryKeyId));
|
|
|
//如果存在数据,则为每张表单保存
|
|
|
- if (projectInsertForm.size() > 0 && Infos.size() > 0){
|
|
|
+ if (projectInsertForm.size() > 0 && Infos.size() > 0) {
|
|
|
List<TextdictInfo> infoAdd = new ArrayList<>();
|
|
|
for (WbsTreePrivate aPrivate : projectInsertForm) {
|
|
|
for (TextdictInfo info : Infos) {
|
|
|
TextdictInfo info2 = new TextdictInfo();
|
|
|
- BeanUtils.copyProperties(info,info2);
|
|
|
+ BeanUtils.copyProperties(info, info2);
|
|
|
info2.setId(null);
|
|
|
- info2.setTabId(aPrivate.getPKeyId()+"");
|
|
|
+ info2.setTabId(aPrivate.getPKeyId() + "");
|
|
|
infoAdd.add(info2);
|
|
|
}
|
|
|
}
|
|
|
textDictInfoService.saveBatch(infoAdd);
|
|
|
}
|
|
|
wbsTreeContractService.saveBatch(contractInsertForm);
|
|
|
- }catch (Exception e){
|
|
|
- throw new ServiceException("分配失败,原因:"+e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("分配失败,原因:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2498,7 +2503,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
for (Long id : longs) {
|
|
|
WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.getByPKeyId(id);
|
|
|
wbsTreePrivate.setParentId(wbsTreeContract.getId());
|
|
|
- wbsTreePrivate.setAncestors(wbsTreeContract.getAncestors()+","+wbsTreeContract.getId());
|
|
|
+ wbsTreePrivate.setAncestors(wbsTreeContract.getAncestors() + "," + wbsTreeContract.getId());
|
|
|
wbsTreePrivate.setWbsId(wbsTreeContract.getWbsId());
|
|
|
wbsTreePrivate.setFullName(wbsTreePrivate.getNodeName());
|
|
|
wbsTreePrivate.setType(2);
|
|
@@ -2716,7 +2721,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
//试验一键重签专用 会传这个四个参数 只是为了重签查询数据 直接查了返回就行 不用校验角色
|
|
|
- if(tableType.equals("1,9,2,10")){
|
|
|
+ if (tableType.equals("1,9,2,10")) {
|
|
|
return baseMapper.selectWbsTreeTrialTabList(tableType, wbsTreePrivate.getProjectId(), wbsTreePrivate.getWbsId(), wbsTreePrivate.getId(), contractId);
|
|
|
}
|
|
|
//当前项目合同段只会存在一个角色roleId
|
|
@@ -2764,10 +2769,10 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
|
|
|
String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
- if(Func.isBlank(htmlString)){
|
|
|
- StaticLog.error(wbsTreePrivate.getHtmlUrl());
|
|
|
- throw new ServiceException("暂无表单!");
|
|
|
- }
|
|
|
+ if (Func.isBlank(htmlString)) {
|
|
|
+ StaticLog.error(wbsTreePrivate.getHtmlUrl());
|
|
|
+ throw new ServiceException("暂无表单!");
|
|
|
+ }
|
|
|
htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
|
|
@@ -2824,12 +2829,12 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
if (fileInputStream != null) {
|
|
|
fileInputStream.close();
|
|
|
}
|
|
|
- return R.data(table + "",primaryKeyId);
|
|
|
+ return R.data(table + "", primaryKeyId);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Object getExcelHtmlEntrust(String nodeId,String contractId) throws Exception {
|
|
|
+ public Object getExcelHtmlEntrust(String nodeId, String contractId) throws Exception {
|
|
|
|
|
|
// 合同段信息
|
|
|
ContractInfo contractInfo = contractInfoMapper.selectOne(Wrappers.<ContractInfo>query().lambda()
|
|
@@ -2840,14 +2845,14 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
.eq(WbsTreePrivate::getPKeyId, nodeId));
|
|
|
|
|
|
String pkeyId = "";
|
|
|
- if(contractInfo==null){
|
|
|
+ if (contractInfo == null) {
|
|
|
throw new ServiceException("合同段信息为null");
|
|
|
}
|
|
|
- if(contractInfo.getContractType()==2 ){ //3 监理
|
|
|
- pkeyId = treePrivate.getJlerTreeId()+"";
|
|
|
- } else if (contractInfo.getContractType()==3 || contractInfo.getContractType()==8) { //业主
|
|
|
- pkeyId = treePrivate.getYzerTreeId()+"";
|
|
|
- }else{
|
|
|
+ if (contractInfo.getContractType() == 2) { //3 监理
|
|
|
+ pkeyId = treePrivate.getJlerTreeId() + "";
|
|
|
+ } else if (contractInfo.getContractType() == 3 || contractInfo.getContractType() == 8) { //业主
|
|
|
+ pkeyId = treePrivate.getYzerTreeId() + "";
|
|
|
+ } else {
|
|
|
return R.fail("该合同段没有委托单权限业务");
|
|
|
}
|
|
|
Object excelHtml = getExcelHtml(pkeyId);
|
|
@@ -2907,7 +2912,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
public Boolean hasPart(String id) {
|
|
|
if (Func.isNotBlank(id)) {
|
|
|
List<Map<String, Object>> mapList = this.jdbcTemplate.queryForList("select a.id from m_wbs_tree a join m_wbs_info b on a.wbs_id=b.id where a.id=" + id + " and b.wbs_type=3 union select p_key_id from m_wbs_tree_private where p_key_id =" + id + " and wbs_type =3");
|
|
|
- /* return mapList.size() == 0;*/
|
|
|
+ /* return mapList.size() == 0;*/
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -2932,6 +2937,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void syncPid(Long projectId) {
|
|
@@ -2939,17 +2945,17 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
List<WbsTreeContract> allNode = baseMapper.getcontractAllNode(projectId);
|
|
|
// 合同节点按照合同id转换为map
|
|
|
Map<String, List<WbsTreeContract>> listMap = allNode.stream().collect(Collectors.groupingBy(WbsTreeContract::getContractId));
|
|
|
- Map<String,Map<Long,WbsTreeContract>> mapMap = new HashMap<>();
|
|
|
+ Map<String, Map<Long, WbsTreeContract>> mapMap = new HashMap<>();
|
|
|
// map中为每个合同段的数据,
|
|
|
for (String s : listMap.keySet()) {
|
|
|
List<WbsTreeContract> list = listMap.get(s);
|
|
|
//为id去重
|
|
|
list = list.stream()
|
|
|
- .collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContract::getId))),
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContract::getId))),
|
|
|
ArrayList::new));
|
|
|
//转换为map key为id
|
|
|
Map<Long, WbsTreeContract> map = list.stream().collect(Collectors.toMap(l -> l.getId(), l -> l));
|
|
|
- mapMap.put(s,map);
|
|
|
+ mapMap.put(s, map);
|
|
|
}
|
|
|
|
|
|
// 1:先取出wbs_contract表按照项目id搜索,所有不带pid的节点
|
|
@@ -2962,7 +2968,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
// 4:如果存在oldId,就把OldId赋值给id
|
|
|
// 如果存在oldId,则直接去map中先查合同段再查id
|
|
|
// 知道不存在oldId,然后把id = id
|
|
|
- if (StringUtils.isNotBlank(contract.getOldId())){
|
|
|
+ if (StringUtils.isNotBlank(contract.getOldId())) {
|
|
|
Long aLong = Long.valueOf(contract.getOldId());
|
|
|
WbsTreeContract wbsTreeContract = mapMap.get(contract.getContractId()).get(aLong);
|
|
|
while (wbsTreeContract != null && StringUtils.isNotBlank(wbsTreeContract.getOldId())) {
|
|
@@ -2973,78 +2979,78 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
// 5: 如果项目中存在,则把private的pId赋值给contract的isPid
|
|
|
Long aLong = map.get(new SyncPidVO1(contract.getId(), contract.getWbsId()));
|
|
|
- if (aLong != null){
|
|
|
+ if (aLong != null) {
|
|
|
contract.setIsTypePrivatePid(aLong);
|
|
|
}
|
|
|
}
|
|
|
- contracts = contracts.stream().filter(l->l.getIsTypePrivatePid() != null && l.getIsTypePrivatePid() != -1).collect(Collectors.toList());
|
|
|
+ contracts = contracts.stream().filter(l -> l.getIsTypePrivatePid() != null && l.getIsTypePrivatePid() != -1).collect(Collectors.toList());
|
|
|
List<List<WbsTreeContract>> lists = CommonUtil.splitList(contracts, 1000);
|
|
|
- int total=0;
|
|
|
+ int total = 0;
|
|
|
for (List<WbsTreeContract> list : lists) {
|
|
|
int upTotal = baseMapper.updateContractByPId(list);
|
|
|
- System.out.println("修改状态:"+upTotal);
|
|
|
+ System.out.println("修改状态:" + upTotal);
|
|
|
total++;
|
|
|
}
|
|
|
- System.out.println("总修改量:"+contracts.size());
|
|
|
- System.out.println("总修改次数:"+total);
|
|
|
+ System.out.println("总修改量:" + contracts.size());
|
|
|
+ System.out.println("总修改次数:" + total);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int linkNodeTreeInfo(String pkeyId, String nodeIds) {
|
|
|
- List<String> strList=new ArrayList<>();
|
|
|
- if(nodeIds!=null&&!nodeIds.equals("")){
|
|
|
- strList= Func.toStrList(nodeIds);
|
|
|
+ List<String> strList = new ArrayList<>();
|
|
|
+ if (nodeIds != null && !nodeIds.equals("")) {
|
|
|
+ strList = Func.toStrList(nodeIds);
|
|
|
}
|
|
|
- String sqlInfo = "SELECT * from m_wbs_tree_private where id = (SELECT parent_id from m_wbs_tree_private c where p_key_id='"+pkeyId+"')";
|
|
|
+ String sqlInfo = "SELECT * from m_wbs_tree_private where id = (SELECT parent_id from m_wbs_tree_private c where p_key_id='" + pkeyId + "')";
|
|
|
List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlInfo);
|
|
|
Integer nodeType = 1;
|
|
|
- if(maps!=null && maps.size()>=1){
|
|
|
- for(Map<String, Object> map:maps){
|
|
|
- String dataType = map.get("node_type")+"";
|
|
|
- if(dataType.equals("1000")){ //业主委托单
|
|
|
+ if (maps != null && maps.size() >= 1) {
|
|
|
+ for (Map<String, Object> map : maps) {
|
|
|
+ String dataType = map.get("node_type") + "";
|
|
|
+ if (dataType.equals("1000")) { //业主委托单
|
|
|
nodeType = 1;
|
|
|
break;
|
|
|
- }else if(dataType.equals("1001")){ //监理委托单
|
|
|
+ } else if (dataType.equals("1001")) { //监理委托单
|
|
|
nodeType = 2;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if(nodeType==2){
|
|
|
- if(strList.size()==0){
|
|
|
+ if (nodeType == 2) {
|
|
|
+ if (strList.size() == 0) {
|
|
|
//取消关联
|
|
|
- return baseMapper.cancelLinkNodeTreeInfoByJL(pkeyId) ;
|
|
|
- }else {
|
|
|
- baseMapper.cancelLinkNodeTreeInfoByJL(pkeyId) ;
|
|
|
- return baseMapper.linkNodeTreeInfoByJL(pkeyId, strList) ;
|
|
|
+ return baseMapper.cancelLinkNodeTreeInfoByJL(pkeyId);
|
|
|
+ } else {
|
|
|
+ baseMapper.cancelLinkNodeTreeInfoByJL(pkeyId);
|
|
|
+ return baseMapper.linkNodeTreeInfoByJL(pkeyId, strList);
|
|
|
}
|
|
|
- }else{
|
|
|
- if(strList.size()==0){
|
|
|
- return baseMapper.cancelLinkNodeTreeInfoByYZ(pkeyId) ;
|
|
|
+ } else {
|
|
|
+ if (strList.size() == 0) {
|
|
|
+ return baseMapper.cancelLinkNodeTreeInfoByYZ(pkeyId);
|
|
|
}
|
|
|
- baseMapper.cancelLinkNodeTreeInfoByYZ(pkeyId) ;
|
|
|
- return baseMapper.linkNodeTreeInfoByYZ(pkeyId, strList) ;
|
|
|
+ baseMapper.cancelLinkNodeTreeInfoByYZ(pkeyId);
|
|
|
+ return baseMapper.linkNodeTreeInfoByYZ(pkeyId, strList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<Long> linkNodeTreeBynodeId(String pkeyId) {
|
|
|
- String sqlInfo = "SELECT * from m_wbs_tree_private where id = (SELECT parent_id from m_wbs_tree_private c where p_key_id='"+pkeyId+"')";
|
|
|
+ String sqlInfo = "SELECT * from m_wbs_tree_private where id = (SELECT parent_id from m_wbs_tree_private c where p_key_id='" + pkeyId + "')";
|
|
|
List<Map<String, Object>> maps = jdbcTemplate.queryForList(sqlInfo);
|
|
|
Integer nodeType = 1;
|
|
|
- if(maps!=null && maps.size()>=1){
|
|
|
- for(Map<String, Object> map:maps){
|
|
|
- String dataType = map.get("node_type")+"";
|
|
|
- if(dataType.equals("1000")){ //业主委托单
|
|
|
+ if (maps != null && maps.size() >= 1) {
|
|
|
+ for (Map<String, Object> map : maps) {
|
|
|
+ String dataType = map.get("node_type") + "";
|
|
|
+ if (dataType.equals("1000")) { //业主委托单
|
|
|
nodeType = 1;
|
|
|
break;
|
|
|
- }else if(dataType.equals("1001")){ //监理委托单
|
|
|
+ } else if (dataType.equals("1001")) { //监理委托单
|
|
|
nodeType = 2;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return baseMapper.linkNodeTreeBynodeId(pkeyId,nodeType);
|
|
|
+ return baseMapper.linkNodeTreeBynodeId(pkeyId, nodeType);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -3054,67 +3060,68 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
public void diGuiWbs(int i) {
|
|
|
QueryWrapper<WbsTreePrivate> wbsTreePrivateQueryWrapper = new QueryWrapper<>();
|
|
|
- wbsTreePrivateQueryWrapper.select("p_key_id","id","p_id","wbs_id","project_id","parent_id","ancestors");
|
|
|
- wbsTreePrivateQueryWrapper.eq("parent_id",0);
|
|
|
- wbsTreePrivateQueryWrapper.eq("is_deleted",0);
|
|
|
+ wbsTreePrivateQueryWrapper.select("p_key_id", "id", "p_id", "wbs_id", "project_id", "parent_id", "ancestors");
|
|
|
+ wbsTreePrivateQueryWrapper.eq("parent_id", 0);
|
|
|
+ wbsTreePrivateQueryWrapper.eq("is_deleted", 0);
|
|
|
wbsTreePrivateQueryWrapper.isNotNull("project_id");
|
|
|
wbsTreePrivateQueryWrapper.isNotNull("wbs_id");
|
|
|
List<WbsTreePrivate> list = this.list(wbsTreePrivateQueryWrapper);
|
|
|
- if(!list.isEmpty()){
|
|
|
+ if (!list.isEmpty()) {
|
|
|
WbsTreePrivate wbsTreePrivate = list.get(i);
|
|
|
//通过parentID,projectID,wbsId分组,映射map
|
|
|
Map<CompositeKey1, List<WbsTreePrivate>> map = findAllContract(wbsTreePrivate).stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- item -> new CompositeKey1(item.getParentId(),item.getProjectId(),item.getWbsId())
|
|
|
- ));
|
|
|
- List<WbsTreePrivate>updateList=new ArrayList<>();
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
+ item -> new CompositeKey1(item.getParentId(), item.getProjectId(), item.getWbsId())
|
|
|
+ ));
|
|
|
+ List<WbsTreePrivate> updateList = new ArrayList<>();
|
|
|
|
|
|
//递归设置pid和ancestors
|
|
|
- setPidAndAncestors(map,wbsTreePrivate,updateList);
|
|
|
+ setPidAndAncestors(map, wbsTreePrivate, updateList);
|
|
|
for (WbsTreePrivate wbsTreePrivate1 : updateList) {
|
|
|
- UpdateWrapper<WbsTreePrivate>wrapper=new UpdateWrapper<>();
|
|
|
- wrapper.set("p_id",wbsTreePrivate1.getPId());
|
|
|
- wrapper.set("ancestors",wbsTreePrivate1.getAncestors());
|
|
|
- wrapper.eq("p_key_id",wbsTreePrivate1.getPKeyId());
|
|
|
+ UpdateWrapper<WbsTreePrivate> wrapper = new UpdateWrapper<>();
|
|
|
+ wrapper.set("p_id", wbsTreePrivate1.getPId());
|
|
|
+ wrapper.set("ancestors", wbsTreePrivate1.getAncestors());
|
|
|
+ wrapper.eq("p_key_id", wbsTreePrivate1.getPKeyId());
|
|
|
this.update(wrapper);
|
|
|
}
|
|
|
}
|
|
|
- System.out.println(Colour.RED.getCode()+"第"+i+"次递归完成======================================================================================="+Colour.RESET.getCode());
|
|
|
+ System.out.println(Colour.RED.getCode() + "第" + i + "次递归完成=======================================================================================" + Colour.RESET.getCode());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public WbsTreePrivateVO tree3(String wbsId, String projectId) {
|
|
|
WbsInfo wbsInfo = wbsInfoMapper.selectOne(Wrappers.<WbsInfo>query().lambda().eq(WbsInfo::getId, wbsId));
|
|
|
- WbsTreePrivateVO vo=new WbsTreePrivateVO();
|
|
|
+ WbsTreePrivateVO vo = new WbsTreePrivateVO();
|
|
|
vo.setId(wbsInfo.getId());
|
|
|
vo.setHasChildren(false);
|
|
|
vo.setProjectName(wbsInfo.getWbsName());
|
|
|
- vo.setWbsType(wbsInfo.getWbsType()+"");
|
|
|
+ vo.setWbsType(wbsInfo.getWbsType() + "");
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
- public List<WbsTreePrivate> findAllContract(WbsTreePrivate wbsTreePrivate){
|
|
|
+ public List<WbsTreePrivate> findAllContract(WbsTreePrivate wbsTreePrivate) {
|
|
|
QueryWrapper<WbsTreePrivate> wbsTreeContractQueryWrapper = new QueryWrapper<>();
|
|
|
- wbsTreeContractQueryWrapper.select("p_key_id","id","p_id","wbs_id","project_id","parent_id","ancestors");
|
|
|
- wbsTreeContractQueryWrapper.eq("project_id",wbsTreePrivate.getProjectId());
|
|
|
- wbsTreeContractQueryWrapper.eq("wbs_id",wbsTreePrivate.getWbsId());
|
|
|
+ wbsTreeContractQueryWrapper.select("p_key_id", "id", "p_id", "wbs_id", "project_id", "parent_id", "ancestors");
|
|
|
+ wbsTreeContractQueryWrapper.eq("project_id", wbsTreePrivate.getProjectId());
|
|
|
+ wbsTreeContractQueryWrapper.eq("wbs_id", wbsTreePrivate.getWbsId());
|
|
|
return this.list(wbsTreeContractQueryWrapper);
|
|
|
}
|
|
|
- public void setPidAndAncestors(Map<CompositeKey1, List<WbsTreePrivate>> map,WbsTreePrivate wbsTreePrivate,List<WbsTreePrivate>updateList){
|
|
|
- CompositeKey1 key = new CompositeKey1(wbsTreePrivate.getId(),wbsTreePrivate.getProjectId(),wbsTreePrivate.getWbsId());
|
|
|
+
|
|
|
+ public void setPidAndAncestors(Map<CompositeKey1, List<WbsTreePrivate>> map, WbsTreePrivate wbsTreePrivate, List<WbsTreePrivate> updateList) {
|
|
|
+ CompositeKey1 key = new CompositeKey1(wbsTreePrivate.getId(), wbsTreePrivate.getProjectId(), wbsTreePrivate.getWbsId());
|
|
|
//拿到当前节点的子节点
|
|
|
List<WbsTreePrivate> childrens = map.get(key);
|
|
|
- if(ObjectUtil.isNotEmpty(childrens)){
|
|
|
+ if (ObjectUtil.isNotEmpty(childrens)) {
|
|
|
for (WbsTreePrivate children : childrens) {
|
|
|
- if(children.getParentId().equals(wbsTreePrivate.getId())){
|
|
|
+ if (children.getParentId().equals(wbsTreePrivate.getId())) {
|
|
|
//设置祖级节点和pid
|
|
|
- String ancestors=wbsTreePrivate.getAncestors()+",";
|
|
|
- ancestors=ancestors+wbsTreePrivate.getPKeyId();
|
|
|
+ String ancestors = wbsTreePrivate.getAncestors() + ",";
|
|
|
+ ancestors = ancestors + wbsTreePrivate.getPKeyId();
|
|
|
children.setAncestors(ancestors);
|
|
|
children.setPId(wbsTreePrivate.getPKeyId());
|
|
|
updateList.add(children);
|
|
|
//递归调用自己继续将一个合同段的子节点设置完
|
|
|
- setPidAndAncestors(map,children,updateList);
|
|
|
+ setPidAndAncestors(map, children, updateList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -3123,7 +3130,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
public void updateAncestors() {
|
|
|
// 获取所有节点
|
|
|
- List<WbsTreePrivate> allNodes = baseMapper.selectList(new LambdaQueryWrapper<>(WbsTreePrivate.class).eq(WbsTreePrivate::getProjectId,1630011899725201410L));
|
|
|
+ List<WbsTreePrivate> allNodes = baseMapper.selectList(new LambdaQueryWrapper<>(WbsTreePrivate.class).eq(WbsTreePrivate::getProjectId, 1630011899725201410L));
|
|
|
|
|
|
// 构建父子关系映射
|
|
|
Map<Long, List<WbsTreePrivate>> parentChildMap = new HashMap<>();
|
|
@@ -3154,7 +3161,7 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
|
|
|
// 更新数据库
|
|
|
UpdateWrapper<WbsTreePrivate> updateWrapper = new UpdateWrapper<>();
|
|
|
- updateWrapper.eq("id", node.getId()).eq("project_id",node.getProjectId()).set("ancestors", node.getAncestors());
|
|
|
+ updateWrapper.eq("id", node.getId()).eq("project_id", node.getProjectId()).set("ancestors", node.getAncestors());
|
|
|
baseMapper.update(null, updateWrapper);
|
|
|
|
|
|
// 递归处理子节点
|
|
@@ -3164,6 +3171,147 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SqlSessionFactory sqlSessionFactory;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新指定项目的私有节点的父节点ID
|
|
|
+ * 此方法首先检查在当前项目下是否存在状态为1(通常表示有效或激活状态)的私有节点
|
|
|
+ * 如果不存在这样的节点,则直接返回,不进行任何更新操作
|
|
|
+ * 如果存在,则尝试更新这些节点的父节点ID
|
|
|
+ * 此方法使用事务管理,确保在遇到异常时可以回滚更改
|
|
|
+ *
|
|
|
+ * @param projectId 项目ID,用于指定需要更新私有节点父节点ID的项目
|
|
|
+ * @throws ServiceException 如果更新操作失败,则抛出此异常
|
|
|
+ */
|
|
|
+@Transactional(rollbackFor = Exception.class)
|
|
|
+public void updatePrivatePid(String projectId) {
|
|
|
+ // 输入校验
|
|
|
+ if (StringUtils.isBlank(projectId)) {
|
|
|
+ throw new IllegalArgumentException("项目ID不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断当前项目级下是否存在私有节点
|
|
|
+ Long count = baseMapper.selectCount(Wrappers.<WbsTreePrivate>lambdaQuery()
|
|
|
+ .select(WbsTreePrivate::getId)
|
|
|
+ .eq(WbsTreePrivate::getProjectId, projectId)
|
|
|
+ .eq(WbsTreePrivate::getStatus, 1));
|
|
|
+ if (count == 0L) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 尝试更新私有节点的父节点ID
|
|
|
+ Integer updatedRows = baseMapper.updatePrivatePid(projectId);
|
|
|
+ if (updatedRows == 0) {
|
|
|
+ throw new ServiceException("操作失败:未找到可更新的节点");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("操作失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取所有节点数据并更新 ancestors 字段
|
|
|
+ try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
|
|
|
+ WbsTreePrivateMapper mapper = sqlSession.getMapper(WbsTreePrivateMapper.class);
|
|
|
+
|
|
|
+ // 获取所有节点数据
|
|
|
+ List<WbsTreePrivate> list = repairWithMemoryCalculation(projectId);
|
|
|
+
|
|
|
+ int batchSize = 1000;
|
|
|
+ for (int i = 0; i < list.size(); i += batchSize) {
|
|
|
+ List<WbsTreePrivate> batch = list.subList(i, Math.min(i + batchSize, list.size()));
|
|
|
+ mapper.updateBatchAncestorsByPKeyId(batch);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 统一提交事务
|
|
|
+ sqlSession.commit();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new ServiceException("操作失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public List<WbsTreePrivate> repairWithMemoryCalculation(String projectId) {
|
|
|
+ // 1. 加载全量数据到内存
|
|
|
+ List<WbsTreePrivate> allNodes = wbsTreePrivateMapper.selectList(new QueryWrapper<WbsTreePrivate>().eq("project_id", projectId));
|
|
|
+ Map<Long, WbsTreePrivate> nodeMap = buildNodeMap(allNodes);
|
|
|
+
|
|
|
+ // 2. 检测并修复循环引用
|
|
|
+ detectAndBreakCircles(allNodes, nodeMap);
|
|
|
+
|
|
|
+ // 3. 重新计算所有ancestors
|
|
|
+ allNodes.stream()
|
|
|
+ .forEach(node -> {
|
|
|
+ String correctAncestors = calculateCorrectAncestors(node, nodeMap);
|
|
|
+ node.setAncestorsPId(correctAncestors);
|
|
|
+ });
|
|
|
+
|
|
|
+ return allNodes;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<Long, WbsTreePrivate> buildNodeMap(List<WbsTreePrivate> nodes) {
|
|
|
+ return nodes.stream().collect(Collectors.toMap(WbsTreePrivate::getPKeyId, Function.identity()));
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ private String calculateCorrectAncestors(WbsTreePrivate node, Map<Long, WbsTreePrivate> nodeMap) {
|
|
|
+ List<Long> path = new ArrayList<>();
|
|
|
+ WbsTreePrivate current = node;
|
|
|
+ Set<Long> visited = new HashSet<>();
|
|
|
+
|
|
|
+ while (true) {
|
|
|
+ if (current == null || current.getPId() == null ||
|
|
|
+ current.getPId() == 0 || current.getPId().equals(current.getPKeyId())) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检测循环引用
|
|
|
+ if (visited.contains(current.getPId())) {
|
|
|
+ log.warn("Circular reference detected at node {}" + current.getPKeyId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ visited.add(current.getPKeyId());
|
|
|
+
|
|
|
+ current = nodeMap.get(current.getPId());
|
|
|
+ if (current != null) {
|
|
|
+ path.add(0, current.getPKeyId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 安全限制
|
|
|
+ if (path.size() > 50) {
|
|
|
+ log.warn("Path too long (>50) at node {}" + node.getPKeyId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ path.add(0,0L);
|
|
|
+ return String.join(",", path.stream().map(String::valueOf).toArray(String[]::new));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void detectAndBreakCircles(List<WbsTreePrivate> nodes, Map<Long, WbsTreePrivate> nodeMap) {
|
|
|
+ nodes.forEach(node -> {
|
|
|
+ if (hasCircle(node, nodeMap)) {
|
|
|
+ log.warn("Breaking circle for node {}" + node.getPKeyId());
|
|
|
+ node.setParentId(null); // 断开循环引用
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean hasCircle(WbsTreePrivate node, Map<Long, WbsTreePrivate> nodeMap) {
|
|
|
+ Set<Long> visited = new HashSet<>();
|
|
|
+ WbsTreePrivate current = node;
|
|
|
+
|
|
|
+ while (current != null && current.getPId() != null &&
|
|
|
+ !current.getPId().equals(current.getPKeyId())) {
|
|
|
+
|
|
|
+ if (visited.contains(current.getPId())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ visited.add(current.getPKeyId());
|
|
|
+
|
|
|
+ current = nodeMap.get(current.getPId());
|
|
|
+ if (current == null) break;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|