t3.sql 1.3 KB

1234567891011121314151617181920212223242526272829
  1. select t.*, IFNULL(pr.`reportery`,0) reporteryQ
  2. from (
  3. SELECT
  4. CONCAT('uploads/thumbnail/',ep.`picpath`,'/',ep.`newpicname`) picpath,
  5. CONCAT('uploads/image/',ep.`picpath`,'/',ep.`newpicname`) srcpath,
  6. IFNULL(pr.`reportery`,0) reporteryQ,
  7. b.`brandName`,
  8. c.`id`,c.`brand`,c.`brandId`,c.`partCode`,c.`partId`,c.`partName`,c.`pastureId`,c.`pastureName`,
  9. TRIM(TRAILING '.' FROM (TRIM(TRAILING '0' FROM c.`price`))) price,
  10. c.`specification`,c.`unit`
  11. FROM
  12. contract c
  13. LEFT JOIN brand b ON b.id = c.brandId
  14. LEFT JOIN bigcontract bc ON bc.id = c.bigId
  15. LEFT JOIN bigcontract bc2 ON bc2.contractCode = left(bc.contractCode,12)
  16. join pasture_bigcontract pbt on pbt.bigcontract_id =bc2.id
  17. LEFT JOIN parts ps ON ps.id = c.partId
  18. LEFT JOIN eq_pic ep ON ep.id = ps.picpath
  19. WHERE bc.`providerId` = ? AND c.enable = 1
  20. AND (bc.`stopTime`>=DATE_FORMAT(NOW(),'%Y-%m-%d') and bc.statue=1 and bc.SHStatus = 7 )
  21. AND (if(?='' ,bc.SHStatus = 7,c.`partCode` LIKE CONCAT('%',?,'%')
  22. OR c.`partName` LIKE CONCAT('%',?,'%')
  23. OR c.`specification` LIKE CONCAT('%',?,'%')))
  24. and (bc.pastureId=? or ?='' or or pbt.pasture_id = ?)
  25. )t
  26. left join
  27. (select reportery,contractId from part_repertory pr2 left join warehouse w on pr2.locationId =w.id
  28. where pr2.pastureId ='631' or (pr2.pastureId =18 and w.pastureId = '?')
  29. ) pr ON pr.`contractId` = t.`id`