s.sql 16 KB

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