|
@@ -1123,3 +1123,101 @@ select t.*,t2.countnum partKind from
|
|
|
)t
|
|
|
left join (SELECT bigid,COUNT(bigid) countnum FROM partlaid pl group by bigid )t2 on t.id =t2.bigid
|
|
|
ORDER by t.storageTime DESC,t.id desc;
|
|
|
+
|
|
|
+# select * from apisql where sqlname = 'getPartsListSG' 备件返回库存字段
|
|
|
+select * from ((
|
|
|
+SELECT
|
|
|
+ c.id contractId,
|
|
|
+ c.id,c.bigId,
|
|
|
+ c.pastureId,
|
|
|
+ c.pastureName,
|
|
|
+ c.partId,
|
|
|
+ c.partName,
|
|
|
+ c.partCode,
|
|
|
+ c.specification,
|
|
|
+ GROUP_CONCAT(c.`price`) price,
|
|
|
+ c.brandId,
|
|
|
+ c.brand,
|
|
|
+ c.unit,
|
|
|
+ c.brand brandName,
|
|
|
+ bc.providerId,
|
|
|
+ bc.providerName,
|
|
|
+ par.reportery -- 这次新加的内容
|
|
|
+FROM
|
|
|
+ contract c
|
|
|
+ inner JOIN bigcontract bc
|
|
|
+ ON bc.`id` = c.`bigId`
|
|
|
+ left join pasture_bigcontract pbt
|
|
|
+ on pbt.bigcontract_id = bc.id
|
|
|
+ join parts ps on ps.id = c.partid
|
|
|
+ join provider p on p.id = bc.providerid and ifnull(p.sapcode,0) > 0
|
|
|
+ join partuse par on par.contractId = c.id -- 这次新加的内容
|
|
|
+WHERE (bc.pastureId=? )
|
|
|
+ and (bc.`stopTime`>=DATE_FORMAT(NOW(),'%Y-%m-%d') and bc.statue=1 and bc.SHStatus = 7 )
|
|
|
+ and c.enable = 1 and ps.enable = 1
|
|
|
+ and (c.`partCode` LIKE CONCAT('%',?,'%')
|
|
|
+ OR c.`partName` LIKE CONCAT('%',?,'%')
|
|
|
+ OR c.`specification` LIKE CONCAT('%',?,'%')) and (bc.providerId = ? or ? = '')
|
|
|
+GROUP BY c.partCode)
|
|
|
+
|
|
|
+UNION ALL
|
|
|
+
|
|
|
+(SELECT
|
|
|
+c.id contractId,
|
|
|
+c.id,c.bigId,c.pastureId,c.pastureName,
|
|
|
+c.partId,c.partName,c.partCode,c.specification,
|
|
|
+GROUP_CONCAT(c.`price`) price,c.brandId,
|
|
|
+c.brand,c.unit,c.brand brandName,
|
|
|
+bc.providerId,bc.providerName,
|
|
|
+par.reportery -- 这次新加的内容
|
|
|
+FROM
|
|
|
+contract c
|
|
|
+ inner JOIN bigcontract bc
|
|
|
+ ON bc.`id` = c.`bigId`
|
|
|
+ left join pasture_bigcontract pbt
|
|
|
+ on pbt.bigcontract_id = bc.id
|
|
|
+ join parts ps on ps.id = c.partid join provider p
|
|
|
+ on p.id = bc.providerid and ifnull(p.sapcode,0) > 0
|
|
|
+ join partuse par on par.contractId = c.id -- 这次新加的内容
|
|
|
+WHERE (bc.pastureId=18)
|
|
|
+and ((select (
|
|
|
+CASE
|
|
|
+ WHEN ? IN (
|
|
|
+ select pasture_id from pasture_bigcontract where bigcontract_id in (
|
|
|
+
|
|
|
+ select id from bigcontract where contractCode in (
|
|
|
+
|
|
|
+ select TRIM(TRAILING '(' FROM TRIM(TRAILING '-' FROM LEFT(tem.contractCode,13))) contractCode from `bigcontract` tem
|
|
|
+ where tem.pastureId = 18 GROUP BY TRIM(TRAILING '(' FROM TRIM(TRAILING '-' FROM LEFT(tem.contractCode,13)))
|
|
|
+
|
|
|
+ )
|
|
|
+
|
|
|
+ ) GROUP BY pasture_id
|
|
|
+ ) and
|
|
|
+ #TRIM(TRAILING '(' FROM TRIM(TRAILING '-' FROM LEFT(bc.contractCode,13))) contractCode
|
|
|
+ # bc.contractCode "BJ0021090008-001"
|
|
|
+ (select TRIM(TRAILING '(' FROM TRIM(TRAILING '-' FROM LEFT(bc.contractCode,13))) contractCode)
|
|
|
+ in (select (select TRIM(TRAILING '(' FROM TRIM(TRAILING '-' FROM LEFT(bc.contractCode,13))) contractCode) from bigcontract bc where bc.id in (select bigcontract_id from pasture_bigcontract bp where bp.pasture_id = ?
|
|
|
+ #and bp.`enable` ="1"
|
|
|
+ )) THEN
|
|
|
+ 'Y'
|
|
|
+ ELSE
|
|
|
+ 'N'
|
|
|
+ END
|
|
|
+) ) = 'Y')
|
|
|
+#and (select `enable` from pasture_bigcontract where bigcontract_id = bc.id)=1
|
|
|
+#AND bc.`providerId` = ? AND bc.`stopTime`=? AND bc.`flag` =? AND bc.isZeroStock = ?
|
|
|
+#AND bc.statue =?
|
|
|
+#(bc.id in (
|
|
|
+#select bigcontract_id from pasture_bigcontract where pasture_id = ? and enable =1
|
|
|
+#) )
|
|
|
+#and ()
|
|
|
+and (bc.`stopTime`>=DATE_FORMAT(NOW(),'%Y-%m-%d') and bc.statue=1 and bc.SHStatus = 7 )
|
|
|
+and c.enable = 1 and ps.enable = 1
|
|
|
+#and c.`partCode`="04.03.01.01.021.02"
|
|
|
+#and (c.`partCode` LIKE CONCAT('%',"04.03.01.01.021.02",'%')
|
|
|
+and (c.`partCode` LIKE CONCAT('%',?,'%')
|
|
|
+OR c.`partName` LIKE CONCAT('%',?,'%')
|
|
|
+OR c.`specification` LIKE CONCAT('%',?,'%')) and (bc.providerId = ? or ? = '')
|
|
|
+GROUP BY c.partCode)) tem
|
|
|
+GROUP BY tem.partCode
|