s.sql 17 KB

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