|
@@ -2,6 +2,7 @@ package org.springblade.manager.service.impl;
|
|
|
|
|
|
import cn.hutool.core.date.StopWatch;
|
|
|
import cn.hutool.log.StaticLog;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.mixsmart.utils.CustomFunction;
|
|
|
import com.mixsmart.utils.FormulaUtils;
|
|
@@ -20,6 +21,7 @@ import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.vo.NameRuleVo;
|
|
|
import org.springblade.manager.vo.WbsParamVo2;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -42,6 +44,7 @@ public class WbsParamServiceImpl extends BaseServiceImpl<WbsParamMapper, WbsPara
|
|
|
private final IElementFormulaMappingService elementFormulaMappingService;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
+
|
|
|
private static final String NOT_SET = "还未配置提名规则";
|
|
|
/**
|
|
|
* 文件题名
|
|
@@ -55,34 +58,45 @@ public class WbsParamServiceImpl extends BaseServiceImpl<WbsParamMapper, WbsPara
|
|
|
if(wtc!=null&&wtc.getPKeyId()!=null){
|
|
|
List<WbsTreeContract> nodes = tracing(wtc.getPKeyId());
|
|
|
if (Func.isNotEmpty(nodes)) {
|
|
|
- WbsTreePrivate wtp = this.wtpId(wtc.getPKeyId());
|
|
|
- if(wtp!=null){
|
|
|
- /*优先取私有*/
|
|
|
- WbsParam wp = this.getOne(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId, wtp.getPKeyId()).eq(WbsParam::getK, FILE_TITLE).last(" limit 1"));
|
|
|
-
|
|
|
- if (wp == null) {
|
|
|
- WbsTreePrivate publicWtp = this.getOriginWtp(wtp.getPKeyId());
|
|
|
- wp = this.getOne(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId, publicWtp.getId()).eq(WbsParam::getK, FILE_TITLE).last(" limit 1 "));
|
|
|
- if(wp==null){
|
|
|
- wp = this.getOne(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId, publicWtp.getTreePId()).eq(WbsParam::getK, FILE_TITLE).last(" limit 1 "));
|
|
|
- }
|
|
|
+ //查询是否是底层节点
|
|
|
+ String sql="select template_type from m_contract_info where id="+wtc.getContractId();
|
|
|
+ Integer type= jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
+ //顶层节点优先使用底层节点配置
|
|
|
+ if(type==2){
|
|
|
+ R nameRule = this.getNameRuleByPkeyId(wtc.getPKeyId(), Long.valueOf(wtc.getProjectId()));
|
|
|
+ if(nameRule.getData()!=null){
|
|
|
+ List<String> nameRules =(List<String>) nameRule.getData();
|
|
|
+ return CustomFunction.tree(nodes, String.join("-", nameRules),2).toString();
|
|
|
}
|
|
|
- if (Func.isNotEmpty(wp)) {
|
|
|
- return CustomFunction.tree(nodes, wp.getV()).toString();
|
|
|
+ }else {
|
|
|
+ WbsTreePrivate wtp = this.wtpId(wtc.getPKeyId());
|
|
|
+ if(wtp!=null){
|
|
|
+ /*优先取私有*/
|
|
|
+ WbsParam wp = this.getOne(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId, wtp.getPKeyId()).eq(WbsParam::getK, FILE_TITLE).last(" limit 1"));
|
|
|
+ if (wp == null) {
|
|
|
+ WbsTreePrivate publicWtp = this.getOriginWtp(wtp.getPKeyId());
|
|
|
+ wp = this.getOne(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId, publicWtp.getId()).eq(WbsParam::getK, FILE_TITLE).last(" limit 1 "));
|
|
|
+ if(wp==null){
|
|
|
+ wp = this.getOne(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId, publicWtp.getTreePId()).eq(WbsParam::getK, FILE_TITLE).last(" limit 1 "));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Func.isNotEmpty(wp)) {
|
|
|
+ return CustomFunction.tree(nodes, wp.getV(),1).toString();
|
|
|
+ }else{
|
|
|
+ return wtp.getNodeName()+"找不到文件题名配置";
|
|
|
+ }
|
|
|
}else{
|
|
|
- return wtp.getNodeName()+"找不到文件题名配置";
|
|
|
+ return nodes.stream().filter(e->e.getNodeType()!=null&&(e.getNodeType().equals(2)||e.getNodeType().equals(4)||e.getNodeType().equals(6))).map(w->StringUtils.isNotEmpty(w.getFullName())?w.getFullName():w.getNodeName()).map(s->s.replaceAll("[\\s\\n\\t]+","")).collect(Collectors.joining());
|
|
|
+ /* return "找不到项目配置信息";*/
|
|
|
}
|
|
|
- }else{
|
|
|
- return nodes.stream().filter(e->e.getNodeType()!=null&&(e.getNodeType().equals(2)||e.getNodeType().equals(4)||e.getNodeType().equals(6))).map(w->StringUtils.isNotEmpty(w.getFullName())?w.getFullName():w.getNodeName()).map(s->s.replaceAll("[\\s\\n\\t]+","")).collect(Collectors.joining());
|
|
|
- /* return "找不到项目配置信息";*/
|
|
|
}
|
|
|
-
|
|
|
}else{
|
|
|
return "层级断链";
|
|
|
}
|
|
|
}else {
|
|
|
return "找不到节点";
|
|
|
}
|
|
|
+ return "找不到节点";
|
|
|
}
|
|
|
//根据选择的文件题名规则,返回文件题名;
|
|
|
@Override
|
|
@@ -93,7 +107,7 @@ public class WbsParamServiceImpl extends BaseServiceImpl<WbsParamMapper, WbsPara
|
|
|
WbsTreePrivate wtp = this.wtpId(wtc.getPKeyId());
|
|
|
if(wtp!=null){
|
|
|
if (Func.isNotEmpty(wp)) {
|
|
|
- return CustomFunction.tree(nodes, wp).toString();
|
|
|
+ return CustomFunction.tree(nodes, wp,null).toString();
|
|
|
}else{
|
|
|
return wtp.getNodeName()+"找不到文件题名配置";
|
|
|
}
|
|
@@ -176,6 +190,68 @@ public class WbsParamServiceImpl extends BaseServiceImpl<WbsParamMapper, WbsPara
|
|
|
return createFileTitle(wtc);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R getNameRuleByPkeyId(Long pKeyId, Long projectId) {
|
|
|
+ //先查询合同段级的
|
|
|
+ NameRuleVo vo = this.getNameRuleByPkeyId(pKeyId);
|
|
|
+ if(vo!=null){
|
|
|
+ List<String> list = Arrays.asList(vo.getNameVaule().split("-"));
|
|
|
+ return R.data(list);
|
|
|
+ }else {
|
|
|
+ //合同段没有 在查项目级的
|
|
|
+ //如果是导入划分树 就不会引用项目级的
|
|
|
+ String sql="select * from m_wbs_tree_contract where p_key_id="+pKeyId;
|
|
|
+ WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ if(contract.getIsTypePrivatePid()==null){
|
|
|
+ return R.success("暂无数据");
|
|
|
+ }
|
|
|
+ String sql1="select * from m_wbs_tree_private where p_key_id="+contract.getIsTypePrivatePid();
|
|
|
+ WbsTreePrivate wbsTreePrivate = jdbcTemplate.queryForObject(sql1,new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ if(wbsTreePrivate==null){
|
|
|
+ return R.success("暂无数据");
|
|
|
+ }
|
|
|
+ String ancestor=wbsTreePrivate.getAncestors();
|
|
|
+ String[] ancestors = ancestor.split(",");
|
|
|
+ List<Long> list2 = Arrays.stream(ancestors)
|
|
|
+ .map(Long::parseLong)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ String join = String.join(",", list2.stream().map(String::valueOf).collect(Collectors.toList()));
|
|
|
+ String sql11 = "SELECT * FROM m_wbs_tree_private WHERE node_type=1 AND parent_id!=0 AND p_key_id IN (" + join + ")";
|
|
|
+ List<WbsTreePrivate> nodeList = jdbcTemplate.query(sql11, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ //List<WbsTreePrivate> nodeList = wbsTreePrivateService.getBaseMapper().selectList(new LambdaQueryWrapper<>(WbsTreePrivate.class).select(WbsTreePrivate::getId).eq(WbsTreePrivate::getNodeType, 1).ne(WbsTreePrivate::getParentId, 0).in(WbsTreePrivate::getPKeyId, list2));
|
|
|
+ List<Long> list3 = nodeList.stream().map(o -> o.getId()).collect(Collectors.toList());
|
|
|
+ if(list3.size()<0){
|
|
|
+ return R.success("暂无数据");
|
|
|
+ }
|
|
|
+ List<WbsParam> wbsParamList = this.getBaseMapper().selectList(new LambdaQueryWrapper<>(WbsParam.class).eq(WbsParam::getProjectId, projectId).eq(WbsParam::getK, "FILE_TITLE"));
|
|
|
+ List<WbsParam> result=new ArrayList<>();
|
|
|
+ if(wbsParamList.size()>0){
|
|
|
+ //筛选出包含当前单位工程节点的
|
|
|
+ for (WbsParam param : wbsParamList) {
|
|
|
+ if(list3.contains(param.getNodeId())){
|
|
|
+ result.add(param);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(result.size()>0){
|
|
|
+ //如果有部分节点优先部分
|
|
|
+ List<WbsParam> collect1 = result.stream().filter(o -> o.getNameType() == 2).collect(Collectors.toList());
|
|
|
+ if(collect1.size()>0){
|
|
|
+ WbsParam param = collect1.get(0);
|
|
|
+ return R.data(Arrays.asList(param.getV().split("-")));
|
|
|
+ }
|
|
|
+ //没有部分节点用所有节点
|
|
|
+ List<WbsParam> collect2 = result.stream().filter(o -> o.getNameType() == 1).collect(Collectors.toList());
|
|
|
+ if(collect2.size()>0){
|
|
|
+ WbsParam param = collect2.get(0);
|
|
|
+ return R.data(Arrays.asList(param.getV().split("-")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.success("暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public List<WbsTreeContract> tracing(@NotNull Long pkeyId){
|