瀏覽代碼

公式参数

yangyj 2 年之前
父節點
當前提交
80ca7789ae

+ 3 - 3
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/dto/FormulaOptionVo.java

@@ -17,11 +17,11 @@ public class FormulaOptionVo {
     private String key;
     private Long contractId;
     private String value;
-    private Long pKeyId;
+    private Long pkeyId;
     private Integer scope;
     private String name;
     public boolean saveChecked(){
-        if( Func.isNotBlank(value)&&contractId!=null&&parentId!=null&&pKeyId!=null&&key!=null&&scope!=null){
+        if( Func.isNotBlank(value)&&contractId!=null&&parentId!=null&&pkeyId!=null&&key!=null&&scope!=null){
             if(scope==0){
                 /*scope==0是元素范围,1是单元格范围*/
                 this.key=key.replaceAll("__[\\d_]+","");
@@ -46,7 +46,7 @@ public class FormulaOptionVo {
         if(isElementScope()){
           return key;
         }else{
-            return pKeyId+ StringPool.AT +key;
+            return pkeyId+ StringPool.AT +key;
         }
     }
 }

+ 3 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java

@@ -348,7 +348,7 @@ public class FormulaController {
              Map<String,Object> result = new LinkedHashMap<>();
              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());
+              List<KeyMapper> kms =  this.service.getKeyMapperList(Collections.singletonList(fo.getPkeyId()),contract.getPId());
               KeyMapper keyMapper=null;
               if(Func.isNotEmpty(kms)){
                 Optional<KeyMapper> optionalKeyMapper=  kms.stream().filter(e->StringUtils.isEquals(e.getField(),key)).findFirst();
@@ -358,7 +358,7 @@ 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());
+                  String data = this.formulaOptionService.queryOption(fo.getContractId(),fo.getParentId(),fo.getPkeyId(),fo.getKey());
                   /*临时处理,等确定数据结构在优化*/
                    if(formula.getFormula().contains(".option")){
                        return R.data(createRadioPanel(0,"是否引用公式数据",data));
@@ -388,8 +388,7 @@ public class FormulaController {
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "公式交互面板参数保存", notes = "公式交互面板参数保存")
     public R<Object> panelSave( @RequestBody FormulaOptionVo fo){
-
-           return    R.success("保存成功");
+           return  R.data(this.formulaOptionService.saveOrUpdateOption(fo));
     }
 
     @GetMapping("/log")

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/IFormulaOptionService.java

@@ -9,6 +9,6 @@ import org.springblade.manager.entity.FormulaOption;
  */
 public interface IFormulaOptionService extends IService<FormulaOption> {
     String queryOption(Long contractId,Long parentId,Long pkeyId,String key);
-    void saveOrUpdateOption(FormulaOptionVo fo);
+    Object saveOrUpdateOption(FormulaOptionVo fo);
 
 }

+ 13 - 9
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaOptionServiceImpl.java

@@ -50,20 +50,24 @@ public class FormulaOptionServiceImpl extends ServiceImpl<FormulaOptionMapper, F
     }
 
     @Override
-    public void saveOrUpdateOption(FormulaOptionVo fo) {
+    public Object saveOrUpdateOption(FormulaOptionVo fo) {
         if(fo.saveChecked()){
-            WbsTreeContract wbc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,fo.getPKeyId()));
+            WbsTreeContract wbc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId,fo.getPkeyId()));
             FormulaOption formulaOption = this.getOne(Wrappers.<FormulaOption>lambdaQuery().eq(FormulaOption::getParentId,fo.getParentId()).eq(FormulaOption::getContractId,fo.getContractId()));
+            JSONObject root;
             if(formulaOption==null){
                 formulaOption=fo.toFo();
-                JSONObject root = new JSONObject();
-                JSONObject table = (JSONObject) root.computeIfAbsent(wbc.getInitTableName(),(k)->new JSONObject());
-                JSONObject data = (JSONObject) table.computeIfAbsent(fo.createKey(),(k)->new JSONObject());
-                data.put(fo.getName(),fo.getValue());
-                formulaOption.setVal(root.toJSONString());
-                this.saveOrUpdate(formulaOption);
+                root = new JSONObject();
+            }else{
+                root=JSON.parseObject(formulaOption.getVal());
             }
+            JSONObject table = (JSONObject) root.computeIfAbsent(wbc.getInitTableName(),(k)->new JSONObject());
+            JSONObject data = (JSONObject) table.computeIfAbsent(fo.createKey(),(k)->new JSONObject());
+            data.put(fo.getName(),fo.getValue());
+            formulaOption.setVal(root.toJSONString());
+            this.saveOrUpdate(formulaOption);
+            return data;
         }
-
+        return null;
     }
 }