use of com.netsteadfast.greenstep.vo.DateRangeScoreVO in project bamboobsc by billchen198318.
the class ScoreCalculationCallable method initKpiDateRangeScores.
private void initKpiDateRangeScores(KpiVO kpi, List<String> dateRange) throws Exception {
for (String date : dateRange) {
DateRangeScoreVO dateScore = new DateRangeScoreVO();
dateScore.setTarget(kpi.getTarget());
dateScore.setMin(kpi.getMin());
dateScore.setDate(date);
dateScore.setScore(0.0f);
dateScore.setFontColor(BscScoreColorUtils.getFontColor(0.0f));
dateScore.setBgColor(BscScoreColorUtils.getBackgroundColor(0.0f));
dateScore.setImgIcon("");
kpi.getDateRangeScores().add(dateScore);
}
}
use of com.netsteadfast.greenstep.vo.DateRangeScoreVO in project bamboobsc by billchen198318.
the class AggregationMethod method averageDistinctDateRange.
public void averageDistinctDateRange(KpiVO kpi, String frequency) throws Exception {
BscReportSupportUtils.loadExpression();
for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
List<Float> scores = new ArrayList<Float>();
float score = 0.0f;
int size = 0;
for (BbMeasureData measureData : kpi.getMeasureDatas()) {
String date = dateScore.getDate().replaceAll("/", "");
if (!this.isDateRange(date, frequency, measureData)) {
continue;
}
BscMeasureData data = new BscMeasureData();
data.setActual(measureData.getActual());
data.setTarget(measureData.getTarget());
try {
Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
if (value == null) {
continue;
}
if (!NumberUtils.isNumber(String.valueOf(value))) {
continue;
}
float nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
if (!scores.contains(nowScore)) {
scores.add(nowScore);
score += nowScore;
size++;
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (score != 0.0f && size > 0) {
score = score / size;
}
dateScore.setScore(score);
dateScore.setFontColor(BscScoreColorUtils.getFontColor(score));
dateScore.setBgColor(BscScoreColorUtils.getBackgroundColor(score));
dateScore.setImgIcon(BscReportSupportUtils.getHtmlIcon(kpi, score));
}
}
use of com.netsteadfast.greenstep.vo.DateRangeScoreVO in project bamboobsc by billchen198318.
the class AggregationMethod method countDateRange.
public void countDateRange(KpiVO kpi, String frequency) throws Exception {
BscReportSupportUtils.loadExpression();
for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
float score = 0.0f;
int size = 0;
for (BbMeasureData measureData : kpi.getMeasureDatas()) {
String date = dateScore.getDate().replaceAll("/", "");
if (!this.isDateRange(date, frequency, measureData)) {
continue;
}
size++;
}
score = Float.valueOf(size);
dateScore.setScore(score);
dateScore.setFontColor(BscScoreColorUtils.getFontColor(score));
dateScore.setBgColor(BscScoreColorUtils.getBackgroundColor(score));
dateScore.setImgIcon(BscReportSupportUtils.getHtmlIcon(kpi, score));
}
}
use of com.netsteadfast.greenstep.vo.DateRangeScoreVO in project bamboobsc by billchen198318.
the class AggregationMethod method sumDistinctDateRange.
public void sumDistinctDateRange(KpiVO kpi, String frequency) throws Exception {
BscReportSupportUtils.loadExpression();
for (DateRangeScoreVO dateScore : kpi.getDateRangeScores()) {
List<Float> scores = new ArrayList<Float>();
float score = 0.0f;
//int size = 0;
for (BbMeasureData measureData : kpi.getMeasureDatas()) {
String date = dateScore.getDate().replaceAll("/", "");
if (!this.isDateRange(date, frequency, measureData)) {
continue;
}
BscMeasureData data = new BscMeasureData();
data.setActual(measureData.getActual());
data.setTarget(measureData.getTarget());
try {
Object value = BscFormulaUtils.parse(kpi.getFormula(), data);
if (value == null) {
continue;
}
if (!NumberUtils.isNumber(String.valueOf(value))) {
continue;
}
float nowScore = NumberUtils.toFloat(String.valueOf(value), 0.0f);
if (!scores.contains(nowScore)) {
scores.add(nowScore);
//size++;
score += nowScore;
}
} catch (Exception e) {
e.printStackTrace();
}
}
dateScore.setScore(score);
dateScore.setFontColor(BscScoreColorUtils.getFontColor(score));
dateScore.setBgColor(BscScoreColorUtils.getBackgroundColor(score));
dateScore.setImgIcon(BscReportSupportUtils.getHtmlIcon(kpi, score));
}
}
use of com.netsteadfast.greenstep.vo.DateRangeScoreVO in project bamboobsc by billchen198318.
the class KpiReportExcelCommand method createDateRange.
private int createDateRange(XSSFWorkbook wb, XSSFSheet sh, int row, VisionVO vision, Context context) throws Exception {
String frequency = (String) context.get("frequency");
String startYearDate = StringUtils.defaultString((String) context.get("startYearDate")).trim();
String endYearDate = StringUtils.defaultString((String) context.get("endYearDate")).trim();
String startDate = StringUtils.defaultString((String) context.get("startDate")).trim();
String endDate = StringUtils.defaultString((String) context.get("endDate")).trim();
String date1 = startDate;
String date2 = endDate;
if (BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency)) {
date1 = startYearDate + "/01/01";
date2 = endYearDate + "/12/" + SimpleUtils.getMaxDayOfMonth(Integer.parseInt(endYearDate), 12);
}
Map<String, Object> headContentMap = new HashMap<String, Object>();
this.fillHeadContent(context, headContentMap);
XSSFCellStyle cellStyleLabel = wb.createCellStyle();
cellStyleLabel.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(BscReportPropertyUtils.getBackgroundColor())));
cellStyleLabel.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFFont cellFontLabel = wb.createFont();
cellFontLabel.setBold(false);
cellFontLabel.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(BscReportPropertyUtils.getFontColor())));
cellStyleLabel.setFont(cellFontLabel);
cellStyleLabel.setWrapText(true);
//cellStyleLabel.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyleLabel.setBorderBottom(BorderStyle.THIN);
cellStyleLabel.setBorderTop(BorderStyle.THIN);
cellStyleLabel.setBorderRight(BorderStyle.THIN);
cellStyleLabel.setBorderLeft(BorderStyle.THIN);
int cols = 4 + vision.getPerspectives().get(0).getObjectives().get(0).getKpis().get(0).getDateRangeScores().size();
int cell = 0;
for (int i = 0; i < cols; i++) {
String content = "Frequency: " + BscMeasureDataFrequency.getFrequencyMap(false).get(frequency) + " Date range: " + date1 + " ~ " + date2 + "\n" + StringUtils.defaultString((String) headContentMap.get("headContent"));
Row headRow = sh.createRow(row);
headRow.setHeight((short) 700);
Cell headCell1 = headRow.createCell(cell);
headCell1.setCellValue(content);
headCell1.setCellStyle(cellStyleLabel);
}
sh.addMergedRegion(new CellRangeAddress(row, row, 0, cols - 1));
row++;
int kpiCols = 4;
int kpiRows = 2;
for (PerspectiveVO perspective : vision.getPerspectives()) {
for (ObjectiveVO objective : perspective.getObjectives()) {
for (KpiVO kpi : objective.getKpis()) {
cell = 0;
for (int r = 0; r < kpiRows; r++) {
Row contentRow = sh.createRow(row++);
contentRow.setHeight((short) 400);
for (int c = 0; c < kpiCols; c++) {
XSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(kpi.getBgColor())));
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFFont cellFont = wb.createFont();
cellFont.setBold(false);
cellFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(kpi.getFontColor())));
cellStyle.setFont(cellFont);
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
Cell contentCell1 = contentRow.createCell(c);
contentCell1.setCellValue(kpi.getName());
contentCell1.setCellStyle(cellStyle);
}
cell = 4;
if (r == 0) {
for (int d = 0; d < kpi.getDateRangeScores().size(); d++) {
DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(d);
XSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getBgColor())));
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFFont cellFont = wb.createFont();
cellFont.setBold(false);
cellFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getFontColor())));
cellStyle.setFont(cellFont);
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
Cell contentCell1 = contentRow.createCell(cell++);
contentCell1.setCellValue(dateRangeScore.getDate());
contentCell1.setCellStyle(cellStyle);
}
}
if (r == 1) {
for (int d = 0; d < kpi.getDateRangeScores().size(); d++) {
DateRangeScoreVO dateRangeScore = kpi.getDateRangeScores().get(d);
XSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getBgColor())));
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
XSSFFont cellFont = wb.createFont();
cellFont.setBold(false);
cellFont.setColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor(dateRangeScore.getFontColor())));
cellStyle.setFont(cellFont);
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
Cell contentCell1 = contentRow.createCell(cell++);
contentCell1.setCellValue(" " + BscReportSupportUtils.parse2(dateRangeScore.getScore()));
contentCell1.setCellStyle(cellStyle);
byte[] imgBytes = BscReportSupportUtils.getByteIcon(kpi, dateRangeScore.getScore());
if (null != imgBytes) {
SimpleUtils.setCellPicture(wb, sh, imgBytes, contentCell1.getRowIndex(), contentCell1.getColumnIndex());
}
}
}
}
sh.addMergedRegion(new CellRangeAddress(row - 2, row - 1, 0, kpiCols - 1));
}
}
}
return row++;
}
Aggregations