Search in sources :

Example 6 with SysUploadVO

use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.

the class PdcaLogicServiceImpl method createDocuments.

private void createDocuments(PdcaVO pdca, List<String> attachment) throws ServiceException, Exception {
    if (attachment == null || attachment.size() < 1) {
        return;
    }
    for (String oid : attachment) {
        SysUploadVO upload = this.findUploadDataForNoByteContent(oid);
        if (!(upload.getSystem().equals(Constants.getSystem()) && upload.getType().equals(UploadTypes.IS_TEMP))) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        PdcaDocVO pdcaDoc = new PdcaDocVO();
        pdcaDoc.setPdcaOid(pdca.getOid());
        pdcaDoc.setUploadOid(upload.getOid());
        pdcaDoc.setViewMode(UploadSupportUtils.getViewMode(upload.getShowName()));
        DefaultResult<PdcaDocVO> result = this.pdcaDocService.saveObject(pdcaDoc);
        if (result.getValue() == null) {
            throw new ServiceException(result.getSystemMessage().getValue());
        }
        UploadSupportUtils.updateType(oid, UploadTypes.IS_PDCA_DOCUMENT);
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) PdcaDocVO(com.netsteadfast.greenstep.vo.PdcaDocVO) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO)

Example 7 with SysUploadVO

use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.

the class PdcaLogicServiceImpl method cloneNewProject.

private void cloneNewProject(PdcaVO parentPdca) throws ServiceException, Exception {
    // 1. PDCA main
    PdcaVO pdca = new PdcaVO();
    this.pdcaService.copyProperties(parentPdca, pdca);
    pdca.setOid(null);
    pdca.setConfirmDate(null);
    pdca.setConfirmEmpId(null);
    pdca.setConfirmFlag(YesNo.NO);
    pdca.setParentOid(parentPdca.getOid());
    String lastTitle = "-(New)";
    if ((pdca.getTitle() + lastTitle).length() <= 100) {
        pdca.setTitle(pdca.getTitle() + lastTitle);
    } else {
        pdca.setTitle(pdca.getTitle().substring(pdca.getTitle().length() - lastTitle.length(), 100) + lastTitle);
    }
    // 2. PDCA measure-freq
    PdcaMeasureFreqVO measureFreq = new PdcaMeasureFreqVO();
    measureFreq.setPdcaOid(parentPdca.getOid());
    DefaultResult<PdcaMeasureFreqVO> mfResult = this.pdcaMeasureFreqService.findByUK(measureFreq);
    if (mfResult.getValue() == null) {
        throw new ServiceException(mfResult.getSystemMessage().getValue());
    }
    measureFreq = mfResult.getValue();
    measureFreq.setOid(null);
    measureFreq.setPdcaOid(null);
    Map<String, Object> paramMap = new HashMap<String, Object>();
    paramMap.put("pdcaOid", parentPdca.getOid());
    // 3. organizationOids
    List<String> organizationOids = new ArrayList<String>();
    List<BbPdcaOrga> pdcaOrgaList = this.pdcaOrgaService.findListByParams(paramMap);
    for (BbPdcaOrga pdcaOrga : pdcaOrgaList) {
        OrganizationVO organization = this.findOrganizationDataByUK(pdcaOrga.getOrgId());
        organizationOids.add(organization.getOid());
    }
    // 4. employeeOids
    List<String> employeeOids = new ArrayList<String>();
    List<BbPdcaOwner> pdcaOwnerList = this.pdcaOwnerService.findListByParams(paramMap);
    for (BbPdcaOwner pdcaOwner : pdcaOwnerList) {
        EmployeeVO employee = this.findEmployeeDataByEmpId(pdcaOwner.getEmpId());
        employeeOids.add(employee.getOid());
    }
    // 5. kpiOids
    List<String> kpiOids = new ArrayList<String>();
    List<BbPdcaKpis> pdcaKpisList = this.pdcaKpisService.findListByParams(paramMap);
    for (BbPdcaKpis pdcaKpi : pdcaKpisList) {
        KpiVO kpi = new KpiVO();
        kpi.setId(pdcaKpi.getKpiId());
        DefaultResult<KpiVO> kResult = this.kpiService.findByUK(kpi);
        if (kResult.getValue() == null) {
            throw new ServiceException(kResult.getSystemMessage().getValue());
        }
        kpi = kResult.getValue();
        kpiOids.add(kpi.getOid());
    }
    // 6. attachment
    List<String> attachment = new ArrayList<String>();
    List<BbPdcaDoc> pdcaDocList = this.pdcaDocService.findListByParams(paramMap);
    for (BbPdcaDoc pdcaDoc : pdcaDocList) {
        DefaultResult<SysUploadVO> upResult = this.getSysUploadService().findForNoByteContent(pdcaDoc.getUploadOid());
        if (upResult.getValue() == null) {
            throw new ServiceException(upResult.getSystemMessage().getValue());
        }
        SysUploadVO upload = upResult.getValue();
        File oldFile = UploadSupportUtils.getRealFile(pdcaDoc.getUploadOid());
        attachment.add(UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, true, oldFile, upload.getShowName()));
    }
    // 7. items - PdcaItemVO
    List<PdcaItemVO> items = new ArrayList<PdcaItemVO>();
    List<BbPdcaItem> pdcaItems = this.pdcaItemService.findListByParams(paramMap);
    for (BbPdcaItem pdcaItem : pdcaItems) {
        PdcaItemVO itemObj = new PdcaItemVO();
        this.pdcaItemService.doMapper(pdcaItem, itemObj, IPdcaItemService.MAPPER_ID_PO2VO);
        items.add(itemObj);
    }
    // 8. item - owner
    for (PdcaItemVO itemObj : items) {
        itemObj.setEmployeeOids(new ArrayList<String>());
        paramMap.put("itemOid", itemObj.getOid());
        List<BbPdcaItemOwner> itemOwnerList = this.pdcaItemOwnerService.findListByParams(paramMap);
        for (BbPdcaItemOwner itemOwner : itemOwnerList) {
            itemObj.getEmployeeOids().add(this.findEmployeeDataByEmpId(itemOwner.getEmpId()).getOid());
        }
    }
    // 9. item - attachment
    for (PdcaItemVO itemObj : items) {
        itemObj.setUploadOids(new ArrayList<String>());
        paramMap.put("itemOid", itemObj.getOid());
        List<BbPdcaItemDoc> itemDocList = this.pdcaItemDocService.findListByParams(paramMap);
        for (BbPdcaItemDoc itemDoc : itemDocList) {
            DefaultResult<SysUploadVO> upResult = this.getSysUploadService().findForNoByteContent(itemDoc.getUploadOid());
            if (upResult.getValue() == null) {
                throw new ServiceException(upResult.getSystemMessage().getValue());
            }
            SysUploadVO upload = upResult.getValue();
            File oldFile = UploadSupportUtils.getRealFile(itemDoc.getUploadOid());
            itemObj.getUploadOids().add(UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, true, oldFile, upload.getShowName()));
        }
    }
    // clear item old OID, PDCA_OID
    for (PdcaItemVO itemObj : items) {
        itemObj.setOid(null);
        itemObj.setPdcaOid(null);
    }
    this.create(pdca, measureFreq, organizationOids, employeeOids, kpiOids, attachment, items);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) BbPdcaDoc(com.netsteadfast.greenstep.po.hbm.BbPdcaDoc) BbPdcaOwner(com.netsteadfast.greenstep.po.hbm.BbPdcaOwner) EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) PdcaVO(com.netsteadfast.greenstep.vo.PdcaVO) BbPdcaKpis(com.netsteadfast.greenstep.po.hbm.BbPdcaKpis) BbPdcaItem(com.netsteadfast.greenstep.po.hbm.BbPdcaItem) BbPdcaItemDoc(com.netsteadfast.greenstep.po.hbm.BbPdcaItemDoc) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) BbPdcaItemOwner(com.netsteadfast.greenstep.po.hbm.BbPdcaItemOwner) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) BbPdcaOrga(com.netsteadfast.greenstep.po.hbm.BbPdcaOrga) File(java.io.File) PdcaItemVO(com.netsteadfast.greenstep.vo.PdcaItemVO) PdcaMeasureFreqVO(com.netsteadfast.greenstep.vo.PdcaMeasureFreqVO)

Example 8 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 9 with SysUploadVO

use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.

the class PdcaReportExcelCommand method createZipFile.

private String createZipFile(List<SysUploadVO> uploads) throws Exception {
    ZipFile zip = new ZipFile(Constants.getWorkTmpDir() + SimpleUtils.getUUIDStr() + ".zip");
    ZipParameters parameters = new ZipParameters();
    parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
    parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
    for (SysUploadVO reportUpload : uploads) {
        zip.addFile(UploadSupportUtils.getRealFile(reportUpload.getOid()), parameters);
    }
    return UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, zip.getFile(), "pdca-report.zip");
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) ZipParameters(net.lingala.zip4j.model.ZipParameters)

Example 10 with SysUploadVO

use of com.netsteadfast.greenstep.vo.SysUploadVO in project bamboobsc by billchen198318.

the class CommonLoadUploadFileAction method loadData.

private void loadData(File file) throws ServiceException, Exception {
    if (StringUtils.isBlank(this.oid)) {
        return;
    }
    DefaultResult<SysUploadVO> result = this.sysUploadService.findForNoByteContent(this.oid);
    if (result.getValue() == null) {
        throw new ControllerException(result.getSystemMessage().getValue());
    }
    SysUploadVO uploadData = result.getValue();
    if (YesNo.YES.equals(uploadData.getIsFile())) {
        file = UploadSupportUtils.getRealFile(this.oid);
        if (!file.exists()) {
            return;
        }
        this.inputStream = new ByteArrayInputStream(FileUtils.readFileToByteArray(file));
        this.filename = file.getName();
    } else {
        this.inputStream = new ByteArrayInputStream(UploadSupportUtils.getDataBytes(this.oid));
        this.filename = UploadSupportUtils.generateRealFileName(uploadData.getShowName());
    }
    if ("view".equals(this.type)) {
        if (file != null) {
            try {
                this.contentType = FSUtils.getMimeType(file);
            } catch (Exception e) {
                logger.warn(e.getMessage().toString());
            }
        } else {
            this.contentType = FSUtils.getMimeType(uploadData.getShowName());
        }
    }
    if (!StringUtils.isAsciiPrintable(result.getValue().getShowName())) {
        String userAgent = super.defaultString(super.getHttpServletRequest().getHeader("User-Agent")).toLowerCase();
        if (userAgent.indexOf("firefox") == -1) {
            // for chrome or other browser.
            this.filename = URLEncoder.encode(result.getValue().getShowName(), Constants.BASE_ENCODING);
        }
        return;
    }
    this.filename = result.getValue().getShowName();
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ByteArrayInputStream(java.io.ByteArrayInputStream) SysUploadVO(com.netsteadfast.greenstep.vo.SysUploadVO) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException)

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