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);
}
Aggregations