|
@@ -417,62 +417,7 @@ public class WbsParamController {
|
|
|
return formula;
|
|
|
}
|
|
|
|
|
|
- /*private R<Object> duplicate() {删除重复节点参数配置,方法已经过时无法直接使用
|
|
|
- try {
|
|
|
- StopWatch stopWatch = new StopWatch();
|
|
|
- stopWatch.start("节点参数查重及删除");
|
|
|
- List<Map<String, Object>> mapList = this.jdbcTemplate.queryForList("select node_id nodeId,k,count(*) num from m_wbs_param where is_deleted=0 and type=1 GROUP BY node_id,k HAVING count(*)>1");
|
|
|
- if (!mapList.isEmpty()) {
|
|
|
- List<WbsParam> list = this.service.list(Wrappers.<WbsParam>lambdaQuery().in(WbsParam::getNodeId, mapList.stream().map(m -> m.get("nodeId")).collect(Collectors.toList())));
|
|
|
- List<Long> removeWpIds = new ArrayList<>();
|
|
|
- List<Long> removeMapingIds = new ArrayList<>();
|
|
|
- List<Long> removeFormulaIds = new ArrayList<>();
|
|
|
- Map<Long, Map<String, List<WbsParam>>> group = list.stream().collect(Collectors.groupingBy(WbsParam::getNodeId, LinkedHashMap::new, Collectors.groupingBy(WbsParam::getK)));
|
|
|
- group.values().forEach(m -> {
|
|
|
- m.forEach((k, v) -> {
|
|
|
- List<Map<String, Object>> relationMap = this.jdbcTemplate.queryForList("select a.id paramId,b.id mappingId,b.formula_id formulaId from m_wbs_param a join m_element_formula_mapping b on a.id=b.param_id where b.scope=35 and a.id in(" + v.stream().map(WbsParam::getId).map(String::valueOf).collect(Collectors.joining("','", "'", "'")) + ") order by b.update_time desc");
|
|
|
- if (!relationMap.isEmpty()) {
|
|
|
- Object id = relationMap.get(0).get("paramId");
|
|
|
- removeWpIds.addAll(v.stream().map(WbsParam::getId).filter(eId -> !StringUtils.isNotEquals(id, eId)).collect(Collectors.toList()));
|
|
|
- *//*同一道工序下,一个节点参数可能会关联多个元素,除了保留参数关联的以外全部添加到待删除列表*//*
|
|
|
- relationMap.stream().filter(x -> StringUtils.isNotEquals(x.get("paramId"), id)).forEach(e -> {
|
|
|
- removeMapingIds.add(Long.parseLong(e.get("mappingId").toString()));
|
|
|
- removeFormulaIds.add(Long.parseLong(e.get("formulaId").toString()));
|
|
|
- });
|
|
|
- } else {
|
|
|
- removeWpIds.addAll(v.stream().skip(1).map(WbsParam::getId).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- System.out.println("查找到重复参数" + list.size() + "个");
|
|
|
- System.out.println("待删除参数" + removeWpIds.size() + "个");
|
|
|
- System.out.println("待删除中间关联" + removeMapingIds.size() + "个");
|
|
|
- System.out.println("待删除公式" + removeFormulaIds.size() + "个");
|
|
|
-// batchDel(this.service,removeWpIds);
|
|
|
-// batchDel(this.elementFormulaMappingService,removeMapingIds);
|
|
|
-// batchDel(this.formulaService,removeFormulaIds);
|
|
|
- Map<String, Integer> result = new HashMap<>();
|
|
|
- result.put("查找到重复参数", list.size());
|
|
|
- result.put("待删除参数", removeWpIds.size());
|
|
|
- result.put("待删除中间关联", removeMapingIds.size());
|
|
|
- result.put("待删除公式", removeFormulaIds.size());
|
|
|
- stopWatch.stop();
|
|
|
- Long totalTime = stopWatch.getTotalTimeMillis();
|
|
|
- StaticLog.info("公式执行用时:{}", totalTime);
|
|
|
- return R.data(result);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return R.fail("执行异常");
|
|
|
- }*/
|
|
|
|
|
|
- public <T> void batchDel(BaseService<T> sv,List<Long> list){
|
|
|
- if(sv!=null&&Func.isNotEmpty(list)) {
|
|
|
- List<List<Long>> removeWpIdsList = BaseUtils.splitList(list, 1000);
|
|
|
- removeWpIdsList.forEach(sv::deleteLogic);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
@GetMapping("/createFormulaForWp")
|
|
|
public R<Object> createFormulaForWp() {
|
|
@@ -617,7 +562,33 @@ public class WbsParamController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
+ @GetMapping("/remove-element-mapping")
|
|
|
+ public R<Object> removeMapping(){
|
|
|
+ long s = System.currentTimeMillis();
|
|
|
+ List<Map<String,Object>> listMap =this.jdbcTemplate.queryForList("select element_id elementId,param_id paramId,count(*) total,max(id) id from m_element_formula_mapping where is_deleted=0 and scope=35 GROUP BY element_id,param_id HAVING count(*)>1 ORDER BY count(*) desc");
|
|
|
+ if(listMap.size()>0){
|
|
|
+ List<String> sqlList = new ArrayList<>();
|
|
|
+ for(Map<String,Object> map:listMap){
|
|
|
+ try {
|
|
|
+ String sql = "update m_element_formula_mapping set is_deleted=1 ,update_time='2023-11-20 00:00:00' where element_id="+map.get("elementId")+" and param_id="+map.get("paramId")+" and id <>"+map.get("id");
|
|
|
+ sqlList.add(sql);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<List<String>> segmentList = BaseUtils.splitList(sqlList,250);
|
|
|
+ segmentList.stream().map(l->String.join(";",l)).forEach(sl->{
|
|
|
+ try {
|
|
|
+ // System.out.println(s);
|
|
|
+ this.jdbcTemplate.execute(sl);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return R.data("处理语句"+listMap.size()+"条,耗时"+(System.currentTimeMillis()-s)+"ms");
|
|
|
+ }
|
|
|
+ return R.data("无数据");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|