s.sql 16 KB

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