Search in sources :

Example 46 with VisionVO

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

the class PersonalAndOrganizationReportDateRangeScoreCommand method execute.

@SuppressWarnings("unchecked")
@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    float total = 0.0f;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    String year = StringUtils.defaultString((String) context.get("startYearDate")).trim();
    String dateType = StringUtils.defaultString((String) context.get("dateType")).trim();
    for (VisionVO vision : treeObj.getVisions()) {
        for (PerspectiveVO perspective : vision.getPerspectives()) {
            for (ObjectiveVO objective : perspective.getObjectives()) {
                for (KpiVO kpi : objective.getKpis()) {
                    this.setDateRangeScore(kpi, dateType, year);
                    // 只有一筆資料
                    total = total + kpi.getDateRangeScores().get(0).getScore();
                }
            }
        }
    }
    context.put("total", total);
    return false;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Example 47 with VisionVO

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

the class PersonalReportPdfCommand method createPdf.

private String createPdf(Context context) throws Exception {
    BscReportPropertyUtils.loadData();
    String visionOid = (String) context.get("visionOid");
    VisionVO vision = null;
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    for (VisionVO visionObj : treeObj.getVisions()) {
        if (visionObj.getOid().equals(visionOid)) {
            vision = visionObj;
        }
    }
    FontFactory.register(BscConstants.PDF_ITEXT_FONT);
    String fileName = UUID.randomUUID().toString() + ".pdf";
    String fileFullPath = Constants.getWorkTmpDir() + "/" + fileName;
    OutputStream os = new FileOutputStream(fileFullPath);
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 10, 10);
    document.left(100f);
    document.top(150f);
    PdfWriter writer = PdfWriter.getInstance(document, os);
    document.open();
    PdfPTable table = new PdfPTable(MAX_COLSPAN);
    table.setWidthPercentage(100f);
    PdfPTable signTable = new PdfPTable(1);
    signTable.setWidthPercentage(100f);
    this.createHead(table, vision, context);
    this.createBody(table, vision);
    this.createFoot(table, context);
    this.putSignature(signTable, context);
    document.add(table);
    document.add(signTable);
    document.close();
    writer.close();
    os.flush();
    os.close();
    os = null;
    File file = new File(fileFullPath);
    String oid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, file, "personal-report.pdf");
    file = null;
    return oid;
}
Also used : PdfWriter(com.itextpdf.text.pdf.PdfWriter) PdfPTable(com.itextpdf.text.pdf.PdfPTable) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Document(com.itextpdf.text.Document) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) File(java.io.File)

Example 48 with VisionVO

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

the class ImportDataLogicServiceImpl method importVisionCsv.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importVisionCsv(String uploadOid) throws ServiceException, Exception {
    List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN001");
    if (csvResults.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
    }
    boolean success = false;
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    StringBuilder msg = new StringBuilder();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    for (int i = 0; i < csvResults.size(); i++) {
        int row = i + 1;
        Map<String, String> data = csvResults.get(i);
        String visId = data.get("VIS_ID");
        String title = data.get("TITLE");
        String content = data.get("CONTENT");
        if (super.isBlank(visId)) {
            msg.append("row: " + row + " id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(title)) {
            msg.append("row: " + row + " title is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(content)) {
            msg.append("row: " + row + " content is blank." + Constants.HTML_BR);
            continue;
        }
        VisionVO vision = new VisionVO();
        vision.setVisId(visId);
        vision.setTitle(title);
        vision.setContent(content.getBytes(Constants.BASE_ENCODING));
        paramMap.put("visId", visId);
        if (this.visionService.countByParams(paramMap) > 0) {
            // update
            DefaultResult<VisionVO> oldResult = this.visionService.findByUK(vision);
            vision.setOid(oldResult.getValue().getOid());
            this.visionLogicService.update(vision);
        } else {
            // insert
            this.visionLogicService.create(vision);
        }
        success = true;
    }
    if (msg.length() > 0) {
        result.setSystemMessage(new SystemMessage(msg.toString()));
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    }
    result.setValue(success);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) HashMap(java.util.HashMap) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 49 with VisionVO

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

the class ImportDataLogicServiceImpl method importPerspectivesCsv.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> importPerspectivesCsv(String uploadOid) throws ServiceException, Exception {
    List<Map<String, String>> csvResults = UploadSupportUtils.getTransformSegmentData(uploadOid, "TRAN002");
    if (csvResults.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_NO_EXIST));
    }
    boolean success = false;
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    StringBuilder msg = new StringBuilder();
    Map<String, Object> paramMap = new HashMap<String, Object>();
    for (int i = 0; i < csvResults.size(); i++) {
        int row = i + 1;
        Map<String, String> data = csvResults.get(i);
        String perId = data.get("PER_ID");
        String visId = data.get("VIS_ID");
        String name = data.get("NAME");
        String weight = data.get("WEIGHT");
        String target = data.get("TARGET");
        String min = data.get("MIN");
        String description = data.get("DESCRIPTION");
        if (super.isBlank(perId)) {
            msg.append("row: " + row + " perspective-id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(visId)) {
            msg.append("row: " + row + " vision-id is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(name)) {
            msg.append("row: " + row + " name is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(weight)) {
            msg.append("row: " + row + " weight is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(target)) {
            msg.append("row: " + row + " target is blank." + Constants.HTML_BR);
            continue;
        }
        if (super.isBlank(min)) {
            msg.append("row: " + row + " min is blank." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(weight)) {
            msg.append("row: " + row + " weight is not number." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(target)) {
            msg.append("row: " + row + " target is not number." + Constants.HTML_BR);
            continue;
        }
        if (!NumberUtils.isNumber(min)) {
            msg.append("row: " + row + " min is not number." + Constants.HTML_BR);
            continue;
        }
        paramMap.clear();
        paramMap.put("visId", visId);
        if (this.visionService.countByParams(paramMap) < 1) {
            throw new ServiceException("row: " + row + " vision is not found " + visId);
        }
        DefaultResult<VisionVO> visionResult = this.visionService.findForSimpleByVisId(visId);
        if (visionResult.getValue() == null) {
            throw new ServiceException(visionResult.getSystemMessage().getValue());
        }
        PerspectiveVO perspective = new PerspectiveVO();
        perspective.setPerId(perId);
        perspective.setVisId(visId);
        perspective.setName(name);
        perspective.setWeight(new BigDecimal(weight));
        perspective.setTarget(Float.valueOf(target));
        perspective.setMin(Float.valueOf(min));
        perspective.setDescription(description);
        paramMap.clear();
        paramMap.put("perId", perId);
        if (this.perspectiveService.countByParams(paramMap) > 0) {
            // update
            DefaultResult<PerspectiveVO> oldResult = this.perspectiveService.findByUK(perspective);
            perspective.setOid(oldResult.getValue().getOid());
            this.perspectiveLogicService.update(perspective, visionResult.getValue().getOid());
        } else {
            // insert
            this.perspectiveLogicService.create(perspective, visionResult.getValue().getOid());
        }
        success = true;
    }
    if (msg.length() > 0) {
        result.setSystemMessage(new SystemMessage(msg.toString()));
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    }
    result.setValue(success);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) HashMap(java.util.HashMap) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) BigDecimal(java.math.BigDecimal) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) Map(java.util.Map) HashMap(java.util.HashMap) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 50 with VisionVO

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

the class VisionServiceImpl method findForSimple.

@Override
public DefaultResult<VisionVO> findForSimple(String oid) throws ServiceException, Exception {
    if (StringUtils.isBlank(oid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<VisionVO> result = new DefaultResult<VisionVO>();
    VisionVO vision = this.visionDAO.findForSimple(oid);
    if (vision != null) {
        result.setValue(vision);
    } else {
        result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) VisionVO(com.netsteadfast.greenstep.vo.VisionVO)

Aggregations

VisionVO (com.netsteadfast.greenstep.vo.VisionVO)66 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)38 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)29 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)22 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)21 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)17 HashMap (java.util.HashMap)16 Map (java.util.Map)8 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)7 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)7 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)7 ArrayList (java.util.ArrayList)7 LinkedList (java.util.LinkedList)7 Transactional (org.springframework.transaction.annotation.Transactional)7 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)6 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 BscMixDataVO (com.netsteadfast.greenstep.bsc.vo.BscMixDataVO)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Document (com.itextpdf.text.Document)3