uo_wfjg_py.sru 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. $PBExportHeader$uo_wfjg_py.sru
  2. forward
  3. global type uo_wfjg_py from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_wfjg_py from nonvisualobject
  7. end type
  8. global uo_wfjg_py uo_wfjg_py
  9. type variables
  10. PUBLIC PROTECTEDWRITE Long scid = 0 //分部id
  11. PUBLIC PROTECTEDWRITE Long outwareid //进仓单表自动增量id
  12. PUBLIC PROTECTEDWRITE String outwarecode //单据的唯一编号
  13. PUBLIC PROTECTEDWRITE Int billtype = 0 //业务类型
  14. //billtype = 4 正常出仓
  15. //billtype =16 加工商盘盈
  16. PUBLIC PROTECTEDWRITE DateTime opdate //建立时间,自动
  17. PUBLIC PROTECTEDWRITE String opemp //建立操作员
  18. PUBLIC PROTECTEDWRITE DateTime moddate //修改时间,自动
  19. PUBLIC PROTECTEDWRITE String modemp //修改操作员
  20. PUBLIC PROTECTEDWRITE Int balcflag = 0 //仓库日结标志
  21. PUBLIC PROTECTEDWRITE Int flag = 0 //仓库审核标志
  22. PUBLIC PROTECTEDWRITE DateTime auditingdate //审核时间
  23. PUBLIC PROTECTEDWRITE String auditingrep //审核操作员
  24. Long relid = 0 //关联id
  25. DateTime outdate //进仓发生时间
  26. String outrep = '' //经手人
  27. String part = '' //相关号码
  28. String dscrp = '' //备注
  29. Long sptid = 0 //供应户id
  30. String sptname = '' //供应商名称 
  31. Int thflag = 0 //退货标记
  32. Boolean if_getid_ture = TRUE
  33. Transaction commit_transaction //数据commit事务
  34. s_outwaremx_wfjg outwaremx[] //明细结构数组
  35. Long it_mxbt = 0 //明细结构数组末指针
  36. Boolean it_newbegin = FALSE //新建标志
  37. Boolean it_updatebegin = FALSE //修改标志
  38. end variables
  39. forward prototypes
  40. public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg)
  41. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  42. public function integer auditing (boolean arg_ifcommit, ref string arg_msg)
  43. public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg)
  44. public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
  45. public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  46. public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg)
  47. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg)
  48. public function integer p_clearmx ()
  49. public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg)
  50. public function integer p_reset ()
  51. public function integer p_update_sptware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, string arg_woodcode, string arg_pcode, ref string arg_msg)
  52. public function integer acceptmx (long arg_mtrlwareid, decimal arg_uqty, string arg_uunit, decimal arg_qty, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_mtrlid, long arg_storageid, integer arg_dxflag, string arg_plancode, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_fprice, decimal arg_rebate, long arg_sptid, decimal arg_rate, string arg_jgdscrp, string arg_mxdscrp2)
  53. end prototypes
  54. public function integer newbegin (long arg_scid, integer arg_billtype, ref string arg_msg);//====================================================================
  55. // Function: newbegin(long arg_scid,int arg_billtype,ref string arg_msg)
  56. //--------------------------------------------------------------------
  57. // Description: 从置对象,设定业务类型,准备建立新进仓单
  58. //--------------------------------------------------------------------
  59. // Arguments:
  60. // value long arg_scid
  61. // value integer arg_billtype
  62. // reference string arg_msg
  63. //--------------------------------------------------------------------
  64. // Returns: integer
  65. //--------------------------------------------------------------------
  66. // Author: yyx Date: 2003.11.12
  67. //--------------------------------------------------------------------
  68. // Modify History:
  69. //
  70. //====================================================================
  71. int rslt=1
  72. if arg_scid < 0 then
  73. arg_msg = '请选择分部'
  74. rslt = 0
  75. goto ext
  76. end if
  77. p_reset()
  78. billtype=arg_billtype
  79. scid=arg_scid
  80. it_newbegin=true
  81. it_updatebegin=false
  82. ext:
  83. if rslt=0 then p_reset()
  84. return rslt
  85. end function
  86. public function integer save (boolean arg_ifcommit, ref string arg_msg);Integer rslt = 1,cnt = 0,i
  87. DateTime server_dt
  88. Long ls_newid
  89. String ls_sccode
  90. IF IsNull(relid) THEN relid = 0
  91. IF IsNull(outrep) THEN outrep = ''
  92. IF IsNull(dscrp) THEN dscrp = ''
  93. IF IsNull(part) THEN part = ''
  94. IF IsNull(sptid) THEN sptid = 0
  95. IF IsNull(sptname) THEN sptname = ''
  96. IF IsNull(thflag) THEN thflag = 0
  97. IF it_newbegin = FALSE AND it_updatebegin = FALSE THEN
  98. rslt = 0
  99. arg_msg = "非编辑状态不可以提交"
  100. GOTO ext
  101. END IF
  102. SELECT Top 1 getdate() INTO :server_dt FROM u_user USING commit_transaction ;
  103. //取得系统时间,借用操作员表
  104. IF commit_transaction.SQLCode <> 0 THEN
  105. rslt = 0
  106. arg_msg = "查询操作失败,日期 "
  107. GOTO ext
  108. END IF
  109. IF it_mxbt = 0 THEN //如果输入物料资料错则已经清空
  110. rslt = 0
  111. arg_msg = "没有正确进仓内容"
  112. GOTO ext
  113. END IF
  114. IF Year(Date(outdate)) < 2000 OR IsNull(outdate) THEN
  115. rslt = 0
  116. arg_msg = "缺少出仓发生时间或不合理"
  117. GOTO ext
  118. END IF
  119. //====================================================================
  120. // Script - save ( boolean arg_ifcommit, ref string arg_msg )
  121. // Reason:
  122. //--------------------------------------------------------------------
  123. // Modified By: yyx Date: 2004.01.02
  124. //--------------------------------------------------------------------
  125. IF DaysAfter(Date(String(server_dt,'yyyy-mm-dd')),Date(String(outdate,'yyyy-mm-dd'))) > sys_option_input_days THEN
  126. rslt = 0
  127. arg_msg = '出仓日期错误,日期不能超前系统日期'
  128. GOTO ext
  129. END IF
  130. IF DaysAfter(Date(String(outdate,'yyyy-mm-dd')),Date(String(server_dt,'yyyy-mm-dd'))) > sys_option_input_days THEN
  131. rslt = 0
  132. arg_msg = '出仓日期错误,日期不能落后系统日期'
  133. GOTO ext
  134. END IF
  135. //====================================================================
  136. SELECT name INTO :sptname
  137. FROM u_spt
  138. Where sptid = :sptid USING commit_transaction;
  139. IF commit_transaction.SQLCode <> 0 THEN
  140. rslt = 0
  141. arg_msg = "查询操作失败,加工商资料"
  142. GOTO ext
  143. END IF
  144. ////////////////////////////////////////////////开始区分:新建/更新 处理
  145. IF outwareid = 0 THEN //新建
  146. ls_newid = f_sys_scidentity(scid,"ow_wfjg_out","outwareid",arg_msg,if_getid_ture,commit_transaction)
  147. IF ls_newid <= 0 THEN
  148. rslt = 0
  149. GOTO ext
  150. END IF
  151. //取分部代号
  152. IF f_get_sccode(scid,commit_transaction,ls_sccode,arg_msg) = 0 THEN
  153. rslt = 0
  154. GOTO ext
  155. END IF
  156. //取得新单据编号
  157. IF thflag = 0 THEN
  158. IF billtype = 5 THEN
  159. outwarecode = getid(scid,ls_sccode + 'WF',Date(server_dt),if_getid_ture,commit_transaction)
  160. ELSEIF billtype = 9 THEN
  161. outwarecode = getid(scid,ls_sccode + 'WY',Date(server_dt),if_getid_ture,commit_transaction)
  162. ELSEIF billtype = 10 THEN
  163. outwarecode = getid(scid,ls_sccode + 'FI',Date(server_dt),if_getid_ture,commit_transaction)
  164. END IF
  165. ELSE
  166. outwarecode = getid(scid,ls_sccode + 'OF',Date(server_dt),if_getid_ture,commit_transaction)
  167. END IF
  168. IF outwarecode = "err" THEN
  169. outwarecode = ''
  170. rslt = 0
  171. arg_msg = "无法获取出仓单编号"+"~n"+commit_transaction.SQLErrText
  172. GOTO ext
  173. END IF
  174. INSERT INTO ow_wfjg_out (
  175. scid,
  176. outwareid,
  177. outwarecode,
  178. billtype,
  179. relid,
  180. outdate,
  181. outrep,
  182. part,
  183. dscrp,
  184. sptid,
  185. sptname,
  186. thflag,
  187. opdate,
  188. opemp)
  189. VALUES (
  190. :scid,
  191. :ls_newid,
  192. :outwarecode,
  193. :billtype,
  194. :relid,
  195. :outdate,
  196. :outrep,
  197. :part,
  198. :dscrp,
  199. :sptid,
  200. :sptname,
  201. :thflag,
  202. :server_dt,
  203. :publ_operator
  204. ) USING commit_transaction ;
  205. IF commit_transaction.SQLCode <> 0 THEN
  206. rslt = 0
  207. IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjg_out') > 0 THEN
  208. arg_msg = '插入操作失败,关键字分部ID、单据ID重复'
  209. ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_ow_wfjg_inspt') > 0 THEN
  210. arg_msg = '插入操作失败,单据编号重复'
  211. ELSE
  212. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  213. END IF
  214. GOTO ext
  215. END IF
  216. //读取新outwareid
  217. outwareid = ls_newid
  218. FOR i = 1 TO it_mxbt
  219. INSERT INTO ow_wfjgmx_out
  220. (scid,
  221. storageid,
  222. outwareid,
  223. mtrlwareid,
  224. printid,
  225. mtrlid,
  226. plancode,
  227. status,
  228. qty,
  229. fprice,
  230. rebate,
  231. price,
  232. mxdscrp,
  233. costamt,
  234. ifrel,
  235. relid,
  236. woodcode,
  237. relcode,
  238. pcode,
  239. cost,
  240. uqty,
  241. uunit,
  242. rate,
  243. uprice,
  244. jgdscrp,
  245. mxdscrp2)
  246. VALUES (
  247. :scid,
  248. :outwaremx[i].storageid,
  249. :ls_newid,
  250. :outwaremx[i].mtrlwareid,
  251. :outwaremx[i].printid,
  252. :outwaremx[i].mtrlid,
  253. :outwaremx[i].plancode,
  254. :outwaremx[i].status,
  255. :outwaremx[i].qty,
  256. :outwaremx[i].fprice,
  257. :outwaremx[i].rebate,
  258. :outwaremx[i].price,
  259. :outwaremx[i].mxdscrp,
  260. :outwaremx[i].costamt,
  261. :outwaremx[i].ifrel,
  262. :outwaremx[i].relid,
  263. :outwaremx[i].woodcode,
  264. :outwaremx[i].relcode,
  265. :outwaremx[i].pcode,
  266. :outwaremx[i].cost,
  267. :outwaremx[i].uqty,
  268. :outwaremx[i].uunit,
  269. :outwaremx[i].rate,
  270. :outwaremx[i].uprice,
  271. :outwaremx[i].jgdscrp,
  272. :outwaremx[i].mxdscrp2) USING commit_transaction;
  273. IF commit_transaction.SQLCode <> 0 THEN
  274. outwareid = 0 //还原outwareid
  275. rslt = 0
  276. IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjgmx_out') > 0 THEN
  277. arg_msg = '插入明细操作失败,关键字分部ID、单据ID、明细ID重复'
  278. ELSE
  279. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  280. END IF
  281. GOTO ext
  282. END IF
  283. NEXT
  284. ELSE //////////////////////////////////////////////////更新
  285. UPDATE ow_wfjg_out
  286. SET billtype = :billtype,
  287. relid = :relid,
  288. outdate = :outdate,
  289. outrep = :outrep,
  290. part = :part,
  291. dscrp = :dscrp,
  292. sptid = :sptid,
  293. sptname = :sptname,
  294. thflag = :thflag,
  295. moddate = :server_dt,
  296. modemp = :publ_operator
  297. WHERE ow_wfjg_out.outwareid = :outwareid
  298. AND ow_wfjg_out.scid = :scid
  299. AND flag = 0 USING commit_transaction;
  300. IF commit_transaction.SQLCode <> 0 OR commit_transaction.SQLNRows <= 0 THEN
  301. rslt = 0
  302. IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjg_out') > 0 THEN
  303. arg_msg = '插入操作失败,关键字分部ID、单据ID重复'
  304. ELSEIF Pos(Lower(commit_transaction.SQLErrText),'ix_ow_wfjg_inspt') > 0 THEN
  305. arg_msg = '插入操作失败,单据编号重复'
  306. ELSE
  307. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+commit_transaction.SQLErrText
  308. END IF
  309. GOTO ext
  310. END IF
  311. //删除原有明细
  312. DELETE FROM ow_wfjgmx_out
  313. WHERE ow_wfjgmx_out.outwareid = :outwareid
  314. AND ow_wfjgmx_out.scid = :scid USING commit_transaction;
  315. IF commit_transaction.SQLCode <> 0 THEN
  316. rslt = 0
  317. arg_msg = "删除旧有明细操作失败"+"~n"+commit_transaction.SQLErrText
  318. GOTO ext
  319. END IF
  320. FOR i = 1 TO it_mxbt
  321. INSERT INTO ow_wfjgmx_out
  322. (scid,
  323. storageid,
  324. outwareid,
  325. mtrlwareid,
  326. printid,
  327. mtrlid,
  328. plancode,
  329. status,
  330. qty,
  331. fprice,
  332. rebate,
  333. price,
  334. mxdscrp,
  335. costamt,
  336. ifrel,
  337. relid,
  338. woodcode,
  339. relcode,
  340. pcode,
  341. cost,
  342. uqty,
  343. uunit,
  344. rate,
  345. uprice,
  346. jgdscrp,
  347. mxdscrp2)
  348. VALUES (
  349. :scid,
  350. :outwaremx[i].storageid,
  351. :outwareid,
  352. :outwaremx[i].mtrlwareid,
  353. :outwaremx[i].printid,
  354. :outwaremx[i].mtrlid,
  355. :outwaremx[i].plancode,
  356. :outwaremx[i].status,
  357. :outwaremx[i].qty,
  358. :outwaremx[i].fprice,
  359. :outwaremx[i].rebate,
  360. :outwaremx[i].price,
  361. :outwaremx[i].mxdscrp,
  362. :outwaremx[i].costamt,
  363. :outwaremx[i].ifrel,
  364. :outwaremx[i].relid,
  365. :outwaremx[i].woodcode,
  366. :outwaremx[i].relcode,
  367. :outwaremx[i].pcode,
  368. :outwaremx[i].cost,
  369. :outwaremx[i].uqty,
  370. :outwaremx[i].uunit,
  371. :outwaremx[i].rate,
  372. :outwaremx[i].uprice,
  373. :outwaremx[i].jgdscrp,
  374. :outwaremx[i].mxdscrp2) USING commit_transaction;
  375. IF commit_transaction.SQLCode <> 0 THEN
  376. rslt = 0
  377. IF Pos(Lower(commit_transaction.SQLErrText),'pk_ow_wfjgmx_out') > 0 THEN
  378. arg_msg = '插入明细操作失败,关键字分部ID、单据ID、明细ID重复'
  379. ELSE
  380. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+commit_transaction.SQLErrText
  381. END IF
  382. GOTO ext
  383. END IF
  384. NEXT
  385. END IF
  386. it_newbegin = FALSE
  387. it_updatebegin = FALSE
  388. ext:
  389. IF rslt = 0 THEN
  390. ROLLBACK USING commit_transaction;
  391. p_clearmx()
  392. ELSEIF rslt = 1 AND arg_ifcommit THEN
  393. COMMIT USING commit_transaction;
  394. END IF
  395. IF thflag = 0 THEN
  396. arg_msg = '车间外协发出单,'+ arg_msg
  397. ELSE
  398. arg_msg = '车间外协退回单,'+ arg_msg
  399. END IF
  400. RETURN rslt
  401. end function
  402. public function integer auditing (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,cnt = 0,i
  403. Dec new_noallocqty = 0
  404. Long ls_newid
  405. IF outwareid = 0 THEN
  406. rslt = 0
  407. arg_msg = "没有审核对象"
  408. GOTO ext
  409. END IF
  410. IF it_newbegin OR it_updatebegin THEN
  411. rslt = 0
  412. arg_msg = "编辑状态下不可以执行审核"
  413. GOTO ext
  414. END IF
  415. IF flag = 1 THEN
  416. rslt = 0
  417. arg_msg = "单据已经审核"
  418. GOTO ext
  419. END IF
  420. UPDATE ow_wfjg_out
  421. SET Auditingemp = :publ_operator,
  422. Auditingdate = getdate(),
  423. flag = 1
  424. WHERE ow_wfjg_out.outwareid = :outwareid
  425. AND flag = 0
  426. AND scid = :scid USING commit_transaction;
  427. IF commit_transaction.SQLCode <> 0 THEN
  428. rslt = 0
  429. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  430. GOTO ext
  431. ELSEIF commit_transaction.SQLNRows = 0 THEN
  432. rslt = 0
  433. arg_msg = "单据正在审核,请稍后查询。"
  434. GOTO ext
  435. END IF
  436. Long ll_orderid
  437. uo_order_wfjg uo_wfjg
  438. uo_wfjg = CREATE uo_order_wfjg
  439. uo_wfjg.commit_transaction = commit_transaction
  440. //更新供应商库存
  441. FOR i = 1 TO it_mxbt
  442. // IF p_update_sptware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  443. // outwaremx[i].mtrlcode, outwaremx[i].plancode,&
  444. // outwaremx[i].status, outwaremx[i].qty, outwaremx[i].costamt,&
  445. // outwaremx[i].planprice, sptid, &
  446. // outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg) = 0 THEN
  447. // rslt = 0
  448. // GOTO ext
  449. // END IF
  450. IF f_update_mtrlware_spt_out (billtype,thflag,scid,outwaremx[i].mtrlid, &
  451. outwaremx[i].mtrlcode, outwaremx[i].plancode,&
  452. outwaremx[i].status, outwaremx[i].qty, outwaremx[i].costamt,&
  453. outwaremx[i].planprice, sptid, &
  454. outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,&
  455. FALSE,commit_transaction) = 0 THEN
  456. rslt = 0
  457. GOTO ext
  458. END IF
  459. IF outwaremx[i].relid > 0 THEN
  460. IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].mtrlid,0,outwaremx[i].status,&
  461. outwaremx[i].woodcode,outwaremx[i].pcode,outwaremx[i].qty,&
  462. arg_msg,FALSE) = 0 THEN
  463. rslt = 0
  464. GOTO ext
  465. END IF
  466. END IF
  467. NEXT
  468. flag = 1
  469. ext:
  470. IF rslt = 0 THEN
  471. ROLLBACK USING commit_transaction;
  472. ELSEIF rslt = 1 AND arg_ifcommit THEN
  473. COMMIT USING commit_transaction;
  474. END IF
  475. if thflag = 0 then
  476. arg_msg = '车间外协发出单,'+ arg_msg
  477. else
  478. arg_msg = '车间外协退回单,'+ arg_msg
  479. end if
  480. RETURN rslt
  481. end function
  482. public function integer updatebegin (long arg_scid, long arg_outwareid, integer arg_billtype, ref string arg_msg);//====================================================================
  483. // Function: updatebegin(arg_scid,arg_inwareid,arg_billtype,arg_msg)
  484. //--------------------------------------------------------------------
  485. // Description: 从置对象,设定业务类型与关联ID,准备更新进仓单
  486. //--------------------------------------------------------------------
  487. // Arguments:
  488. // value long arg_scid
  489. // value long arg_inwareid
  490. // value integer arg_billtype
  491. // reference string arg_msg
  492. //--------------------------------------------------------------------
  493. // Returns: integer
  494. //--------------------------------------------------------------------
  495. // Author: yyx Date: 2003.11.12
  496. //--------------------------------------------------------------------
  497. // Modify History:
  498. //
  499. //====================================================================
  500. long rslt=1
  501. if arg_scid < 0 then
  502. arg_msg = '请选择分部'
  503. rslt = 0
  504. goto ext
  505. end if
  506. if arg_outwareid<=0 then
  507. rslt=0
  508. goto ext
  509. end if
  510. rslt=p_getinfo(arg_scid,arg_outwareid,arg_msg)
  511. if rslt=0 then goto ext
  512. if flag=1 then
  513. rslt=0
  514. arg_msg='单据已经审核,不可以修改'
  515. goto ext
  516. end if
  517. outwareid=arg_outwareid
  518. billtype=arg_billtype
  519. scid=arg_scid
  520. it_newbegin=false
  521. it_updatebegin=true
  522. p_clearmx() //清除明细
  523. ext:
  524. if rslt=0 then p_reset()
  525. if thflag = 0 then
  526. arg_msg = '车间外协发出单,'+ arg_msg
  527. else
  528. arg_msg = '车间外协退回单,'+ arg_msg
  529. end if
  530. return rslt
  531. end function
  532. public function integer getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//getinfo(arg_scid,arg_outwareid,arg_msg)
  533. //0 失败 1成功
  534. Int rslt = 1,i = 1,no_mxcheck = 0
  535. IF arg_outwareid <= 0 THEN
  536. rslt = 0
  537. arg_msg = "非法出仓单唯一码"
  538. GOTO ext
  539. END IF
  540. rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
  541. IF rslt = 0 THEN GOTO ext
  542. //用游标读取明细
  543. DECLARE cur_inwaermx CURSOR FOR
  544. SELECT ow_wfjgmx_out.printid,
  545. ow_wfjgmx_out.mtrlid,
  546. ow_wfjgmx_out.plancode,
  547. ow_wfjgmx_out.status,
  548. ow_wfjgmx_out.qty,
  549. ow_wfjgmx_out.fprice,
  550. ow_wfjgmx_out.rebate,
  551. ow_wfjgmx_out.price,
  552. ow_wfjgmx_out.mxdscrp,
  553. u_mtrldef.mtrlcode,
  554. ow_wfjgmx_out.mtrlwareid,
  555. ow_wfjgmx_out.storageid,
  556. ow_wfjgmx_out.costamt,
  557. ow_wfjgmx_out.ifrel,
  558. ow_wfjgmx_out.relid,
  559. ow_wfjgmx_out.woodcode,
  560. ow_wfjgmx_out.pcode,
  561. ow_wfjgmx_out.cost,
  562. ow_wfjgmx_out.uprice,
  563. ow_wfjgmx_out.uqty,
  564. ow_wfjgmx_out.rate,
  565. ow_wfjgmx_out.uunit,
  566. ow_wfjgmx_out.mxdscrp2
  567. FROM ow_wfjgmx_out,u_mtrldef,ow_wfjg_out
  568. WHERE ow_wfjg_out.outwareid = :arg_outwareid AND
  569. ow_wfjgmx_out.mtrlid = u_mtrldef.mtrlid AND
  570. ow_wfjg_out.scid = :arg_scid AND
  571. ow_wfjg_out.outwareid = ow_wfjgmx_out.outwareid AND
  572. ow_wfjg_out.scid = ow_wfjgmx_out.scid USING commit_transaction;
  573. OPEN cur_inwaermx;
  574. FETCH cur_inwaermx INTO
  575. :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
  576. :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
  577. :outwaremx[i].rebate,:outwaremx[i].price,
  578. :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
  579. :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
  580. :outwaremx[i].costamt,:outwaremx[i].ifrel,
  581. :outwaremx[i].relid,
  582. :outwaremx[i].woodcode,:outwaremx[i].pcode,
  583. :outwaremx[i].cost,:outwaremx[i].uprice,
  584. :outwaremx[i].uqty,
  585. :outwaremx[i].rate,
  586. :outwaremx[i].uunit,
  587. :outwaremx[i].mxdscrp2;
  588. DO WHILE commit_transaction.SQLCode = 0
  589. i++
  590. FETCH cur_inwaermx INTO
  591. :outwaremx[i].printid,:outwaremx[i].mtrlid,:outwaremx[i].plancode,
  592. :outwaremx[i].status,:outwaremx[i].qty,:outwaremx[i].fprice,
  593. :outwaremx[i].rebate,:outwaremx[i].price,
  594. :outwaremx[i].mxdscrp,:outwaremx[i].mtrlcode,
  595. :outwaremx[i].mtrlwareid,:outwaremx[i].storageid,
  596. :outwaremx[i].costamt,:outwaremx[i].ifrel,
  597. :outwaremx[i].relid,
  598. :outwaremx[i].woodcode,:outwaremx[i].pcode,
  599. :outwaremx[i].cost,:outwaremx[i].uprice,
  600. :outwaremx[i].uqty,
  601. :outwaremx[i].rate,
  602. :outwaremx[i].uunit,
  603. :outwaremx[i].mxdscrp2;
  604. LOOP
  605. CLOSE cur_inwaermx;
  606. //检验明细是否读入完整
  607. SELECT count(*) INTO :no_mxcheck
  608. FROM ow_wfjgmx_out,u_mtrldef,ow_wfjg_out
  609. WHERE ow_wfjg_out.outwareid = :arg_outwareid AND
  610. ow_wfjgmx_out.mtrlid = u_mtrldef.mtrlid AND
  611. ow_wfjg_out.scid = :arg_scid AND
  612. ow_wfjg_out.outwareid = ow_wfjgmx_out.outwareid AND
  613. ow_wfjg_out.scid = ow_wfjgmx_out.scid USING commit_transaction;
  614. IF commit_transaction.SQLCode <> 0 THEN
  615. rslt = 0
  616. arg_msg = "查询操作失败,出仓单明细数量"
  617. GOTO ext
  618. END IF
  619. IF i <> (no_mxcheck+1) THEN
  620. rslt = 0
  621. arg_msg = "查询操作失败,出仓单明细"
  622. GOTO ext
  623. END IF
  624. outwareid = arg_outwareid
  625. scid = arg_scid
  626. it_mxbt = i - 1
  627. it_newbegin = FALSE
  628. it_updatebegin = FALSE
  629. ext:
  630. IF rslt = 0 THEN p_reset()
  631. RETURN rslt
  632. end function
  633. public function integer del (long arg_scid, long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);//如果单据还没有审核删除单据极其明细
  634. //0 FAIL, 1 SUCCESS
  635. Int rslt = 1
  636. IF arg_outwareid <= 0 THEN
  637. rslt = 0
  638. arG_MSG = "没有删除对象,操作取消"
  639. GOTO ext
  640. END IF
  641. p_getinfo(arg_scid,arg_outwareid,arg_msg)
  642. IF flag = 1 THEN
  643. rslt = 0
  644. arG_MSG = "单据已经审核,不可以删除"
  645. GOTO ext
  646. END IF
  647. DELETE FROM ow_wfjg_out
  648. WHERE ow_wfjg_out.outwareid = :arg_outwareid
  649. AND ow_wfjg_out.scid = :arg_scid USING commit_transaction;
  650. IF commit_transaction.SQLCode <> 0 THEN
  651. rslt = 0
  652. arG_MSG = "删除进仓单操作失败"+"~n"+commit_transaction.SQLErrText
  653. GOTO ext
  654. END IF
  655. DELETE FROM ow_wfjgmx_out
  656. WHERE ow_wfjgmx_out.outwareid = :arg_outwareid
  657. AND ow_wfjgmx_out.scid = :arg_scid USING commit_transaction;
  658. IF commit_transaction.SQLCode <> 0 THEN
  659. rslt = 0
  660. arG_MSG = "删除进仓单明细操作失败"+"~n"+commit_transaction.SQLErrText
  661. GOTO ext
  662. END IF
  663. it_newbegin = FALSE
  664. it_updatebegin = FALSE
  665. ext:
  666. IF rslt = 0 THEN
  667. ROLLBACK USING commit_transaction;
  668. p_reset()
  669. ELSEIF rslt = 1 AND arg_ifcommit THEN
  670. COMMIT USING commit_transaction;
  671. END IF
  672. if thflag = 0 then
  673. arg_msg = '车间外协发出单,'+ arg_msg
  674. else
  675. arg_msg = '车间外协退回单,'+ arg_msg
  676. end if
  677. RETURN (rslt)
  678. end function
  679. public function integer add_dscrp (long arg_scid, long arg_outwareid, string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  680. //0 fail 1 success
  681. Int rslt = 1
  682. arg_newdescppart = Trim(arg_newdescppart)
  683. IF it_updatebegin Or it_newbegin THEN
  684. rslt = 0
  685. arg_msg = "编辑状态下不可用"
  686. GOTO ext
  687. END IF
  688. IF arg_newdescppart = '' THEN
  689. rslt = 0
  690. arg_msg = "要添加内容为空,操作取消"
  691. GOTO ext
  692. END IF
  693. rslt = p_getinfo(arg_scid,arg_outwareid,arg_msg)
  694. IF rslt = 0 THEN GOTO ext
  695. IF flag = 0 THEN
  696. rslt = 0
  697. arg_msg = "非审核状态下不可用"
  698. GOTO ext
  699. END IF
  700. UPDATE u_outware
  701. SET dscrp = dscrp+' '+:arg_newdescppart
  702. WHERE u_outware.outwareid = :outwareid
  703. And scid = :scid Using commit_transaction;
  704. IF commit_transaction.SQLCode <> 0 THEN
  705. ROLLBACK ;
  706. rslt = 0
  707. arg_msg = "因网络或其它原因导致添加单据备注操作失败"+"~n"+commit_transaction.SQLErrText
  708. GOTO ext
  709. END IF
  710. COMMIT Using commit_transaction;
  711. dscrp = dscrp+' '+arg_newdescppart
  712. ext:
  713. IF thflag = 0 THEN
  714. arg_msg = '车间外协发出单,'+ arg_msg
  715. ELSE
  716. arg_msg = '车间外协退回单,'+ arg_msg
  717. END IF
  718. Return (rslt)
  719. end function
  720. public function integer c_auditing (boolean arg_ifcommit, ref string arg_msg);
  721. Long rslt = 1,cnt = 0,i
  722. Long ls_newid
  723. DateTime null_dt
  724. SetNull(null_dt)
  725. IF outwareid = 0 THEN
  726. rslt = 0
  727. arg_msg = "没有审核对象"
  728. GOTO ext
  729. END IF
  730. IF it_newbegin OR it_updatebegin THEN
  731. rslt = 0
  732. arg_msg = "编辑状态下不可以执行审核"
  733. GOTO ext
  734. END IF
  735. IF flag = 0 THEN
  736. rslt = 0
  737. arg_msg = "单据还未审核"
  738. GOTO ext
  739. END IF
  740. IF balcflag = 1 THEN
  741. rslt = 0
  742. arg_msg = "单据已经日结,不能撤审"
  743. GOTO ext
  744. END IF
  745. UPDATE ow_wfjg_out
  746. SET Auditingemp = '',
  747. Auditingdate = :null_dt,
  748. flag = 0
  749. WHERE ow_wfjg_out.outwareid = :outwareid
  750. AND flag = 1
  751. AND scid = :scid USING commit_transaction;
  752. IF commit_transaction.SQLCode <> 0 THEN
  753. rslt = 0
  754. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+commit_transaction.SQLErrText
  755. GOTO ext
  756. ELSEIF commit_transaction.SQLNRows = 0 THEN
  757. rslt = 0
  758. arg_msg = "单据正在撤审,请稍后查询。"
  759. GOTO ext
  760. END IF
  761. uo_order_wfjg uo_wfjg
  762. uo_wfjg=create uo_order_wfjg
  763. uo_wfjg.commit_transaction=commit_transaction
  764. FOR i = 1 TO it_mxbt
  765. // IF p_update_sptware ( outwaremx[i].mtrlwareid, outwaremx[i].mtrlid, &
  766. // outwaremx[i].mtrlcode, outwaremx[i].plancode,&
  767. // outwaremx[i].status, 0 - outwaremx[i].qty, 0 - outwaremx[i].costamt,&
  768. // outwaremx[i].planprice, sptid, &
  769. // outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg) = 0 THEN
  770. // rslt = 0
  771. // GOTO ext
  772. // END IF
  773. IF f_update_mtrlware_spt_out(billtype,thflag,scid,outwaremx[i].mtrlid, &
  774. outwaremx[i].mtrlcode, outwaremx[i].plancode,&
  775. outwaremx[i].status, 0 - outwaremx[i].qty, 0 - outwaremx[i].costamt,&
  776. outwaremx[i].planprice, sptid, &
  777. outwaremx[i].woodcode, outwaremx[i].pcode,arg_msg,false,commit_transaction) = 0 THEN
  778. rslt = 0
  779. GOTO ext
  780. END IF
  781. IF outwaremx[i].relid > 0 THEN
  782. IF uo_wfjg.addmxcmpl_out(scid,outwaremx[i].relid,outwaremx[i].mtrlid,0,outwaremx[i].status,&
  783. outwaremx[i].woodcode,outwaremx[i].pcode,0 - outwaremx[i].qty,&
  784. arg_msg,FALSE) = 0 THEN
  785. rslt = 0
  786. GOTO ext
  787. END IF
  788. end if
  789. NEXT
  790. flag = 0
  791. ext:
  792. IF rslt = 0 THEN
  793. ROLLBACK USING commit_transaction;
  794. ELSEIF rslt = 1 AND arg_ifcommit THEN
  795. COMMIT USING commit_transaction;
  796. END IF
  797. if thflag = 0 then
  798. arg_msg = '车间外协发出单,'+ arg_msg
  799. else
  800. arg_msg = '车间外协退回单,'+ arg_msg
  801. end if
  802. RETURN rslt
  803. end function
  804. public function integer p_clearmx ();//int p_clearmx()
  805. //清除明细
  806. it_mxbt=0
  807. return 1
  808. end function
  809. public function integer p_getinfo (long arg_scid, long arg_outwareid, ref string arg_msg);//p_getinfo(arg_scid,arg_outwareid,arg_msg)
  810. //0 失败 1成功
  811. INT rslt=1
  812. IF arg_outwareid<=0 THEN
  813. rslt=0
  814. arG_MSG="非法出仓单唯一码"
  815. goto ext
  816. end if
  817. SELECT ow_wfjg_out.outwarecode,
  818. ow_wfjg_out.billtype,
  819. ow_wfjg_out.relid,
  820. ow_wfjg_out.outdate,
  821. ow_wfjg_out.outrep,
  822. ow_wfjg_out.part,
  823. ow_wfjg_out.sptid,
  824. ow_wfjg_out.sptname,
  825. ow_wfjg_out.dscrp,
  826. ow_wfjg_out.thflag,
  827. ow_wfjg_out.flag,
  828. ow_wfjg_out.balcflag
  829. INTO :outwarecode,
  830. :billtype,
  831. :relid,
  832. :outdate,
  833. :outrep,
  834. :part,
  835. :sptid,
  836. :sptname,
  837. :dscrp,
  838. :thflag,
  839. :flag,
  840. :balcflag
  841. FROM ow_wfjg_out
  842. WHERE ow_wfjg_out.outwareid = :arg_outwareid
  843. and scid=:arg_scid
  844. using commit_transaction;
  845. if commit_transaction.sqlcode<>0 then
  846. rslt=0
  847. if pos(lower(commit_transaction.SQLErrText),'more than') > 0 then
  848. arg_msg = '查询操作失败,查询数据返回值多于一个'
  849. else
  850. arG_MSG="查询操作失败(错误出仓单唯一码)"
  851. end if
  852. goto ext
  853. end if
  854. outwareid = arg_outwareid
  855. scid = arg_scid
  856. ext:
  857. IF rslt=0 THEN p_reset()
  858. return rslt
  859. end function
  860. public function integer p_reset ();//int p_reset()
  861. //清除对象及其明细
  862. scid = 0
  863. outwareid = 0
  864. outwarecode = ''
  865. billtype = 0
  866. opemp = ''
  867. modemp = ''
  868. auditingrep = ''
  869. flag = 0
  870. relid = 0
  871. //storageid = 0
  872. outrep = ''
  873. part = ''
  874. dscrp = ''
  875. sptid = 0
  876. sptname = ''
  877. thflag = 0
  878. it_newbegin = FALSE
  879. it_updatebegin = FALSE
  880. //清除明细
  881. p_clearmx()
  882. RETURN 1
  883. end function
  884. public function integer p_update_sptware (long arg_mtrlwareid, long arg_mtrlid, string arg_mtrlcode, string arg_plancode, string arg_status, decimal arg_qty, decimal arg_costamt, decimal arg_planprice, long arg_sptid, string arg_woodcode, string arg_pcode, ref string arg_msg);Int rslt = 1
  885. Long ls_newid
  886. Decimal ld_cost
  887. UPDATE ow_wfjgware
  888. SET noallocqty = noallocqty + :arg_qty ,
  889. wareamt = wareamt + :arg_costamt,
  890. cost = case noallocqty + :arg_qty when 0 then cost else round((wareamt + :arg_costamt)/(noallocqty + :arg_qty),10) END ,
  891. waredate = getdate()
  892. WHERE ( mtrlid = :arg_mtrlid ) AND
  893. ( scid = :scid ) AND (status = :arg_Status) AND woodcode = :arg_woodcode AND
  894. pcode = :arg_pcode AND plancode = :arg_plancode AND sptid = :arg_sptid USING commit_transaction ;
  895. IF commit_transaction.SQLCode = 0 THEN
  896. IF commit_transaction.SQLNRows = 0 THEN
  897. ls_newid = f_sys_scidentity(scid,"ow_wfjgware","mtrlwareid",arg_msg,FALSE,commit_transaction)
  898. IF ls_newid <= 0 THEN
  899. rslt = 0
  900. GOTO ext
  901. END IF
  902. ld_cost = Round(arg_costamt/arg_qty,10)
  903. INSERT INTO ow_wfjgware
  904. ( scid,
  905. mtrlwareid,
  906. mtrlid,
  907. plancode,
  908. status,
  909. noallocqty,
  910. allocqty,
  911. wareamt,
  912. planprice,
  913. sptid,
  914. woodcode,
  915. pcode,
  916. cost)
  917. VALUES (
  918. :scid,
  919. :ls_newid,
  920. :arg_mtrlid,
  921. :arg_plancode,
  922. :arg_status,
  923. :arg_qty,
  924. 0,
  925. :arg_costamt,
  926. :arg_planprice,
  927. :arg_sptid,
  928. :arg_woodcode,
  929. :arg_pcode,
  930. :ld_cost) USING commit_transaction ;
  931. IF commit_transaction.SQLCode <> 0 THEN
  932. rslt = 0
  933. if pos(lower(commit_transaction.SQLErrText),'pk_ow_wfjgware') > 0 then
  934. arg_msg = '插入外协商库存操作失败,关键字分部ID、库存ID重复'
  935. else
  936. arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存建立操作失败"+"~n"+commit_transaction.SQLErrText
  937. end if
  938. GOTO ext
  939. END IF
  940. END IF
  941. ELSE
  942. rslt = 0
  943. String or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  944. IF commit_transaction.SQLCode = 513 OR Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  945. arg_msg = "物料["+arg_mtrlcode+"]同供应商仓库内同批号没有足够的库存支持冲减"
  946. ELSE
  947. arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]库存更新操作失败"+"~n"+commit_transaction.SQLErrText
  948. END IF
  949. GOTO ext
  950. END IF
  951. //--------------------更新结存
  952. Decimal ld_thqty,ld_thamt
  953. Decimal ld_inqty,ld_inamt
  954. Decimal ld_balcqty,ld_balcamt
  955. ld_balcqty = arg_qty
  956. ld_balcamt = arg_costamt
  957. IF thflag = 0 THEN
  958. ld_inqty = arg_qty
  959. ld_inamt = arg_costamt
  960. ld_thqty = 0
  961. ld_thamt = 0
  962. ELSE
  963. ld_inqty = 0
  964. ld_inamt = 0
  965. ld_thqty = 0 - arg_qty
  966. ld_thamt = 0 - arg_costamt
  967. END IF
  968. UPDATE ow_wfjgbalc
  969. SET
  970. balcqty = balcqty + :ld_balcqty,
  971. balcamt = balcamt + :ld_balcamt,
  972. inqty = inqty + :ld_inqty,
  973. inamt = inamt + :ld_inamt,
  974. thqty = thqty + :ld_thqty,
  975. thamt = thamt + :ld_thamt
  976. WHERE ( mtrlid = :arg_mtrlid ) AND
  977. ( balcdateint = 0 ) AND
  978. ( status = :arg_status ) AND
  979. ( woodcode = :arg_woodcode ) AND
  980. ( sptid = :arg_sptid ) USING commit_transaction ;
  981. IF commit_transaction.SQLCode = 0 THEN
  982. IF commit_transaction.SQLNRows = 0 THEN
  983. INSERT INTO ow_wfjgbalc
  984. (scid,
  985. balcdateint,
  986. sptid,
  987. mtrlid,
  988. status,
  989. woodcode,
  990. thqty,
  991. thamt,
  992. inqty,
  993. inamt,
  994. balcqty,
  995. balcamt)
  996. VALUES (:scid,
  997. 0,
  998. :arg_sptid,
  999. :arg_mtrlid,
  1000. :arg_status,
  1001. :arg_woodcode,
  1002. :ld_thqty,
  1003. :ld_thamt,
  1004. :ld_inqty,
  1005. :ld_inamt,
  1006. :ld_balcqty,
  1007. :ld_balcamt) USING commit_transaction;
  1008. IF commit_transaction.SQLCode <> 0 THEN
  1009. rslt = 0
  1010. if pos(lower(commit_transaction.SQLErrText),'pk_ow_wfjgbalc') > 0 then
  1011. arg_msg = '插入外协商结存操作失败,关键字重复'
  1012. else
  1013. arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]结存建立操作失败"+"~n"+commit_transaction.SQLErrText
  1014. end if
  1015. GOTO ext
  1016. END IF
  1017. END IF
  1018. ELSE
  1019. rslt = 0
  1020. or_err_part = 'column insert or update conflicts with a rule imposed by a previous create rule statement'
  1021. IF commit_transaction.SQLCode = 513 OR Pos(Lower(commit_transaction.SQLErrText),or_err_part) > 0 THEN
  1022. arg_msg = "物料["+arg_mtrlcode+"]同仓库内同批号没有足够的结存支持冲减"
  1023. ELSE
  1024. arg_msg = "因网络或其它原因导致物料["+arg_mtrlcode+"]结存更新操作失败"+"~n"+commit_transaction.SQLErrText
  1025. END IF
  1026. GOTO ext
  1027. END IF
  1028. ext:
  1029. IF rslt = 0 THEN
  1030. ROLLBACK;
  1031. END IF
  1032. RETURN rslt
  1033. end function
  1034. public function integer acceptmx (long arg_mtrlwareid, decimal arg_uqty, string arg_uunit, decimal arg_qty, string arg_mxdscrp, long arg_printid, ref string arg_msg, integer arg_ifrel, long arg_relid, long arg_mtrlid, long arg_storageid, integer arg_dxflag, string arg_plancode, string arg_mtrlcode, string arg_status, string arg_woodcode, string arg_pcode, decimal arg_fprice, decimal arg_rebate, long arg_sptid, decimal arg_rate, string arg_jgdscrp, string arg_mxdscrp2);//此对象淘汰不用
  1035. Long rslt = 1,cnt = 0,LS_i
  1036. Decimal i_planprice,ld_dftsaleprice
  1037. Double i_newprice
  1038. String ls_relcode
  1039. IF it_newbegin = False And it_updatebegin = False THEN
  1040. rslt = 0
  1041. arg_msg = "非编辑状态不可以使用,操作取消"
  1042. GOTO ext
  1043. END IF
  1044. //清除空值
  1045. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  1046. IF IsNull(arg_printid) THEN arg_printid = 0
  1047. IF IsNull(arg_qty) THEN arg_qty = 0
  1048. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1049. IF IsNull(arg_ifrel) THEN arg_ifrel = 0
  1050. IF IsNull(arg_relid) THEN arg_relid = 0
  1051. IF IsNull(arg_mtrlid) THEN arg_mtrlid = 0
  1052. IF IsNull(arg_mtrlcode) THEN arg_mtrlcode = ''
  1053. IF IsNull(arg_plancode) THEN arg_plancode = ''
  1054. IF IsNull(arg_status) THEN arg_status = ''
  1055. IF IsNull(arg_fprice) THEN arg_fprice = 0
  1056. IF IsNull(arg_rebate) THEN arg_rebate = 0
  1057. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1058. IF IsNull(arg_relid) THEN arg_relid = 0
  1059. IF IsNull(arg_ifrel) THEN arg_ifrel = 0
  1060. IF IsNull(arg_mxdscrp) THEN arg_woodcode = ''
  1061. IF IsNull(arg_pcode) THEN arg_pcode = ''
  1062. IF IsNull(arg_storageid) THEN arg_storageid = 0
  1063. IF IsNull(arg_uqty) THEN arg_uqty = 0
  1064. IF IsNull(arg_uunit) THEN arg_uunit = ''
  1065. IF IsNull(arg_rate) THEN arg_rate = 1
  1066. IF IsNull(arg_jgdscrp) THEN arg_jgdscrp = ''
  1067. IF IsNull(arg_mxdscrp2) THEN arg_mxdscrp2 = ''
  1068. // 如果出仓数量为 0,或物料编号为空,则不作任何处理
  1069. IF arg_mtrlid = 0 Or arg_qty = 0 THEN
  1070. rslt = 1
  1071. GOTO ext
  1072. END IF
  1073. IF sys_option_2unit = 1 THEN
  1074. IF arg_uqty = 0 THEN
  1075. arg_msg = '行:'+String(arg_printid)+ ',请输入计价数量'
  1076. rslt = 0
  1077. GOTO ext
  1078. END IF
  1079. IF Trim(arg_uunit) = '' THEN
  1080. arg_msg = '行:'+String(arg_printid)+ ',请输入计价单位'
  1081. rslt = 0
  1082. GOTO ext
  1083. END IF
  1084. END IF
  1085. //检查物料id
  1086. SELECT planprice
  1087. INTO :i_planprice
  1088. FROM u_mtrldef
  1089. Where u_mtrldef.mtrlid = :arg_mtrlid Using commit_transaction ;
  1090. IF commit_transaction.SQLCode <> 0 THEN
  1091. rslt = 0
  1092. IF Pos(Lower(commit_transaction.SQLErrText),'more than') > 0 THEN
  1093. arg_msg = '查询物料资料操作失败,查询数据返回值多于一个'
  1094. ELSE
  1095. arg_msg = "查询操作失败,编码:"+arg_mtrlcode
  1096. END IF
  1097. GOTO ext
  1098. END IF
  1099. IF f_check_status(1, arg_status) = 0 THEN
  1100. rslt = 0
  1101. arg_msg = "查询操作失败,可能颜色未定义,编码:"+arg_mtrlcode+",颜色:"+arg_status
  1102. GOTO ext
  1103. END IF
  1104. IF arg_ifrel = 1 THEN
  1105. IF arg_relid = 0 THEN
  1106. rslt = 0
  1107. arg_msg = '请选择加工计划!'
  1108. GOTO ext
  1109. END IF
  1110. SELECT taskcode INTO :ls_relcode
  1111. FROM u_order_wfjg
  1112. Where wfjgID = :arg_relid Using commit_transaction;
  1113. IF commit_transaction.SQLCode <> 0 THEN
  1114. rslt = 0
  1115. arg_msg = '查询加工计划号失败!没有对应的外加工计划'
  1116. GOTO ext
  1117. END IF
  1118. SELECT count(*) INTO :cnt
  1119. FROM u_order_wfjgMx_out
  1120. WHERE wfjgid = :arg_relid
  1121. AND mtrlid = :arg_mtrlid
  1122. AND status = :arg_status
  1123. Using commit_transaction;
  1124. IF commit_transaction.SQLCode <> 0 THEN
  1125. rslt = 0
  1126. arg_msg = '查询加工计划出仓明细失败!,外加工计划没有对应物料明细'
  1127. GOTO ext
  1128. END IF
  1129. IF cnt = 0 THEN
  1130. rslt = 0
  1131. arg_msg = '出仓物料:'+arg_mtrlcode+'不在加工计划出仓明细中!'
  1132. GOTO ext
  1133. END IF
  1134. END IF
  1135. //***********************************************
  1136. IF arg_fprice * arg_rebate < 0 THEN //检查进仓价
  1137. rslt = 0
  1138. arg_msg = "编码:" + String(arg_mtrlcode)+" 单价错误"
  1139. GOTO ext
  1140. END IF
  1141. //写入内容
  1142. it_mxbt++
  1143. outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
  1144. outwaremx[it_mxbt].mtrlid = arg_mtrlid
  1145. outwaremx[it_mxbt].status = arg_status
  1146. outwaremx[it_mxbt].qty = arg_qty
  1147. outwaremx[it_mxbt].storageid = arg_storageid
  1148. outwaremx[it_mxbt].cost = arg_fprice
  1149. outwaremx[it_mxbt].costamt = Round(arg_fprice * arg_qty,2)
  1150. outwaremx[it_mxbt].newpriceamt = Round(i_newprice * arg_qty,2)
  1151. //IF sys_option_buyprice_type = 1 THEN
  1152. outwaremx[it_mxbt].plancode = arg_plancode
  1153. //ELSE
  1154. // outwaremx[it_mxbt].plancode = String(Round(arg_fprice * arg_rebate,10))
  1155. //END IF
  1156. outwaremx[it_mxbt].planprice = i_planprice
  1157. outwaremx[it_mxbt].mtrlcode = arg_mtrlcode
  1158. outwaremx[it_mxbt].mxdscrp = arg_mxdscrp
  1159. outwaremx[it_mxbt].mxdscrp2 = arg_mxdscrp2
  1160. outwaremx[it_mxbt].printid = arg_printid
  1161. outwaremx[it_mxbt].rebate = arg_rebate
  1162. outwaremx[it_mxbt].fprice = arg_fprice
  1163. outwaremx[it_mxbt].price = Round(arg_fprice * arg_rebate,10)
  1164. outwaremx[it_mxbt].sptid = arg_sptid
  1165. outwaremx[it_mxbt].dxflag = arg_dxflag
  1166. outwaremx[it_mxbt].ifrel = arg_ifrel
  1167. outwaremx[it_mxbt].relid = arg_relid
  1168. outwaremx[it_mxbt].rate = arg_rate
  1169. outwaremx[it_mxbt].woodcode = arg_woodcode
  1170. outwaremx[it_mxbt].pcode = arg_pcode
  1171. outwaremx[it_mxbt].relcode = ls_relcode
  1172. outwaremx[it_mxbt].jgdscrp = arg_jgdscrp
  1173. IF sys_option_2unit = 0 THEN
  1174. outwaremx[it_mxbt].uprice = arg_fprice
  1175. outwaremx[it_mxbt].uqty = arg_qty
  1176. ELSE
  1177. outwaremx[it_mxbt].uprice = Round(arg_qty * arg_fprice/arg_uqty,5)
  1178. outwaremx[it_mxbt].uqty = arg_uqty
  1179. END IF
  1180. outwaremx[it_mxbt].uunit = arg_uunit
  1181. ext:
  1182. IF rslt = 0 THEN p_clearmx()
  1183. IF thflag = 0 THEN
  1184. arg_msg = '车间外协发出单,'+ arg_msg
  1185. ELSE
  1186. arg_msg = '车间外协退回单,'+ arg_msg
  1187. END IF
  1188. RETURN rslt
  1189. end function
  1190. on uo_wfjg_py.create
  1191. call super::create
  1192. TriggerEvent( this, "constructor" )
  1193. end on
  1194. on uo_wfjg_py.destroy
  1195. TriggerEvent( this, "destructor" )
  1196. call super::destroy
  1197. end on