瀏覽代碼

公式相关

yangyj 2 年之前
父節點
當前提交
8b8fc3b7d7

+ 2 - 2
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/FormulaOption.java

@@ -11,13 +11,13 @@ import lombok.Data;
 public class FormulaOption {
     private Long id;
     private Long parentId;
-    private String key;
+    private String ekey;
     private Long contractId;
     private String value;
     private Long pKeyId;
     private Integer scope;
 
     public String toSql(){
-        return ","+pKeyId+","+parentId+","+key+","+contractId+",'"+value+"',"+pKeyId+","+scope;
+        return ","+parentId+",'"+ekey+"',"+contractId+",'"+value+"',"+pKeyId+","+scope;
     }
 }

+ 14 - 10
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java

@@ -312,15 +312,18 @@ public class FormulaController {
     @ApiOperation(value = "公式交互面板", notes = "公式交互面板")
     public R<Object> panel(FormulaOption fo)  {
              Map<String,Object> result = new LinkedHashMap<>();
-             String  key=fo.getKey();
-             if(fo.getScope()==0){
-                 /*针对元素级别*/
-               key=key.replaceAll("__[\\d_]+","");
-             }
+             String  key=fo.getEkey().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());
+              KeyMapper keyMapper=null;
+              if(Func.isNotEmpty(kms)){
+                Optional<KeyMapper> optionalKeyMapper=  kms.stream().filter(e->StringUtils.isEquals(e.getField(),key)).findFirst();
+                if(optionalKeyMapper.isPresent()){
+                    keyMapper=optionalKeyMapper.get();
+                }
+              }
+              if(keyMapper!=null&&Func.isNotEmpty(keyMapper.getFormulaId())){
+                   Formula formula = this.service.getById(keyMapper.getFormulaId());
                    /*临时处理,等确定数据结构在优化*/
                    if(formula.getFormula().contains(".option")){
                        result.put("type","radio");
@@ -338,7 +341,8 @@ public class FormulaController {
                         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=0 and parent_id ="+fo.getParentId()+" and key='"+key+"' and contract_id="+fo.getContractId());
+                       /*针对元素级别*/
+                       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)){
                            result.put("data",mapList.get(0));
                        }
@@ -359,7 +363,7 @@ public class FormulaController {
                           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());
+                          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));
                           }
@@ -378,7 +382,7 @@ public class FormulaController {
             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()+")");
+            this.jdbcTemplate.execute("insert into m_formula_option values ("+SnowFlakeUtil.getId()+fo.toSql()+")");
            return    R.success("保存成功");
     }