材料出库单到中间.sql 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. --将材料出库单传递到中间库(委外订单不受约束)
  2. if exists (select * from sysobjects where id = object_id('dbo.usp_transrdrecord11') )
  3. drop procedure dbo.usp_transrdrecord11
  4. go
  5. Create PROCEDURE usp_transrdrecord11
  6. @v_start datetime, --开始时间
  7. @v_end datetime --结束时间
  8. as
  9. select Id into #t_01 from rdrecord11 r
  10. where (dnmaketime>=@v_start and dnmaketime <= @v_end and ISNULL(cDefine5,0) = 0)
  11. or (exists (select Id from RdRecord01 where cBusType='委外加工' and ID=r.ID) )
  12. if @@ROWCOUNT=0 return
  13. --delete from wtu..rdrecord11 where exists (select id from #t_01)
  14. --delete from wtu..rdrecords11 where exists (select id from #t_01)
  15. delete from wtu..rdrecord11 where exists (select id from #t_01 where ID=wtu..rdrecord11.ID)
  16. delete from wtu..rdrecords11 where exists (select id from #t_01 where ID=wtu..rdrecords11.ID)
  17. insert into wtu..RdRecord11
  18. (ID,
  19. bRdFlag,
  20. cVouchType,
  21. cBusType,
  22. cSource,
  23. cBusCode,
  24. cWhCode,
  25. dDate,
  26. cCode,
  27. cRdCode,
  28. cDepCode,
  29. cPersonCode,
  30. cPTCode,
  31. cSTCode,
  32. cCusCode,
  33. cVenCode,
  34. cOrderCode,
  35. cARVCode,
  36. cBillCode,
  37. cDLCode,
  38. cProBatch,
  39. cHandler,
  40. cMemo,
  41. bTransFlag,
  42. cAccounter,
  43. cMaker,
  44. cDefine1,
  45. cDefine2,
  46. cDefine3,
  47. cDefine4,
  48. cDefine5,
  49. cDefine6,
  50. cDefine7,
  51. cDefine8,
  52. cDefine9,
  53. cDefine10,
  54. dKeepDate,
  55. dVeriDate,
  56. bpufirst,
  57. biafirst,
  58. iMQuantity,
  59. dARVDate,
  60. cChkCode,
  61. dChkDate,
  62. cChkPerson,
  63. VT_ID,
  64. bIsSTQc,
  65. cDefine11,
  66. cDefine12,
  67. cDefine13,
  68. cDefine14,
  69. cDefine15,
  70. cDefine16,
  71. cPsPcode,
  72. cMPoCode,
  73. gspcheck,
  74. ipurorderid,
  75. iproorderid,
  76. iExchRate,
  77. cExch_Name,
  78. bOMFirst,
  79. bFromPreYear,
  80. bIsLsQuery,
  81. bIsComplement,
  82. iDiscountTaxType,
  83. ireturncount,
  84. iverifystate,
  85. iswfcontrolled,
  86. cModifyPerson,
  87. dModifyDate,
  88. dnmaketime,
  89. dnmodifytime,
  90. dnverifytime,
  91. bredvouch,
  92. bmotran,
  93. iFlowId,
  94. cPZID,
  95. cSourceLs,
  96. cSourceCodeLs,
  97. bHYVouch,
  98. iPrintCount,
  99. csysbarcode,
  100. cCurrentAuditor,
  101. cCheckSignFlag
  102. )
  103. select
  104. r.ID,
  105. bRdFlag,
  106. cVouchType,
  107. cBusType,
  108. cSource,
  109. cBusCode,
  110. cWhCode,
  111. dDate,
  112. cCode,
  113. cRdCode,
  114. cDepCode,
  115. cPersonCode,
  116. cPTCode,
  117. cSTCode,
  118. cCusCode,
  119. cVenCode,
  120. cOrderCode,
  121. cARVCode,
  122. cBillCode,
  123. cDLCode,
  124. cProBatch,
  125. cHandler,
  126. cMemo,
  127. bTransFlag,
  128. cAccounter,
  129. cMaker,
  130. cDefine1,
  131. cDefine2,
  132. cDefine3,
  133. cDefine4,
  134. cDefine5,
  135. cDefine6,
  136. cDefine7,
  137. cDefine8,
  138. cDefine9,
  139. cDefine10,
  140. dKeepDate,
  141. dVeriDate,
  142. bpufirst,
  143. biafirst,
  144. iMQuantity,
  145. dARVDate,
  146. cChkCode,
  147. dChkDate,
  148. cChkPerson,
  149. VT_ID,
  150. bIsSTQc,
  151. cDefine11,
  152. cDefine12,
  153. cDefine13,
  154. cDefine14,
  155. cDefine15,
  156. cDefine16,
  157. cPsPcode,
  158. cMPoCode,
  159. gspcheck,
  160. ipurorderid,
  161. iproorderid,
  162. iExchRate,
  163. cExch_Name,
  164. bOMFirst,
  165. bFromPreYear,
  166. bIsLsQuery,
  167. bIsComplement,
  168. iDiscountTaxType,
  169. ireturncount,
  170. iverifystate,
  171. iswfcontrolled,
  172. cModifyPerson,
  173. dModifyDate,
  174. dnmaketime,
  175. dnmodifytime,
  176. dnverifytime,
  177. bredvouch,
  178. bmotran,
  179. iFlowId,
  180. cPZID,
  181. cSourceLs,
  182. cSourceCodeLs,
  183. bHYVouch,
  184. iPrintCount,
  185. csysbarcode,
  186. cCurrentAuditor,
  187. cCheckSignFlag
  188. from RdRecord11 r where exists(select ID from #t_01 t where t.ID=r.ID)
  189. ---------------------------------------------
  190. insert into wtu..RdRecords11
  191. (
  192. AutoID,
  193. r.ID,
  194. cInvCode,
  195. iNum,
  196. iQuantity,
  197. iUnitCost,
  198. iPrice,
  199. iAPrice,
  200. iPUnitCost,
  201. iPPrice,
  202. cBatch,
  203. cObjCode,
  204. cVouchCode,
  205. cInVouchCode,
  206. cinvouchtype,
  207. iSOutQuantity,
  208. iSOutNum,
  209. coutvouchid,
  210. coutvouchtype,
  211. iSRedOutQuantity,
  212. iSRedOutNum,
  213. cFree1,
  214. cFree2,
  215. iFlag,
  216. iSQuantity,
  217. iSNum,
  218. iFNum,
  219. iFQuantity,
  220. dVDate,
  221. iTrIds,
  222. cPosition,
  223. cDefine22,
  224. cDefine23,
  225. cDefine24,
  226. cDefine25,
  227. cDefine26,
  228. cDefine27,
  229. cItem_class,
  230. cItemCode,
  231. cName,
  232. cItemCName,
  233. cFree3,
  234. cFree4,
  235. cFree5,
  236. cFree6,
  237. cFree7,
  238. cFree8,
  239. cFree9,
  240. cFree10,
  241. cBarCode,
  242. iNQuantity,
  243. iNNum,
  244. cAssUnit,
  245. dMadeDate,
  246. iMassDate,
  247. cDefine28,
  248. cDefine29,
  249. cDefine30,
  250. cDefine31,
  251. cDefine32,
  252. cDefine33,
  253. cDefine34,
  254. cDefine35,
  255. cDefine36,
  256. cDefine37,
  257. iMPoIds,
  258. iCheckIds,
  259. cBVencode,
  260. bGsp,
  261. cGspState,
  262. cCheckCode,
  263. iCheckIdBaks,
  264. cRejectCode,
  265. iRejectIds,
  266. cCheckPersonCode,
  267. dCheckDate,
  268. cMassUnit,
  269. cMoLotCode,
  270. iMaterialFee,
  271. iProcessCost,
  272. iProcessFee,
  273. dMSDate,
  274. iSMaterialFee,
  275. iSProcessFee,
  276. iOMoDID,
  277. bFilled,
  278. bChecked,
  279. iOMoMID,
  280. cmworkcentercode,
  281. bLPUseFree,
  282. iRSRowNO,
  283. iOriTrackID,
  284. coritracktype,
  285. cbaccounter,
  286. dbKeepDate,
  287. bCosting,
  288. bVMIUsed,
  289. iVMISettleQuantity,
  290. iVMISettleNum,
  291. cvmivencode,
  292. iInvSNCount,
  293. cwhpersoncode,
  294. cwhpersonname,
  295. iMaIDs,
  296. cserviceoid,
  297. cbserviceoid,
  298. iinvexchrate
  299. )
  300. select
  301. AutoID,
  302. r.ID,
  303. cInvCode,
  304. iNum,
  305. iQuantity,
  306. iUnitCost,
  307. iPrice,
  308. iAPrice,
  309. iPUnitCost,
  310. iPPrice,
  311. cBatch,
  312. cObjCode,
  313. cVouchCode,
  314. cInVouchCode,
  315. cinvouchtype,
  316. iSOutQuantity,
  317. iSOutNum,
  318. coutvouchid,
  319. coutvouchtype,
  320. iSRedOutQuantity,
  321. iSRedOutNum,
  322. cFree1,
  323. cFree2,
  324. iFlag,
  325. iSQuantity,
  326. iSNum,
  327. iFNum,
  328. iFQuantity,
  329. dVDate,
  330. iTrIds,
  331. cPosition,
  332. cDefine22,
  333. cDefine23,
  334. cDefine24,
  335. cDefine25,
  336. cDefine26,
  337. cDefine27,
  338. cItem_class,
  339. cItemCode,
  340. cName,
  341. cItemCName,
  342. cFree3,
  343. cFree4,
  344. cFree5,
  345. cFree6,
  346. cFree7,
  347. cFree8,
  348. cFree9,
  349. cFree10,
  350. cBarCode,
  351. iNQuantity,
  352. iNNum,
  353. cAssUnit,
  354. dMadeDate,
  355. iMassDate,
  356. cDefine28,
  357. cDefine29,
  358. cDefine30,
  359. cDefine31,
  360. cDefine32,
  361. cDefine33,
  362. cDefine34,
  363. cDefine35,
  364. cDefine36,
  365. cDefine37,
  366. iMPoIds,
  367. iCheckIds,
  368. cBVencode,
  369. bGsp,
  370. cGspState,
  371. cCheckCode,
  372. iCheckIdBaks,
  373. cRejectCode,
  374. iRejectIds,
  375. cCheckPersonCode,
  376. dCheckDate,
  377. cMassUnit,
  378. cMoLotCode,
  379. iMaterialFee,
  380. iProcessCost,
  381. iProcessFee,
  382. dMSDate,
  383. iSMaterialFee,
  384. iSProcessFee,
  385. iOMoDID,
  386. bFilled,
  387. bChecked,
  388. iOMoMID,
  389. cmworkcentercode,
  390. bLPUseFree,
  391. iRSRowNO,
  392. iOriTrackID,
  393. coritracktype,
  394. cbaccounter,
  395. dbKeepDate,
  396. bCosting,
  397. bVMIUsed,
  398. iVMISettleQuantity,
  399. iVMISettleNum,
  400. cvmivencode,
  401. iInvSNCount,
  402. cwhpersoncode,
  403. cwhpersonname,
  404. iMaIDs,
  405. cserviceoid,
  406. cbserviceoid,
  407. iinvexchrate
  408. from RdRecords11 r where exists(select ID from #t_01 t where t.ID=r.ID)
  409. --释放临时表
  410. drop table #t_01