doum
7 天以前 074bcb8394fab66ce531c219e1e7de7c142ff2d5
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalWarningServiceImpl.java
@@ -22,6 +22,7 @@
import com.doumee.dao.business.model.YwElectricalRoom;
import com.doumee.dao.business.model.YwElectricalWarning;
import com.doumee.dao.business.model.YwRoom;
import com.doumee.dao.business.vo.WarningTypeStatVO;
import com.doumee.service.business.YwElectricalWarningService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
@@ -159,6 +160,38 @@
        return list;
    }
    @Override
    public List<WarningTypeStatVO> warningTypeStats() {
        QueryWrapper<YwElectricalWarning> wrapper = new QueryWrapper<>();
        wrapper.select("warning_def_id", "count(1) as cnt")
                .eq("isdeleted", Constants.ZERO)
                .eq("device_type", ELECTRICAL_DEVICE_TYPE)
                .isNotNull("warning_def_id")
                .groupBy("warning_def_id")
                .orderByDesc("cnt");
        List<Map<String, Object>> rows = ywElectricalWarningMapper.selectMaps(wrapper);
        List<WarningTypeStatVO> list = new ArrayList<>();
        if (CollectionUtils.isEmpty(rows)) {
            return list;
        }
        for (Map<String, Object> row : rows) {
            Object defIdObj = row.get("warning_def_id");
            if (defIdObj == null) {
                continue;
            }
            Integer warningDefId = Integer.parseInt(String.valueOf(defIdObj));
            Object cntObj = row.get("cnt");
            long count = cntObj == null ? 0L : Long.parseLong(String.valueOf(cntObj));
            WarningTypeStatVO stat = new WarningTypeStatVO();
            stat.setWarningDefId(warningDefId);
            stat.setCount(count);
            ElectronicConstant.warningDefId def = ElectronicConstant.warningDefId.getByKey(warningDefId);
            stat.setWarningName(def != null ? def.getName() : "未知报警");
            list.add(stat);
        }
        return list;
    }
    private MPJLambdaWrapper<YwElectricalWarning> buildPageQuery(PageWrap<YwElectricalWarning> pageWrap) {
        MPJLambdaWrapper<YwElectricalWarning> queryWrapper = new MPJLambdaWrapper<>();
        YwElectricalWarning model = pageWrap.getModel() == null ? new YwElectricalWarning() : pageWrap.getModel();