|
@@ -52,6 +52,7 @@ public class FormulaController {
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
private final IContractInfoService contractInfoService;
|
|
|
private final ITextdictInfoService textdictInfoService;
|
|
|
+ private final IFormulaOptionService formulaOptionService;
|
|
|
/**
|
|
|
* 新增或修改
|
|
|
*/
|
|
@@ -174,8 +175,10 @@ public class FormulaController {
|
|
|
FormulaBean fb=BeanUtil.toBean(map,FormulaBean.class);
|
|
|
if(StringUtils.isNotEmpty(rely)){
|
|
|
String[] relyArr = rely.split(StringPool.COMMA);
|
|
|
- List<Map<String,Object>> mapList =this.jdbcTemplate.queryForList("select CONCAT(a.tab_en_name,':',b.e_key) ekey,a.tab_ch_name tableName,b.e_name ename ,b.e_length elength,c.dict_value type from m_table_info a JOIN m_wbs_form_element b on a.id=b.f_id LEFT JOIN (select dict_key, dict_value from blade_dict where code ='data_type' and parent_id > 0 and is_sealed = 0 and is_deleted = 0 )c on b.e_type=c.dict_key" +
|
|
|
- " where a.tab_en_name in( "+ Arrays.stream(relyArr).map(e->e.split(StringPool.COLON)[0]).distinct().collect(Collectors.joining(StringPool.COMMA,"'","'"))+")");
|
|
|
+ List<Map<String,Object>> mapList =this.jdbcTemplate.queryForList("select CONCAT(a.tab_en_name,':',b.e_key) ekey,a.tab_ch_name tableName,b.e_name ename ,b.e_length elength,c.dict_value type f" +
|
|
|
+ "rom m_table_info a JOIN m_wbs_form_element b on a.id=b.f_id " +
|
|
|
+ "LEFT JOIN (select dict_key, dict_value from blade_dict where code ='data_type' and parent_id > 0 and is_sealed = 0 and is_deleted = 0 )c on b.e_type=c.dict_key" +
|
|
|
+ " where a.tab_en_name in( "+ Arrays.stream(relyArr).map(e->e.split(StringPool.COLON)[0]).distinct().collect(Collectors.joining(StringPool.COMMA,"'","'"))+")");
|
|
|
if(ListUtils.isNotEmpty(mapList)){
|
|
|
fb.setDict(mapList.stream().filter(e-> Arrays.stream(relyArr).anyMatch(c->StringUtils.isEquals(e.get("ekey"),c))).collect(Collectors.toMap(e->StringUtils.handleNull(e.get("ekey")), e->e)));
|
|
|
}
|
|
@@ -340,9 +343,9 @@ public class FormulaController {
|
|
|
@GetMapping("/panel")
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "公式交互面板", notes = "公式交互面板")
|
|
|
- public R<Object> panel(FormulaOption fo) {
|
|
|
+ public R<Object> panel(FormulaOptionVo fo) {
|
|
|
Map<String,Object> result = new LinkedHashMap<>();
|
|
|
- String key=fo.getEkey().replaceAll("__[\\d_]+","");;
|
|
|
+ String key=fo.getKey().replaceAll("__[\\d_]+","");
|
|
|
ContractInfo contract = this.contractInfoService.getById(fo.getContractId());
|
|
|
List<KeyMapper> kms = this.service.getKeyMapperList(Collections.singletonList(fo.getPKeyId()),contract.getPId());
|
|
|
KeyMapper keyMapper=null;
|
|
@@ -354,28 +357,13 @@ public class FormulaController {
|
|
|
}
|
|
|
if(keyMapper!=null&&Func.isNotEmpty(keyMapper.getFormulaId())){
|
|
|
Formula formula = this.service.getById(keyMapper.getFormulaId());
|
|
|
- /*临时处理,等确定数据结构在优化*/
|
|
|
+ String data = this.formulaOptionService.queryOption(fo.getContractId(),fo.getParentId(),fo.getPKeyId(),fo.getKey());
|
|
|
+ /*临时处理,等确定数据结构在优化*/
|
|
|
if(formula.getFormula().contains(".option")){
|
|
|
- JSONObject jo =JSON.parseObject(TEMPLATE);
|
|
|
- jo.put("scope",0);
|
|
|
- JSONObject info =jo.getJSONObject("info");
|
|
|
- info.put("label","是否引用公式数据");
|
|
|
- /*针对元素级别*/
|
|
|
- List<Map<String,Object>> mapList=this.jdbcTemplate.queryForList("select id,parent_id parentId,table_id pKeyId,val value,e_key ekey,contract_id contractId,scope from m_formula_option where scope=0 and parent_id ="+fo.getParentId()+" and e_key='"+key+"' and contract_id="+fo.getContractId());
|
|
|
- if(Func.isNotEmpty(mapList)){
|
|
|
- info.put("data",mapList.get(0));
|
|
|
- }
|
|
|
- return R.data(jo);
|
|
|
+ return R.data(createRadioPanel(0,"是否引用公式数据",data));
|
|
|
}else if (StringUtils.isEquals("MILE",formula.getNumber())){
|
|
|
if(StringUtils.isEquals(key,formula.getRelyList().get(0).split(StringPool.COLON)[1])){
|
|
|
- JSONObject jo =JSON.parseObject(TEMPLATE);
|
|
|
- jo.put("scope",1);
|
|
|
- JSONObject info =jo.getJSONObject("info");
|
|
|
- info.put("label","竖直方向");
|
|
|
- List<Map<String,Object>> mapList=this.jdbcTemplate.queryForList("select id,parent_id parentId,table_id pKeyId,val value,e_key ekey,contract_id contractId,scope from m_formula_option where scope=1 and table_id="+fo.getPKeyId()+" and parent_id ="+fo.getParentId()+" and e_key='"+key+"' and contract_id="+fo.getContractId());
|
|
|
- if(Func.isNotEmpty(mapList)){
|
|
|
- result.put("data",mapList.get(0));
|
|
|
- }
|
|
|
+ return R.data(createRadioPanel(1,"竖直方向",data));
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
@@ -384,14 +372,22 @@ public class FormulaController {
|
|
|
return R.data(result);
|
|
|
}
|
|
|
|
|
|
+ public JSONObject createRadioPanel(Integer scope,String label,String data){
|
|
|
+ JSONObject jo =JSON.parseObject(TEMPLATE);
|
|
|
+ jo.put("scope",1);
|
|
|
+ JSONObject info =jo.getJSONObject("info");
|
|
|
+ info.put("label","竖直方向");
|
|
|
+ if(Func.isNotEmpty(data)){
|
|
|
+ info.put("data",data);
|
|
|
+ }
|
|
|
+ return jo;
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/panel-save")
|
|
|
@ApiOperationSupport(order = 10)
|
|
|
@ApiOperation(value = "公式交互面板参数保存", notes = "公式交互面板参数保存")
|
|
|
- public R<Object> panelSave( @RequestBody FormulaOption fo){
|
|
|
- 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.getId()+fo.toSql()+")");
|
|
|
+ public R<Object> panelSave( @RequestBody FormulaOptionVo fo){
|
|
|
+
|
|
|
return R.success("保存成功");
|
|
|
}
|
|
|
|