|
@@ -1,7 +1,6 @@
|
|
|
package org.springblade.manager.controller;
|
|
|
|
|
|
import cn.hutool.core.date.StopWatch;
|
|
|
-import cn.hutool.log.StaticLog;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
@@ -31,9 +30,7 @@ import org.springblade.manager.vo.ParamBean;
|
|
|
import org.springblade.manager.vo.ParamSearch;
|
|
|
import org.springblade.manager.wrapper.WbsParamWrapper;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
-import org.springframework.data.redis.serializer.RedisSerializer;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -133,26 +130,8 @@ public class WbsParamController {
|
|
|
}
|
|
|
if (!elementMap.isEmpty()) {
|
|
|
List<Map<String, Object>> finalElementMap = elementMap;
|
|
|
- // List<Map<String,Object>> formulaIdAndKmaps=this.jdbcTemplate.queryForList("select a.id,b.k from m_formula a join m_wbs_param b on a.param_id=b.id where b.k in ("+entityList.stream().map(WbsParam::getK).collect(Collectors.joining("','","'","'"))+") AND b.type=0");
|
|
|
Map<String,Long> fkMap=this.service.formulaIdKeyMap(entityList.stream().map(WbsParam::getK).collect(Collectors.toList()));
|
|
|
entityList.forEach(e -> {
|
|
|
-// Formula formula = new Formula();
|
|
|
-// formula.setOutm(Formula.FULL);
|
|
|
-// formula.setParamId(e.getId());
|
|
|
-// Map<String, String> keyMap = new HashMap<>();
|
|
|
-// keyMap.put("name", e.getName());
|
|
|
-// keyMap.put("id", e.getId().toString());
|
|
|
-// tmpMap.put(e.getK(), keyMap);
|
|
|
-// if (RegexUtil.match(ParamElements.LEVEL_REG, e.getV().trim())) {
|
|
|
-// /*取层级*/
|
|
|
-// formula.setFormula("FC.tree(trees,WP[" + e.getK() + "])");
|
|
|
-// } else {
|
|
|
-// /*直接取数*/
|
|
|
-// formula.setFormula("WP[" + e.getK() + "]");
|
|
|
-// }
|
|
|
-// formula.setMap(JSON.toJSONString(tmpMap));
|
|
|
-// this.formulaService.save(formula);
|
|
|
-// tmpMap.clear();
|
|
|
finalElementMap.forEach(m -> {
|
|
|
if (StringUtils.handleNull(m.get("name")).contains(e.getName())) {
|
|
|
ElementFormulaMapping efm = new ElementFormulaMapping();
|
|
@@ -594,128 +573,35 @@ public class WbsParamController {
|
|
|
return R.fail("项目Id格式有问题");
|
|
|
}
|
|
|
|
|
|
+ /*检查指定节点的文件提名*/
|
|
|
+ @GetMapping("/file-title-check")
|
|
|
+ public R<Object> titleCheck(Long pkeyId){
|
|
|
+ return R.data(this.service.createFileTitle(pkeyId));
|
|
|
+ }
|
|
|
|
|
|
/**按合同段或者项目刷入m_wbs_tree_contract的treeCode*/
|
|
|
@GetMapping("/tree-code")
|
|
|
public R<Object> treeCode(Long contractId,Long projectId) {
|
|
|
- StopWatch stopWatch = new StopWatch();
|
|
|
- stopWatch.start("treeCode刷新");
|
|
|
- Set<Long> contractIds=new HashSet<>();
|
|
|
- if(projectId!=null){
|
|
|
- contractIds= new HashSet<>(this.jdbcTemplate.queryForList(" select id from m_contract_info where p_id="+projectId+" and is_deleted=0 ",Long.class));
|
|
|
- }else if( contractId!=null){
|
|
|
- contractIds.add(contractId);
|
|
|
- }
|
|
|
- if(contractIds.size()>0){
|
|
|
- this.treeCodeUpdate(contractIds);
|
|
|
- stopWatch.stop();
|
|
|
- return R.success((stopWatch.getLastTaskName()+"执行用时:"+stopWatch.getTotalTimeMillis()));
|
|
|
- }
|
|
|
- return R.fail("执行失败");
|
|
|
+ return this.service.treeCode(contractId,projectId);
|
|
|
}
|
|
|
|
|
|
/*把所有项目的合同段都刷新treeCode*/
|
|
|
@GetMapping("/tree-code-all")
|
|
|
public R<Object> treeCodeAll() {
|
|
|
- return this.treeCodeUpdateProjectAllForJob();
|
|
|
+ return this.service.treeCodeUpdateProjectAllForJob();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Scheduled(cron = " 0 0 3,13 * * ?")
|
|
|
public void job(){
|
|
|
System.out.println("treeCode刷新任务开始"+ LocalDateTime.now());
|
|
|
if(!Optional.ofNullable(System.getProperty("os.name")).orElse(StringPool.EMPTY).equals("Linux")){
|
|
|
- this.treeCodeUpdateProjectAllForJob();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public void builder(Long id,List<String>sqlList){
|
|
|
- List<Map<String,Object>> treeNodeList= this.jdbcTemplate.queryForList("select node_name name,p_key_id value, id, parent_id parentId from m_wbs_tree_contract where contract_id="+id+" and is_deleted=0 and type=1 ");
|
|
|
- if(treeNodeList.size()>0){
|
|
|
- Map<Long,TreeNode<Long>> treeNodeMap = new HashMap<>(treeNodeList.size()*2);
|
|
|
- Long topId=null;
|
|
|
- for (Map<String,Object> map:treeNodeList){
|
|
|
- TreeNode<Long> treeNode = new TreeNode<>();
|
|
|
- treeNode.setId(Long.parseLong(map.get("id").toString()));
|
|
|
- treeNode.setParentId(Long.parseLong(map.get("parentId").toString()));
|
|
|
- treeNode.setValue(Long.parseLong(map.get("value").toString()));
|
|
|
- treeNode.setName(map.get("name").toString());
|
|
|
- if(treeNode.getParentId().equals(0L)){
|
|
|
- topId=treeNode.getId();
|
|
|
- }
|
|
|
- treeNodeMap.put(treeNode.getId(),treeNode);
|
|
|
- }
|
|
|
- Map<Long,List<TreeNode<Long>>> group= treeNodeMap.values().stream().collect(Collectors.groupingBy(TreeNode::getParentId));
|
|
|
- group.forEach((k,v)->{
|
|
|
- TreeNode<Long> tmp = treeNodeMap.get(k);
|
|
|
- if(tmp!=null) {
|
|
|
- tmp.setChildren(v);
|
|
|
- }
|
|
|
- });
|
|
|
- sqlBuilder2(treeNodeMap.get(topId),sqlList,ZERO);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void treeCodeUpdate(Set<Long> contractIds){
|
|
|
- List<String>sqlList=new ArrayList<>();
|
|
|
- contractIds.forEach(id->{
|
|
|
- builder(id,sqlList);
|
|
|
- });
|
|
|
- if(sqlList.size()>0){
|
|
|
- List<List<String>> sqlListSeg = BaseUtils.splitList(sqlList, 250);
|
|
|
- sqlListSeg.parallelStream().forEach(sql->{
|
|
|
- try {
|
|
|
- String joinSql=String.join(";",sql);
|
|
|
- this.jdbcTemplate.execute(joinSql);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**批量任務*/
|
|
|
- public R<Object> treeCodeUpdateProjectAllForJob(){
|
|
|
- StopWatch stopWatch = new StopWatch();
|
|
|
- stopWatch.start("全部项目treeCode刷新");
|
|
|
- Set<Long> contractIds= new HashSet<>(this.jdbcTemplate.queryForList(" select id from m_contract_info where is_deleted=0 ",Long.class));
|
|
|
- if(contractIds.size()>0){
|
|
|
- this.treeCodeUpdate(contractIds);
|
|
|
- stopWatch.stop();
|
|
|
- return R.success((stopWatch.getLastTaskName()+"执行用时:"+stopWatch.getTotalTimeMillis()));
|
|
|
+ this.service.treeCodeUpdateProjectAllForJob();
|
|
|
}
|
|
|
- return R.fail("执行失败");
|
|
|
}
|
|
|
|
|
|
- static String ZERO="0";
|
|
|
- public void sqlBuilder(TreeNode<Long> top, List<Object[]>paramList, String treeCode){
|
|
|
- if(top!=null){
|
|
|
- paramList.add(new Object[]{treeCode,top.getValue()});
|
|
|
- if(top.hasChildren()){
|
|
|
- for(int i=0;i<top.getChildren().size();i++){
|
|
|
- TreeNode<Long> child=top.getChildren().get(i);
|
|
|
- int base=ZERO.equals(treeCode)?100:1000;
|
|
|
- sqlBuilder(child,paramList,treeCode+String.valueOf(base+i).substring(1));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- public void sqlBuilder2(TreeNode<Long> top, List<String>sqlList, String treeCode){
|
|
|
- if(top!=null){
|
|
|
- sqlList.add("update m_wbs_tree_contract set tree_code ='"+treeCode+"' where p_key_id="+top.getValue());
|
|
|
- if(top.hasChildren()){
|
|
|
- for(int i=0;i<top.getChildren().size();i++){
|
|
|
- TreeNode<Long> child=top.getChildren().get(i);
|
|
|
- int base=ZERO.equals(treeCode)?100:1000;
|
|
|
- sqlBuilder2(child,sqlList,treeCode+String.valueOf(base+i).substring(1));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|