|
@@ -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
|