Search in sources :

Example 1 with Statistic

use of com.eservice.api.model.dashboard.Statistic in project sinsim by WilsonHu.

the class DashboardController method getStatistics.

/**
 * @return 返回dashboard中用到的安装中、改拆单等数据信息
 */
@PostMapping("/getStatistic")
public Result getStatistics() {
    Statistic statistic = new Statistic();
    Condition condition = new Condition(Machine.class);
    condition.createCriteria().andCondition("status !=", Constant.MACHINE_INITIAL).andCondition("status !=", Constant.MACHINE_CONFIGURED).andCondition("status !=", Constant.MACHINE_CANCELED).andCondition("status !=", Constant.MACHINE_INSTALLED);
    List<Machine> machineList = machineService.findByCondition(condition);
    int installingNum = machineList.size();
    int changeNum = 0;
    int splitNum = 0;
    for (Machine item : machineList) {
        if (item.getStatus().equals(Constant.MACHINE_CHANGED)) {
            changeNum++;
        } else if (item.getStatus().equals(Constant.MACHINE_SPLITED)) {
            splitNum++;
        }
    }
    statistic.setInstallingMachineNum(installingNum);
    statistic.setChangeMachineNum(changeNum);
    statistic.setSplitMachineNum(splitNum);
    // 获取异常工序数量
    Condition taskRecordCondition = new Condition(TaskRecord.class);
    taskRecordCondition.createCriteria().andCondition("status >= ", Constant.TASK_INSTALL_ABNORMAL).andCondition("status <= ", Constant.TASK_QUALITY_ABNORMAL);
    List<TaskRecord> abnormalTaskRecordList = taskRecordService.findByCondition(taskRecordCondition);
    statistic.setAbnormalTaskNum(abnormalTaskRecordList.size());
    return ResultGenerator.genSuccessResult(statistic);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) TaskRecord(com.eservice.api.model.task_record.TaskRecord) Statistic(com.eservice.api.model.dashboard.Statistic) Machine(com.eservice.api.model.machine.Machine) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Statistic (com.eservice.api.model.dashboard.Statistic)1 Machine (com.eservice.api.model.machine.Machine)1 TaskRecord (com.eservice.api.model.task_record.TaskRecord)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 Condition (tk.mybatis.mapper.entity.Condition)1