|
|
@@ -31,6 +31,8 @@ import org.springblade.business.dto.WbsTreeContractStatisticsDTO;
|
|
|
import org.springblade.business.dto.FlushQueryNameDTO;
|
|
|
import org.springblade.business.dto.PreviewNodeNameDTO;
|
|
|
import org.springblade.business.dto.PreviewNodeNameDTO1;
|
|
|
+import org.springblade.business.dto.*;
|
|
|
+import org.springblade.business.dto.FlushQueryNameDTO;
|
|
|
import org.springblade.business.entity.*;
|
|
|
import org.springblade.business.feign.MessageWarningClient;
|
|
|
import org.springblade.business.feign.OperationLogClient;
|
|
|
@@ -233,41 +235,56 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
|
|
|
jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
|
|
|
}
|
|
|
- for (InformationQuery query : queryList) {
|
|
|
- String result="";
|
|
|
- String sql="select * from m_wbs_tree_contract where p_key_id="+query.getWbsId()+" and is_deleted=0";
|
|
|
- WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
- if(dto.getType()==1){
|
|
|
- result=wbsParamClient.createFileTitle(contract);
|
|
|
- }else {
|
|
|
- result=nodeNameMap.get(query.getId());
|
|
|
- //同时修改工程划分节点命名规则
|
|
|
- if(contract!=null){
|
|
|
- wbsTreeContractClient.saveNameRuleByPkeyId(contract.getPKeyId(),paramMap.get(query.getId()),Long.parseLong(contract.getProjectId()));
|
|
|
- }
|
|
|
- }
|
|
|
- if(contract!=null&&contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
|
|
|
- if(result==null){
|
|
|
- result="";
|
|
|
- }
|
|
|
- if(query.getClassify()!=null&&query.getClassify()==1&&StringUtils.isNotEmpty(sgSuffix)){
|
|
|
- if(!result.contains(sgSuffix)){
|
|
|
- result=result+sgSuffix;
|
|
|
+ for (InformationQuery query : queryList) {
|
|
|
+ String result="";
|
|
|
+ String sql="select * from m_wbs_tree_contract where p_key_id="+query.getWbsId()+" and is_deleted=0";
|
|
|
+ WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ //底层节点
|
|
|
+ if(projectInfos.get(0).getTemplateType()==2){
|
|
|
+ if(dto.getType()==1){
|
|
|
+ result=wbsParamClient.createFileTitle(contract);
|
|
|
+ }else {
|
|
|
+ result=nodeNameMap.get(query.getId());
|
|
|
+ //同时修改工程划分节点命名规则
|
|
|
+ if(contract!=null){
|
|
|
+ wbsTreeContractClient.saveNameRuleByPkeyId(contract.getPKeyId(),paramMap.get(query.getId()),Long.parseLong(contract.getProjectId()));
|
|
|
+ }
|
|
|
}
|
|
|
- if(!query.getName().equals(result)){
|
|
|
- query.setName(result);
|
|
|
+ }else {
|
|
|
+ String mbnameRule = paramMap.get(query.getId());
|
|
|
+ //模板节点 先保存文件题名规则,在重刷
|
|
|
+ if(StringUtils.isNotEmpty(mbnameRule)){
|
|
|
+ //先删在保存
|
|
|
+ String delNameRule="delete from mb_name_rule where wbs_id="+query.getWbsId()+" and classify="+query.getClassify();
|
|
|
+ jdbcTemplate.execute(delNameRule);
|
|
|
+ String insertNameRule = "INSERT INTO mb_name_rule(id, wbs_id, name_rule, classify) VALUES(?, ?, ?, ?)";
|
|
|
+ jdbcTemplate.update(insertNameRule, SnowFlakeUtil.getId(), query.getWbsId(), mbnameRule, query.getClassify());
|
|
|
+ result=nodeNameMap.get(query.getId());
|
|
|
}
|
|
|
- }else if(query.getClassify()!=null&&query.getClassify()==2&&StringUtils.isNotEmpty(jlSuffix)){
|
|
|
- if(!result.contains(jlSuffix)){
|
|
|
- result=result+jlSuffix;
|
|
|
+ }
|
|
|
+ if(contract!=null&&contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
|
|
|
+ if(result==null){
|
|
|
+ result="";
|
|
|
}
|
|
|
- if(!query.getName().equals(result)){
|
|
|
- query.setName(result);
|
|
|
+ if(query.getClassify()!=null&&query.getClassify()==1&&StringUtils.isNotEmpty(sgSuffix)){
|
|
|
+ if(!result.contains(sgSuffix)){
|
|
|
+ result=result+sgSuffix;
|
|
|
+ }
|
|
|
+ if(!query.getName().equals(result)){
|
|
|
+ query.setName(result);
|
|
|
+ }
|
|
|
+ }else if(query.getClassify()!=null&&query.getClassify()==2&&StringUtils.isNotEmpty(jlSuffix)){
|
|
|
+ if(!result.contains(jlSuffix)){
|
|
|
+ result=result+jlSuffix;
|
|
|
+ }
|
|
|
+ if(!query.getName().equals(result)){
|
|
|
+ query.setName(result);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ query.setName(result);
|
|
|
}
|
|
|
- query.setName(result);
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
List<InformationQuery> taskList = queryList.stream().filter(o -> o.getStatus() == 1 || o.getStatus() == 2).collect(Collectors.toList());
|
|
|
if(taskList.size()>0){
|
|
|
@@ -280,81 +297,93 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public List<String> getNameRuleByPkeyId(Long pKeyId, Long projectId) {
|
|
|
+ public List<String> getNameRuleByPkeyId(Long pKeyId, Long projectId,Integer templateType) {
|
|
|
NameRuleVo vo = new NameRuleVo();
|
|
|
- String sql2="select * from m_wbs_param where node_id="+pKeyId+" and type=200"+" and is_deleted=0 and k='FILE_TITLE'";
|
|
|
- List<WbsParam> wbsParams = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
- WbsParam wbsParam = null;
|
|
|
- if (!wbsParams.isEmpty()) {
|
|
|
- wbsParam = wbsParams.get(0);
|
|
|
- }
|
|
|
- if(wbsParam!=null){
|
|
|
- vo.setNameId(wbsParam.getNameId());
|
|
|
- vo.setNameVaule(wbsParam.getV());
|
|
|
- }
|
|
|
- if(vo!=null&&StringUtils.isNotEmpty(vo.getNameVaule())){
|
|
|
- List<String> list = Arrays.asList(vo.getNameVaule().split("-"));
|
|
|
- return 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 null;
|
|
|
- }
|
|
|
- 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 null;
|
|
|
- }
|
|
|
- //拿到引用项目级节点的祖级节点
|
|
|
- String ancestor=wbsTreePrivate.getAncestorsPId()+","+wbsTreePrivate.getPKeyId();
|
|
|
- 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 project_id="+projectId+" 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));
|
|
|
- //那点祖级节点的Id
|
|
|
- List<Long> list3 = nodeList.stream().map(o -> o.getId()).collect(Collectors.toList());
|
|
|
- if(list3.size()<0){
|
|
|
- return null;
|
|
|
- }
|
|
|
- //查出这个项目所有的文件题名配置
|
|
|
- String wbsParamsql="select * from m_wbs_param where project_id="+projectId+" and k='FILE_TITLE' and is_deleted=0";
|
|
|
- List<WbsParam> wbsParamList=jdbcTemplate.query(wbsParamsql, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
- List<WbsParam> result=new ArrayList<>();
|
|
|
- if(wbsParamList.size()>0){
|
|
|
- //筛选出包含当前单位工程节点的
|
|
|
- for (WbsParam param : wbsParamList) {
|
|
|
- //祖级节点里有文件题名配置就加进去
|
|
|
- if(list3.contains(param.getNodeId())){
|
|
|
- result.add(param);
|
|
|
- }
|
|
|
- //如果是全局的也加进去
|
|
|
- if(param.getNameType()==1){
|
|
|
- result.add(param);
|
|
|
- }
|
|
|
+ if (templateType == 2) {
|
|
|
+ String sql2 = "select * from m_wbs_param where node_id=" + pKeyId + " and type=200" + " and is_deleted=0 and k='FILE_TITLE'";
|
|
|
+ List<WbsParam> wbsParams = jdbcTemplate.query(sql2, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
+ WbsParam wbsParam = null;
|
|
|
+ if (!wbsParams.isEmpty()) {
|
|
|
+ wbsParam = wbsParams.get(0);
|
|
|
+ }
|
|
|
+ if (wbsParam != null) {
|
|
|
+ vo.setNameId(wbsParam.getNameId());
|
|
|
+ vo.setNameVaule(wbsParam.getV());
|
|
|
+ }
|
|
|
+ if (vo != null && StringUtils.isNotEmpty(vo.getNameVaule())) {
|
|
|
+ List<String> list = Arrays.asList(vo.getNameVaule().split("-"));
|
|
|
+ return 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 null;
|
|
|
}
|
|
|
- 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 Arrays.asList(param.getV().split("-"));
|
|
|
+ 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 null;
|
|
|
+ }
|
|
|
+ //拿到引用项目级节点的祖级节点
|
|
|
+ String ancestor = wbsTreePrivate.getAncestorsPId() + "," + wbsTreePrivate.getPKeyId();
|
|
|
+ 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 project_id=" + projectId + " 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));
|
|
|
+ //那点祖级节点的Id
|
|
|
+ List<Long> list3 = nodeList.stream().map(o -> o.getId()).collect(Collectors.toList());
|
|
|
+ if (list3.size() < 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //查出这个项目所有的文件题名配置
|
|
|
+ String wbsParamsql = "select * from m_wbs_param where project_id=" + projectId + " and k='FILE_TITLE' and is_deleted=0";
|
|
|
+ List<WbsParam> wbsParamList = jdbcTemplate.query(wbsParamsql, new BeanPropertyRowMapper<>(WbsParam.class));
|
|
|
+ List<WbsParam> result = new ArrayList<>();
|
|
|
+ if (wbsParamList.size() > 0) {
|
|
|
+ //筛选出包含当前单位工程节点的
|
|
|
+ for (WbsParam param : wbsParamList) {
|
|
|
+ //祖级节点里有文件题名配置就加进去
|
|
|
+ if (list3.contains(param.getNodeId())) {
|
|
|
+ result.add(param);
|
|
|
+ }
|
|
|
+ //如果是全局的也加进去
|
|
|
+ if (param.getNameType() == 1) {
|
|
|
+ result.add(param);
|
|
|
+ }
|
|
|
}
|
|
|
- //没有部分节点用所有节点
|
|
|
- List<WbsParam> collect2 = result.stream().filter(o -> o.getNameType() == 1).collect(Collectors.toList());
|
|
|
- if(collect2.size()>0){
|
|
|
- WbsParam param = collect2.get(0);
|
|
|
- return Arrays.asList(param.getV().split("-"));
|
|
|
+ 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 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 Arrays.asList(param.getV().split("-"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String wbsContractSql="select * from m_wbs_tree_contract where p_key_id="+pKeyId;
|
|
|
+ WbsTreeContract contract = jdbcTemplate.queryForObject(wbsContractSql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ //优先使用自己配置的文件题名规则
|
|
|
+ Integer classify=contract.getTableOwner()==null?1:"123".contains(contract.getTableOwner())?1:2;
|
|
|
+ String sqlmbNameRule="select name_rule from mb_name_rule where wbs_id=? and classify=?";
|
|
|
+ List<String> nameRuleVos = jdbcTemplate.query(sqlmbNameRule, new SingleColumnRowMapper<>(String.class), contract.getPKeyId(),classify);
|
|
|
+ if(!nameRuleVos.isEmpty()){
|
|
|
+ return Arrays.asList(nameRuleVos.get(0).split("-"));
|
|
|
+ }
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
@@ -379,24 +408,15 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
WbsTreeContract::getNodeName,
|
|
|
(existing, replacement) -> replacement // 如果键重复,保留后者
|
|
|
));
|
|
|
- StringBuilder result = new StringBuilder("");
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
for (Integer i : index) {
|
|
|
- if(i==0){
|
|
|
- if(map.containsKey(1)){
|
|
|
- result.append(map.get(1));
|
|
|
- }
|
|
|
- }
|
|
|
- else if(i==1){
|
|
|
- if(map.containsKey(18)){
|
|
|
- result.append(map.get(18));
|
|
|
- }
|
|
|
- }else {
|
|
|
- if(map.containsKey(i)){
|
|
|
- result.append(map.get(i));
|
|
|
- }
|
|
|
+ String title = map.get(i == 0 ? 1 : i == 1 && map.containsKey(18) ? 18 : i);
|
|
|
+ if(title == null || result.stream().anyMatch(f -> f.contains(title))){
|
|
|
+ continue;
|
|
|
}
|
|
|
+ result.add(title);
|
|
|
}
|
|
|
- return result.toString();
|
|
|
+ return String.join("", result);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/previewNodeName")
|
|
|
@@ -443,12 +463,21 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
return R.data(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@PostMapping("/getNameRuleList")
|
|
|
@ApiOperation(value = "获取题名规则列表")
|
|
|
- public R<List<PreviewNodeNameVO>> getNameRuleList(@RequestBody List<PreviewNodeNameDTO>dtos){
|
|
|
+ public R<List<PreviewNodeNameVO>> getNameRuleList(@RequestBody GetNameRuleListDTO param){
|
|
|
List<PreviewNodeNameVO>list=new ArrayList<>();
|
|
|
- for (PreviewNodeNameDTO dto : dtos) {
|
|
|
- List<String> nameRules = getNameRuleByPkeyId(dto.getWbsId(), dto.getProjectId());
|
|
|
+ String sql1="Select sg_suffix,jl_suffix,template_type from m_project_info where id="+param.getDtos().get(0).getProjectId()+" and is_deleted=0";
|
|
|
+ List<ProjectInfo> projectInfos = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
+ String sgSuffix="";
|
|
|
+ String jlSuffix="";
|
|
|
+ if(projectInfos.size()>0){
|
|
|
+ sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
|
|
|
+ jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
|
|
|
+ }
|
|
|
+ for (PreviewNodeNameDTO dto : param.getDtos()) {
|
|
|
+ List<String> nameRules = getNameRuleByPkeyId(dto.getWbsId(), dto.getProjectId(),param.getTemplateType());
|
|
|
String sql="select p_key_id,ancestors_p_id,major_data_type from m_wbs_tree_contract where p_key_id="+dto.getWbsId()+" and is_deleted=0";
|
|
|
WbsTreeContract contract = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
String sql2="select IFNULL(classify,0) from u_information_query where id="+dto.getId();
|
|
|
@@ -456,20 +485,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
String result="";
|
|
|
if(nameRules!=null){
|
|
|
result= createFileTitle(contract, String.join("-", nameRules));
|
|
|
- //result = nodeBaseInfoServiceClient.getNameRuleByRule(String.join("-", nameRules), contract.getPKeyId() + "");
|
|
|
if(contract!=null){
|
|
|
- String sql1="Select sg_suffix,jl_suffix,template_type from m_project_info where id="+dtos.get(0).getProjectId()+" and is_deleted=0";
|
|
|
- List<ProjectInfo> projectInfos = jdbcTemplate.query(sql1, new BeanPropertyRowMapper<>(ProjectInfo.class));
|
|
|
- String sgSuffix="";
|
|
|
- String jlSuffix="";
|
|
|
- if(projectInfos.size()>0){
|
|
|
- sgSuffix=projectInfos.get(0).getSgSuffix()==null?"":projectInfos.get(0).getSgSuffix();
|
|
|
- jlSuffix=projectInfos.get(0).getJlSuffix()==null?"":projectInfos.get(0).getJlSuffix();
|
|
|
- }
|
|
|
- if(contract!=null&&contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
|
|
|
- if(result==null){
|
|
|
- result="";
|
|
|
- }
|
|
|
+ if(contract.getMajorDataType()!=null&&contract.getMajorDataType()==4){
|
|
|
if(classify==1&&StringUtils.isNotEmpty(sgSuffix)){
|
|
|
result=result+sgSuffix;
|
|
|
}else if(classify==2&&StringUtils.isNotEmpty(jlSuffix)){
|