use of com.netsteadfast.greenstep.vo.TsaVO in project bamboobsc by billchen198318.
the class TimeSeriesAnalysisUtils method getResultForExcel.
public static String getResultForExcel(String tsaOid, String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
Map<String, Object> dataMap = getResultWithVision(tsaOid, visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
List<TimeSeriesAnalysisResult> tsaResults = (List<TimeSeriesAnalysisResult>) dataMap.get("result");
VisionVO vision = (VisionVO) dataMap.get("vision");
TsaVO tsa = getParam(tsaOid);
List<BbTsaMaCoefficients> coefficients = getCoefficients(tsa);
Context context = new ContextBase();
context.put("tsaResults", tsaResults);
context.put("tsa", tsa);
context.put("coefficients", coefficients);
// for show only.
context.put("visionName", vision.getTitle());
if (BscMeasureDataFrequency.FREQUENCY_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_HALF_OF_YEAR.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_QUARTER.equals(frequency)) {
context.put("date1", startYearDate);
context.put("date2", endYearDate);
} else {
context.put("date1", startDate);
context.put("date2", endDate);
}
context.put("frequencyName", BscMeasureDataFrequency.getFrequencyMap(false).get(frequency));
context.put("dataFor", dataFor);
context.put("organizationName", "");
context.put("employeeName", "");
if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataOrganizationOid) && !StringUtils.isBlank(measureDataOrganizationOid)) {
context.put("organizationName", BscBaseLogicServiceCommonSupport.findOrganizationData(organizationService, measureDataOrganizationOid).getName());
}
if (!Constants.HTML_SELECT_NO_SELECT_ID.equals(measureDataEmployeeOid) && !StringUtils.isBlank(measureDataEmployeeOid)) {
context.put("employeeName", BscBaseLogicServiceCommonSupport.findEmployeeData(employeeService, measureDataEmployeeOid).getFullName());
}
SimpleChain chain = new SimpleChain();
ChainResultObj resultObj = chain.getResultFromResource("timeSeriesAnalysisExcelCommandContentChain", context);
if (!(resultObj.getValue() instanceof String)) {
throw new java.lang.IllegalStateException("timeSeriesAnalysisExcelCommandContentChain error!");
}
return (String) resultObj.getValue();
}
use of com.netsteadfast.greenstep.vo.TsaVO in project bamboobsc by billchen198318.
the class TsaSaveOrUpdateAction method delete.
private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
TsaVO tsa = new TsaVO();
this.transformFields2ValueObject(tsa, new String[] { "oid" });
DefaultResult<Boolean> result = this.tsaLogicService.delete(tsa);
this.message = result.getSystemMessage().getValue();
if (result.getValue() != null && result.getValue()) {
this.success = IS_YES;
}
}
use of com.netsteadfast.greenstep.vo.TsaVO in project bamboobsc by billchen198318.
the class TsaSaveOrUpdateAction method saveOrUpdate.
private void saveOrUpdate(String type) throws ControllerException, AuthorityException, ServiceException, Exception {
this.checkFields();
TsaVO tsa = new TsaVO();
this.transformFields2ValueObject(tsa, new String[] { "name", "integrationOrder", "forecastNext", "description" }, new String[] { "name", "integration", "forecast", "description" });
this.getFields().remove("measureFreq_date1");
this.getFields().remove("measureFreq_date2");
this.getFields().remove("measureFreq_dateType");
String frequency = this.getFields().get("measureFreq_frequency");
if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_WEEK.equals(frequency) || BscMeasureDataFrequency.FREQUENCY_MONTH.equals(frequency)) {
this.getFields().put("measureFreq_date1", this.getFields().get("measureFreq_startDate"));
this.getFields().put("measureFreq_date2", this.getFields().get("measureFreq_endDate"));
} else {
this.getFields().put("measureFreq_date1", this.getFields().get("measureFreq_startYearDate"));
this.getFields().put("measureFreq_date2", this.getFields().get("measureFreq_endYearDate"));
}
String dataFor = this.getFields().get("measureFreq_dataFor");
this.getFields().put("measureFreq_dateType", "3");
if ("organization".equals(dataFor)) {
this.getFields().put("measureFreq_dateType", "1");
}
if ("employee".equals(dataFor)) {
this.getFields().put("measureFreq_dateType", "2");
}
TsaMeasureFreqVO measureFreq = new TsaMeasureFreqVO();
this.transformFields2ValueObject(measureFreq, new String[] { "freq", "dataType", "organizationOid", "employeeOid", "startDate", "endDate" }, new String[] { "measureFreq_frequency", "measureFreq_dateType", "measureFreq_measureDataOrganizationOid", "measureFreq_measureDataEmployeeOid", "measureFreq_date1", "measureFreq_date2" });
TsaMaCoefficientsVO coefficient1 = new TsaMaCoefficientsVO();
TsaMaCoefficientsVO coefficient2 = new TsaMaCoefficientsVO();
TsaMaCoefficientsVO coefficient3 = new TsaMaCoefficientsVO();
this.transformFields2ValueObject(coefficient1, new String[] { "seqValue" }, new String[] { "coefficient1" });
this.transformFields2ValueObject(coefficient2, new String[] { "seqValue" }, new String[] { "coefficient2" });
this.transformFields2ValueObject(coefficient3, new String[] { "seqValue" }, new String[] { "coefficient3" });
DefaultResult<TsaVO> result = null;
if ("save".equals(type)) {
result = this.tsaLogicService.create(tsa, measureFreq, coefficient1, coefficient2, coefficient3);
} else {
tsa.setOid(this.getFields().get("oid"));
result = this.tsaLogicService.update(tsa, measureFreq, coefficient1, coefficient2, coefficient3);
}
this.message = result.getSystemMessage().getValue();
if (result.getValue() != null) {
this.success = IS_YES;
}
}
use of com.netsteadfast.greenstep.vo.TsaVO in project bamboobsc by billchen198318.
the class TimeSeriesAnalysisExcelCommand method putTables.
private void putTables(XSSFWorkbook wb, XSSFSheet sh, Context context) throws Exception {
TsaVO tsa = (TsaVO) context.get("tsa");
@SuppressWarnings("unchecked") List<BbTsaMaCoefficients> coefficients = (List<BbTsaMaCoefficients>) context.get("coefficients");
@SuppressWarnings("unchecked") List<TimeSeriesAnalysisResult> tsaResults = (List<TimeSeriesAnalysisResult>) context.get("tsaResults");
XSSFFont cellHeadFont = wb.createFont();
cellHeadFont.setBold(true);
XSSFCellStyle cellHeadStyle = wb.createCellStyle();
cellHeadStyle.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#f5f5f5")));
cellHeadStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellHeadStyle.setBorderBottom(BorderStyle.THIN);
cellHeadStyle.setBorderTop(BorderStyle.THIN);
cellHeadStyle.setBorderRight(BorderStyle.THIN);
cellHeadStyle.setBorderLeft(BorderStyle.THIN);
cellHeadStyle.setFont(cellHeadFont);
XSSFCellStyle cellHeadStyleBlank = wb.createCellStyle();
cellHeadStyleBlank.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff")));
cellHeadStyleBlank.setFont(cellHeadFont);
XSSFCellStyle cellHeadStyle2 = wb.createCellStyle();
cellHeadStyle2.setFillForegroundColor(new XSSFColor(SimpleUtils.getColorRGB4POIColor("#ffffff")));
cellHeadStyle2.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cellHeadStyle2.setBorderBottom(BorderStyle.THIN);
cellHeadStyle2.setBorderTop(BorderStyle.THIN);
cellHeadStyle2.setBorderRight(BorderStyle.THIN);
cellHeadStyle2.setBorderLeft(BorderStyle.THIN);
sh.setColumnWidth(0, 12000);
int row = 0;
// ==============================================================
Row nowRow = sh.createRow(row);
Cell cellTitle = nowRow.createCell(0);
cellTitle.setCellStyle(cellHeadStyleBlank);
cellTitle.setCellValue("Forecast analysis - " + context.get("visionName"));
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell0a = nowRow.createCell(0);
cell0a.setCellStyle(cellHeadStyleBlank);
cell0a.setCellValue("Frequency: " + context.get("frequencyName") + " , Date range: " + context.get("date1") + " - " + context.get("date2") + " , " + "Measure data type for: " + context.get("dataFor") + " , " + context.get("organizationName") + context.get("employeeName"));
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell0b = nowRow.createCell(0);
cell0b.setCellStyle(cellHeadStyleBlank);
cell0b.setCellValue("");
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell1 = nowRow.createCell(0);
cell1.setCellStyle(cellHeadStyleBlank);
cell1.setCellValue("Param infornation");
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell2_a = nowRow.createCell(0);
cell2_a.setCellStyle(cellHeadStyle);
cell2_a.setCellValue("Item");
Cell cell2_b = nowRow.createCell(1);
cell2_b.setCellStyle(cellHeadStyle);
cell2_b.setCellValue("Value");
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell3_a = nowRow.createCell(0);
cell3_a.setCellStyle(cellHeadStyle2);
cell3_a.setCellValue("Param name");
Cell cell3_b = nowRow.createCell(1);
cell3_b.setCellStyle(cellHeadStyle2);
cell3_b.setCellValue(tsa.getName());
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell4_a = nowRow.createCell(0);
cell4_a.setCellStyle(cellHeadStyle2);
cell4_a.setCellValue("Integration order");
Cell cell4_b = nowRow.createCell(1);
cell4_b.setCellStyle(cellHeadStyle2);
cell4_b.setCellValue(tsa.getIntegrationOrder());
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell5_a = nowRow.createCell(0);
cell5_a.setCellStyle(cellHeadStyle2);
cell5_a.setCellValue("Forecast next");
Cell cell5_b = nowRow.createCell(1);
cell5_b.setCellStyle(cellHeadStyle2);
cell5_b.setCellValue(tsa.getForecastNext());
row++;
// ==============================================================
nowRow = sh.createRow(row);
Cell cell6_a = nowRow.createCell(0);
cell6_a.setCellStyle(cellHeadStyle2);
cell6_a.setCellValue("Description");
Cell cell6_b = nowRow.createCell(1);
cell6_b.setCellStyle(cellHeadStyle2);
cell6_b.setCellValue(StringUtils.defaultString(tsa.getDescription()).trim());
row++;
// ==============================================================
for (int i = 0; coefficients != null && i < coefficients.size(); i++) {
BbTsaMaCoefficients coefficient = coefficients.get(i);
nowRow = sh.createRow(row);
Cell cell7x_a = nowRow.createCell(0);
cell7x_a.setCellStyle(cellHeadStyle2);
cell7x_a.setCellValue("Coefficient (" + (i + 1) + ")");
Cell cell7x_b = nowRow.createCell(1);
cell7x_b.setCellStyle(cellHeadStyle2);
cell7x_b.setCellValue(String.valueOf(coefficient.getSeqValue()));
row++;
}
// ==============================================================
nowRow = sh.createRow(row);
Cell cellTitle3a = nowRow.createCell(0);
cellTitle3a.setCellStyle(cellHeadStyleBlank);
cellTitle3a.setCellValue("");
row++;
// 填寫標題
nowRow = sh.createRow(row);
Cell cellTitle2a = nowRow.createCell(0);
cellTitle2a.setCellStyle(cellHeadStyle);
cellTitle2a.setCellValue("KPIs");
int j = 1;
TimeSeriesAnalysisResult firstResult = tsaResults.get(0);
for (int i = 0; i < firstResult.getKpi().getDateRangeScores().size(); i++) {
DateRangeScoreVO dateRangeScore = firstResult.getKpi().getDateRangeScores().get(i);
Cell cellTitle2a_dateRange = nowRow.createCell(j);
j++;
cellTitle2a_dateRange.setCellStyle(cellHeadStyle);
cellTitle2a_dateRange.setCellValue(dateRangeScore.getDate());
}
for (int i = 0; i < firstResult.getForecastNext().size(); i++) {
Cell cellTitle2a_dateRange = nowRow.createCell(j);
j++;
cellTitle2a_dateRange.setCellStyle(cellHeadStyle);
cellTitle2a_dateRange.setCellValue("next(" + (i + 1) + ")");
}
row++;
// 填寫 Date Range score 與 Forecast next score
for (int i = 0; i < tsaResults.size(); i++) {
nowRow = sh.createRow(row);
j = 0;
TimeSeriesAnalysisResult resultModel = tsaResults.get(i);
Cell cell_kpi = nowRow.createCell(j);
cell_kpi.setCellStyle(cellHeadStyle);
cell_kpi.setCellValue(resultModel.getKpi().getName());
j++;
for (int n = 0; n < resultModel.getKpi().getDateRangeScores().size(); n++) {
DateRangeScoreVO dateRangeScore = resultModel.getKpi().getDateRangeScores().get(n);
Cell cell_dateRangeScore = nowRow.createCell(j);
cell_dateRangeScore.setCellStyle(cellHeadStyle2);
cell_dateRangeScore.setCellValue(dateRangeScore.getScore());
j++;
}
for (int n = 0; n < resultModel.getForecastNext().size(); n++) {
double forecastScore = resultModel.getForecastNext().get(n);
Cell cell_forecastScore = nowRow.createCell(j);
cell_forecastScore.setCellStyle(cellHeadStyle2);
cell_forecastScore.setCellValue(forecastScore);
j++;
}
row++;
}
}
use of com.netsteadfast.greenstep.vo.TsaVO in project bamboobsc by billchen198318.
the class TimeSeriesAnalysisUtils method getParam.
public static TsaVO getParam(String tsaOid) throws ServiceException, Exception {
if (StringUtils.isBlank(tsaOid)) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
}
TsaVO tsa = new TsaVO();
tsa.setOid(tsaOid);
DefaultResult<TsaVO> result = tsaService.findObjectByOid(tsa);
if (result.getValue() == null) {
throw new ServiceException(result.getSystemMessage().getValue());
}
tsa = result.getValue();
return tsa;
}
Aggregations