use of com.netsteadfast.greenstep.vo.VisionVO in project bamboobsc by billchen198318.
the class KpiReportPdfCommand method createPdf.
private String createPdf(Context context) throws Exception {
BscReportPropertyUtils.loadData();
// 2015-04-18 add
BscReportSupportUtils.loadExpression();
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 document = new Document(PageSize.A4, 10, 10, 10, 10);
document.left(100f);
document.top(150f);
PdfWriter writer = PdfWriter.getInstance(document, os);
document.open();
int dateRangeRows = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0).getDateRangeScores().size();
PdfPTable table = new PdfPTable(MAX_COLSPAN);
PdfPTable dateRangeTable = new PdfPTable(dateRangeRows);
PdfPTable chartsTable = new PdfPTable(2);
PdfPTable signTable = new PdfPTable(1);
table.setWidthPercentage(100f);
dateRangeTable.setWidthPercentage(100f);
chartsTable.setWidthPercentage(100f);
signTable.setWidthPercentage(100f);
this.createHead(table, vision);
this.createBody(table, vision);
this.createDateRange(dateRangeTable, vision, context, dateRangeRows);
this.putCharts(chartsTable, context);
this.putSignature(signTable, context);
document.add(chartsTable);
document.add(table);
document.add(dateRangeTable);
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, "kpi-report.pdf");
file = null;
return oid;
}
use of com.netsteadfast.greenstep.vo.VisionVO in project bamboobsc by billchen198318.
the class StrategyMapLogicServiceImpl method create.
@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> create(String visionOid, Map<String, Object> jsonData) throws ServiceException, Exception {
this.delete(visionOid);
VisionVO vision = new VisionVO();
vision.setOid(visionOid);
DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
if (vResult.getValue() == null) {
// 沒 TB_VISION 資料, 不用清 STRATEGY MAP
throw new ServiceException(vResult.getSystemMessage().getValue());
}
vision = vResult.getValue();
StrategyMapVO strategyMap = new StrategyMapVO();
strategyMap.setVisId(vision.getVisId());
DefaultResult<StrategyMapVO> smResult = strategyMapService.saveObject(strategyMap);
if (smResult.getValue() == null) {
throw new ServiceException(smResult.getSystemMessage().getValue());
}
strategyMap = smResult.getValue();
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
result.setValue(Boolean.TRUE);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
this.saveNodesAndConnections(strategyMap, jsonData);
return result;
}
use of com.netsteadfast.greenstep.vo.VisionVO in project bamboobsc by billchen198318.
the class StrategyMapLogicServiceImpl method delete.
@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(String visionOid) throws ServiceException, Exception {
if (super.isBlank(visionOid) || super.isNoSelectId(visionOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
DefaultResult<Boolean> result = new DefaultResult<Boolean>();
result.setValue(Boolean.TRUE);
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_SUCCESS)));
VisionVO vision = new VisionVO();
vision.setOid(visionOid);
DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
if (vResult.getValue() == null) {
// 沒 TB_VISION 資料, 不用清 STRATEGY MAP
return result;
}
vision = vResult.getValue();
StrategyMapVO strategyMap = new StrategyMapVO();
strategyMap.setVisId(vision.getVisId());
DefaultResult<StrategyMapVO> smResult = this.strategyMapService.findByUK(strategyMap);
if (smResult.getValue() == null) {
// 沒有 BB_STRATEGY_MAP 資料
return result;
}
strategyMap = smResult.getValue();
Map<String, Object> params = new HashMap<String, Object>();
params.put("masterOid", strategyMap.getOid());
List<BbStrategyMapNodes> nodes = this.strategyMapNodesService.findListByParams(params);
List<BbStrategyMapConns> conns = this.strategyMapConnsService.findListByParams(params);
for (int i = 0; nodes != null && i < nodes.size(); i++) {
strategyMapNodesService.delete(nodes.get(i));
}
for (int i = 0; conns != null && i < conns.size(); i++) {
strategyMapConnsService.delete(conns.get(i));
}
return strategyMapService.deleteObject(strategyMap);
}
use of com.netsteadfast.greenstep.vo.VisionVO in project bamboobsc by billchen198318.
the class BscMobileCardUtils method getVisionCardFromUpload.
public static VisionVO getVisionCardFromUpload(String uploadOid) throws ServiceException, Exception {
byte[] content = UploadSupportUtils.getDataBytes(uploadOid);
String jsonStr = new String(content, Constants.BASE_ENCODING);
if (StringUtils.isBlank(jsonStr)) {
throw new Exception("vision-card json data error.");
}
VisionVO vision = new ObjectMapper().readValue(jsonStr, VisionVO.class);
return vision;
}
use of com.netsteadfast.greenstep.vo.VisionVO in project bamboobsc by billchen198318.
the class BscMobileCardUtils method getVisionCard.
public static List<VisionVO> getVisionCard(String frequency, String startDate, String endDate) throws ServiceException, Exception {
List<VisionVO> visionScores = new ArrayList<VisionVO>();
Map<String, String> visions = visionService.findForMap(false);
if (null == visions || visions.size() < 1) {
return visionScores;
}
Context context = new ContextBase();
context.put("startDate", startDate);
context.put("endDate", endDate);
context.put("startYearDate", startDate.substring(0, 4));
context.put("endYearDate", endDate.substring(0, 4));
context.put("frequency", frequency);
context.put("dataFor", BscConstants.MEASURE_DATA_FOR_ALL);
context.put("orgId", BscConstants.MEASURE_DATA_ORGANIZATION_FULL);
context.put("empId", BscConstants.MEASURE_DATA_EMPLOYEE_FULL);
for (Map.Entry<String, String> entry : visions.entrySet()) {
String visionOid = entry.getKey();
context.put("visionOid", visionOid);
SimpleChain chain = new SimpleChain();
ChainResultObj resultObj = chain.getResultFromResource("performanceScoreChain", context);
BscStructTreeObj treeObj = (BscStructTreeObj) resultObj.getValue();
for (int i = 0; treeObj.getVisions() != null && i < treeObj.getVisions().size(); i++) {
VisionVO vision = treeObj.getVisions().get(i);
vision.setContent(" ".getBytes());
DefaultResult<VisionVO> vResult = visionService.findObjectByOid(vision);
if (vResult.getValue() != null) {
// 計算分數chain 取出的vision資料沒有放 content 欄位, 但這邊要用到, 所以取出content欄位
vision.setContent(new String(vResult.getValue().getContent(), Constants.BASE_ENCODING).getBytes());
}
for (PerspectiveVO perspective : vision.getPerspectives()) {
for (ObjectiveVO objective : perspective.getObjectives()) {
for (KpiVO kpi : objective.getKpis()) {
// 產生報表不需要以下欄位
kpi.getAggregationMethod().setDescription(" ");
kpi.getAggregationMethod().setExpression1(" ");
kpi.getAggregationMethod().setExpression2(" ");
kpi.getFormula().setExpression(" ");
}
}
}
visionScores.add(vision);
}
}
return visionScores;
}
Aggregations