|
@@ -26,6 +26,7 @@ import org.springblade.manager.service.IElementFormulaMappingService;
|
|
|
import org.springblade.manager.service.IFormulaService;
|
|
|
import org.springblade.manager.service.IWbsParamService;
|
|
|
import org.springblade.manager.vo.ParamBean;
|
|
|
+import org.springblade.manager.vo.ParamSearch;
|
|
|
import org.springblade.manager.vo.TableElementParam;
|
|
|
import org.springblade.manager.vo.WbsFormElementVO;
|
|
|
import org.springblade.manager.wrapper.WbsParamWrapper;
|
|
@@ -103,15 +104,26 @@ public class WbsParamController {
|
|
|
this.service.saveBatch(entityList);
|
|
|
if(!pb.isCommon()){
|
|
|
/*新建的时候需要初始化绑定表单元素*/
|
|
|
- List<Map<String,Object>> elementMap= this.jdbcTemplate.queryForList(
|
|
|
- "select a.e_name as name ,a.id " +
|
|
|
- "from m_wbs_form_element a " +
|
|
|
- "inner join m_wbs_tree b on a.f_id=b.init_table_id " +
|
|
|
- "inner join m_wbs_tree c on b.parent_id=c.id " +
|
|
|
- "where a.is_deleted=0 and c.id="+pb.getNodeId()
|
|
|
- );
|
|
|
+ List<Map<String,Object>> elementMap=new ArrayList<>();
|
|
|
+ if(pb.isWbs()){
|
|
|
+ elementMap= this.jdbcTemplate.queryForList(
|
|
|
+ "select a.e_name as name ,a.id " +
|
|
|
+ "from m_wbs_form_element a " +
|
|
|
+ "inner join m_wbs_tree b on a.f_id=b.init_table_id " +
|
|
|
+ "inner join m_wbs_tree c on b.parent_id=c.id " +
|
|
|
+ "where a.is_deleted=0 and c.id="+pb.getNodeId()
|
|
|
+ );
|
|
|
+ }else if(pb.isPrivate()){
|
|
|
+ elementMap= this.jdbcTemplate.queryForList(
|
|
|
+ "select a.e_name as name ,a.id " +
|
|
|
+ "from m_wbs_form_element a " +
|
|
|
+ "inner join m_wbs_tree_private b on a.f_id=b.init_table_id " +
|
|
|
+ "inner join m_wbs_tree_private c on b.parent_id=c.id " +
|
|
|
+ "where a.is_deleted=0 and b.project_id="+pb.getProjectId()+" and c.p_key_id="+pb.getNodeId()+" and a.is_deleted=0");
|
|
|
+ }
|
|
|
if(!elementMap.isEmpty()){
|
|
|
Map<String,Object> tmpMap=new HashMap<>();
|
|
|
+ List<Map<String, Object>> finalElementMap = elementMap;
|
|
|
entityList.forEach(e->{
|
|
|
Formula formula = new Formula();
|
|
|
formula.setOutm(Formula.FULL);
|
|
@@ -130,16 +142,12 @@ public class WbsParamController {
|
|
|
formula.setMap(JSON.toJSONString(tmpMap));
|
|
|
this.formulaService.save(formula);
|
|
|
tmpMap.clear();
|
|
|
- elementMap.forEach(m->{
|
|
|
+ finalElementMap.forEach(m->{
|
|
|
if(m.get("name").toString().contains(e.getName())){
|
|
|
ElementFormulaMapping efm = new ElementFormulaMapping();
|
|
|
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());
|
|
|
efm.setFormulaId(formula.getId());
|
|
|
this.elementFormulaMappingService.save(efm);
|
|
|
}
|
|
@@ -243,19 +251,32 @@ public class WbsParamController {
|
|
|
@ApiOperationSupport(order = 7)
|
|
|
@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) {
|
|
|
+ public R<List<Map<String,Object>>> associated(ParamSearch ps) {
|
|
|
/*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"));
|
|
|
-
|
|
|
+ if(ParamSearch.WBS.equals(ps.getScopeType())){
|
|
|
+ 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="+ps.getNodeId()+" 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="+ps.getNodeId()+" and c.param_id ="+ps.getParamId()+")as BB " +
|
|
|
+ "on AA.id=BB.id"));
|
|
|
+ }else if(ParamSearch.PRI.equals(ps.getScopeType())){
|
|
|
+ return R.data(this.jdbcTemplate.queryForList(
|
|
|
+ "select AA.id,AA.tableName,BB.elementName,BB.mappingId from (" +
|
|
|
+ " select id ,node_name AS tableName,init_table_id" +
|
|
|
+ " FROM m_wbs_tree_private AS wt" +
|
|
|
+ " WHERE type = 2" +
|
|
|
+ " AND is_deleted = 0" +
|
|
|
+ " AND parent_id = " +ps.getNodeId()+
|
|
|
+ " AND project_id = " +ps.getProjectId()+
|
|
|
+ " ORDER BY wt.sort, wt.node_name, wt.create_time) 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_private 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 a.project_id="+ps.getProjectId()+" and c.is_deleted=0 and a.is_deleted=0 and a.parent_id="+ps.getNodeId()+" and c.param_id ="+ps.getParamId()+")as BB on AA.id=BB.id"));
|
|
|
+ }
|
|
|
+ return R.fail("暂无数据");
|
|
|
}
|
|
|
@ApiOperationSupport(order = 8)
|
|
|
@ApiOperation(value = "解除参数关联元素", notes = "解除参数关联元素")
|