关于数据源为授权车辆、企业车辆的判断(限foton)

复制代码
int mode = carInfoService.getCompanyCarMode(companyId);

public int getCompanyCarMode(Long companyId) {
        String sql = "select t.id from iov_biz_car_info t join iov_biz_device d on d.iov_biz_car_info_id = t.id and d.is_primary = 1 where d.cbm_mag_company_id = ? and rownum = 1";
        List<Number> create = findBySQL(sql, new Object[] { companyId });
        sql = "select t.id from iov_biz_car_info t join iov_biz_device d on d.iov_biz_car_info_id = t.id and d.is_primary = 1 join iov_biz_l_car_info_company lc on lc.iov_biz_car_info_id =t.id where lc.cbm_mag_company_id = ? and rownum = 1";
        List<Number> link = findBySQL(sql, new Object[] { companyId });
        if (create.size() > 0 && link.size() < 1) {//本企业
            return 1;
        }
        if (create.size() < 1 && link.size() > 0) {//授权
            return 2;
        }
        return 0;
    }

objectList = getService().findCountGroupByProvince(companyId, companyIds, posIds, mode);

public List<Object[]> findCountByProvince(Long companyId, List<Long> companyIds, List<Long> posIds, int carMode) {
        Map<String, Object> params = Maps.newHashMap();
        StringBuilder hql = new StringBuilder();
        hql.append("select t.province, count(distinct t.id) as count from ");
        hql.append(Device.class.getName()).append(" t inner join t.carInfo t10 left join t10.companies t3 ");
        if (CollectionUtils.isNotEmpty(posIds)) {
            hql.append(" join t10.positions t2 ");
        }
        hql.append(" where 1=1 ");
        switch (carMode) {
        case 1:
            hql.append(" and t.company.id in (:companyIds) ");
            params.put("companyIds", companyIds);
            break;
        case 2:
            hql.append(" and t3.id =:companyId ");
            params.put("companyId", companyId);
            break;
        default:
            hql.append(" and (t.company.id in (:companyIds) or t3.id =:companyId)  ");
            params.put("companyId", companyId);
            params.put("companyIds", companyIds);
            break;
        }
        if (CollectionUtils.isNotEmpty(posIds)) {
            hql.append(" and t2.id in (:posIds) ");
            params.put("posIds", posIds);
        }
        hql.append(" and t.primary=1 group by t.province order by count(distinct t.id) desc");
        return findByNamedParam(hql.toString(), params);
    }
复制代码

 

posted @   蔡徐坤1987  阅读(174)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示