Search in sources :

Example 1 with WorkFlowBuildHistoryCriteria

use of com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistoryCriteria in project tis by qlangtech.

the class DataxAction method doGetExecStatistics.

@Func(value = PermissionConstant.DATAX_MANAGE, sideEffect = false)
public void doGetExecStatistics(Context context) throws Exception {
    WorkFlowBuildHistoryCriteria historyCriteria = new WorkFlowBuildHistoryCriteria();
    Date from = ManageUtils.getOffsetDate(-7);
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd");
    Map<String, DataXExecStatus> execStatis = Maps.newTreeMap();
    ExecResult execResult = null;
    DataXExecStatus execStatus = null;
    String timeLab = null;
    for (int i = 0; i < 8; i++) {
        timeLab = dateFormat.format(ManageUtils.getOffsetDate(-i));
        execStatis.put(timeLab, new DataXExecStatus(timeLab));
    }
    int successCount = 0;
    int errCount = 0;
    historyCriteria.createCriteria().andAppIdEqualTo(this.getAppDomain().getAppid()).andCreateTimeGreaterThan(from);
    for (WorkFlowBuildHistory h : this.wfDAOFacade.getWorkFlowBuildHistoryDAO().selectByExample(historyCriteria)) {
        execResult = ExecResult.parse(h.getState());
        execStatus = execStatis.get(dateFormat.format(h.getCreateTime()));
        if (execStatus == null) {
            continue;
        }
        if (execResult == ExecResult.SUCCESS) {
            execStatus.successCount++;
            successCount++;
        } else if (execResult == ExecResult.FAILD) {
            execStatus.errCount++;
            errCount++;
        }
    }
    Map<String, Object> bizResult = Maps.newHashMap();
    bizResult.put("data", execStatis.values());
    Map<String, Integer> allStatis = Maps.newHashMap();
    allStatis.put("errCount", errCount);
    allStatis.put("successCount", successCount);
    bizResult.put("statis", allStatis);
    this.setBizResult(context, bizResult);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) WorkFlowBuildHistory(com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory) WorkFlowBuildHistoryCriteria(com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistoryCriteria) ExecResult(com.qlangtech.tis.assemble.ExecResult) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

JSONObject (com.alibaba.fastjson.JSONObject)1 ExecResult (com.qlangtech.tis.assemble.ExecResult)1 Func (com.qlangtech.tis.manage.spring.aop.Func)1 WorkFlowBuildHistory (com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistory)1 WorkFlowBuildHistoryCriteria (com.qlangtech.tis.workflow.pojo.WorkFlowBuildHistoryCriteria)1 SimpleDateFormat (java.text.SimpleDateFormat)1