Parcourir la source

Merge branch 'refs/heads/feature-g08-lihb-20250910' into dev

LHB il y a 1 semaine
Parent
commit
461acfe000

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

@@ -5,6 +5,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringPool;
 import org.springblade.manager.entity.FormulaOption;
 
+import java.util.List;
+
 /**
  * @author yangyj
  * @Date 2023/3/1 17:35
@@ -17,6 +19,8 @@ public class FormulaOptionVo {
     private Long parentId;
     /**元素码*/
     private String key;
+    /**元素码*/
+    private List<String> keys;
     /**合同段id*/
     private Long contractId;
     /**参数值*/

+ 43 - 20
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/FormulaController.java

@@ -413,29 +413,45 @@ public class FormulaController {
     @ApiOperation(value = "公式交互面板", notes = "公式交互面板")
     public R<Object> panel(FormulaOptionVo fo) {
         Map<String, Object> result = new LinkedHashMap<>();
-        String key = fo.getKey().replaceAll("__[\\d_]+", "");
-        ContractInfo contract = this.contractInfoService.getById(fo.getContractId());
-        WbsTreeContract parent = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getId,fo.getParentId()).eq(WbsTreeContract::getContractId,fo.getContractId()).last("limit 1"));
-
-        List<KeyMapper> kms = this.service.getKeyMapperList(Collections.singletonList(fo.getPkeyId()), contract.getPId(), parent.getPKeyId().toString(), ExecuteType.INSPECTION);
-        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();
+        String key1 = fo.getKey();
+        String[] split = key1.split(",");
+
+        int i = 0;
+        int type = 0;
+
+        for (String key2 : split) {
+            String key = key2.replaceAll("__[\\d_]+", "");
+            ContractInfo contract = this.contractInfoService.getById(fo.getContractId());
+            WbsTreeContract parent = this.wbsTreeContractService.getOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getId,fo.getParentId()).eq(WbsTreeContract::getContractId,fo.getContractId()).last("limit 1"));
+
+            List<KeyMapper> kms = this.service.getKeyMapperList(Collections.singletonList(fo.getPkeyId()), contract.getPId(), parent.getPKeyId().toString(), ExecuteType.INSPECTION);
+            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")) {
-                return R.data(createRadioPanel(0, "是否引用公式数据", this.formulaOptionService.queryOption(fo.getContractId(), fo.getParentId(), fo.getPkeyId(), key)));
-            } else if (StringUtils.isEquals("MILE", formula.getNumber()) || StringUtils.isEquals("TURN_POINT", formula.getNumber())) {
-                if (StringUtils.isEquals(key, formula.getRelyList().get(0).split(StringPool.COLON)[1])) {
-                    return R.data(createRadioPanel(1, "竖直方向", this.formulaOptionService.queryOption(fo.getContractId(), fo.getParentId(), fo.getPkeyId(), fo.getKey())));
+            if (keyMapper != null && Func.isNotEmpty(keyMapper.getFormulaId())) {
+                Formula formula = this.service.getById(keyMapper.getFormulaId());
+                /*临时处理,等确定数据结构在优化*/
+                if (formula.getFormula().contains(".option")) {
+                    i++;
+                } else if (StringUtils.isEquals("MILE", formula.getNumber()) || StringUtils.isEquals("TURN_POINT", formula.getNumber())) {
+                    if (StringUtils.isEquals(key, formula.getRelyList().get(0).split(StringPool.COLON)[1])) {
+                        type = 1;
+                        i++;
+                    }
                 }
+                R.success("暂无公式控件");
+            }
+        }
+        if(split.length == i){
+            if(type == 0){
+                return R.data(createRadioPanel(0, "是否引用公式数据", this.formulaOptionService.queryOption(fo.getContractId(), fo.getParentId(), fo.getPkeyId(), split[0])));
+            }else{
+                return R.data(createRadioPanel(1, "竖直方向", this.formulaOptionService.queryOption(fo.getContractId(), fo.getParentId(), fo.getPkeyId(), split[0])));
             }
-            R.success("暂无公式控件");
         }
         return R.data(result);
     }
@@ -459,6 +475,13 @@ public class FormulaController {
         return R.data(this.formulaOptionService.saveOrUpdateOption(fo));
     }
 
+    @PostMapping("/panel-save-list")
+    @ApiOperationSupport(order = 10)
+    @ApiOperation(value = "公式交互面板参数保存(批量)", notes = "公式交互面板参数保存(批量)")
+    public R<Object> panelSaveList(@RequestBody FormulaOptionVo fos) {
+        return R.data(this.formulaOptionService.saveOrUpdateOption(fos));
+    }
+
     @GetMapping("/log")
     public R<Object> log(Long pkeyId) throws UnknownHostException {
         Map<String, Object> result = new HashMap<>();

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

@@ -5,6 +5,8 @@ import org.springblade.manager.dto.FormulaOptionVo;
 import org.springblade.manager.dto.RangeInfo;
 import org.springblade.manager.entity.FormulaOption;
 
+import java.util.List;
+
 /**
  * @author yangyj
  */

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

@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.mixsmart.utils.StringUtils;
 import lombok.RequiredArgsConstructor;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.CollectionUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.manager.dto.FormulaOptionVo;
 import org.springblade.manager.dto.RangeInfo;
@@ -20,6 +22,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 +87,40 @@ 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(FormulaOptionVo fos) {
+        List<FormulaOptionVo> formulaOptionVos = new ArrayList<>();
+        if(CollectionUtil.isNotEmpty(fos.getKeys())){
+            for (String key : fos.getKeys()) {
+                FormulaOptionVo formulaOptionVo = BeanUtil.copyProperties(fos, FormulaOptionVo.class);
+                formulaOptionVo.setKey(key);
+                formulaOptionVos.add(formulaOptionVo);
             }
-            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;
+
+        List<JSONObject> jsonObjects = new ArrayList<>();
+        for (FormulaOptionVo fo : formulaOptionVos) {
+            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);
+
+            }
+        }
+        return jsonObjects;
     }
 
     @Override