uo_outware_ly.sru 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. $PBExportHeader$uo_outware_ly.sru
  2. forward
  3. global type uo_outware_ly from uo_outware
  4. end type
  5. end forward
  6. global type uo_outware_ly from uo_outware
  7. end type
  8. global uo_outware_ly uo_outware_ly
  9. type variables
  10. end variables
  11. forward prototypes
  12. public function integer c_sec_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  13. public function integer sec_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit)
  14. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  15. public function integer uof_add_empmtrl_ly (integer arg_flag, boolean arg_ifcommit, ref string arg_msg)
  16. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  17. end prototypes
  18. public function integer c_sec_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  19. Long cnt = 0,i
  20. Decimal ls_emp_sumwage
  21. DateTime null_server_dt
  22. SetNull(null_server_dt)
  23. IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  24. rslt = 0
  25. GOTO ext
  26. END IF
  27. IF secflag = 0 THEN
  28. rslt = 0
  29. arg_msg = '单据还没有财审,操作取消'
  30. GOTO ext
  31. END IF
  32. UPDATE u_outware SET
  33. secflag = 0,
  34. secauditingrep = '',
  35. secAuditingdate = :null_server_dt
  36. WHERE scid = :arg_scid
  37. and outwareid = :arg_billid
  38. AND flag = 1
  39. AND secflag = 1;
  40. IF sqlca.SQLCode <> 0 THEN
  41. arg_msg = '审核扣费单失败,原因>>'+sqlca.SQLErrText
  42. rslt = 0
  43. GOTO ext
  44. END IF
  45. secflag = 0
  46. ext:
  47. IF rslt = 0 THEN
  48. ROLLBACK;
  49. ELSEIF rslt = 1 AND arg_ifcommit THEN
  50. COMMIT;
  51. END IF
  52. RETURN rslt
  53. end function
  54. public function integer sec_auditing (long arg_scid, long arg_billid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  55. Long cnt = 0,i
  56. Decimal ls_emp_sumwage
  57. uo_wage u_wage
  58. u_wage = CREATE uo_wage
  59. Long ll_wagemth
  60. IF getinfo(arg_scid,arg_billid,arg_msg) = 0 THEN
  61. rslt = 0
  62. GOTO ext
  63. END IF
  64. IF secflag = 1 THEN
  65. rslt = 0
  66. arg_msg = '单据还已经财审,操作取消'
  67. GOTO ext
  68. END IF
  69. UPDATE u_outware SET
  70. secflag = 1,
  71. secauditingrep = :publ_operator,
  72. secAuditingdate = getdate()
  73. WHERE scid = :arg_scid
  74. AND outwareid = :arg_billid
  75. AND flag = 1
  76. AND secflag = 0;
  77. IF sqlca.SQLCode <> 0 THEN
  78. arg_msg = '审核扣费单失败,原因>>'+sqlca.SQLErrText
  79. rslt = 0
  80. GOTO ext
  81. END IF
  82. secflag = 1
  83. ext:
  84. IF rslt = 0 THEN
  85. ROLLBACK;
  86. ELSEIF rslt = 1 AND arg_ifcommit THEN
  87. COMMIT;
  88. END IF
  89. DESTROY u_wage
  90. RETURN rslt
  91. end function
  92. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  93. Long cnt = 0,i,j,mx_barcode_cnt
  94. String ls_storagename
  95. Int li_outtype,li_storagetype
  96. Decimal ld_sumnotoutqty
  97. IF uo_option_inout_type = -1000 THEN
  98. rslt = 0
  99. arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
  100. GOTO ext
  101. END IF
  102. IF uo_option_barcode_outwareother_paudit = -1000 THEN
  103. rslt = 0
  104. arg_msg = '选项:[205]仓库使用条码流程,其它出仓单使用先确认后审核流程,读取初始默认值失败,操作取消!'
  105. GOTO ext
  106. END IF
  107. uo_mtrlware_assign uo_ma
  108. uo_ma = Create uo_mtrlware_assign
  109. uo_ma.commit_transaction = commit_transaction
  110. uo_sqlpro uo_pro
  111. uo_pro = Create uo_sqlpro
  112. uo_pro.commit_transaction = commit_transaction
  113. //库存分配ds
  114. datastore ds_out_assign
  115. ds_out_assign = Create datastore
  116. ds_out_assign.DataObject = 'ds_outwaremx_assign'
  117. ds_out_assign.SetTransObject(commit_transaction)
  118. IF outwareid = 0 THEN
  119. rslt = 0
  120. arg_msg = "没有出仓审核对象"
  121. GOTO ext
  122. END IF
  123. IF storageid = 0 THEN
  124. rslt = 0
  125. arg_msg = '没有正确的仓库'
  126. GOTO ext
  127. END IF
  128. IF billtype <> 9 THEN
  129. IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN
  130. rslt = 0
  131. GOTO ext
  132. END IF
  133. END IF
  134. SELECT storagename,outtype,storagetype
  135. INTO :ls_storagename,:li_outtype,:li_storagetype
  136. FROM u_storage
  137. Where storageid = :storageid Using commit_transaction ;
  138. IF commit_transaction.SQLCode <> 0 THEN
  139. rslt = 0
  140. arg_msg = "查询操作失败,仓库"
  141. GOTO ext
  142. END IF
  143. //检查是否有该仓库的建立权限
  144. IF sys_user_storagestr_audit <> '0' THEN
  145. IF Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 THEN
  146. rslt = 0
  147. arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许审核该仓库的单据'
  148. GOTO ext
  149. END IF
  150. END IF
  151. //
  152. IF uo_option_inout_type = 2 And &
  153. ( uo_option_barcode_outwareother_paudit = 1 And billtype = 8 ) THEN
  154. IF priceflag = 0 THEN
  155. arg_msg = '单据未确认,不能审核'
  156. rslt = 0
  157. GOTO ext
  158. END IF
  159. END IF
  160. IF flag = 1 THEN
  161. rslt = 0
  162. arg_msg = "单据已经审核"
  163. GOTO ext
  164. END IF
  165. IF li_outtype = 2 THEN
  166. FOR i = 1 To it_mxbt
  167. IF outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
  168. NEXT
  169. IF billtype = 8 And mx_barcode_cnt > 0 THEN
  170. IF uof_check_qty_to_bqty(arg_msg) = 0 THEN
  171. rslt = 0
  172. GOTO ext
  173. END IF
  174. END IF
  175. END IF
  176. UPDATE u_outware
  177. SET Auditingrep = :publ_operator,
  178. Auditingdate = getdate(),
  179. flag = 1
  180. WHERE u_outware.outwareid = :outwareid
  181. AND flag = 0
  182. And scid = :scid Using commit_transaction;
  183. IF commit_transaction.SQLCode <> 0 THEN
  184. rslt = 0
  185. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  186. GOTO ext
  187. ELSEIF commit_transaction.SQLNRows = 0 THEN
  188. rslt = 0
  189. arg_msg = "单据正在审核,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  190. GOTO ext
  191. END IF
  192. FOR i = 1 To it_mxbt
  193. Decimal ld_ref_costamt
  194. // ld_ref_costamt = 0
  195. IF p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].mtrlcode,&
  196. outwaremx[i].qty,outwaremx[i].printid,ld_ref_costamt,arg_msg,False) = 0 THEN
  197. arg_msg = '行:'+String(i)+','+arg_msg
  198. rslt = 0
  199. GOTO ext
  200. END IF
  201. IF billtype <> 19 THEN
  202. IF sys_option_inout_procedure = 0 THEN
  203. IF p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  204. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  205. outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  206. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  207. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 THEN
  208. arg_msg = '行:'+String(i)+','+arg_msg
  209. rslt = 0
  210. GOTO ext
  211. END IF
  212. ELSE
  213. IF uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  214. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  215. outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  216. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  217. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
  218. arg_msg = '行:'+String(i)+','+arg_msg
  219. rslt = 0
  220. GOTO ext
  221. END IF
  222. END IF
  223. //更新库存分配(销售出仓单包件出仓)
  224. Long ll_taskid,ll_taskprintid
  225. Decimal ld_assign_outqty
  226. IF li_storagetype = 1 And billtype = 21 And outwaremx[i].ifpack = 1 THEN
  227. ll_taskid = 0
  228. ll_taskprintid = 0
  229. ld_assign_outqty = 0
  230. SELECT u_outwaremx.relid,
  231. u_outwaremx.relprintid
  232. INTO :ll_taskid,
  233. :ll_taskprintid
  234. FROM u_outwaremx
  235. WHERE u_outwaremx.scid = :scid
  236. AND u_outwaremx.outwareid = :outwareid
  237. AND u_outwaremx.printid = :outwaremx[i].olmtrlid
  238. Using commit_transaction;
  239. IF commit_transaction.SQLCode <> 0 THEN
  240. arg_msg = '销售出仓单明细行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
  241. rslt = 0
  242. GOTO ext
  243. END IF
  244. ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
  245. IF ds_out_assign.RowCount() > 0 THEN
  246. ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
  247. ELSE
  248. ld_sumnotoutqty = 0
  249. END IF
  250. ds_out_assign.AcceptText()
  251. IF outwaremx[i].qty > ld_sumnotoutqty THEN
  252. arg_msg = '行:'+String(i)+'订单库存分配数不足,请检查库存分配明细'
  253. rslt = 0
  254. GOTO ext
  255. ELSE
  256. ld_assign_outqty = 0
  257. FOR j = 1 To ds_out_assign.RowCount()
  258. IF ds_out_assign.Object.notoutqty[j] >= outwaremx[i].qty THEN
  259. ld_assign_outqty = outwaremx[i].qty
  260. IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 THEN
  261. arg_msg = '行:'+String(i)+','+arg_msg
  262. rslt = 0
  263. GOTO ext
  264. END IF
  265. EXIT
  266. ELSE
  267. ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
  268. IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],ld_assign_outqty,arg_msg,False) = 0 THEN
  269. arg_msg = '行:'+String(i)+','+arg_msg
  270. rslt = 0
  271. GOTO ext
  272. END IF
  273. outwaremx[i].qty = outwaremx[i].qty - ds_out_assign.Object.notoutqty[j]
  274. END IF
  275. NEXT
  276. END IF
  277. END IF
  278. ELSE
  279. IF sys_option_inout_procedure = 0 THEN
  280. IF p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  281. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  282. outwaremx[i].status, outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  283. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  284. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
  285. arg_msg = '行:'+String(i)+','+arg_msg
  286. rslt = 0
  287. GOTO ext
  288. END IF
  289. ELSE
  290. IF uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  291. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  292. outwaremx[i].qty,outwaremx[i].uqty,ld_ref_costamt,&
  293. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  294. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
  295. arg_msg = '行:'+String(i)+','+arg_msg
  296. rslt = 0
  297. GOTO ext
  298. END IF
  299. END IF
  300. END IF
  301. NEXT
  302. IF li_outtype = 2 And mx_barcode_cnt > 0 THEN
  303. IF uof_p_barcode(1,arg_msg) = 0 THEN
  304. rslt = 0
  305. GOTO ext
  306. END IF
  307. END IF
  308. //更新人员 领用物料信息
  309. IF relint_1 = 0 THEN
  310. IF uof_add_empmtrl_ly(0, False, arg_msg) = 0 THEN
  311. rslt = 0
  312. GOTO ext
  313. END IF
  314. END IF
  315. //更新库存已开单数(减)
  316. If uof_noauditingqty_del(scid,outwareid,arG_MSG) = 0 Then
  317. rslt = 0
  318. Goto ext
  319. End If
  320. flag = 1
  321. ext:
  322. IF rslt = 0 THEN
  323. ROLLBACK Using commit_transaction;
  324. ELSEIF rslt = 1 And arg_ifcommit THEN
  325. COMMIT Using commit_transaction;
  326. END IF
  327. Destroy uo_ma
  328. Destroy ds_out_assign
  329. Destroy uo_pro
  330. RETURN rslt
  331. end function
  332. public function integer uof_add_empmtrl_ly (integer arg_flag, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  333. Long i
  334. uo_empinfo uo_emp
  335. uo_emp = Create uo_empinfo
  336. IF arg_flag = 0 THEN //审核
  337. FOR i = 1 To it_mxbt
  338. IF uo_emp.uof_add_empmtrl_ly(outwaremx[i].relid, outwaremx[i].mtrlid, outwaremx[i].status, outwaremx[i].woodcode, outwaremx[i].pcode, outwaremx[i].qty,outwaremx[i].cost, False, arg_msg) = 0 THEN
  339. rslt = 0
  340. GOTO ext
  341. END IF
  342. NEXT
  343. ELSE
  344. FOR i = 1 To it_mxbt
  345. IF uo_emp.uof_add_empmtrl_ly(outwaremx[i].relid, outwaremx[i].mtrlid, outwaremx[i].status, outwaremx[i].woodcode, outwaremx[i].pcode, 0 - outwaremx[i].qty,outwaremx[i].cost, False, arg_msg) = 0 THEN
  346. rslt = 0
  347. GOTO ext
  348. END IF
  349. NEXT
  350. END IF
  351. ext:
  352. Destroy uo_emp
  353. RETURN rslt
  354. end function
  355. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  356. Long cnt = 0,i,j,mx_barcode_cnt
  357. String ls_storagename
  358. Int li_outtype,li_storagetype
  359. Decimal ld_sumnotoutqty
  360. DateTime null_dt
  361. SetNull(null_dt)
  362. uo_mtrlware_assign uo_ma
  363. uo_ma = Create uo_mtrlware_assign
  364. uo_ma.commit_transaction = commit_transaction
  365. uo_sqlpro uo_pro
  366. uo_pro = Create uo_sqlpro
  367. uo_pro.commit_transaction = commit_transaction
  368. //库存分配ds
  369. datastore ds_out_assign
  370. ds_out_assign = Create datastore
  371. ds_out_assign.DataObject = 'ds_outwaremx_assign_cancel'
  372. ds_out_assign.SetTransObject(commit_transaction)
  373. IF storageid = 0 THEN
  374. rslt = 0
  375. arg_msg = '没有正确的仓库'
  376. GOTO ext
  377. END IF
  378. IF billtype <> 9 THEN
  379. IF uof_check_warepdb_audit(storageid,arg_msg) = 0 THEN
  380. rslt = 0
  381. GOTO ext
  382. END IF
  383. END IF
  384. SELECT storagename,outtype,storagetype
  385. INTO :ls_storagename,:li_outtype,:li_storagetype
  386. FROM u_storage
  387. Where storageid = :storageid Using commit_transaction ;
  388. IF commit_transaction.SQLCode <> 0 THEN
  389. rslt = 0
  390. arg_msg = "查询操作失败,仓库"
  391. GOTO ext
  392. END IF
  393. //检查是否有该仓库的建立权限
  394. IF sys_user_storagestr_audit <> '0' THEN
  395. IF Pos(sys_user_storagestr_audit,','+String(storageid)+',') <= 0 THEN
  396. rslt = 0
  397. arg_msg = '没有仓库: '+ls_storagename+' 的审核权限,不允许撤审该仓库的单据'
  398. GOTO ext
  399. END IF
  400. END IF
  401. //
  402. IF outwareid = 0 THEN
  403. rslt = 0
  404. arg_msg = "没有出仓撤审对象"
  405. GOTO ext
  406. END IF
  407. IF ctmint > 0 THEN
  408. arg_msg = '单据已截数,不能操作'
  409. rslt = 0
  410. GOTO ext
  411. END IF
  412. IF flag = 0 THEN
  413. rslt = 0
  414. arg_msg = "单据还未审核"
  415. GOTO ext
  416. END IF
  417. IF balcflag = 1 THEN
  418. rslt = 0
  419. arg_msg = "单据已经日结,不能撤审"
  420. GOTO ext
  421. END IF
  422. //检查是否开归还单
  423. UPDATE u_outware
  424. SET Auditingrep = '',
  425. Auditingdate = :null_dt,
  426. flag = 0
  427. WHERE u_outware.outwareid = :outwareid
  428. AND flag = 1
  429. AND secflag = 0
  430. And scid = :scid Using commit_transaction;
  431. IF commit_transaction.SQLCode <> 0 THEN
  432. rslt = 0
  433. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  434. GOTO ext
  435. ELSEIF commit_transaction.SQLNRows = 0 THEN
  436. rslt = 0
  437. arg_msg = "单据正在撤审,请稍后查询。"+"~n"+commit_transaction.SQLErrText
  438. GOTO ext
  439. END IF
  440. FOR i = 1 To it_mxbt
  441. IF billtype <> 19 THEN
  442. IF sys_option_inout_procedure = 0 THEN
  443. IF p_update_mtrlware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  444. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  445. outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
  446. outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
  447. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,outwaremx[i].ifvqty,arg_msg) = 0 THEN
  448. arg_msg = '行:'+String(i)+','+arg_msg
  449. rslt = 0
  450. GOTO ext
  451. END IF
  452. ELSE
  453. IF uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  454. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  455. 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,outwaremx[i].costamt,&
  456. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  457. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
  458. arg_msg = '行:'+String(i)+','+arg_msg
  459. rslt = 0
  460. GOTO ext
  461. END IF
  462. END IF
  463. //更新库存分配
  464. Decimal ld_assign_outqty
  465. Long ll_taskid,ll_taskprintid
  466. IF li_storagetype = 1 And billtype = 21 And outwaremx[i].ifpack = 1 THEN
  467. ll_taskid = 0
  468. ll_taskprintid = 0
  469. ld_assign_outqty = 0
  470. SELECT u_outwaremx.relid,
  471. u_outwaremx.relprintid
  472. INTO :ll_taskid,
  473. :ll_taskprintid
  474. FROM u_outwaremx
  475. WHERE u_outwaremx.scid = :scid
  476. AND u_outwaremx.outwareid = :outwareid
  477. AND u_outwaremx.printid = :outwaremx[i].olmtrlid
  478. Using commit_transaction;
  479. IF commit_transaction.SQLCode <> 0 THEN
  480. arg_msg = '销售出仓单明细行:'+String(i)+'查询相关发货单明细所属订单明细失败,'+commit_transaction.SQLErrText
  481. rslt = 0
  482. GOTO ext
  483. END IF
  484. ds_out_assign.Retrieve(scid,outwaremx[i].mtrlwareid,ll_taskid,ll_taskprintid)
  485. IF ds_out_assign.RowCount() > 0 THEN
  486. ld_sumnotoutqty = ds_out_assign.Object.sumnotoutqty[1]
  487. ELSE
  488. ld_sumnotoutqty = 0
  489. END IF
  490. ds_out_assign.AcceptText()
  491. IF outwaremx[i].qty > ld_sumnotoutqty THEN
  492. arg_msg = '行:'+String(i)+'订单库存分配已出仓数不足,不能撤审,请检查库存分配明细'
  493. rslt = 0
  494. GOTO ext
  495. ELSE
  496. ld_assign_outqty = 0
  497. FOR j = 1 To ds_out_assign.RowCount()
  498. IF ds_out_assign.Object.notoutqty[j] >= outwaremx[i].qty THEN
  499. ld_assign_outqty = outwaremx[i].qty
  500. IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 THEN
  501. arg_msg = '行:'+String(i)+','+arg_msg
  502. rslt = 0
  503. GOTO ext
  504. END IF
  505. EXIT
  506. ELSE
  507. ld_assign_outqty = ds_out_assign.Object.notoutqty[j]
  508. IF uo_ma.uof_assign_addoutqty(ds_out_assign.Object.assignid[j],0 - ld_assign_outqty,arg_msg,False) = 0 THEN
  509. arg_msg = '行:'+String(i)+','+arg_msg
  510. rslt = 0
  511. GOTO ext
  512. END IF
  513. outwaremx[i].qty = outwaremx[i].qty - ds_out_assign.Object.notoutqty[j]
  514. END IF
  515. NEXT
  516. END IF
  517. END IF
  518. ELSE
  519. IF sys_option_inout_procedure = 0 THEN
  520. IF p_update_mtrlware_ws( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  521. outwaremx[i].mtrlcode, storageid, outwaremx[i].plancode,&
  522. outwaremx[i].status, 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,0 - outwaremx[i].costamt,&
  523. outwaremx[i].planprice, outwaremx[i].sptid, outwaremx[i].dxflag,&
  524. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
  525. arg_msg = '行:'+String(i)+','+arg_msg
  526. rslt = 0
  527. GOTO ext
  528. END IF
  529. ELSE
  530. IF uo_pro.p_outware_update_mtrlware(scid,outwareid,outwaremx[i].printid,outwaremx[i].mtrlwareid,&
  531. outwaremx[i].mtrlid,outwaremx[i].mtrlcode,storageid,outwaremx[i].plancode,outwaremx[i].status,&
  532. 0 - outwaremx[i].qty,0 - outwaremx[i].uqty,outwaremx[i].costamt,&
  533. outwaremx[i].planprice, outwaremx[i].sptid,outwaremx[i].dxflag,&
  534. outwaremx[i].woodcode, outwaremx[i].pcode,outwaremx[i].mtrlcuscode,outwaremx[i].Location,arg_msg) = 0 THEN
  535. arg_msg = '行:'+String(i)+','+arg_msg
  536. rslt = 0
  537. GOTO ext
  538. END IF
  539. END IF
  540. END IF
  541. IF li_outtype = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
  542. NEXT
  543. IF li_outtype = 2 And mx_barcode_cnt > 0 THEN
  544. IF uof_p_barcode(0,arg_msg) = 0 THEN
  545. rslt = 0
  546. GOTO ext
  547. END IF
  548. END IF
  549. //更新人员 领用物料信息
  550. IF relint_1 = 0 THEN
  551. IF uof_add_empmtrl_ly(1, False, arg_msg) = 0 THEN
  552. rslt = 0
  553. GOTO ext
  554. END IF
  555. END IF
  556. //增加已开单数
  557. If uof_noauditingqty_add(scid,billtype,relint_1,arg_msg) = 0 Then
  558. rslt = 0
  559. Goto ext
  560. End If
  561. flag = 0
  562. ext:
  563. IF rslt = 0 THEN
  564. ROLLBACK Using commit_transaction;
  565. ELSEIF rslt = 1 And arg_ifcommit THEN
  566. COMMIT Using commit_transaction;
  567. END IF
  568. Destroy uo_ma
  569. Destroy ds_out_assign
  570. Destroy uo_pro
  571. RETURN rslt
  572. end function
  573. on uo_outware_ly.create
  574. call super::create
  575. end on
  576. on uo_outware_ly.destroy
  577. call super::destroy
  578. end on