Ver código fonte

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

LHB 3 semanas atrás
pai
commit
bc110cf3d9

+ 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;
     /**参数值*/

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

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

@@ -13,7 +13,7 @@ import java.util.List;
 public interface IFormulaOptionService extends IService<FormulaOption> {
     String queryOption(Long contractId, Long parentId, Long pkeyId, String key);
 
-    Object saveOrUpdateOption(List<FormulaOptionVo> fo);
+    Object saveOrUpdateOption(FormulaOptionVo fo);
     void saveOrUpdateOption(RangeInfo rg , String[] dw, int start);
 
 }

+ 13 - 2
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;
@@ -85,9 +87,18 @@ public class FormulaOptionServiceImpl extends ServiceImpl<FormulaOptionMapper, F
     }
 
     @Override
-    public Object saveOrUpdateOption(List<FormulaOptionVo> fos) {
+    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);
+            }
+        }
+
         List<JSONObject> jsonObjects = new ArrayList<>();
-        for (FormulaOptionVo fo : fos) {
+        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()));