s.sql 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. select sqlname,sqlstr,params from apisql where
  2. -- 申购
  3. sqlname ='getPartsListSG'
  4. -- 入库
  5. sqlname ='insertPartRepertory' -- (手动,调拨)
  6. or sqlname ='getPartListByProvider' -- 手动入库备件列表(已修复)
  7. or sqlname ='getWarehouseListByProvider' -- 手动入库库位列表
  8. or sqlname ='getTransferCodeRK' -- 调拨单列表
  9. -- 出库
  10. or sqlname ='insertPartUseRepertory' -- (手动、报废、领用)
  11. or sqlname ='updatePartUseRepertory' -- (调拨)
  12. or sqlname ='getPartsListCK' -- 手动、报废备件列表
  13. or sqlname ='getPartsListLY' -- 调拨、领用(维修、保养)备件列表(已修改)
  14. -- 退货
  15. or sqlname ='getPartsListTH' -- 退货备件列表 (已修改)
  16. or sqlname ='updatePartRepertoryTHS' -- (已修改)
  17. -- 退库(选出库单)
  18. or sqlname ='updatePartRepertoryTK' --(还需要前端 修改参数)
  19. -- sqlname ='insertBigPartquit'
  20. -- or sqlname ='insertPartquit'
  21. -- or sqlname ='updatePartUseQuit'
  22. select sqlname,sqlstr,params from apisql where sqlname ='getPartsListLY';
  23. select sqlname,sqlstr,params from apisql where sqlname ='getPartsListLY_m'
  24. select sqlname,sqlstr,params from apisql where sqlname ="insertBigPartTransfer";
  25. select sqlname,sqlstr,params from apisql where sqlname ="getWarehouselistDB";
  26. select sqlname,sqlstr,params from apisql where sqlname ="getBigpartapplyList";
  27. select sqlname,sqlstr,params from apisql where sqlname ="updatePartapplyuseAmount_m";
  28. select sqlname,sqlstr,params from apisql where sqlname ="autoCreatCode";
  29. select sqlname,sqlstr,params from apisql where sqlname ='insertBigpartapply';
  30. select sqlname,sqlstr,params from apisql where sqlname ='insertpartapply_m';
  31. select sqlname,sqlstr,params from apisql where sqlname ='insertpartapply'
  32. select sqlname,sqlstr,params from apisql where sqlname ='getBigpartusecode'
  33. select sqlname,sqlstr,params from apisql where sqlname ='getpartUseListBybigTK'
  34. select sqlname,sqlstr,params from apisql where sqlname ='getUserPCButtons'
  35. select sqlname,sqlstr,params from apisql where sqlname ='updatePartUseQuit'
  36. select sqlname,sqlstr,params from apisql where sqlname ='updatePartRepertoryTK'
  37. select sqlname,sqlstr,params from apisql where sqlname ='updateBigPartTransfer'
  38. select sqlname,sqlstr,params from apisql where sqlname ='getbuydetailList'
  39. select sqlname,sqlstr,params from apisql where sqlname ='getPartListByProvider'
  40. select sqlname,sqlstr,params from apisql where sqlname ='insertPartUseRepertory'
  41. select sqlname,sqlstr,params from apisql where sqlname ='insertBigPartTransfer'
  42. select sqlname,sqlstr,params from apisql where sqlname ='insertContractV2'
  43. select sqlname,sqlstr,params from apisql where sqlname ='getbuydetailListbyBig'
  44. select sqlname,sqlstr,params from apisql where sqlname ='getWXworkMsg'
  45. select sqlname,sqlstr,params from apisql where sqlname ='getNoMesList'
  46. select sqlname,sqlstr,params from apisql where sqlname ='getNoMesCount'
  47. update apisql set sqlname='getNoMesList_bk' where sqlname ='getNoMesList';
  48. update apisql set sqlname='getNoMesCount_bk' where sqlname ='getNoMesCount';
  49. select pr.partcode ,c.partcode code2 ,p.name,pr.location,bc.contractCode,t.id tid from part_repertory pr
  50. join warehouse w on w.id = pr.locationId
  51. join pasture p on p.id =w.pastureid
  52. join contract c on pr.contractId = c.id
  53. join bigcontract bc on bc.id =c.bigid
  54. join (select bc.contractCode,c.partcode ,c.id from contract c join bigcontract bc on bc.id =c.bigid)t
  55. on pr.partcode =t.partcode and bc.contractCode =t.contractCode
  56. where pr.contractId = 643094
  57. and pr.locationid=29126
  58. select pr.partcode ,c.partcode code2 ,c.id,p.name,pr.location,bc.contractCode,bc.id from part_repertory pr
  59. join warehouse w on w.id = pr.locationId
  60. join pasture p on p.id =w.pastureid
  61. join contract c on pr.partcode = c.partcode
  62. join bigcontract bc on bc.id =c.bigid
  63. where pr.contractId = 643094
  64. and pr.locationid=29126
  65. (备件查询接口已修改,并删除库位信息返回值)
  66. call updatePartRepertoryTHS(?)
  67. call updatePartRepertoryTHS(?)
  68. show create procedure updatePartRepertoryTHS
  69. show create procedure updatePartRepertoryTHS
  70. update apisql set params ="quitNumber,contractId,locationId,partCode",
  71. sqlstr="UPDATE part_repertory SET reportery = reportery + ? WHERE contractId = ? AND locationId = ? and partCode =?"
  72. where sqlname ='updatePartRepertoryTK'
  73. update apisql set params ="quitNumber,contractId,locationId",
  74. sqlstr="UPDATE part_repertory SET reportery = reportery + ? WHERE contractId = ? AND locationId = ? limit 1"
  75. where sqlname ='updatePartRepertoryTK'
  76. UPDATE part_repertory SET reportery = reportery + ? WHERE contractId = ? AND locationid = ? and partcode =?
  77. | quitNumber,price,quitNumber,quitNumber,contractId,location |
  78. show create procedure createBuydetailBySG;
  79. select p.* from partquit p join bigpartquit bp on p.bigid =bp.id
  80. where bp.useform ='CK56220923012'
  81. describe bigpartrefund
  82. select count(*) from bigpartrefund where pastureid =18
  83. select * from warehouse
  84. select pr.partcode ,c.partcode code2 ,p.name,pr.location,bc.contractCode from part_repertory pr
  85. join warehouse w on w.id = pr.locationId
  86. join pasture p on p.id =w.pastureid
  87. join contract c on pr.contractId = c.id
  88. join bigcontract bc on bc.id =c.bigid
  89. where contractId = 643094
  90. and locationid=29126
  91. and partcode ='14.02.15.07.000258'
  92. SELECT sqlstr,params FROM apisql WHERE sqlname = 'syncEASPpartlaid' limit 1
  93. select sapstatus ,count(*) from bigparttransfer group by sapstatus
  94. select statue,sapstatus from bigparttransfer where statue=1 and SapStatus=0 CreatDate >'2022-09-28'
  95. select * from parts where 1=1 and if('14.01.01.01.000002'='',1=1,'14.01.01.01.000002'=partcode) limit 10;
  96. alter table bigbuydetail add index(buyerDate);
  97. alter table bigbuydetail add index(buyerPerson);
  98. alter table bigbuydetail add index(providerId);
  99. alter table bigbuydetail add index(pastureId);
  100. alter table bigbuydetail drop index buyerDate_2;
  101. alter table bigbuydetail drop index buyerPerson_2;
  102. alter table bigbuydetail drop index providerId_2;
  103. alter table bigbuydetail drop index pastureId_2;
  104. drop index(buyerDate_2) on bigbuydetail;
  105. drop index(buyerPerson_2) on bigbuydetail;
  106. drop index(providerId_2) on bigbuydetail;
  107. drop index(pastureId_2) on bigbuydetail;
  108. select buye from bigbuydetail order by buyerDate limti 100;
  109. select count(*) from bigbuydetail buyerDate >'2022--09-22'
  110. show index from bigbuydetail
  111. providerName,providerName,
  112. partName,partName,
  113. partCode,partCode,
  114. isStorage,isStorage,
  115. matchCode,matchCode,
  116. buyeCode,buyeCode,
  117. startTime,startTime,
  118. stopTime,stopTime
  119. (pa.name=? or ?='现代牧业') AND
  120. (? ='' or ?=p.providerName)
  121. AND ('陕西合力' =''or '陕西合力'=p.providerName)
  122. AND if (? ='',1=1,?=ps.name)
  123. AND if (? ='',1=1,?=bd.partcode)
  124. AND if (? ='',1=1,?=bd.isStorage)
  125. AND if (? ='',1=1,?=bbd.matchCode)
  126. AND if (? ='',1=1,?=bbd.buyeCode)
  127. AND if (? ='',1=1,bbd.`buyerDate` >= ?)
  128. AND if (? ='',1=1,bbd.`buyerDate` <= ?)
  129. select * from provider where providerName = '北京京东'
  130. alter table bigparttransfer add column group varchar(100) default ''
  131. alter table bigparttransfer add column groupName varchar(100) default ''
  132. select bd.id, bd.partcode,bbd.buyeCode from bigbuydetail bbd join buydetail bd on bd.bigid =bbd.id where bbd.buyeCode ='CG08220924024'
  133. 14.01.01.02.000093
  134. select * from partapply where note ='test0930'
  135. alter table contract add column taxcode varchar(100) default ''
  136. (
  137. select contractid ,count(*)c from part_repertory group by contractid
  138. having count(*)>1
  139. )t
  140. select * from part_repertory pr
  141. join (
  142. select partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price
  143. having count(*)>1
  144. )t on
  145. pr.partCode= t.partCode,
  146. pr.locationId= t.locationId,
  147. pr.contractId= t.contractId,
  148. pr.providerId= t.providerId,
  149. pr.price= t.price
  150. limit 10
  151. select count(*) from (
  152. select partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price
  153. having count(*)>1
  154. )a
  155. select pr.id, pr.partcode ,pr.contractId ,c.id ,c.partcode,c2.id,c2.partcode
  156. from part_repertory pr
  157. left join contract c on c.id =pr.contractId
  158. left join contract c2 on c2.partcode = pr.partcode
  159. join bigcontract bc on bc.id =c2.bigid
  160. where pr.providerId = bc.providerId and pr.brandid =c2.brandid and pr.price =c2.price
  161. and c.partcode <>c2.partcode
  162. delete pr from part_repertory pr
  163. left join contract c on c.id =pr.contractId
  164. left join contract c2 on c2.partcode = pr.partcode
  165. join bigcontract bc on bc.id =c2.bigid
  166. set pr.contractId = c2.id
  167. where pr.providerId = bc.providerId and pr.brandid =c2.brandid and pr.price =c2.price
  168. and c.partcode <>c2.partcode
  169. where pr.reportery <0
  170. insert index part_repertory4 (
  171. select * part_repertory from part_repertory where reportery <0
  172. )
  173. delete from part_repertory where reportery <0
  174. insert into part_repertory3
  175. (
  176. select pr.*
  177. from part_repertory pr
  178. left join contract c on c.id =pr.contractId
  179. left join contract c2 on c2.partcode = pr.partcode
  180. join bigcontract bc on bc.id =c2.bigid
  181. where pr.providerId = bc.providerId and pr.brandid =c2.brandid and pr.price =c2.price
  182. and c.partcode <>c2.partcode
  183. )a
  184. select partcode ,count(*) from parts group by partCode having count(*) > 1
  185. select contractid ,count(*)c from part_repertory group by contractid having count(*)>1
  186. select pr.id
  187. from part_repertory pr
  188. left join contract c on c.id =pr.contractId
  189. left join contract c2 on c2.partcode = pr.partcode
  190. join bigcontract bc on bc.id =c2.bigid
  191. where pr.providerId = bc.providerId and pr.brandid =c2.brandid and pr.price =c2.price
  192. and c.partcode <>c2.partcode
  193. group by pr.id
  194. having count(*) >1
  195. CREATE TABLE `part_repertory` (
  196. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
  197. `pastureId` int(11) NOT NULL COMMENT '牧场主键',
  198. `partId` int(11) DEFAULT NULL COMMENT '设备主键',
  199. `partName` varchar(100) DEFAULT NULL,
  200. `partCode` varchar(100) DEFAULT NULL,
  201. `specification` varchar(100) DEFAULT NULL COMMENT '规格',
  202. `location` varchar(100) DEFAULT NULL COMMENT '位置',
  203. `locationId` int(11) NOT NULL,
  204. `reportery` decimal(10,2) DEFAULT NULL COMMENT '库存',
  205. `minRepertory` decimal(11,0) NOT NULL DEFAULT 0 COMMENT '最低库存',
  206. `maxRepertory` decimal(11,0) NOT NULL DEFAULT 10 COMMENT '最高库存',
  207. `contractId` bigint(50) NOT NULL,
  208. `providerId` int(11) DEFAULT NULL,
  209. `providerNames` varchar(100) DEFAULT NULL,
  210. `brand` varchar(100) DEFAULT NULL COMMENT '品牌',
  211. `brandId` int(11) NOT NULL,
  212. `unit` varchar(20) DEFAULT NULL COMMENT '单位',
  213. `price` decimal(15,5) NOT NULL COMMENT '单价',
  214. `enable` tinyint(4) DEFAULT NULL,
  215. `precontractId` varchar(50) DEFAULT NULL,
  216. PRIMARY KEY (`id`),
  217. UNIQUE KEY `pastureId` (`partCode`,`precontractId`,`locationId`),
  218. KEY `partcode` (`partCode`,`locationId`,`contractId`,`providerId`,`price`),
  219. KEY `contractId_2` (`contractId`)
  220. ) ENGINE=InnoDB AUTO_INCREMENT=587463 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC
  221. alter table part_repertory add UNIQUE index (`partCode`,`locationId`,`contractId`,`providerId`,`price`)
  222. delete pr from part_repertory pr
  223. join
  224. (select group_concat(id,',') gid,partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price having count(*)>1
  225. )t on
  226. pr.partCode= t.partCode and
  227. pr.locationId= t.locationId and
  228. pr.contractId= t.contractId and
  229. pr.providerId= t.providerId and
  230. pr.price= t.price
  231. select pr.* from part_repertory pr join
  232. (
  233. select pr.id ,
  234. rank() over (partition by pr.partCode,
  235. pr.locationId,
  236. pr.contractId,
  237. pr.providerId,
  238. pr.price order by id) as Ranking
  239. from part_repertory pr
  240. join
  241. (select partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price having count(*)>1
  242. )t on
  243. pr.partCode= t.partCode and
  244. pr.locationId= t.locationId and
  245. pr.contractId= t.contractId and
  246. pr.providerId= t.providerId and
  247. pr.price= t.price
  248. )t2 on pr.id =t2.id
  249. where t2.Ranking >1
  250. select pr.*
  251. from part_repertory pr
  252. join
  253. (select partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price having count(*)>1
  254. )t on
  255. pr.partCode= t.partCode and
  256. pr.locationId= t.locationId and
  257. pr.contractId= t.contractId and
  258. pr.providerId= t.providerId and
  259. pr.price= t.price
  260. delete pr from part_repertory pr join
  261. (
  262. select pr.id ,
  263. rank() over (partition by pr.partCode,
  264. pr.locationId,
  265. pr.contractId,
  266. pr.providerId,
  267. pr.price order by id) as Ranking
  268. from part_repertory pr
  269. join
  270. (select partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price having count(*)>1
  271. )t on
  272. pr.partCode= t.partCode and
  273. pr.locationId= t.locationId and
  274. pr.contractId= t.contractId and
  275. pr.providerId= t.providerId and
  276. pr.price= t.price
  277. )t2 on pr.id =t2.id
  278. where t2.Ranking >1
  279. select partCode,locationId,contractId,providerId,price,reportery from part_repertory4 where reportery 0
  280. select pr.* from part_repertory pr join (
  281. select sum(reportery)c,partCode,locationId,contractId,providerId,price from part_repertory4
  282. where reportery <0
  283. group by partCode,locationId,contractId,providerId,price
  284. )t on
  285. pr.partCode= t.partCode and
  286. pr.locationId= t.locationId and
  287. pr.contractId= t.contractId and
  288. pr.providerId= t.providerId and
  289. pr.price= t.price
  290. update part_repertory pr join (
  291. select sum(reportery)c,partCode,locationId,contractId,providerId,price from part_repertory4
  292. where reportery <0
  293. group by partCode,locationId,contractId,providerId,price
  294. )t on
  295. pr.partCode= t.partCode and
  296. pr.locationId= t.locationId and
  297. pr.contractId= t.contractId and
  298. pr.providerId= t.providerId and
  299. pr.price= t.price
  300. set pr.reportery =pr.reportery+t.c
  301. SELECT pr.contractid,sum(pu.checkoutNumber) sumuse
  302. FROM part_repertory pr
  303. join warehouse w on w.id = pr.locationId
  304. left join partuse pu on pr.contractId =pu.contractId and pr.locationId = pu.locationId
  305. group by pr.contractId
  306. select pr.id ,
  307. rank() over (partition by pr.partCode,
  308. pr.locationId,
  309. pr.contractId,
  310. pr.providerId,
  311. pr.price order by id) as Ranking
  312. from part_repertory pr
  313. join
  314. (select partCode,locationId,contractId,providerId,price from part_repertory group by partCode,locationId,contractId,providerId,price having count(*)>1
  315. )t on
  316. pr.partCode= t.partCode and
  317. pr.locationId= t.locationId and
  318. pr.contractId= t.contractId and
  319. pr.providerId= t.providerId and
  320. pr.price= t.price
  321. select * from role where name ='系统管理员'
  322. select * from role_menu where role_id=44
  323. delete from role_menu where role_id=44
  324. select * from bigpartuse where id =669407
  325. select * from bigpartuse where id =669407
  326. select * from partuse where bigid =669407
  327. select trim( TRAILING '.' from (TRAILING '0' FROM 3.10))
  328. select trim( TRAILING '.' from 3.10)
  329. select CAST('123.12' as DECIMAL)
  330. UPDATE part_repertory SET reportery = reportery + '1' WHERE contractId = 497108 AND locationid = 10559 and partcode ="14.01.07.01.001030"
  331. select pa.* from bigpartapply bpa join partapply pa on pa.bigid =bpa.id where bpa.applycode ='LY19221008018'
  332. select id from bigpartapply order by id desc limit 5
  333. select count(*) from partapply
  334. select * from partapply where bigid =210605
  335. select * from partapply where bigid ='BX19220929004'
  336. select * from partapply where bigid =419328
  337. select * from parts where partcode ='14.02.03.02.000013'
  338. select pr.partcode, pr.contractId,pr.reportery,pr.pastureid,p.name from part_repertory pr
  339. left join warehouse w on pr.locationid = w.id
  340. left join pasture p on w.pastureId =p.id
  341. where pr.id =488222
  342. select * from contract where id =521518
  343. update part_repertory pr
  344. left join warehouse w on pr.locationid = w.id
  345. left join pasture p on w.pastureId =p.id
  346. set pr.contractId =-pr.contractId
  347. where pr.id =488222
  348. CK56221002011-17
  349. SELECT pr.*
  350. FROM part_repertory pr
  351. join warehouse w on w.id = pr.locationId
  352. left join partuse pu on pr.contractId =pu.contractId and pr.locationId = pu.locationId
  353. join bigpartuse bpu on bpu.id =pu.bigid
  354. where bpu.useform ='CK56221002011'
  355. group by pr.contractId,w.pastureid
  356. select pu.* from partuse pu join bigpartuse bpu on bpu.id =pu.bigid where bpu.useform ='CK56221002011'