|
@@ -16,8 +16,10 @@ import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.manager.dto.FormulaBean;
|
|
|
import org.springblade.manager.dto.WbsParamBean;
|
|
|
+import org.springblade.manager.entity.ElementFormulaMapping;
|
|
|
import org.springblade.manager.entity.Formula;
|
|
|
import org.springblade.manager.entity.WbsParam;
|
|
|
+import org.springblade.manager.service.IElementFormulaMappingService;
|
|
|
import org.springblade.manager.service.IFormulaService;
|
|
|
import org.springblade.manager.service.IWbsParamService;
|
|
|
import org.springblade.manager.vo.ParamBean;
|
|
@@ -47,6 +49,7 @@ public class WbsParamController {
|
|
|
private final IWbsParamService service;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
private final IFormulaService formulaService;
|
|
|
+ private final IElementFormulaMappingService elementFormulaMappingService;
|
|
|
|
|
|
/**
|
|
|
* 保存或修改
|
|
@@ -77,50 +80,45 @@ public class WbsParamController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "批量保存或修改参数", notes = "批量保存或修改参数")
|
|
|
public R saveOrUpdateBatch(@RequestBody ParamBean pb) {
|
|
|
- List<WbsParamBean> wps =pb.getWps();
|
|
|
- /*执行顺序,删>增>改*/
|
|
|
- if(CollectionUtil.isNotEmpty(wps)){
|
|
|
- if(wps.size()==1){
|
|
|
- WbsParamBean kone = wps.get(0);
|
|
|
- if(kone.getType()<0){
|
|
|
- if(Func.isNotEmpty(kone.getNodeId())) {
|
|
|
- this.service.update(Wrappers.<WbsParam>update().lambda().set(WbsParam::getIsDeleted, 1).eq(WbsParam::getNodeId, kone.getNodeId()));
|
|
|
- return R.status(true);
|
|
|
- }else{
|
|
|
- return R.fail("至少保留一个模版");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<Long> ids= wps.stream().map(WbsParamBean::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- if(CollectionUtil.isNotEmpty(ids)){
|
|
|
- WbsParamBean one = wps.get(0);
|
|
|
- if(one.getType().equals(0)){
|
|
|
- this.service.update(Wrappers.<WbsParam>update().lambda().set(WbsParam::getIsDeleted,1).eq(WbsParam::getType,0).notIn(WbsParam::getId,ids));
|
|
|
- }else{
|
|
|
- this.service.update(Wrappers.<WbsParam>update().lambda().set(WbsParam::getIsDeleted,1).eq(WbsParam::getNodeId,one.getNodeId()).notIn(WbsParam::getId,ids));
|
|
|
- /*把当前节点已删除参数的关联公式删除*/
|
|
|
- }
|
|
|
- }
|
|
|
- Map<Boolean,List<WbsParamBean>> map = wps.stream().collect(Collectors.partitioningBy(e->e.getId()!=null));
|
|
|
- List<WbsParamBean> saveList = map.get(false);
|
|
|
- List<WbsParamBean> updateList = map.get(true);
|
|
|
- if(CollectionUtil.isNotEmpty(saveList)){
|
|
|
- this.service.saveBatch(BeanUtil.copy(saveList,WbsParam.class));
|
|
|
- /*新建的时候需要初始化绑定表单元素*/
|
|
|
- }
|
|
|
- if(CollectionUtil.isNotEmpty(updateList)){
|
|
|
- List<WbsParam> ul = new ArrayList<>();
|
|
|
- for(WbsParamBean b:updateList){
|
|
|
- WbsParam old = this.service.getById(b.getId());
|
|
|
- old.setIsDeleted(0);
|
|
|
- BeanUtils.copyProperties(b,old);
|
|
|
- ul.add(old);
|
|
|
- }
|
|
|
- this.service.saveOrUpdateBatch(ul);
|
|
|
- }
|
|
|
- return R.status(true);
|
|
|
- }
|
|
|
- return R.fail("没有提交任何参数");
|
|
|
+ try {
|
|
|
+ List<WbsParamBean> wps =pb.getWps();
|
|
|
+ /*执行顺序,删>增>改*/
|
|
|
+ if(Func.isNotEmpty(pb.getDelIds())){
|
|
|
+ this.service.deleteLogic(pb.getDelIds());
|
|
|
+ this.elementFormulaMappingService.update(Wrappers.<ElementFormulaMapping>lambdaUpdate().set(ElementFormulaMapping::getIsDeleted,1).in(ElementFormulaMapping::getParamId,pb.getDelIds()));
|
|
|
+ /*应该检查接触关联的参数公式还是否存在引用,不存在的情况也要删去*/
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isNotEmpty(wps)){
|
|
|
+ Map<Boolean,List<WbsParamBean>> map = wps.stream().collect(Collectors.partitioningBy(e->e.getId()!=null));
|
|
|
+ List<WbsParamBean> saveList = map.get(false);
|
|
|
+ List<WbsParamBean> updateList = map.get(true);
|
|
|
+ if(CollectionUtil.isNotEmpty(saveList)){
|
|
|
+ this.service.saveBatch(BeanUtil.copy(saveList,WbsParam.class));
|
|
|
+ /*新建的时候需要初始化绑定表单元素*/
|
|
|
+ List<Map<String,Object>> elementMap= this.jdbcTemplate.queryForList(
|
|
|
+ "select a.e_name as name ,a.id " +
|
|
|
+ "from m_wbs_form_element a " +
|
|
|
+ "inner join m_wbs_tree b on a.f_id=b.init_table_id " +
|
|
|
+ "inner join m_wbs_tree c on b.parent_id=c.id " +
|
|
|
+ "where a.is_deleted=0 and c.id="+pb.getNodeId()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if(CollectionUtil.isNotEmpty(updateList)){
|
|
|
+ List<WbsParam> ul = new ArrayList<>();
|
|
|
+ for(WbsParamBean b:updateList){
|
|
|
+ WbsParam old = this.service.getById(b.getId());
|
|
|
+ old.setIsDeleted(0);
|
|
|
+ BeanUtils.copyProperties(b,old);
|
|
|
+ ul.add(old);
|
|
|
+ }
|
|
|
+ this.service.saveOrUpdateBatch(ul);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }catch (Exception e){
|
|
|
+ return R.fail("操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|