ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/OsActionServiceImpl.java
@@ -6,11 +6,7 @@
import com.vci.corba.portal.data.PLAction;
import com.vci.corba.portal.data.PLActionCls;
import com.vci.corba.portal.data.PLActionParam;
import com.vci.dto.PLActionClsDTO;
import com.vci.dto.PLActionDTO;
import com.vci.dto.PLActionExpDTO;
import com.vci.dto.PLActionQueryDTO;
import com.vci.pagemodel.OsAttributeVO;
import com.vci.dto.*;
import com.vci.starter.poi.bo.WriteExcelData;
import com.vci.starter.poi.bo.WriteExcelOption;
import com.vci.starter.poi.util.ExcelUtil;
@@ -131,6 +127,7 @@
        PLActionCls[] clses = platformClientUtil.getUIService().getPLActionClsArray();
        PLActionClsDTO treDto = new PLActionClsDTO();
        treDto.setName("Action分类");
        treDto.setId("root");
        Map<String, List<PLActionCls>> allDataMap = Arrays.stream(clses).collect(Collectors.groupingBy(pl -> pl.pid));
        for (PLActionCls cls : clses) {
@@ -138,7 +135,7 @@
                PLActionClsDTO parentDto = new PLActionClsDTO();
                parentDto.setId(cls.id);
                parentDto.setName(cls.name);
                parentDto.setPid(cls.pid);
                parentDto.setPid("root");
                parentDto.setDescription(cls.description);
                parentDto.setCreator(cls.creator);
                parentDto.setCreateTime(cls.createTime);
@@ -190,7 +187,7 @@
        Constraint[] consArray ;
        if(StringUtils.isNotBlank(dto.getPlactioncls())){
            consArray = new Constraint[7];
            consArray[6] = new Constraint("plactioncls", dto.getPlactioncls());
            consArray[6] = new Constraint("plactioncls", dto.getPlactioncls().equals("root") ? "": dto.getPlactioncls());
        }else {
            consArray = new Constraint[6];
        }
@@ -503,6 +500,123 @@
        ControllerUtil.writeFileToResponse(response,excelPath);
        FileUtil.del(defaultTempFolder + File.separator);
    }
    /**
     * 保存Action参数数据
     * dto action传输对象
     * @return 保存结果
     */
    @Override
    public BaseResult savePLActionParam(PLActionParamDTO dto) throws PLException {
        if(dto.getName() == null || dto.getName().equals("")) {
            throw new PLException("500",new String[]{"参数名称不能为空"});
        }
        PLActionParam param = new PLActionParam();
        param.oid = "";
        param.name = dto.getName();
        param.defaultValue = dto.getDefaultValue();
        param.description = dto.getDescription();
        param.action = dto.getAction();
        String message = platformClientUtil.getUIService().createPLActionParam(param);
        if(message.startsWith("0")) {
            if(message.equals("01")) {
                throw new PLException("500",new String[]{"参数名已经存在!"});
            } else {
                throw new PLException("500",new String[]{"添加按钮参数时发生异常:" + message.substring(1)});
            }
        }
        return BaseResult.success();
    }
    @Override
    public BaseResult updatePLActionParam(PLActionParamDTO dto) throws PLException {
        if(dto.getName() == null || dto.getName().equals("")) {
            throw new PLException("500",new String[]{"参数名称不能为空"});
        }
        PLActionParam param = new PLActionParam();
        param.oid = dto.getOid();
        param.name = dto.getName();
        param.defaultValue = dto.getDefaultValue();
        param.description = dto.getDescription();
        param.action = dto.getAction();
        String message = platformClientUtil.getUIService().editPLActionParam(param);
        if(message.startsWith("0")) {
            if(message.equals("01")) {
                throw new PLException("500",new String[]{"参数名已经存在!"});
            } else {
                throw new PLException("500",new String[]{"添加按钮参数时发生异常:" + message.substring(1)});
            }
        }
        return BaseResult.success();
    }
    /**
     * 删除Action参数数据
     * oid 参数主键
     * @return 保存结果
     */
    @Override
    public BaseResult deletePLActionParam(String oid) throws PLException {
        if(StringUtils.isBlank(oid)){
            throw new PLException("500", new String[]{"参数主键不能为空"});
        }
        String message = platformClientUtil.getUIService().deletePLActionParam(oid);
        if (message.startsWith("0")) {
            throw new PLException("500", new String[]{"删除按钮参数时发生异常:" + message.substring(1)});
        }
        return BaseResult.success();
    }
    /**
     * 查询Action参数列表数据
     * actionOid 参数主键
     * @return 保存结果
     */
    @Override
    public BaseResult getPLActionParam(String actionOid) throws PLException {
        if (StringUtils.isBlank(actionOid)){
            throw new PLException("500", new String[]{"Action主键不能为空!"});
        }
        PLActionParam[] paramArrays = platformClientUtil.getUIService().getPLActionParamArrayByActionId(actionOid);
        List<PLActionParamDTO> dtos = new ArrayList<>();
        for (PLActionParam paramArray : paramArrays) {
            PLActionParamDTO dto = new PLActionParamDTO();
            dto.setAction(paramArray.action);
            dto.setOid(paramArray.oid);
            dto.setName(paramArray.name);
            dto.setDescription(paramArray.description);
            dto.setDefaultValue(paramArray.defaultValue);
            dtos.add(dto);
        }
        return BaseResult.dataList(dtos);
    }
    /**
     * 删除分类
     * @param dto 分类对象
     * @return 处理结果
     * @throws PLException
     */
    @Override
    public BaseResult deleteActionCls(PLActionClsDTO dto) throws PLException {
        PLActionCls[] clses = platformClientUtil.getUIService().getPLActionClsArray();
        // 将所有分类父分类保存
        HashSet<String> clsPids = new HashSet<String>();
        for (PLActionCls plActionCls : clses) {
            clsPids.add(plActionCls.pid);
        }
        if (dto.getName().equals("未分类")) {
            throw new PLException("500", new String[]{"未分类不能删除!"});
        }
        if (clsPids.contains(dto.getId())) {
            throw new PLException("500", new String[]{"该分类下存在子分类不能删除!\n请删除此分类下的子分类!"});
        }
        // 执行删除操作
        String message = platformClientUtil.getUIService().deletePLActionClsById(dto.getId());
        if (message.startsWith("0")) {
            throw new PLException("500", new String[]{"删除分类失败!" + message.substring(1)});
        }
        return BaseResult.success("分类删除成功!" + message.substring(1));
    }
    public boolean isValidPageForamt(PLActionExpDTO plActionExpDTO) throws PLException {