package com.vci.web.controller;
|
|
import com.vci.corba.common.PLException;
|
import com.vci.corba.framework.data.PvolumeInfo;
|
import com.vci.dto.*;
|
import com.vci.starter.web.annotation.log.VciBusinessLog;
|
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.VciBaseUtil;
|
import com.vci.web.service.OsActionServiceI;
|
import com.vci.web.service.OsPvolumesServiceI;
|
import com.vci.web.util.Func;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.util.Arrays;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 文件柜管理的控制器
|
* @author yuxc
|
* @date 2024-10-14
|
*/
|
@RequestMapping("/pvolumesController")
|
@RestController
|
public class OsPvolumesController {
|
|
/**
|
* Action服务
|
*/
|
@Autowired
|
private OsPvolumesServiceI osPvolumesServiceI;
|
|
/**
|
* 分页查询卷
|
* @param pageSize 第几页
|
* @param pageIndex 页数
|
* @return 分页数据
|
*/
|
@GetMapping("/getPvolumesPage")
|
public BaseResult getPvolumesPage(Integer pageSize, Integer pageIndex){
|
try {
|
if(pageIndex == null){
|
pageIndex = 1000 ;
|
}
|
if(pageSize == null){
|
pageSize = 0;
|
}
|
return osPvolumesServiceI.getPvolumesPage(pageSize.shortValue(), pageIndex.shortValue());
|
} catch (PLException e) {
|
BaseResult objectBaseResult = new BaseResult<>();
|
objectBaseResult.setCode(Integer.parseInt(e.code));
|
objectBaseResult.setMsg(Arrays.toString(e.messages));
|
return objectBaseResult;
|
}
|
}
|
|
/**
|
* 增加卷
|
* @param dto 卷的传输信息
|
* @return 保存结果
|
*/
|
@PostMapping("/savePvolume")
|
public BaseResult savePvolume(@RequestBody OsPvolumeDTO dto){
|
try {
|
return osPvolumesServiceI.savePvolume(dto);
|
} catch (PLException e) {
|
BaseResult objectBaseResult = new BaseResult<>();
|
objectBaseResult.setCode(Integer.parseInt(e.code));
|
objectBaseResult.setMsg(Arrays.toString(e.messages));
|
return objectBaseResult;
|
}
|
}
|
|
/**
|
* 修改卷
|
* @param dto 卷的传输信息
|
* @return 修改结果
|
*/
|
@PostMapping("/updatePvolume")
|
public BaseResult updatePvolume(@RequestBody OsPvolumeDTO dto){
|
try {
|
return osPvolumesServiceI.updatePvolume(dto);
|
} catch (PLException e) {
|
BaseResult objectBaseResult = new BaseResult<>();
|
objectBaseResult.setCode(Integer.parseInt(e.code));
|
objectBaseResult.setMsg(Arrays.toString(e.messages));
|
return objectBaseResult;
|
}
|
}
|
|
/**
|
* 删除卷
|
* @param ids 主键集合
|
* @return 删除结果
|
*/
|
@DeleteMapping("/deletePvolume")
|
public BaseResult deletePvolume(String ids){
|
try {
|
return osPvolumesServiceI.deletePvolume(ids);
|
} catch (PLException e) {
|
BaseResult objectBaseResult = new BaseResult<>();
|
objectBaseResult.setCode(Integer.parseInt(e.code));
|
objectBaseResult.setMsg(Arrays.toString(e.messages));
|
return objectBaseResult;
|
}
|
}
|
|
/**
|
* 为文件柜分配成员
|
* @param pvolumId
|
* @param userIds
|
* @return
|
*/
|
@PostMapping("/savePvolumeUser")
|
public BaseResult savePvolumeUser(String pvolumId ,String userIds){
|
try {
|
return osPvolumesServiceI.savePvolumeUser(pvolumId,Func.toStrList(userIds)) ? BaseResult.success("文件柜分配成员成功!"):BaseResult.fail("文件柜分配成员失败!");
|
} catch (PLException e) {
|
BaseResult objectBaseResult = new BaseResult<>();
|
objectBaseResult.setCode(Integer.parseInt(e.code));
|
objectBaseResult.setMsg(Arrays.toString(e.messages));
|
return objectBaseResult;
|
}
|
}
|
|
/**
|
* 导出选中的文件柜信息
|
* @param exportFileName 导出的文件名
|
* @param pvolumeIds 需要导出的属性英文名称
|
* @param response
|
*/
|
@GetMapping( "/exportPvolumes")
|
@VciBusinessLog(operateName = "导出选中的文件柜信息")
|
public void exportPvolumes(String exportFileName, String pvolumeIds, HttpServletResponse response){
|
try {
|
String excelPath = osPvolumesServiceI.exportPvolumes(exportFileName,pvolumeIds);
|
ControllerUtil.writeFileToResponse(response,excelPath);
|
} catch (Exception e) {
|
String msg = "导出文件柜时出现错误,原因:" + VciBaseUtil.getExceptionMessage(e);
|
try {
|
e.printStackTrace();
|
ControllerUtil.writeDataToResponse(response,"error_" + Func.format(new Date(),"yyyy-MM-dd HHmmss.sss") + ".txt", StringUtils.isNotBlank(msg)?msg.getBytes():new byte[0],null);
|
} catch (IOException ioException) {
|
ioException.printStackTrace();
|
}
|
}
|
}
|
|
}
|