码迷,mamicode.com
首页 > 其他好文 > 详细

ORM 多表查询 CreateQueryBuilder

时间:2021-03-04 13:11:51      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:col   card   ice   inf   net   list   sig   div   inner   

let fieldStr = `
      DENSE_RANK() OVER(order by W.wayBillCode) as 序号,  W.expressCode as 分运单号, CASE WHEN  P.CIQNameCn IS NULL THEN K.ProductName  ELSE P.CIQNameCn END AS 货物品名,
        CASE WHEN P.BrandName IS NULL THEN K.BrandName ELSE P.BrandName END AS 品牌, 1 AS 件数,
          (Case when P.TypeName = 奶粉 THEN(L.QuantityOrder * 1.2) ELSE(CASE WHEN P.Weight IS NULL THEN K.Weight ELSE P.Weight end) * L.QuantityOrder  END) AS 毛重(提单重量),
            (L.QuantityOrder * 1.2) - 0.1 AS 净重(实际重量),
              (CASE WHEN P.TypeName = 鞋靴 THEN(P.DeclareQuantityOrder * L.QuantityOrder)
      WHEN P.TypeName = 奶粉 THEN((CASE WHEN P.NetWeight IS NULL THEN K.NetWeight ELSE P.NetWeight end) * L.QuantityOrder) ELSE(L.QuantityOrder) END) AS 数量,
        L.QuantityOrder as 实际数量, CASE WHEN P.DeclareUnit IS NULL THEN  K.DeclareUnit ELSE P.DeclareUnit END AS 单位,
          RMB AS 货币编码, P.DeclarePrice as 单价, CASE WHEN  P.PostMailCode IS NULL THEN K.PostMailCode ELSE P.PostMailCode END AS 个人完税税号, CASE WHEN  P.ProductSpec IS NULL THEN K.ProductSpec ELSE P.ProductSpec END AS 型号, 601 AS 国别代码, 澳大利亚 AS 原产国,
            CASE WHEN P.HSCode IS NULL THEN K.HSCode ELSE P.HSCode END AS HS编码, W.ConsigneeIdcard as 收件人ID, W.consigneeName as 收件人,
            REPLACE(REPLACE(REPLACE( REPLACE(REPLACE( W.consigneeAddress,中国,‘‘),北京市北京市,北京市),上海市上海市,上海市),天津市天津市,天津市),重庆市重庆市,重庆市) as 地址,
              W.consigneeMobile as 收件人电话, 
              REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( W.provinceName,,‘‘),,‘‘),维吾尔自治区,‘‘),特别行政区,‘‘),壮族自治区,‘‘),回族自治区,‘‘),中国,‘‘),自治区,‘‘) AS TO,
               W.expressCode as 落地配单号, AUOD PTY LTD as 寄件人公司, AUOD AS 寄件人, auburn AS 寄件人地址, 0061287103969 AS 寄件人电话, SYD AS FROM,
               REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( W.provinceName,,‘‘),,‘‘),维吾尔自治区,‘‘),特别行政区,‘‘),壮族自治区,‘‘),回族自治区,‘‘),中国,‘‘),自治区,‘‘) as 货主城市`;
   let   fields = fieldStr.split(",");
      where.portName = "福州口岸";
      let wayBillBgList: Array<any> = await this.dbRead
        .createQueryBuilder(TMSWayBill, "W")
        .select(fields)
        .innerJoin("TMSWayBillList", "L", "W.wayBill_Id = L.wayBill_Id")
        .leftJoin("BaseProductInfo", "K", "L.product_Id = K.product_Id")
        .leftJoin("TMSProductInfoPort", "P", "L.product_Id = P.product_Id And W.port_Id=P.port_Id")
        .where(where)
        .take(5000)
        .andWhere("W.portName = ‘福州口岸‘ AND W.port_Id = 5")
        .getRawMany();

 

ORM 多表查询 CreateQueryBuilder

标签:col   card   ice   inf   net   list   sig   div   inner   

原文地址:https://www.cnblogs.com/lvqianqian/p/14476041.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!