Search in sources :

Example 6 with TsaVO

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

the class TimeSeriesAnalysisUtils method getResultWithVision.

public static Map<String, Object> getResultWithVision(String tsaOid, String visionOid, String startDate, String endDate, String startYearDate, String endYearDate, String frequency, String dataFor, String measureDataOrganizationOid, String measureDataEmployeeOid) throws ServiceException, Exception {
    List<TimeSeriesAnalysisResult> results = new ArrayList<TimeSeriesAnalysisResult>();
    ChainResultObj chainResult = PerformanceScoreChainUtils.getResult(visionOid, startDate, endDate, startYearDate, endYearDate, frequency, dataFor, measureDataOrganizationOid, measureDataEmployeeOid);
    if (chainResult.getValue() == null || ((BscStructTreeObj) chainResult.getValue()).getVisions() == null || ((BscStructTreeObj) chainResult.getValue()).getVisions().size() == 0) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA));
    }
    TsaVO tsa = getParam(tsaOid);
    BscStructTreeObj resultObj = (BscStructTreeObj) chainResult.getValue();
    VisionVO visionObj = resultObj.getVisions().get(0);
    for (PerspectiveVO perspective : visionObj.getPerspectives()) {
        for (ObjectiveVO objective : perspective.getObjectives()) {
            for (KpiVO kpi : objective.getKpis()) {
                double[] observations = new double[kpi.getDateRangeScores().size()];
                for (int i = 0; i < observations.length; i++) {
                    observations[i] = Double.parseDouble(Float.toString(kpi.getDateRangeScores().get(i).getScore()));
                }
                double[] forecastNext = getForecastNext(tsa, observations);
                TimeSeriesAnalysisResult tsaModel = new TimeSeriesAnalysisResult(kpi, forecastNext);
                results.add(tsaModel);
            }
        }
    }
    Map<String, Object> dataMap = new HashMap<String, Object>();
    dataMap.put("vision", visionObj);
    dataMap.put("result", results);
    return dataMap;
}
Also used : ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) TsaVO(com.netsteadfast.greenstep.vo.TsaVO) TimeSeriesAnalysisResult(com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ChainResultObj(com.netsteadfast.greenstep.base.model.ChainResultObj) BscStructTreeObj(com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)

Example 7 with TsaVO

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

the class TsaManagementAction method fetchData.

private void fetchData() throws ServiceException, Exception {
    // ==========================================================================================
    // main
    this.tsa = new TsaVO();
    this.transformFields2ValueObject(this.tsa, "oid");
    DefaultResult<TsaVO> result = this.tsaService.findObjectByOid(this.tsa);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.tsa = result.getValue();
    // ==========================================================================================
    // ==========================================================================================
    // measure - freq
    this.measureFreq = new TsaMeasureFreqVO();
    this.measureFreq.setTsaOid(this.tsa.getOid());
    DefaultResult<TsaMeasureFreqVO> mfResult = this.tsaMeasureFreqService.findByUK(this.measureFreq);
    if (mfResult.getValue() == null) {
        throw new ServiceException(mfResult.getSystemMessage().getValue());
    }
    this.measureFreq = mfResult.getValue();
    this.measureFreq.setEmployeeOid("");
    if (!BscConstants.MEASURE_DATA_EMPLOYEE_FULL.equals(this.measureFreq.getEmpId()) && !StringUtils.isBlank(this.measureFreq.getEmpId())) {
        EmployeeVO employee = BscBaseLogicServiceCommonSupport.findEmployeeDataByEmpId(this.employeeService, this.measureFreq.getEmpId());
        this.measureFreq.setEmployeeOid(employee.getOid());
    }
    this.measureFreq.setOrganizationOid("");
    if (!BscConstants.MEASURE_DATA_ORGANIZATION_FULL.equals(this.measureFreq.getOrgId()) && !StringUtils.isBlank(this.measureFreq.getOrgId())) {
        OrganizationVO organization = new OrganizationVO();
        organization.setOrgId(this.measureFreq.getOrgId());
        DefaultResult<OrganizationVO> orgResult = this.organizationService.findByUK(organization);
        if (orgResult.getValue() != null) {
            this.measureFreq.setOrganizationOid(orgResult.getValue().getOid());
        }
    }
    this.getFields().put("measureFreqStartDate", "");
    this.getFields().put("measureFreqEndDate", "");
    this.getFields().put("measureFreqStartYearDate", this.measureFreq.getStartDateTextBoxValue());
    this.getFields().put("measureFreqEndYearDate", this.measureFreq.getEndDateTextBoxValue());
    if (BscMeasureDataFrequency.FREQUENCY_DAY.equals(measureFreq.getFreq()) || BscMeasureDataFrequency.FREQUENCY_WEEK.equals(measureFreq.getFreq()) || BscMeasureDataFrequency.FREQUENCY_MONTH.equals(measureFreq.getFreq())) {
        this.getFields().put("measureFreqStartDate", this.measureFreq.getStartDateTextBoxValue());
        this.getFields().put("measureFreqEndDate", this.measureFreq.getEndDateTextBoxValue());
        this.getFields().put("measureFreqStartYearDate", "");
        this.getFields().put("measureFreqEndYearDate", "");
    }
    //1-DEPT,2-EMP,3-Both
    this.getFields().put("measureFreqDataFor", "all");
    if ("1".equals(this.measureFreq.getDataType())) {
        this.getFields().put("measureFreqDataFor", "organization");
    }
    if ("2".equals(this.measureFreq.getDataType())) {
        this.getFields().put("measureFreqDataFor", "employee");
    }
    // ==========================================================================================
    // ==========================================================================================
    // coefficients
    this.coefficient1 = new TsaMaCoefficientsVO();
    this.coefficient2 = new TsaMaCoefficientsVO();
    this.coefficient3 = new TsaMaCoefficientsVO();
    this.coefficient1.setTsaOid(this.tsa.getOid());
    this.coefficient1.setSeq(1);
    this.coefficient2.setTsaOid(this.tsa.getOid());
    this.coefficient2.setSeq(2);
    this.coefficient3.setTsaOid(this.tsa.getOid());
    this.coefficient3.setSeq(3);
    DefaultResult<TsaMaCoefficientsVO> cResult1 = this.tsaMaCoefficientsService.findByUK(this.coefficient1);
    DefaultResult<TsaMaCoefficientsVO> cResult2 = this.tsaMaCoefficientsService.findByUK(this.coefficient2);
    DefaultResult<TsaMaCoefficientsVO> cResult3 = this.tsaMaCoefficientsService.findByUK(this.coefficient3);
    if (cResult1.getValue() == null) {
        throw new ServiceException(cResult1.getSystemMessage().getValue());
    }
    if (cResult2.getValue() == null) {
        throw new ServiceException(cResult2.getSystemMessage().getValue());
    }
    if (cResult3.getValue() == null) {
        throw new ServiceException(cResult3.getSystemMessage().getValue());
    }
    this.coefficient1 = cResult1.getValue();
    this.coefficient2 = cResult2.getValue();
    this.coefficient3 = cResult3.getValue();
// ==========================================================================================
}
Also used : EmployeeVO(com.netsteadfast.greenstep.vo.EmployeeVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) TsaMeasureFreqVO(com.netsteadfast.greenstep.vo.TsaMeasureFreqVO) TsaMaCoefficientsVO(com.netsteadfast.greenstep.vo.TsaMaCoefficientsVO) TsaVO(com.netsteadfast.greenstep.vo.TsaVO)

Aggregations

TsaVO (com.netsteadfast.greenstep.vo.TsaVO)7 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 TimeSeriesAnalysisResult (com.netsteadfast.greenstep.bsc.model.TimeSeriesAnalysisResult)3 ChainResultObj (com.netsteadfast.greenstep.base.model.ChainResultObj)2 BbTsaMaCoefficients (com.netsteadfast.greenstep.po.hbm.BbTsaMaCoefficients)2 TsaMaCoefficientsVO (com.netsteadfast.greenstep.vo.TsaMaCoefficientsVO)2 TsaMeasureFreqVO (com.netsteadfast.greenstep.vo.TsaMeasureFreqVO)2 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AppContext (com.netsteadfast.greenstep.base.AppContext)1 SimpleChain (com.netsteadfast.greenstep.base.chain.SimpleChain)1 BscStructTreeObj (com.netsteadfast.greenstep.bsc.model.BscStructTreeObj)1 DateRangeScoreVO (com.netsteadfast.greenstep.vo.DateRangeScoreVO)1 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)1 KpiVO (com.netsteadfast.greenstep.vo.KpiVO)1 ObjectiveVO (com.netsteadfast.greenstep.vo.ObjectiveVO)1 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)1 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)1 HashMap (java.util.HashMap)1