Search in sources :

Example 21 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class WeightBodyCommand method execute.

@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    if (YesNo.YES.equals(context.get("autoAllocation"))) {
        this.autoAllocation(treeObj);
    }
    Map<String, Object> parameter = new HashMap<String, Object>();
    parameter.put("treeObj", treeObj);
    parameter.put("weightName", String.valueOf(context.get("weightName")));
    /*
		StringTemplateLoader templateLoader = new StringTemplateLoader();
		templateLoader.putTemplate("resourceTemplate", 
				TemplateUtils.getResourceSrc(WeightBodyCommand.class.getClassLoader(), templateResource) );
		Configuration cfg = new Configuration();
		cfg.setTemplateLoader(templateLoader);
		Template template = cfg.getTemplate("resourceTemplate", "utf-8");
		Writer out = new StringWriter();
		template.process(parameter, out);				
		this.setResult(context, out.toString() );
		*/
    String content = TemplateUtils.processTemplate("resourceTemplate", WeightBodyCommand.class.getClassLoader(), templateResource, parameter);
    this.setResult(context, content);
    return false;
}
Also used : HashMap(java.util.HashMap) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Example 22 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class PersonalReportBodyCommand method execute.

@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    String dateType = (String) context.get("dateType");
    String empId = (String) context.get("empId");
    String account = (String) context.get("account");
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    Map<String, Object> parameter = new HashMap<String, Object>();
    parameter.put("treeObj", treeObj);
    parameter.put("dateType", dateType);
    parameter.put("year", (String) context.get("startYearDate"));
    parameter.put("fullName", " ");
    parameter.put("jobTitle", " ");
    parameter.put("departmentName", " ");
    parameter.put("employeeOid", " ");
    parameter.put("total", 0.0f);
    if (context.get("total") != null && context.get("total") instanceof Float) {
        parameter.put("total", context.get("total"));
    }
    EmployeeVO employee = new EmployeeVO();
    employee.setEmpId(empId);
    employee.setAccount(account);
    DefaultResult<EmployeeVO> result = this.employeeService.findByUK(employee);
    if (result.getValue() != null) {
        parameter.put("fullName", result.getValue().getEmpId() + " - " + result.getValue().getFullName());
        parameter.put("jobTitle", result.getValue().getJobTitle());
        parameter.put("employeeOid", result.getValue().getOid());
        List<String> appendIds = this.organizationService.findForAppendOrganizationOids(result.getValue().getEmpId());
        List<String> appendNames = this.organizationService.findForAppendNames(appendIds);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; appendNames != null && i < appendNames.size(); i++) {
            sb.append(appendNames.get(i)).append(Constants.ID_DELIMITER);
        }
        parameter.put("departmentName", sb.toString());
    }
    this.fillReportProperty(parameter);
    String content = TemplateUtils.processTemplate("resourceTemplate", PersonalReportBodyCommand.class.getClassLoader(), templateResource, parameter);
    this.setResult(context, content);
    return false;
}
Also used : EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) HashMap(java.util.HashMap) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Example 23 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj 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 24 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj 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 25 with BscStructTreeObj

use of com.netsteadfast.greenstep.bsc.model.BscStructTreeObj in project bamboobsc by billchen198318.

the class ScoreCalculationCommand method execute.

@Override
public boolean execute(Context context) throws Exception {
    if (this.getResult(context) == null || !(this.getResult(context) instanceof BscStructTreeObj)) {
        return false;
    }
    BscStructTreeObj treeObj = (BscStructTreeObj) this.getResult(context);
    this.scoreCalculation(treeObj);
    return false;
}
Also used : BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Aggregations

BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)28 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)17 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)8 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)8 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)8 HashMap (java.util.HashMap)8 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)7 File (java.io.File)6 FileOutputStream (java.io.FileOutputStream)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Document (com.itextpdf.text.Document)3 PdfPTable (com.itextpdf.text.pdf.PdfPTable)3 PdfWriter (com.itextpdf.text.pdf.PdfWriter)3 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)3 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 OutputStream (java.io.OutputStream)3 Context (org.apache.commons.chain.Context)3 XSSFSheet (org.apache.poi.xssf.usermodel.XSSFSheet)3 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)3 StrategyMapItemsVO (com.netsteadfast.greenstep.bsc.vo.StrategyMapItemsVO)2