Răsfoiți Sursa

质检
1、CL08 设置公式参数的时候添加批量接口

LHB 3 săptămâni în urmă
părinte
comite
11746e11ea

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

@@ -456,7 +456,16 @@ public class FormulaController {
     @ApiOperationSupport(order = 10)
     @ApiOperation(value = "公式交互面板参数保存", notes = "公式交互面板参数保存")
     public R<Object> panelSave(@RequestBody FormulaOptionVo fo) {
-        return R.data(this.formulaOptionService.saveOrUpdateOption(fo));
+        List<FormulaOptionVo> formulaOptionVos = new ArrayList<>();
+        formulaOptionVos.add(fo);
+        return R.data(this.formulaOptionService.saveOrUpdateOption(formulaOptionVos));
+    }
+
+    @PostMapping("/panel-save-list")
+    @ApiOperationSupport(order = 10)
+    @ApiOperation(value = "公式交互面板参数保存(批量)", notes = "公式交互面板参数保存(批量)")
+    public R<Object> panelSaveList(@RequestBody List<FormulaOptionVo> fos) {
+        return R.data(this.formulaOptionService.saveOrUpdateOption(fos));
     }
 
     @GetMapping("/log")

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

@@ -5,13 +5,15 @@ import org.springblade.manager.dto.FormulaOptionVo;
 import org.springblade.manager.dto.RangeInfo;
 import org.springblade.manager.entity.FormulaOption;
 
+import java.util.List;
+
 /**
  * @author yangyj
  */
 public interface IFormulaOptionService extends IService<FormulaOption> {
     String queryOption(Long contractId, Long parentId, Long pkeyId, String key);
 
-    Object saveOrUpdateOption(FormulaOptionVo fo);
+    Object saveOrUpdateOption(List<FormulaOptionVo> fo);
     void saveOrUpdateOption(RangeInfo rg , String[] dw, int start);
 
 }

+ 24 - 19
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/FormulaOptionServiceImpl.java

@@ -20,6 +20,7 @@ import org.springblade.manager.service.IWbsTreeContractService;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
@@ -84,27 +85,31 @@ public class FormulaOptionServiceImpl extends ServiceImpl<FormulaOptionMapper, F
     }
 
     @Override
-    public Object saveOrUpdateOption(FormulaOptionVo fo) {
-        if (fo.saveChecked()) {
-            WbsTreeContract wbc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, fo.getPkeyId()));
-            WbsTreeContract parent= this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getId, fo.getParentId()).eq(WbsTreeContract::getContractId, fo.getContractId()));
-            FormulaOption formulaOption = this.getById(parent.getPKeyId());
-            JSONObject root;
-            if (formulaOption == null) {
-                formulaOption = fo.toFo();
-                formulaOption.setId(parent.getPKeyId());
-                root = new JSONObject();
-            } else {
-                root = JSON.parseObject(formulaOption.getVal());
+    public Object saveOrUpdateOption(List<FormulaOptionVo> fos) {
+        List<JSONObject> jsonObjects = new ArrayList<>();
+        for (FormulaOptionVo fo : fos) {
+            if (fo.saveChecked()) {
+                WbsTreeContract wbc = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, fo.getPkeyId()));
+                WbsTreeContract parent= this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getId, fo.getParentId()).eq(WbsTreeContract::getContractId, fo.getContractId()));
+                FormulaOption formulaOption = this.getById(parent.getPKeyId());
+                JSONObject root;
+                if (formulaOption == null) {
+                    formulaOption = fo.toFo();
+                    formulaOption.setId(parent.getPKeyId());
+                    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.getCode(), fo.getValue());
+                formulaOption.setVal(root.toJSONString());
+                this.saveOrUpdate(formulaOption);
+                jsonObjects.add(data);
+
             }
-            JSONObject table = (JSONObject) root.computeIfAbsent(wbc.getInitTableName(), (k) -> new JSONObject());
-            JSONObject data = (JSONObject) table.computeIfAbsent(fo.createKey(), (k) -> new JSONObject());
-            data.put(fo.getCode(), fo.getValue());
-            formulaOption.setVal(root.toJSONString());
-            this.saveOrUpdate(formulaOption);
-            return data;
         }
-        return null;
+        return jsonObjects;
     }
 
     @Override