zhangherong
2025-05-09 140248961e5f865d48e850f8d6b10e3338171283
lxzn-module-eam/src/main/java/org/jeecg/modules/eam/controller/EamDashboardController.java
@@ -8,6 +8,7 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.TranslateDictTextUtils;
import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
@@ -217,4 +218,33 @@
            return Result.error("数据转译失败!");
        }
    }
    @ApiOperation(value = "维修看板-故障类型统计", notes = "维修看板-故障类型统计")
    @GetMapping(value = "/faultTypeStatistics")
    public Result<?> faultTypeStatistics() {
        //统计今年来故障分类情况
        LocalDate today = LocalDate.now();
        LocalDate end = today.plusDays(1);
        //今年第一天
        LocalDate start = today.withDayOfYear(1);
        // 统计个数
        List<FaultTypeStatisticsVO> list = reportRepairService.faultTypeStatistics(start.toString(), end.toString());
        if (CollectionUtil.isEmpty(list)) {
            return Result.ok(Collections.emptyList());
        }
        List<JSONObject> items = new ArrayList<>();
        try {
            for (FaultTypeStatisticsVO vo : list) {
                String json = objectMapper.writeValueAsString(vo);
                JSONObject item = JSONObject.parseObject(json, Feature.OrderedField);
                translateDictTextUtils.translateField("faultType", vo.getFaultType(), item, "fault_reason_category");
                if (item.get("faultType" + CommonConstant.DICT_TEXT_SUFFIX) != null) {
                    items.add(item);
                }
            }
            return Result.OK(items);
        } catch (Exception e) {
            return Result.error("数据转译失败!");
        }
    }
}