use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class PdcaManagementAction method loadPdcaItemsData.
private void loadPdcaItemsData() throws ServiceException, Exception {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("pdcaOid", pdca.getOid());
this.pdcaItems = this.pdcaItemService.findListVOByParams(paramMap);
for (PdcaItemVO item : this.pdcaItems) {
List<String> appendEmplOidsPdcaItemOwner = this.employeeService.findForAppendEmployeeOidsByPdcaItemOwner(item.getPdcaOid(), item.getOid());
List<String> appendEmplNamesPdcaItemOwner = this.employeeService.findForAppendNames(appendEmplOidsPdcaItemOwner);
item.setEmployeeAppendOids(this.joinAppend2String(appendEmplOidsPdcaItemOwner));
item.setEmployeeAppendNames(this.joinAppend2String(appendEmplNamesPdcaItemOwner));
paramMap.put("itemOid", item.getOid());
List<PdcaItemDocVO> itemDocs = this.pdcaItemDocService.findListVOByParams(paramMap);
for (int i = 0; itemDocs != null && i < itemDocs.size(); i++) {
PdcaItemDocVO itemDoc = itemDocs.get(i);
itemDoc.setShowName("unknown-" + itemDoc.getUploadOid());
DefaultResult<SysUploadVO> upResult = this.sysUploadService.findForNoByteContent(itemDoc.getUploadOid());
if (upResult.getValue() != null) {
itemDoc.setShowName(upResult.getValue().getShowName());
}
item.getDocs().add(itemDoc);
}
}
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class UploadSupportUtils method getDataBytes.
public static byte[] getDataBytes(String uploadOid) throws ServiceException, IOException, Exception {
if (StringUtils.isBlank(uploadOid)) {
throw new Exception("parameter is blank!");
}
byte[] datas = null;
SysUploadVO uploadObj = findUpload(uploadOid);
datas = uploadObj.getContent();
if (YesNo.YES.equals(uploadObj.getIsFile())) {
String uploadDir = getUploadFileDir(uploadObj.getSystem(), uploadObj.getSubDir(), uploadObj.getType());
File file = new File(uploadDir + "/" + uploadObj.getFileName());
datas = FileUtils.readFileToByteArray(file);
file = null;
}
return datas;
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class UploadSupportUtils method updateType.
public static DefaultResult<Boolean> updateType(String oid, String type) throws ServiceException, IOException, Exception {
DefaultResult<SysUploadVO> uploadResult = sysUploadService.findForNoByteContent(oid);
if (uploadResult.getValue() == null) {
throw new ServiceException(uploadResult.getSystemMessage().getValue());
}
SysUploadVO upload = uploadResult.getValue();
if (!YesNo.YES.equals(upload.getIsFile())) {
return sysUploadService.updateTypeOnly(oid, type);
}
DefaultResult<Boolean> result = sysUploadService.updateTypeOnly(oid, type);
if (result.getValue() == null || !result.getValue()) {
return result;
}
// move file to new dir.
String oldFullPath = getUploadFileDir(upload.getSystem(), upload.getSubDir(), upload.getType()) + upload.getFileName();
String newFullPath = getUploadFileDir(upload.getSystem(), upload.getSubDir(), type) + upload.getFileName();
File newFile = new File(newFullPath);
if (newFile.isFile() && newFile.exists()) {
newFile = null;
throw new Exception("error. file exists, cannot operate!");
}
newFile = null;
File oldFile = new File(oldFullPath);
if (!oldFile.exists()) {
oldFile = null;
throw new Exception("error. file no exists: " + oldFullPath);
}
oldFile = null;
FSUtils.mv(oldFullPath, newFullPath);
/*
FSUtils.cp(oldFullPath, newFullPath);
FSUtils.rm(oldFullPath);
*/
return result;
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class UploadSupportUtils method create.
public static String create(String system, String type, boolean isFile, File file, String showName) throws ServiceException, IOException, Exception {
if (StringUtils.isBlank(type) || null == file || StringUtils.isBlank(showName)) {
throw new Exception("parameter is blank!");
}
if (!file.exists()) {
throw new Exception("file no exists!");
}
SysUploadVO upload = new SysUploadVO();
upload.setIsFile((isFile ? YesNo.YES : YesNo.NO));
upload.setShowName(showName);
upload.setSystem(system);
upload.setType(type);
upload.setSubDir(getSubDir());
if (isFile) {
String uploadDir = getUploadFileDir(system, type);
String uploadFileName = generateRealFileName(file);
mkdirUploadFileDir(system, type);
FSUtils.cp(file.getPath(), uploadDir + "/" + uploadFileName);
upload.setFileName(uploadFileName);
} else {
upload.setContent(FileUtils.readFileToByteArray(file));
upload.setFileName(" ");
}
DefaultResult<SysUploadVO> result = sysUploadService.saveObject(upload);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
return result.getValue().getOid();
}
use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.
the class UploadSupportUtils method create.
public static String create(String system, String type, boolean isFile, byte[] datas, String showName) throws ServiceException, IOException, Exception {
if (StringUtils.isBlank(type) || null == datas || StringUtils.isBlank(showName)) {
throw new Exception("parameter is blank!");
}
SysUploadVO upload = new SysUploadVO();
upload.setIsFile((isFile ? YesNo.YES : YesNo.NO));
upload.setShowName(showName);
upload.setSystem(system);
upload.setType(type);
upload.setSubDir(getSubDir());
if (isFile) {
String uploadDir = getUploadFileDir(system, type);
String uploadFileName = generateRealFileName(showName);
mkdirUploadFileDir(system, type);
File file = null;
try {
file = new File(uploadDir + "/" + uploadFileName);
FileUtils.writeByteArrayToFile(file, datas);
} catch (Exception e) {
throw e;
} finally {
file = null;
}
upload.setFileName(uploadFileName);
} else {
upload.setContent(datas);
upload.setFileName(" ");
}
DefaultResult<SysUploadVO> result = sysUploadService.saveObject(upload);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
return result.getValue().getOid();
}
Aggregations