jeecgboot多表联合查询

在数据大屏中需要多表联合查询的业务处理,而Jeecgboot提供的生成工具只能满足最普遍的简单代码,mybatis-plus框架使用的QueryWrapper显然无法满足多表联合查询,需要重写API接口。

1.新建返回对象的实体类

import lombok.Data;
@Data
public class Vendorcount {
    private Integer vendor;
    private Integer material;
}

2.mapper层接口

public interface VendorcountMapper extends BaseMapper<Vendorcount> {
    List<Vendorcount> pageByVendor();
}

3.xml中写入sql

<select id="pageByVendor" resultType="org.jeecg.modules.demo.vendorquery.entity.Vendorcount">
        select count(DISTINCT material13.Vendor) as vendor,count(DISTINCT material13.Material) as material
        from material13 INNER JOIN stock on material13.Vendor=stock.create_by and material13.Plant=stock.plant
        and material13.Material=stock.partno
</select>

4.service接口

public interface IVendorcountService extends IService<Vendorcount> {
    List<Vendorcount> pageByVendorService();
}

5.serviceImpl

@Service
public class VendorcountServiceImpl extends ServiceImpl<VendorcountMapper, Vendorcount> implements IVendorcountService {
    @Autowired
    private VendorcountMapper vendorcountMapper;

    @Override
    public List<Vendorcount> pageByVendorService() {
        return vendorcountMapper.pageByVendor();
    }
}

6.control层

@Api(tags = "供应商查询")
@RestController
@RequestMapping("/Vendorcount/vendorcount")
@Slf4j
public class VendorcountController extends JeecgController<Vendorcount, IVendorcountService> {
    @Autowired
    private IVendorcountService vendorcountService;
    @AutoLog(value = "供应商查询-统计个数")
    @ApiOperation(value = "供应商查询-统计个数", notes = "供应商查询-统计个数")
    @GetMapping(value = "/list")
    public Result<?> queryVendor(HttpServletRequest req) {
        List<Vendorcount> pageList = vendorcountService.pageByVendorService();
        return Result.ok(pageList);
    }
}

7.Shiro配置

// 配置不会被拦截的链接
filterChainDefinitionMap.put("/Vendorcount/vendorcount/**", "anon"); //

8.调试API接口

图片

9.前端定时调用接口刷新数据

getAction("/Vendorcount/vendorcount/list").then((res) => {
    if (res.success) {
      let a = res.result
      this.titleItem[0].number.number = [a[0]["material"]]
      this.titleItem[1].number.number = [a[0]["vendor"]]
      this.titleItem = {
        ...this.titleItem
      }
      this.show = false
      this.$nextTick(() => {
        this.show = true
      })

大屏展示

图片

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值