|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
|
+import com.mixsmart.utils.StringUtils;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
@@ -27,8 +28,6 @@ import org.springblade.manager.service.IFormulaService;
|
|
import org.springblade.manager.service.IWbsParamService;
|
|
import org.springblade.manager.service.IWbsParamService;
|
|
import org.springblade.manager.vo.ParamBean;
|
|
import org.springblade.manager.vo.ParamBean;
|
|
import org.springblade.manager.vo.ParamSearch;
|
|
import org.springblade.manager.vo.ParamSearch;
|
|
-import org.springblade.manager.vo.TableElementParam;
|
|
|
|
-import org.springblade.manager.vo.WbsFormElementVO;
|
|
|
|
import org.springblade.manager.wrapper.WbsParamWrapper;
|
|
import org.springblade.manager.wrapper.WbsParamWrapper;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@@ -318,5 +317,84 @@ public class WbsParamController {
|
|
return R.status(this.elementFormulaMappingService.save(efm));
|
|
return R.status(this.elementFormulaMappingService.save(efm));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @GetMapping("/refresh")
|
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
|
+ @ApiOperation(value = "刷新当前节点的节点参数", notes = "刷新当前节点的节点参数")
|
|
|
|
+ public R refresh(Long nodeId,Integer type,Long projectId) {
|
|
|
|
+ try {
|
|
|
|
+ /*先查出所有的节点参数*/
|
|
|
|
+ List<WbsParam> paramList= this.service.list(Wrappers.<WbsParam>lambdaQuery().eq(WbsParam::getNodeId,nodeId));
|
|
|
|
+ if(Func.isNotEmpty(paramList)){
|
|
|
|
+ List<Map<String,Object>> elementMap=new ArrayList<>();
|
|
|
|
+ /*当前节点所包含的所有元素*/
|
|
|
|
+ if(StringUtils.isEquals(0,type)){
|
|
|
|
+ /*wbs*/
|
|
|
|
+ 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="+nodeId
|
|
|
|
+ );
|
|
|
|
+ }else{
|
|
|
|
+ /*project*/
|
|
|
|
+ elementMap= this.jdbcTemplate.queryForList(
|
|
|
|
+ "select c.e_name as name ,c.id from m_wbs_tree_private a " +
|
|
|
|
+ "inner join m_wbs_tree_private b on a.id=b.parent_id " +
|
|
|
|
+ "inner join m_wbs_form_element c on b.init_table_id=c.f_id " +
|
|
|
|
+ "where b.project_id="+projectId+" and a.p_key_id="+nodeId+" and b.is_deleted=0 and c.is_deleted=0 ");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Long> longList=this.jdbcTemplate.queryForList("select element_id from m_element_formula_mapping where param_id in("+paramList.stream().map(WbsParam::getId).map(String::valueOf).collect(Collectors.joining(","))+")",Long.class);
|
|
|
|
+ if(Func.isNotEmpty(elementMap)){
|
|
|
|
+ Map<String,Object> tmpMap=new HashMap<>();
|
|
|
|
+ List<Map<String, Object>> finalElementMap = elementMap;
|
|
|
|
+ paramList.forEach(e->{
|
|
|
|
+ Formula formula = this.formulaService.getOne(Wrappers.<Formula>lambdaQuery().eq(Formula::getParamId,e.getId()));
|
|
|
|
+ if(formula==null){
|
|
|
|
+ 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())){
|
|
|
|
+ /*取层级*/
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ Formula finalFormula = formula;
|
|
|
|
+ finalElementMap.forEach(m->{
|
|
|
|
+ if(m.get("name").toString().contains(e.getName())){
|
|
|
|
+ /*匹配名称,且该元素没有绑定任何节点参数公式*/
|
|
|
|
+ if(longList.stream().noneMatch(k->StringUtils.isEquals(k,m.get("id")))){
|
|
|
|
+ ElementFormulaMapping efm = new ElementFormulaMapping();
|
|
|
|
+ efm.setScope(FormulaBean.PARAM);
|
|
|
|
+ efm.setParamId(e.getId());
|
|
|
|
+ efm.setElementId(Long.parseLong(m.get("id").toString()));
|
|
|
|
+ efm.setFormulaId(finalFormula.getId());
|
|
|
|
+ this.elementFormulaMappingService.save(efm);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return R.success("操作成功");
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ return R.fail("操作失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|