t5.sql 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. SELECT
  2. 0 as mr,
  3. CONCAT('uploads/thumbnail/',ep.`picpath`,'/',ep.`newpicname`) picpath,
  4. CONCAT('uploads/image/',ep.`picpath`,'/',ep.`newpicname`) srcpath,
  5. pr.partId id,
  6. pr.id prid,
  7. c.id contractId,c.bigId,pr.pastureId,c.pastureName,pr.partId,pr.partName,pr.partCode,pr.specification,
  8. TRIM(TRAILING'.' FROM (TRIM(TRAILING'0' FROM pr.price))) price,pr.brandId,pr.brand,c.inventoryType,
  9. c.planAmount,c.remark,c.enable,pr.unit,c.isZeroStock,
  10. trim(pr.`reportery`) reportery,
  11. pv.providerName,
  12. pv.id providerId,
  13. pr.locationId,
  14. pr.id partRepId
  15. FROM
  16. part_repertory pr
  17. LEFT JOIN contract c
  18. ON c.`id` = pr.`contractId`
  19. LEFT JOIN bigcontract bc
  20. ON bc.`id` = c.`bigId`
  21. LEFT JOIN provider pv
  22. ON pv.`id` = pr.`providerId`
  23. LEFT JOIN parts ps
  24. ON ps.id = pr.partId
  25. LEFT JOIN eq_pic ep
  26. ON ep.id = ps.picpath
  27. left join warehouse w
  28. on w.id = pr.locationId
  29. WHERE
  30. (pr.pastureId =31 or (pr.pastureId =18 and (select pastureId from warehouse where id = pr.`locationId`)= 31) )
  31. and
  32. (
  33. (
  34. (
  35. (bc.`stopTime`>=DATE_FORMAT(NOW(),'%Y-%m-%d') and bc.statue=1 AND c.`enable`=1 )
  36. or bc.isZeroStock=0 )
  37. and bc.SHStatus = 7)
  38. or pr.`contractId` <0
  39. )
  40. and (pr.reportery>0 or(bc.`stopTime`>=DATE_FORMAT(NOW(),'%Y-%m-%d') and bc.statue=1))
  41. -- and ps.enable = 1
  42. and (pr.`partCode` LIKE CONCAT('%','14.02.03.02.000013','%')
  43. )