|
@@ -21,15 +21,9 @@ import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.core.tool.utils.RegexUtil;
|
|
|
import org.springblade.core.tool.utils.StringPool;
|
|
|
import org.springblade.manager.dto.*;
|
|
|
-import org.springblade.manager.entity.ElementFormulaMapping;
|
|
|
-import org.springblade.manager.entity.Formula;
|
|
|
-import org.springblade.manager.entity.TextdictInfo;
|
|
|
-import org.springblade.manager.entity.WbsTreeContract;
|
|
|
+import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.formula.KeyMapper;
|
|
|
-import org.springblade.manager.service.IElementFormulaMappingService;
|
|
|
-import org.springblade.manager.service.IExcelTabService;
|
|
|
-import org.springblade.manager.service.ITextdictInfoService;
|
|
|
-import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
+import org.springblade.manager.service.*;
|
|
|
import org.springblade.manager.service.impl.FormulaServiceImpl;
|
|
|
import org.springblade.manager.wrapper.FormulaWrapper;
|
|
|
import org.springframework.dao.EmptyResultDataAccessException;
|
|
@@ -56,6 +50,7 @@ public class FormulaController {
|
|
|
private final IExcelTabService tabService;
|
|
|
private final IElementFormulaMappingService elementFormulaMappingService;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
private final ITextdictInfoService textdictInfoService;
|
|
|
/**
|
|
|
* 新增或修改
|
|
@@ -315,14 +310,21 @@ public class FormulaController {
|
|
|
@GetMapping("/panel")
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "公式交互面板", notes = "公式交互面板")
|
|
|
- public R<Object> panel(Long pkeyId ,String key,String projectId) {
|
|
|
+ public R<Object> panel(FormulaOption fo) {
|
|
|
Map<String,Object> result = new LinkedHashMap<>();
|
|
|
- key=key.replaceAll("__[\\d_]+","");
|
|
|
- List<KeyMapper> kms = this.service.getKeyMapperList(Collections.singletonList(pkeyId),projectId);
|
|
|
+ String key=fo.getKey();
|
|
|
+ if(fo.getScope()==0){
|
|
|
+ /*针对元素级别*/
|
|
|
+ key=key.replaceAll("__[\\d_]+","");
|
|
|
+ }
|
|
|
+ ContractInfo contract = this.contractInfoService.getById(fo.getContractId());
|
|
|
+ List<KeyMapper> kms = this.service.getKeyMapperList(Collections.singletonList(fo.getPKeyId()),contract.getPId());
|
|
|
if(Func.isNotEmpty(kms)&&Func.isNotEmpty(kms.get(0).getFormulaId())){
|
|
|
Formula formula = this.service.getById(kms.get(0).getFormulaId());
|
|
|
+ /*临时处理,等确定数据结构在优化*/
|
|
|
if(formula.getFormula().contains(".option")){
|
|
|
result.put("type","radio");
|
|
|
+ result.put("scope",0);
|
|
|
Map<String,Object> info = new LinkedHashMap<>();
|
|
|
result.put("info",info);
|
|
|
info.put("label","是否引用公式数据");
|
|
@@ -334,9 +336,37 @@ public class FormulaController {
|
|
|
value.add(n);
|
|
|
y.put("label","是");
|
|
|
y.put("value",1);
|
|
|
- n.put("label","是");
|
|
|
- n.put("value",1);
|
|
|
- }
|
|
|
+ n.put("label","否");
|
|
|
+ n.put("value",0);
|
|
|
+ List<Map<String,Object>> mapList=this.jdbcTemplate.queryForList("select id,parent_id parentId,table_id pkeyId,value,key,contract_id contractId,scope from m_formula_option where scope=0 and parent_id ="+fo.getParentId()+" and key='"+key+"' and contract_id="+fo.getContractId());
|
|
|
+ if(Func.isNotEmpty(mapList)){
|
|
|
+ result.put("data",mapList.get(0));
|
|
|
+ }
|
|
|
+ }else if (StringUtils.isEquals("MILE",formula.getNumber())){
|
|
|
+ if(StringUtils.isEquals(key,formula.getRelyList().get(0).split(StringPool.COLON)[1])){
|
|
|
+ result.put("type","radio");
|
|
|
+ result.put("scope",1);
|
|
|
+ Map<String,Object> info = new LinkedHashMap<>();
|
|
|
+ result.put("info",info);
|
|
|
+ info.put("label","竖直方向");
|
|
|
+ List<Map<String,Object>> value = new ArrayList<>();
|
|
|
+ info.put("value",value);
|
|
|
+ Map<String,Object> y=new LinkedHashMap<>();
|
|
|
+ Map<String,Object> n=new LinkedHashMap<>();
|
|
|
+ value.add(y);
|
|
|
+ value.add(n);
|
|
|
+ y.put("label","是");
|
|
|
+ y.put("value",1);
|
|
|
+ n.put("label","否");
|
|
|
+ n.put("value",0);
|
|
|
+ List<Map<String,Object>> mapList=this.jdbcTemplate.queryForList("select id,parent_id parentId,table_id pkeyId,value,key,contract_id contractId,scope from m_formula_option where scope=1 and table_id="+fo.getPKeyId()+" and parent_id ="+fo.getParentId()+" and key='"+key+"' and contract_id="+fo.getContractId());
|
|
|
+ if(Func.isNotEmpty(mapList)){
|
|
|
+ result.put("data",mapList.get(0));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ R.success("暂无公式控件");
|
|
|
}
|
|
|
return R.data(result);
|
|
|
}
|
|
@@ -345,11 +375,10 @@ public class FormulaController {
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "公式交互面板参数保存", notes = "公式交互面板参数保存")
|
|
|
public R<Object> panelSave( @RequestBody FormulaOption fo){
|
|
|
- List<Map<String,Object>> mapList = this.jdbcTemplate.queryForList("select parent_id pid,contract_id cid from m_wbs_tree_contract where p_key_id="+fo.getPKeyId());
|
|
|
- if(Func.isNotEmpty(mapList)){
|
|
|
- Map<String,Object> map = mapList.get(0);
|
|
|
- this.jdbcTemplate.execute("");
|
|
|
+ if(Func.isNotEmpty(fo.getId())){
|
|
|
+ this.jdbcTemplate.execute("delete from m_formula_option where id="+fo.getId());
|
|
|
}
|
|
|
+ this.jdbcTemplate.execute("insert into m_formula_option values ("+SnowFlakeUtil.get()+fo.toSql()+")");
|
|
|
return R.success("保存成功");
|
|
|
}
|
|
|
|