Search in sources :

Example 11 with SysUploadVO

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);
        }
    }
}
Also used : PdcaItemDocVO(com.netsteadfast.greenstep.vo.PdcaItemDocVO) HashMap(java.util.HashMap) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) PdcaItemVO(com.netsteadfast.greenstep.vo.PdcaItemVO)

Example 12 with SysUploadVO

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;
}
Also used : SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) File(java.io.File) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 13 with SysUploadVO

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;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) File(java.io.File) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 14 with SysUploadVO

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();
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Example 15 with SysUploadVO

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();
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) File(java.io.File) IOException(java.io.IOException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

SysUploadVO (com.netsteadfast.greenstep.vo.SysUploadVO)20 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)14 File (java.io.File)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)5 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)3 KpiAttacVO (com.netsteadfast.greenstep.vo.KpiAttacVO)3 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)3 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)2 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)2 PdcaDocVO (com.netsteadfast.greenstep.vo.PdcaDocVO)2 PdcaItemDocVO (com.netsteadfast.greenstep.vo.PdcaItemDocVO)2 PdcaItemVO (com.netsteadfast.greenstep.vo.PdcaItemVO)2 PdcaMeasureFreqVO (com.netsteadfast.greenstep.vo.PdcaMeasureFreqVO)2 AuthorityException (com.netsteadfast.greenstep.base.exception.AuthorityException)1 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 BbPdcaDoc (com.netsteadfast.greenstep.po.hbm.BbPdcaDoc)1 BbPdcaItem (com.netsteadfast.greenstep.po.hbm.BbPdcaItem)1 BbPdcaItemDoc (com.netsteadfast.greenstep.po.hbm.BbPdcaItemDoc)1