t4.sql 1.4 KB

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