|
@@ -16,6 +16,7 @@ import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.RegexUtil;
|
|
|
+import org.springblade.manager.dto.FormulaBean;
|
|
|
import org.springblade.manager.dto.ParamElements;
|
|
|
import org.springblade.manager.dto.WbsParamBean;
|
|
|
import org.springblade.manager.entity.ElementFormulaMapping;
|
|
@@ -114,6 +115,7 @@ public class WbsParamController {
|
|
|
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());
|
|
@@ -131,13 +133,13 @@ public class WbsParamController {
|
|
|
elementMap.forEach(m->{
|
|
|
if(m.get("name").toString().contains(e.getName())){
|
|
|
ElementFormulaMapping efm = new ElementFormulaMapping();
|
|
|
- efm.setScope(20);
|
|
|
+ efm.setScope(FormulaBean.PARAM);
|
|
|
efm.setParamId(e.getId());
|
|
|
efm.setElementId(Long.parseLong(m.get("id").toString()));
|
|
|
- if(pb.getProjectId()!=null){
|
|
|
- efm.setProjectId(Long.parseLong(pb.getProjectId()));
|
|
|
- }
|
|
|
- efm.setNodeId(pb.getNodeId());
|
|
|
+// if(pb.getProjectId()!=null){
|
|
|
+// efm.setProjectId(Long.parseLong(pb.getProjectId()));
|
|
|
+// }
|
|
|
+// efm.setNodeId(pb.getNodeId());
|
|
|
efm.setFormulaId(formula.getId());
|
|
|
this.elementFormulaMappingService.save(efm);
|
|
|
}
|
|
@@ -242,17 +244,59 @@ public class WbsParamController {
|
|
|
@ApiOperation(value = "参数关联元素", notes = "参数关联元素")
|
|
|
@GetMapping("/get-param-elements")
|
|
|
public R<List<Map<String,Object>>> associated(@ApiParam(value = "节点参数id", required = true) Long paramId,@ApiParam(value = "当前节点id", required = true) Long nodeId) {
|
|
|
- List<Map<String,Object>> listMap = this.jdbcTemplate.queryForList(
|
|
|
- "select a.node_name AS tableName,b.e_name as elementName ,c.id as mappingId " +
|
|
|
- "from m_wbs_tree a " +
|
|
|
- "left join m_wbs_form_element b on b.f_id=a.init_table_id " +
|
|
|
- "left join m_element_formula_mapping c on c.element_id=b.id " +
|
|
|
- "where c.is_deleted=0 and a.is_deleted=0 and a.parent_id="+nodeId+" and c.param_id ="+paramId);
|
|
|
- if(listMap.size()>0){
|
|
|
- //R.data(listMap.stream().map(m->BeanUtil.toBean(m, TableElementParam.class)).collect(Collectors.toList()));
|
|
|
- return R.data(listMap);
|
|
|
+ /*R.data(listMap.stream().map(m->BeanUtil.toBean(m, TableElementParam.class)).collect(Collectors.toList()));*/
|
|
|
+ return R.data(this.jdbcTemplate.queryForList(
|
|
|
+ "select AA.id,AA.tableName,BB.elementName,BB.mappingId from " +
|
|
|
+ "(select id ,node_name AS tableName from m_wbs_tree where parent_id="+nodeId+" and is_deleted=0) as AA" +
|
|
|
+ " left join " +
|
|
|
+ "(select a.id as id, b.e_name as elementName ,c.id as mappingId,c.is_deleted " +
|
|
|
+ "from m_wbs_tree a " +
|
|
|
+ "inner join m_wbs_form_element b on b.f_id=a.init_table_id " +
|
|
|
+ "inner join m_element_formula_mapping c on c.element_id=b.id " +
|
|
|
+ "where c.is_deleted=0 and a.is_deleted=0 and a.parent_id="+nodeId+" and c.param_id ="+paramId+")as BB " +
|
|
|
+ "on AA.id=BB.id"));
|
|
|
+
|
|
|
+ }
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "解除参数关联元素", notes = "解除参数关联元素")
|
|
|
+ @GetMapping("/del-param-elements")
|
|
|
+ public R<Boolean> disassociate(@ApiParam(value = "关联id", required = true) Long mappingId) {
|
|
|
+ return R.status(this.elementFormulaMappingService.deleteLogic(Collections.singletonList(mappingId)));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperationSupport(order = 8)
|
|
|
+ @ApiOperation(value = "指定关联元素", notes = "指定关联元素")
|
|
|
+ @PostMapping("/specified-param-elements")
|
|
|
+ public R<Boolean> specified(@ApiParam(value = "关联id", required = true) Long paramId,Long elementId) {
|
|
|
+ /*先删旧关联,检查是否存在公式,没有就新增 再增新关联*/
|
|
|
+ this.jdbcTemplate.execute("update m_element_formula_mapping set is_deleted=1 where element_id="+elementId+" and param_id="+paramId);
|
|
|
+ Formula formula= this.formulaService.getOne(Wrappers.<Formula>lambdaQuery().eq(Formula::getParamId,paramId));
|
|
|
+ if(formula==null){
|
|
|
+ Map<String,Object> tmpMap=new HashMap<>();
|
|
|
+ formula=new Formula();
|
|
|
+ WbsParam param = this.service.getById(paramId);
|
|
|
+ formula.setOutm(Formula.FULL);
|
|
|
+ formula.setParamId(param.getId());
|
|
|
+ Map<String,String> keyMap= new HashMap<>();
|
|
|
+ keyMap.put("name",param.getName());
|
|
|
+ keyMap.put("id",param.getId().toString());
|
|
|
+ tmpMap.put(param.getK(),keyMap);
|
|
|
+ if(RegexUtil.match(ParamElements.LEVEL_REG,param.getV())){
|
|
|
+ /*取层级*/
|
|
|
+ formula.setFormula("FC.tree(trees,WP["+param.getK()+"])");
|
|
|
+ }else{
|
|
|
+ /*直接取数*/
|
|
|
+ formula.setFormula("WP["+param.getK()+"]");
|
|
|
+ }
|
|
|
+ formula.setMap(JSON.toJSONString(tmpMap));
|
|
|
+ this.formulaService.save(formula);
|
|
|
}
|
|
|
- return R.data(Collections.emptyList());
|
|
|
+ ElementFormulaMapping efm = new ElementFormulaMapping();
|
|
|
+ efm.setScope(FormulaBean.PARAM);
|
|
|
+ efm.setParamId(paramId);
|
|
|
+ efm.setElementId(elementId);
|
|
|
+ efm.setFormulaId(formula.getId());
|
|
|
+ return R.status(this.elementFormulaMappingService.save(efm));
|
|
|
}
|
|
|
|
|
|
|