| | |
| | | package com.vci.web.service.impl; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.vci.constant.FrameWorkLangCodeConstant; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | | import com.vci.corba.framework.data.PvolumeInfo; |
| | | import com.vci.corba.portal.data.Constraint; |
| | | 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.*; |
| | | import com.vci.starter.poi.bo.WriteExcelData; |
| | | import com.vci.starter.poi.bo.WriteExcelOption; |
| | | import com.vci.starter.poi.util.ExcelUtil; |
| | | import com.vci.starter.web.exception.VciBaseException; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.util.ControllerUtil; |
| | | import com.vci.starter.web.util.LangBaseUtil; |
| | | import com.vci.starter.web.util.LocalFileUtil; |
| | | import com.vci.web.enumpck.ActionEnum; |
| | | import com.vci.web.enumpck.PlTypetypeEnum; |
| | | import com.vci.web.other.ExportActionLogBean; |
| | | import com.vci.web.other.ExportBeans; |
| | | import com.vci.web.service.OsActionServiceI; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | | import com.vci.starter.web.util.WebThreadLocalUtil; |
| | | import com.vci.web.service.OsPvolumesServiceI; |
| | | import com.vci.web.util.Func; |
| | | import com.vci.web.util.PinyinCommon; |
| | | import com.vci.web.util.PlatformClientUtil; |
| | | import com.vci.web.util.WebUtil; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.*; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | /** |
| | | * 分页查询卷 |
| | | * @param pageSize 页数 |
| | | * @param pageIndex 第几页 |
| | | * @param pageSize 第几页 |
| | | * @param pageIndex 页数 |
| | | * @return 分页数据 |
| | | */ |
| | | @Override |
| | |
| | | public BaseResult savePvolume(OsPvolumeDTO dto) throws PLException { |
| | | PvolumeInfo pvoInfo = new PvolumeInfo(); |
| | | pvoInfo.service = dto.getService(); |
| | | pvoInfo.id = dto.getId(); |
| | | // pvoInfo.id = dto.getId(); |
| | | pvoInfo.name = dto.getName(); |
| | | pvoInfo.host = dto.getHost(); |
| | | pvoInfo.isvalid = dto.isIsvalid(); |
| | |
| | | } |
| | | return BaseResult.success("修改成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 删除卷 |
| | | * @param ids 主键集合 |
| | | * @return 删除结果 |
| | | */ |
| | | @Override |
| | | public BaseResult deletePvolume(String[] ids) throws PLException { |
| | | if ( ids.length == 0){ |
| | | public BaseResult deletePvolume(String ids) throws PLException { |
| | | if ( StringUtils.isBlank(ids)){ |
| | | throw new PLException("500", new String[]{"请选择相关数据!!"}); |
| | | } |
| | | for (String id : ids) { |
| | | for (String id : ids.split(",")) { |
| | | boolean isvalid = platformClientUtil.getFrameworkService().checkIsvalid(id); |
| | | if(isvalid) { |
| | | throw new PLException("500", new String[]{"选择数据为首选路径,不能删除!"}); |
| | |
| | | UserEntityInfo userInfo = new UserEntityInfo(); |
| | | userInfo.setUserName(WebUtil.getCurrentUserId()); |
| | | userInfo.setModules("com.vci.client.framework.systemConfig.volumn.PvolumePanel"); |
| | | boolean rs = platformClientUtil.getFrameworkService().deletePvolume(ids, userInfo); |
| | | boolean rs = platformClientUtil.getFrameworkService().deletePvolume(ids.split(","), userInfo); |
| | | if(!rs){ |
| | | return BaseResult.fail("删除失败!"); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 文件柜导出 |
| | | * @param exportFileName 导出的文件名 |
| | | * @param pvolumeIds 导出选中的卷id |
| | | * @return |
| | | * @throws PLException |
| | | */ |
| | | @Override |
| | | public String exportPvolumes(String exportFileName, String pvolumeIds) throws PLException { |
| | | if(Func.isBlank(pvolumeIds)){ |
| | | throw new PLException("500",new String[]{"请勾选要导出的数据!"}); |
| | | } |
| | | //界面没传名称,使用默认导出名称 |
| | | exportFileName = Func.isBlank(exportFileName) ? "文件柜导出_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss"):exportFileName; |
| | | //设置列名 |
| | | List<String> columns = new ArrayList<>(Arrays.asList("卷名","机器类型","路径名称","首选路径","服务器","卷服务")); |
| | | |
| | | //写excel |
| | | String excelPath = LocalFileUtil.getDefaultTempFolder() + File.separator + exportFileName + ".xls"; |
| | | try { |
| | | new File(excelPath).createNewFile(); |
| | | } catch (Throwable e) { |
| | | throw new VciBaseException(LangBaseUtil.getErrorMsg(e), new String[]{excelPath}, e); |
| | | } |
| | | //设置列 |
| | | List<WriteExcelData> excelDataList = new ArrayList<>(); |
| | | //设置列头 |
| | | for (int index = 0; index < columns.size(); index++) { |
| | | excelDataList.add(new WriteExcelData(0,index, columns.get(index))); |
| | | } |
| | | //按照文件柜ID查询文件柜 |
| | | List<String> pvolumeIdList = Func.toStrList(pvolumeIds); |
| | | List<PvolumeInfo> pvolumeInfoList = this.getPvolumeInfoByIds(pvolumeIdList); |
| | | |
| | | if(Func.isEmpty(pvolumeInfoList)){ |
| | | excelDataList.add(new WriteExcelData(1,1, "未获取到要导出的文件柜信息,请刷新后尝试重新导出!")); |
| | | }else{ |
| | | for (int i = 0; i < pvolumeInfoList.size(); i++) { |
| | | PvolumeInfo pvolumeInfo = pvolumeInfoList.get(i); |
| | | excelDataList.add(new WriteExcelData(i+1,0, pvolumeInfo.name)); |
| | | excelDataList.add(new WriteExcelData(i+1,1, pvolumeInfo.type)); |
| | | excelDataList.add(new WriteExcelData(i+1,2, pvolumeInfo.path)); |
| | | excelDataList.add(new WriteExcelData(i+1,3, pvolumeInfo.isvalid)); |
| | | excelDataList.add(new WriteExcelData(i+1,4, pvolumeInfo.host)); |
| | | excelDataList.add(new WriteExcelData(i+1,5, pvolumeInfo.service)); |
| | | } |
| | | } |
| | | WriteExcelOption excelOption = new WriteExcelOption(excelDataList); |
| | | ExcelUtil.writeDataToFile(excelPath, excelOption); |
| | | return excelPath; |
| | | } |
| | | |
| | | /** |
| | | * 根据卷id查询卷 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PvolumeInfo> getPvolumeInfoByIds(List<String> ids) throws PLException { |
| | | List<PvolumeInfo> pvolumeInfos = new ArrayList<>(); |
| | | if(Func.isEmpty(ids)){ |
| | | return pvolumeInfos; |
| | | } |
| | | PvolumeInfo[] allPvolumes = platformClientUtil.getFrameworkService().getAllPvolumes(); |
| | | if (Func.isEmpty(allPvolumes)){ |
| | | return pvolumeInfos; |
| | | } |
| | | pvolumeInfos = Arrays.stream(allPvolumes).filter(pvolumeInfo -> ids.contains(pvolumeInfo.id)).collect(Collectors.toList()); |
| | | return pvolumeInfos; |
| | | } |
| | | |
| | | /** |
| | | * 为文件柜分配成员----这个功能现在没用上,平台的保存方法是注释掉的 |
| | | * @param pvolumId |
| | | * @param userIds |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean savePvolumeUser(String pvolumId ,List<String> userIds) throws PLException { |
| | | VciBaseUtil.alertNotNull(pvolumId,"文件柜主键",userIds,"用户主键集合"); |
| | | UserEntityInfo userEntityInfo = new UserEntityInfo(); |
| | | userEntityInfo.setUserName(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()); |
| | | boolean resBoolean = platformClientUtil.getFrameworkService().savePvolumeUser(pvolumId, userIds.toArray(new String[userIds.size()]), userEntityInfo); |
| | | return resBoolean; |
| | | } |
| | | |
| | | /** |
| | | * 卷 从Corba端转到Hibernate对象端 |
| | | * @param pvoInfo |
| | | * @return |