s.sql 15 KB

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