|
@@ -511,7 +511,7 @@ public class FormulaController {
|
|
|
})
|
|
|
.collect(Collectors.joining("\n"));
|
|
|
System.out.println(result);
|
|
|
- return R.data(result);
|
|
|
+ return R.data(list);
|
|
|
}
|
|
|
return R.fail("无数据");
|
|
|
}
|
|
@@ -797,7 +797,7 @@ public class FormulaController {
|
|
|
return R.success("成功");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /*项目级*/
|
|
|
public R<Object> flushPri(){
|
|
|
List<Map<String,Object>> listMap=this.jdbcTemplate.queryForList("select p_key_id nodeId,init_table_id tableId from m_wbs_tree_private where project_id=1630011899725201410 and init_table_id is not null and init_table_name is null and is_deleted=0");
|
|
|
if(listMap.size()>0){
|
|
@@ -822,16 +822,93 @@ public class FormulaController {
|
|
|
}
|
|
|
|
|
|
@GetMapping("/ref")
|
|
|
- public R<Object> ref() {
|
|
|
+ public R<Object> ref(Long projectId) {
|
|
|
+ if(!StringUtils.isNumber(projectId)){
|
|
|
+ R.fail("项目Id格式有问题");
|
|
|
+ }
|
|
|
/*专门用刷数据的*/
|
|
|
- Long contractId=1630017379264610305L;
|
|
|
- String sql ="select p_key_id pkeyId ,id,old_id originId,full_name fullName,node_name nodeName from m_wbs_tree_contract where contract_id=? and node_type=6 AND is_deleted=0 and is_type_private_pid is null";
|
|
|
+ // Long contractId=1630017379264610305L;
|
|
|
+ if(projectId==null) {
|
|
|
+ projectId = 1630011899725201410L;
|
|
|
+ }
|
|
|
+ List<ContractInfo> contractInfoList =this.contractInfoService.list(Wrappers.<ContractInfo>lambdaQuery().eq(ContractInfo::getPId,projectId.toString()).eq(ContractInfo::getContractType,1));
|
|
|
+ for (ContractInfo info:contractInfoList){
|
|
|
+ System.out.println("刷新开始");
|
|
|
+ System.out.println(info.getContractName());
|
|
|
+ if(cp(info.getId(),projectId)){
|
|
|
+ System.out.println("成功");
|
|
|
+ }else{
|
|
|
+ System.out.println("失败");
|
|
|
+ }
|
|
|
+ System.out.println("刷新结束");
|
|
|
+ }
|
|
|
+
|
|
|
+ /* String sql ="select p_key_id pkeyId ,id,old_id originId,full_name fullName,node_name nodeName from m_wbs_tree_contract where contract_id=? and node_type in(6,4) and major_data_type in(2,3,4) AND is_deleted=0 and is_type_private_pid is null";
|
|
|
List<Map<String,Object>> listMaps=this.jdbcTemplate.queryForList(sql,contractId);
|
|
|
if(listMaps.size()>0){
|
|
|
-
|
|
|
- }
|
|
|
+ Map<Long,List<Map<String,Object>>> group=listMaps.stream().collect(Collectors.groupingBy(m->{Object id=m.get("id");Object originId=m.get("originId");if(originId!=null){
|
|
|
+ return Long.parseLong(originId.toString());
|
|
|
+ }else{
|
|
|
+ return Long.parseLong(id.toString());
|
|
|
+ }}));
|
|
|
+ String sql2="select node_name nodeName,p_key_id pkeyId,id from m_wbs_tree_private where id in ("+group.keySet().stream().map(Objects::toString).collect(Collectors.joining(","))+") and project_id=?";
|
|
|
+ List<Map<String,Object>> privateListMap= this.jdbcTemplate.queryForList(sql2,projectId);
|
|
|
+ if(privateListMap.size()>0){
|
|
|
+ Map<Long,Long> kkm=privateListMap.stream().collect(Collectors.toMap(s->Long.parseLong(s.get("id").toString()),s->Long.parseLong(s.get("pkeyId").toString())));
|
|
|
+ System.out.println(kkm.size());
|
|
|
+ *//*{id,pkeyId}*//*
|
|
|
+ Set<Long> set = new HashSet<>(group.keySet());
|
|
|
+ set.removeAll(kkm.keySet());
|
|
|
+ System.out.println("剩余数量:"+set.size());
|
|
|
+ }
|
|
|
+
|
|
|
+ }*/
|
|
|
return R.success("成功");
|
|
|
}
|
|
|
|
|
|
+ private boolean cp(Long contractId,Long projectId){
|
|
|
+ try{
|
|
|
+ String sql ="select p_key_id pkeyId ,id,old_id originId,full_name fullName,node_name nodeName from m_wbs_tree_contract where contract_id=? and node_type in(6,4) and major_data_type in(2,3,4) AND is_deleted=0 and is_type_private_pid is null";
|
|
|
+ List<Map<String,Object>> listMaps=this.jdbcTemplate.queryForList(sql,contractId);
|
|
|
+ if(listMaps.size()>0){
|
|
|
+ Map<Long,List<Map<String,Object>>> group=listMaps.stream().collect(Collectors.groupingBy(m->{Object id=m.get("id");Object originId=m.get("originId");if(originId!=null){
|
|
|
+ return Long.parseLong(originId.toString());
|
|
|
+ }else{
|
|
|
+ return Long.parseLong(id.toString());
|
|
|
+ }}));
|
|
|
+ String sql2="select node_name nodeName,p_key_id pkeyId,id from m_wbs_tree_private where id in ("+group.keySet().stream().map(Objects::toString).collect(Collectors.joining(","))+") and project_id=?";
|
|
|
+ List<Map<String,Object>> privateListMap= this.jdbcTemplate.queryForList(sql2,projectId);
|
|
|
+ if(privateListMap.size()>0){
|
|
|
+ Map<Long,Long> kkm=privateListMap.stream().collect(Collectors.toMap(s->Long.parseLong(s.get("id").toString()),s->Long.parseLong(s.get("pkeyId").toString())));
|
|
|
+ /*{id,pkeyId}*/
|
|
|
+ List<String> updateSql= new ArrayList<>();
|
|
|
+ group.forEach((k,v)->{
|
|
|
+ Long pkeyId=kkm.get(k);
|
|
|
+ String ids = v.stream().map(g->g.get("pkeyId").toString()).collect(Collectors.joining(","));
|
|
|
+ String sqlTg="update m_wbs_tree_contract set is_type_private_pid="+pkeyId+" where p_key_id in("+ids+") ";
|
|
|
+ updateSql.add(sqlTg);
|
|
|
+ });
|
|
|
+ if(updateSql.size()>0){
|
|
|
+ /*每一百条为一组*/
|
|
|
+ List<List<String>> lists= BaseUtils.splitList(updateSql,100);
|
|
|
+ lists.forEach(l->{
|
|
|
+ try {
|
|
|
+ this.jdbcTemplate.batchUpdate(l.toArray(new String[0]));
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Set<Long> set = new HashSet<>(group.keySet());
|
|
|
+ set.removeAll(kkm.keySet());
|
|
|
+ System.out.println("剩余无非关联的数量:"+set.size());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
}
|