s.sql 18 KB

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