uo_outware_move.sru 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599
  1. $PBExportHeader$uo_outware_move.sru
  2. forward
  3. global type uo_outware_move from nonvisualobject
  4. end type
  5. type s_outwaremx from structure within uo_outware_move
  6. end type
  7. end forward
  8. type s_outwaremx from structure
  9. long mtrlwareid
  10. long mtrlid
  11. long storageid
  12. decimal { 10 } qty
  13. decimal { 10 } uqty
  14. decimal { 5 } rate
  15. string unit
  16. string plancode
  17. decimal { 10 } cost
  18. string mtrlcode
  19. string mxdscrp
  20. long printid
  21. string status
  22. long scid
  23. integer dxflag
  24. long sptid
  25. string woodcode
  26. string pcode
  27. decimal { 10 } price
  28. string mtrlcuscode
  29. string location
  30. string newlocation
  31. decimal { 10 } inqty
  32. decimal { 10 } outqty
  33. integer outtype_mtrl
  34. integer ifrel
  35. long relid
  36. long relprintid
  37. string relcode
  38. end type
  39. global type uo_outware_move from nonvisualobject
  40. end type
  41. global uo_outware_move uo_outware_move
  42. type variables
  43. Public ProtectedWrite Long outwareid //出仓单表自动增量id
  44. Public ProtectedWrite String outwarecode //所有单据的唯一编号
  45. Public ProtectedWrite DateTime opdate //建立时间,自动
  46. Public ProtectedWrite Int flag = 0 //仓库审核标志,默认0,审核时(变1)才减少库存
  47. Public ProtectedWrite DateTime auditingdate //审核时间
  48. Public ProtectedWrite String auditingrep //审核操作员
  49. Public ProtectedWrite Int d_auditflag = 0 //仓库审核标志,默认0,审核时(变1)才减少库存
  50. Public ProtectedWrite DateTime d_auditingdate //审核时间
  51. Public ProtectedWrite String d_auditingrep //审核操作员
  52. Public ProtectedWrite String operator //建立操作员
  53. Public ProtectedWrite DateTime moddate //修改时间
  54. Public ProtectedWrite String modrep //修改操作员
  55. Public ProtectedWrite Int priceflag = 0
  56. long sscid
  57. long dscid
  58. Long sstorageid //原仓位
  59. Long dstorageid //目标仓位
  60. DateTime outdate //进仓发生时间
  61. DateTime indate //进仓发生时间
  62. String outrep = '' //经手人
  63. String dscrp = '' //备注
  64. String relcode = ''
  65. Int ifauto = 0 //自动建立
  66. long il_newlocation_cnt
  67. Boolean if_getid_ture = True
  68. Private:
  69. s_outwaremx outwaremx[] //明细结构数组
  70. s_outwaremx_barcode s_mx_barcode[]
  71. s_outwaremx_barcode s_mx_barcode_in[]
  72. Long it_mxbt = 0 //明细结构数组末指针
  73. Long it_mxbt_barcode = 0
  74. Long it_mxbt_barcode_in = 0
  75. Boolean it_newbegin = True //新建标志
  76. Boolean it_updatebegin = False //修改标志
  77. Int uo_option_barcode_outwaremove_paudit
  78. Int uo_option_inout_type
  79. Int uo_option_noauditingqty_mode
  80. Int uo_option_barcodelocation_use_inwaremx_location
  81. end variables
  82. forward prototypes
  83. public function integer add_dscrp (string arg_newdescppart, ref string arg_msg)
  84. public function integer p_clearmx ()
  85. public function integer p_reset ()
  86. public function integer p_getinfo (long arg_outwareid, ref string arg_msg)
  87. public function integer newbegin (ref string arg_msg)
  88. public function integer getinfo (long arg_outwareid, ref string arg_msg)
  89. public function integer updatebegin (long arg_outwareid, ref string arg_msg)
  90. public function integer ss_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  91. public function integer c_ds_auditing (ref string arg_msg, boolean arg_ifcommit)
  92. public function integer c_ss_auditing (ref string arg_msg, boolean arg_ifcommit)
  93. public function integer ds_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  94. public function integer cancel (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  95. public function integer save (ref string arg_msg, boolean arg_ifcommit)
  96. public function integer p_update_cost (long arg_mtrlwareid, long arg_printid, string arg_mtrlcode, ref decimal arg_ref_cost, ref string arg_msg, boolean arg_ifcommit)
  97. public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg)
  98. public function integer p_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  99. public function integer c_p_auditing (ref string arg_msg, boolean arg_ifcommit)
  100. public function integer uof_set_qty_equal_bqty (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit)
  101. public function integer uof_mod_indate (long arg_outwareid, datetime arg_indate, ref string arg_msg)
  102. public function integer uof_noauditingqty_add (ref string arg_msg)
  103. public function integer uof_noauditingqty_del (long arg_outwareid, ref string arg_msg)
  104. public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_newlocation, integer arg_ifrel, long arg_relid, long arg_relprintid, string arg_relcode)
  105. end prototypes
  106. public function integer add_dscrp (string arg_newdescppart, ref string arg_msg);//add_dscrp(string arg_newdescppart)
  107. //0 fail 1 success
  108. int rslt=1
  109. arg_newdescppart=trim(arg_newdescppart)
  110. if it_updatebegin or it_newbegin then
  111. rslt=0
  112. arg_msg="编辑状态下不可用"
  113. goto ext
  114. end if
  115. update u_outware_move
  116. set dscrp = dscrp+' '+:arg_newdescppart
  117. where u_outware_move.outwareid = :outwareid;
  118. if sqlca.sqlcode<>0 then
  119. rollback ;
  120. rslt=0
  121. arg_msg="因网络或其它原因导致添加单据备注操作失败"+"~n"+sqlca.sqlerrtext
  122. goto ext
  123. end if
  124. commit;
  125. dscrp = dscrp+' '+arg_newdescppart
  126. ext: return (rslt)
  127. end function
  128. public function integer p_clearmx ();//INT p_clearmx()
  129. //清除明细
  130. il_newlocation_cnt = 0
  131. it_mxbt = 0
  132. it_mxbt_barcode = 0
  133. it_mxbt_barcode_in = 0
  134. RETURN 1
  135. end function
  136. public function integer p_reset ();//int p_reset()
  137. //清除对象及其明细
  138. outwareid = 0
  139. outwarecode = ''
  140. flag = 0
  141. relcode = ''
  142. sstorageid = 0
  143. dstorageid = 0
  144. outrep = ''
  145. dscrp = ''
  146. d_auditflag = 0
  147. ifauto = 0
  148. it_newbegin = FALSE
  149. it_updatebegin = FALSE
  150. //清除明细
  151. p_clearmx()
  152. RETURN 1
  153. end function
  154. public function integer p_getinfo (long arg_outwareid, ref string arg_msg);//getinfo(arg_outwareid,string arg_msg)
  155. //0 失败 1成功
  156. Int rslt = 1
  157. IF arg_outwareid <= 0 THEN
  158. rslt = 0
  159. arg_msg = "非法调拨单唯一码"
  160. GOTO ext
  161. END IF
  162. SELECT
  163. u_outware_move.outwarecode,
  164. u_outware_move.opdate,
  165. u_outware_move.operator,
  166. u_outware_move.flag,
  167. u_outware_move.auditingdate,
  168. u_outware_move.auditingrep,
  169. u_outware_move.moddate,
  170. u_outware_move.modrep,
  171. u_outware_move.outdate,
  172. u_outware_move.indate,
  173. u_outware_move.outrep,
  174. u_outware_move.dscrp,
  175. u_outware_move.sstorageid,
  176. u_outware_move.dstorageid,
  177. u_outware_move.relcode,
  178. u_outware_move.d_auditflag,
  179. u_outware_move.d_auditingdate,
  180. u_outware_move.d_auditingrep,
  181. u_outware_move.ifauto,
  182. u_outware_move.priceflag
  183. Into :outwarecode,
  184. :opdate,
  185. :operator,
  186. :flag,
  187. :auditingdate,
  188. :auditingrep,
  189. :moddate,
  190. :modrep,
  191. :outdate,
  192. :indate,
  193. :outrep,
  194. :dscrp,
  195. :sstorageid,
  196. :dstorageid,
  197. :relcode,
  198. :d_auditflag,
  199. :d_auditingdate,
  200. :d_auditingrep,
  201. :ifauto,
  202. :priceflag
  203. From u_outware_move
  204. Where u_outware_move.outwareid = :arg_outwareid;
  205. IF sqlca.SQLCode <> 0 THEN
  206. rslt = 0
  207. arg_msg = "查询操作失败(错误出仓单唯一码),调拨单"
  208. GOTO ext
  209. END IF
  210. SELECT scid
  211. INTO :sscid
  212. FROM u_storage
  213. Where storageid = :sstorageid;
  214. IF sqlca.SQLCode <> 0 THEN
  215. rslt = 0
  216. arg_msg = "查询操作失败(原仓库分部),调拨单"
  217. GOTO ext
  218. END IF
  219. SELECT scid
  220. INTO :dscid
  221. FROM u_storage
  222. Where storageid = :dstorageid;
  223. IF sqlca.SQLCode <> 0 THEN
  224. rslt = 0
  225. arg_msg = "查询操作失败(目标仓库分部),调拨单"
  226. GOTO ext
  227. END IF
  228. ext:
  229. IF rslt = 0 THEN p_reset()
  230. RETURN rslt
  231. end function
  232. public function integer newbegin (ref string arg_msg);//newbegin(INT arg_billtype,long arg_relid)
  233. //从置对象,设定业务类型与关联ID,准备建立新出仓单
  234. //0 fail 1 success
  235. LONG RSLT=1,CNT=0
  236. p_reset()
  237. it_newbegin=TRUE
  238. it_updatebegin=FALSE
  239. //EXT:
  240. IF RSLT=0 THEN p_reset()
  241. return RSLT
  242. end function
  243. public function integer getinfo (long arg_outwareid, ref string arg_msg);//getinfo(long arg_outwareid,string arg_msg)
  244. //0 失败 1成功
  245. Int rslt = 1
  246. Long i = 1,no_mxcheck = 0
  247. Long k = 1,no_mxcheck_barcode = 0
  248. Long j = 1,no_mxcheck_barcode_in = 0
  249. Int li_outtype,li_outtype_in
  250. IF arg_outwareid <= 0 THEN
  251. rslt = 0
  252. arg_msg = "非法调拨仓单唯一码"
  253. GOTO ext
  254. END IF
  255. IF p_getinfo(arg_outwareid,arg_msg) = 0 THEN
  256. rslt = 0
  257. GOTO ext
  258. END IF
  259. SELECT outtype
  260. INTO :li_outtype
  261. FROM u_storage
  262. Where storageid = :sstorageid;
  263. IF sqlca.SQLCode <> 0 THEN
  264. rslt = 0
  265. arg_msg = "查询操作失败,调出仓库出仓类型,"+sqlca.SQLErrText
  266. GOTO ext
  267. END IF
  268. SELECT outtype
  269. INTO :li_outtype_in
  270. FROM u_storage
  271. Where storageid = :dstorageid;
  272. IF sqlca.SQLCode <> 0 THEN
  273. rslt = 0
  274. arg_msg = "查询操作失败,调入仓库出仓类型,"+sqlca.SQLErrText
  275. GOTO ext
  276. END IF
  277. //用游标读取明细
  278. DECLARE cur_outwaermx CURSOR FOR
  279. SELECT u_outwaremovemx.mtrlwareid,
  280. u_outwaremovemx.mtrlid,
  281. u_outwaremovemx.storageid,
  282. u_outwaremovemx.qty,
  283. u_outwaremovemx.cost,
  284. u_outwaremovemx.price,
  285. u_mtrldef.mtrlcode,
  286. u_outwaremovemx.printid,
  287. u_outwaremovemx.mxdscrp,
  288. u_outwaremovemx.status,
  289. u_outwaremovemx.plancode,
  290. u_outwaremovemx.scid,
  291. u_outwaremovemx.dxflag,
  292. u_outwaremovemx.sptid,
  293. u_outwaremovemx.woodcode,
  294. u_outwaremovemx.pcode,
  295. u_outwaremovemx.unit,
  296. u_outwaremovemx.uqty,
  297. u_outwaremovemx.rate,
  298. u_outwaremovemx.mtrlcuscode,
  299. u_outwaremovemx.location,
  300. u_outwaremovemx.newlocation,
  301. u_outwaremovemx.inqty,
  302. u_outwaremovemx.outqty,
  303. u_mtrldef.outtype,
  304. u_outwaremovemx.ifrel,
  305. u_outwaremovemx.relid,
  306. u_outwaremovemx.relprintid,
  307. u_outwaremovemx.relcode
  308. FROM u_outwaremovemx,u_mtrldef
  309. WHERE u_outwaremovemx.outwareid = :arg_outwareid AND
  310. u_outwaremovemx.mtrlid = u_mtrldef.mtrlid
  311. Order By u_outwaremovemx.printid;
  312. OPEN cur_outwaermx;
  313. FETCH cur_outwaermx INTO :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
  314. :outwaremx[i].storageid,:outwaremx[i].qty,
  315. :outwaremx[i].cost,:outwaremx[i].price,
  316. :outwaremx[i].mtrlcode,:outwaremx[i].printid,
  317. :outwaremx[i].mxdscrp,:outwaremx[i].status,
  318. :outwaremx[i].plancode,:outwaremx[i].scid,
  319. :outwaremx[i].dxflag,:outwaremx[i].sptid,
  320. :outwaremx[i].woodcode,:outwaremx[i].pcode,
  321. :outwaremx[i].unit,:outwaremx[i].uqty,
  322. :outwaremx[i].rate,:outwaremx[i].mtrlcuscode,
  323. :outwaremx[i].Location,:outwaremx[i].newlocation,
  324. :outwaremx[i].inqty,:outwaremx[i].outqty,:outwaremx[i].outtype_mtrl,
  325. :outwaremx[i].ifrel,:outwaremx[i].relid,:outwaremx[i].relprintid,:outwaremx[i].relcode;
  326. DO WHILE sqlca.SQLCode = 0
  327. i++
  328. FETCH cur_outwaermx INTO :outwaremx[i].mtrlwareid,:outwaremx[i].mtrlid,
  329. :outwaremx[i].storageid,:outwaremx[i].qty,
  330. :outwaremx[i].cost,:outwaremx[i].price,
  331. :outwaremx[i].mtrlcode,:outwaremx[i].printid,
  332. :outwaremx[i].mxdscrp,:outwaremx[i].status,
  333. :outwaremx[i].plancode,:outwaremx[i].scid,
  334. :outwaremx[i].dxflag,:outwaremx[i].sptid,
  335. :outwaremx[i].woodcode,:outwaremx[i].pcode,
  336. :outwaremx[i].unit,:outwaremx[i].uqty,
  337. :outwaremx[i].rate,:outwaremx[i].mtrlcuscode,
  338. :outwaremx[i].Location,:outwaremx[i].newlocation,
  339. :outwaremx[i].inqty,:outwaremx[i].outqty,:outwaremx[i].outtype_mtrl,
  340. :outwaremx[i].ifrel,:outwaremx[i].relid,:outwaremx[i].relprintid,:outwaremx[i].relcode;
  341. LOOP
  342. CLOSE cur_outwaermx;
  343. //检验明细是否读入完整
  344. SELECT count(*) INTO :no_mxcheck
  345. FROM u_outwaremovemx
  346. Where u_outwaremovemx.outwareid = :arg_outwareid;
  347. IF sqlca.SQLCode <> 0 THEN
  348. rslt = 0
  349. arg_msg = "查询操作失败,调拨单明细数量"
  350. GOTO ext
  351. END IF
  352. IF i <> no_mxcheck+1 THEN
  353. rslt = 0
  354. arg_msg = "查询操作失败,调拨单明细"
  355. GOTO ext
  356. END IF
  357. //用游标读取调出条码明细
  358. If (li_outtype = 2 Or li_outtype_in = 2 Or li_outtype_in = 3 ) And uo_option_barcode_outwaremove_paudit = 0 Or &
  359. li_outtype = 2 And uo_option_barcode_outwaremove_paudit = 1 THEN
  360. DECLARE cur_outwaremx_barcode CURSOR FOR
  361. SELECT u_outwaremx_mx_barcode.barcode,
  362. u_outwaremx_mx_barcode.qty
  363. FROM u_outwaremx_mx_barcode
  364. WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND
  365. //u_outwaremx_mx_barcode.scid = 0 AND
  366. u_outwaremx_mx_barcode.billtype = 50
  367. Order By u_outwaremx_mx_barcode.barcode;
  368. OPEN cur_outwaremx_barcode;
  369. FETCH cur_outwaremx_barcode Into :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty;
  370. DO WHILE sqlca.SQLCode = 0
  371. k++
  372. FETCH cur_outwaremx_barcode Into :s_mx_barcode[k].barcode,:s_mx_barcode[k].qty;
  373. LOOP
  374. CLOSE cur_outwaremx_barcode;
  375. //检验明细是否读入完整
  376. SELECT count(*) INTO :no_mxcheck_barcode
  377. FROM u_outwaremx_mx_barcode
  378. WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid
  379. //AND u_outwaremx_mx_barcode.scid = 0
  380. And u_outwaremx_mx_barcode.billtype = 50;
  381. IF sqlca.SQLCode <> 0 THEN
  382. rslt = 0
  383. arg_msg = "查询操作失败,调仓单调出条码明细数量"
  384. GOTO ext
  385. END IF
  386. IF k <> (no_mxcheck_barcode+1) THEN
  387. rslt = 0
  388. arg_msg = "查询操作失败,调仓单调出条码明细"
  389. GOTO ext
  390. END IF
  391. it_mxbt_barcode = k - 1
  392. END IF
  393. //调入条码明细
  394. IF (li_outtype_in = 2 Or li_outtype_in = 3) And uo_option_barcode_outwaremove_paudit = 1 THEN
  395. DECLARE cur_outwaremx_barcode_in CURSOR FOR
  396. SELECT u_outwaremx_mx_barcode.barcode,
  397. u_outwaremx_mx_barcode.qty
  398. FROM u_outwaremx_mx_barcode
  399. WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid AND
  400. //u_outwaremx_mx_barcode.scid = 0 AND
  401. u_outwaremx_mx_barcode.billtype = 53
  402. Order By u_outwaremx_mx_barcode.barcode;
  403. OPEN cur_outwaremx_barcode_in;
  404. FETCH cur_outwaremx_barcode_in Into :s_mx_barcode_in[j].barcode,:s_mx_barcode_in[j].qty;
  405. DO WHILE sqlca.SQLCode = 0
  406. j++
  407. FETCH cur_outwaremx_barcode_in Into :s_mx_barcode_in[j].barcode,:s_mx_barcode_in[j].qty;
  408. LOOP
  409. CLOSE cur_outwaremx_barcode_in;
  410. //检验明细是否读入完整
  411. SELECT count(*) INTO :no_mxcheck_barcode_in
  412. FROM u_outwaremx_mx_barcode
  413. WHERE u_outwaremx_mx_barcode.outwareid = :arg_outwareid
  414. //AND u_outwaremx_mx_barcode.scid = 0
  415. And u_outwaremx_mx_barcode.billtype = 53;
  416. IF sqlca.SQLCode <> 0 THEN
  417. rslt = 0
  418. arg_msg = "查询操作失败,调仓单调入条码明细数量"
  419. GOTO ext
  420. END IF
  421. IF j <> (no_mxcheck_barcode_in+1) THEN
  422. rslt = 0
  423. arg_msg = "查询操作失败,调仓单调入条码明细"
  424. GOTO ext
  425. END IF
  426. it_mxbt_barcode_in = j - 1
  427. END IF
  428. outwareid = arg_outwareid
  429. it_mxbt = i - 1
  430. it_newbegin = False
  431. it_updatebegin = False
  432. ext:
  433. IF rslt = 0 THEN p_reset()
  434. RETURN rslt
  435. end function
  436. public function integer updatebegin (long arg_outwareid, ref string arg_msg);//updatebegin(long arg_outwareid,int arg_billtype,long arg_relid)
  437. //从置对象,设定业务类型与关联id,准备更新出仓单
  438. //0 fail 1 success
  439. Int rslt = 1,cnt = 0
  440. IF uo_option_barcode_outwaremove_paudit = -1000 THEN
  441. rslt = 0
  442. arg_msg = '选项:[204]仓库使用条码流程,仓库调拨单使用先确认扫描后审核流程,读取初始默认值失败,操作取消!'
  443. GOTO ext
  444. END IF
  445. IF arg_outwareid <= 0 THEN
  446. rslt = 0
  447. outwareid = 0
  448. GOTO ext
  449. END IF
  450. rslt = p_getinfo(arg_outwareid,arg_msg)
  451. IF rslt = 0 THEN GOTO ext
  452. IF uo_option_barcode_outwaremove_paudit = 1 THEN
  453. IF priceflag = 1 THEN
  454. rslt = 0
  455. arg_msg = '单据已经确认,不可以修改'
  456. GOTO ext
  457. END IF
  458. IF it_mxbt_barcode > 0 THEN
  459. arg_msg = '单据已扫描条码,不能修改,如果修改请先清除已扫描条码'
  460. rslt = 0
  461. GOTO ext
  462. END IF
  463. END IF
  464. IF flag = 1 THEN
  465. rslt = 0
  466. arg_msg = '单据已经审核,不可以修改'
  467. GOTO ext
  468. END IF
  469. outwareid = arg_outwareid
  470. p_clearmx()
  471. it_newbegin = FALSE
  472. it_updatebegin = TRUE
  473. ext:
  474. IF rslt = 0 THEN p_reset()
  475. RETURN rslt
  476. end function
  477. public function integer ss_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);//调仓单调出审核
  478. Int rslt = 1
  479. Long cnt = 0,i,j,mx_barcode_cnt
  480. Long rst_outwareid //调拨出仓id
  481. Long s_scid
  482. Int li_outtype
  483. IF uo_option_inout_type = -1000 THEN
  484. rslt = 0
  485. arg_msg = '选项:[142]进出仓高级选项,读取初始默认值失败,操作取消!'
  486. GOTO ext
  487. END IF
  488. IF uo_option_barcode_outwaremove_paudit = -1000 THEN
  489. rslt = 0
  490. arg_msg = '选项:[204]仓库使用条码流程,仓库调拨单使用先确认扫描后审核流程,读取初始默认值失败,操作取消!'
  491. GOTO ext
  492. END IF
  493. uo_outware uo_out
  494. uo_out = Create uo_outware
  495. uo_out.commit_transaction = sqlca
  496. uo_out.if_getid_ture = False
  497. uo_saletask uo_task
  498. uo_task = Create uo_saletask
  499. uo_task.commit_transaction = sqlca
  500. IF outwareid = 0 THEN
  501. rslt = 0
  502. arg_msg = "没有审核对象"
  503. GOTO ext
  504. END IF
  505. SELECT scid,outtype INTO :s_scid,:li_outtype
  506. FROM u_storage
  507. Where storageid = :sstorageid;
  508. IF sqlca.SQLCode <> 0 THEN
  509. arg_msg = '查询调出仓库所属分部资料,出仓类型失败,'+sqlca.SQLErrText
  510. rslt = 0
  511. GOTO ext
  512. END IF
  513. IF uo_option_inout_type = 2 And uo_option_barcode_outwaremove_paudit = 1 THEN
  514. IF priceflag = 0 THEN
  515. arg_msg = '单据未确认,不能调出审核'
  516. rslt = 0
  517. GOTO ext
  518. END IF
  519. END IF
  520. IF flag = 1 THEN
  521. rslt = 0
  522. arg_msg = "单据已经调出审核"
  523. GOTO ext
  524. END IF
  525. FOR i = 1 To it_mxbt
  526. IF li_outtype = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
  527. IF outwaremx[i].qty <> outwaremx[i].outqty THEN
  528. arg_msg = '明细行:'+String(i)+',调出数与调拨数不相符,请检查'
  529. rslt = 0
  530. GOTO ext
  531. END IF
  532. NEXT
  533. IF li_outtype = 2 And mx_barcode_cnt > 0 And it_mxbt_barcode = 0 THEN
  534. rslt = 0
  535. arg_msg = "单据调出未扫描条码,请检查"
  536. GOTO ext
  537. END IF
  538. UPDATE u_outware_move
  539. SET auditingrep = :arg_auditingrep,
  540. auditingdate = getdate(),
  541. flag = 1
  542. WHERE u_outware_move.outwareid = :outwareid
  543. AND flag = 0
  544. And d_auditflag = 0;
  545. IF sqlca.SQLCode <> 0 THEN
  546. rslt = 0
  547. arg_msg = "因网络或其它原因导致调出审核单据操作失败"+"~n"+sqlca.SQLErrText
  548. GOTO ext
  549. ELSEIF sqlca.SQLNRows = 0 THEN
  550. rslt = 0
  551. arg_msg = "调仓单据正在审核,请稍后查询。"+"~n"+sqlca.SQLErrText
  552. GOTO ext
  553. END IF
  554. Decimal ld_ref_cost
  555. FOR i = 1 To it_mxbt
  556. ld_ref_cost = 0
  557. IF p_update_cost(outwaremx[i].mtrlwareid,outwaremx[i].printid,&
  558. outwaremx[i].mtrlcode,ld_ref_cost,arg_msg,False) = 0 THEN
  559. rslt = 0
  560. GOTO ext
  561. END IF
  562. outwaremx[i].cost = ld_ref_cost
  563. NEXT
  564. //2.原事务生成出仓单
  565. IF uo_out.newbegin(s_scid,12,arg_msg) = 0 THEN
  566. rslt = 0
  567. GOTO ext
  568. END IF
  569. uo_out.relid = outwareid
  570. uo_out.outdate = outdate
  571. uo_out.outrep = outrep
  572. uo_out.part = outwarecode
  573. uo_out.dscrp = dscrp
  574. uo_out.cusname = '调拨出仓'
  575. uo_out.storageid = sstorageid
  576. FOR i = 1 To it_mxbt
  577. IF uo_out.acceptmx(outwaremx[i].mtrlwareid,&
  578. outwaremx[i].qty,outwaremx[i].cost,1,&
  579. outwaremx[i].mxdscrp,outwaremx[i].printid,arg_msg,0,0,0,0,'',0,0,&
  580. outwaremx[i].unit,outwaremx[i].uqty,outwaremx[i].rate,'','',0,0,'',0,0,0,0,'','') = 0 THEN
  581. rslt = 0
  582. GOTO ext
  583. END IF
  584. NEXT
  585. IF uo_out.Save(False,arg_msg) = 0 THEN
  586. rslt = 0
  587. GOTO ext
  588. END IF
  589. rst_outwareid = uo_out.outwareid
  590. //条码
  591. IF li_outtype = 2 THEN
  592. FOR j = 1 To it_mxbt_barcode
  593. IF uo_out.uof_outbarcode_add(12,s_scid,rst_outwareid,&
  594. s_mx_barcode[j].barcode,s_mx_barcode[j].qty,arg_msg,False) = 0 THEN
  595. rslt = 0
  596. GOTO ext
  597. END IF
  598. NEXT
  599. END IF
  600. //4.原事务审核出仓单
  601. IF uo_out.getinfo(s_scid,rst_outwareid,arg_msg) = 0 THEN
  602. rslt = 0
  603. GOTO ext
  604. END IF
  605. IF uo_out.auditing(False,arg_msg) = 0 THEN
  606. rslt = 0
  607. GOTO ext
  608. END IF
  609. //更新库存已开单数(减)
  610. IF uof_noauditingqty_del(outwareid,arg_msg) = 0 THEN
  611. rslt = 0
  612. GOTO ext
  613. END IF
  614. //完成分部需求单
  615. FOR i = 1 To it_mxbt
  616. IF outwaremx[i].relid > 0 THEN
  617. IF uo_task.addmxcmpl(sscid,outwaremx[i].relid,outwaremx[i].relprintid,outwaremx[i].uqty,arg_msg,False) <> 1 THEN
  618. arg_msg = '行:'+String(i)+','+arg_msg
  619. rslt = 0
  620. GOTO ext
  621. END IF
  622. IF uo_task.trycmplsaletask(sscid,outwaremx[i].relid,arg_msg,False) = 0 THEN
  623. arg_msg = '行:'+String(i)+','+arg_msg
  624. rslt = 0
  625. GOTO ext
  626. END IF
  627. END IF
  628. NEXT
  629. flag = 1
  630. ext:
  631. IF rslt = 0 THEN
  632. ROLLBACK;
  633. ELSEIF rslt = 1 And arg_ifcommit THEN
  634. COMMIT;
  635. END IF
  636. Destroy uo_out
  637. Destroy uo_task
  638. RETURN rslt
  639. end function
  640. public function integer c_ds_auditing (ref string arg_msg, boolean arg_ifcommit);
  641. Long rslt = 1,cnt = 0,i
  642. Long rst_inwareid //调拨进仓id
  643. Long o_scid
  644. Long mx_barcode_cnt
  645. Int li_outtype_out,li_outtype_in
  646. DateTime null_dt
  647. SetNull(null_dt)
  648. uo_inware uo_in
  649. uo_in = Create uo_inware
  650. uo_in.commit_transaction = sqlca
  651. uo_in.if_getid_ture = False
  652. IF outwareid = 0 THEN
  653. rslt = 0
  654. arg_msg = "没有撤审对象"
  655. GOTO ext
  656. END IF
  657. IF d_auditflag = 0 THEN
  658. rslt = 0
  659. arg_msg = "单据未调入审核"
  660. GOTO ext
  661. END IF
  662. SELECT outtype
  663. INTO :li_outtype_out
  664. FROM u_storage
  665. Where storageid = :sstorageid;
  666. IF sqlca.SQLCode <> 0 THEN
  667. rslt = 0
  668. arg_msg = "查询调出仓库出仓策略失败,"+sqlca.SQLErrText
  669. GOTO ext
  670. END IF
  671. SELECT outtype
  672. INTO :li_outtype_in
  673. FROM u_storage
  674. Where storageid = :dstorageid;
  675. IF sqlca.SQLCode <> 0 THEN
  676. rslt = 0
  677. arg_msg = "查询调出仓库出仓策略失败,"+sqlca.SQLErrText
  678. GOTO ext
  679. END IF
  680. //限制条码调入撤审清除条码库存id问题
  681. FOR i = 1 To it_mxbt
  682. IF li_outtype_in = 2 And outwaremx[i].outtype_mtrl = 2 THEN mx_barcode_cnt++
  683. NEXT
  684. IF li_outtype_in = 2 And li_outtype_out = 2 And mx_barcode_cnt > 0 THEN
  685. rslt = 0
  686. arg_msg = '单据已调入审核,明细包含条码不允许撤审,请开仓库调拨单调回'
  687. GOTO ext
  688. END IF
  689. //
  690. UPDATE u_outware_move
  691. SET d_auditingrep = '',
  692. d_auditingdate = :null_dt,
  693. d_auditflag = 0
  694. WHERE u_outware_move.outwareid = :outwareid
  695. And d_auditflag = 1;
  696. IF sqlca.SQLCode <> 0 THEN
  697. rslt = 0
  698. arg_msg = "因网络或其它原因导致调入撤审单据操作失败"+"~n"+sqlca.SQLErrText
  699. GOTO ext
  700. ELSEIF sqlca.SQLNRows = 0 THEN
  701. rslt = 0
  702. arg_msg = "调仓单据正在调入撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
  703. GOTO ext
  704. END IF
  705. SELECT scid INTO :o_scid
  706. FROM u_storage
  707. Where storageid = :dstorageid;
  708. IF sqlca.SQLCode <> 0 THEN
  709. arg_msg = '查询调入仓库所属分部资料失败'
  710. rslt = 0
  711. GOTO ext
  712. END IF
  713. //查询调仓单相关的入仓单
  714. SELECT inwareid INTO :rst_inwareid
  715. FROM u_inware
  716. WHERE scid = :o_scid
  717. AND relid = :outwareid
  718. And billtype = 12;
  719. IF sqlca.SQLCode <> 0 THEN
  720. arg_msg = '查询该调仓单相关入仓单失败,'+sqlca.SQLErrText
  721. rslt = 0
  722. GOTO ext
  723. END IF
  724. //撤审入仓单,再删除
  725. IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
  726. rslt = 0
  727. GOTO ext
  728. END IF
  729. IF uo_in.c_auditing(False,arg_msg) = 0 THEN
  730. rslt = 0
  731. GOTO ext
  732. END IF
  733. IF uo_in.del(o_scid,rst_inwareid,arg_msg,False) = 0 THEN
  734. rslt = 0
  735. GOTO ext
  736. END IF
  737. Long ll_scid,ll_mtrlwareid
  738. //更新条码调出仓的库存id,注释原因:如果开了条码库存配置调整单,找不到调出条码的库存id
  739. //IF li_outtype_in = 2 And li_outtype_out = 2 And mx_barcode_cnt > 0 THEN
  740. // FOR i = 1 To it_mxbt_barcode
  741. // ll_scid = 0
  742. // ll_mtrlwareid = 0
  743. // SELECT u_mtrlware.scid,u_mtrlware.mtrlwareid
  744. // INTO :ll_scid,:ll_mtrlwareid
  745. // FROM u_mtrlware,u_getbar,u_mtrlware_mx
  746. // WHERE u_mtrlware.storageid = :sstorageid
  747. // AND u_mtrlware_mx.barcode = :s_mx_barcode[i].barcode
  748. // AND u_getbar.getbarid = u_mtrlware_mx.getbarid
  749. // AND u_mtrlware.mtrlid = u_getbar.mtrlid
  750. // AND ( u_mtrlware.sptid = u_getbar.cusid AND :li_storagetype_storage = 0 OR
  751. // u_mtrlware.sptid = 0 AND :li_storagetype_storage = 1 )
  752. // AND u_mtrlware.status = u_getbar.status
  753. // AND u_mtrlware.woodcode = u_getbar.woodcode
  754. // AND u_mtrlware.pcode = u_getbar.pcode
  755. // AND u_mtrlware.plancode = u_getbar.plancode
  756. // AND ( u_mtrlware.mtrlcuscode = u_getbar.mtrlcuscode AND :li_storagetype_storage = 0 OR
  757. // u_mtrlware.mtrlcuscode = '' AND :li_storagetype_storage = 1 )
  758. // And u_mtrlware.Location = u_getbar.Location Using commit_transaction;
  759. // IF commit_transaction.SQLCode <> 0 THEN
  760. // arg_msg = '条码:'+s_mx_barcode[i].barcode+',查询库存资料失败,请检查对应条码单与库存资料,'+commit_transaction.SQLErrText
  761. // rslt = 0
  762. // GOTO ext
  763. // END IF
  764. // NEXT
  765. //END IF
  766. d_auditflag = 0
  767. ext:
  768. IF rslt = 0 THEN
  769. ROLLBACK;
  770. ELSEIF rslt = 1 And arg_ifcommit THEN
  771. COMMIT;
  772. END IF
  773. Destroy uo_in
  774. RETURN rslt
  775. end function
  776. public function integer c_ss_auditing (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,cnt = 0,i
  777. Long rst_outwareid //调拨出仓id
  778. Long s_scid
  779. DateTime null_dt
  780. SetNull(null_dt)
  781. uo_outware uo_out
  782. uo_out = Create uo_outware
  783. uo_out.commit_transaction = sqlca
  784. uo_out.if_getid_ture = False
  785. uo_saletask uo_task
  786. uo_task = Create uo_saletask
  787. uo_task.commit_transaction = sqlca
  788. If outwareid = 0 Then
  789. rslt = 0
  790. arg_msg = "没有撤审对象"
  791. Goto ext
  792. End If
  793. If flag = 0 Then
  794. rslt = 0
  795. arg_msg = "单据未调出审核"
  796. Goto ext
  797. End If
  798. If d_auditflag = 1 Then
  799. rslt = 0
  800. arg_msg = "单据已调入审核"
  801. Goto ext
  802. End If
  803. Update u_outware_move
  804. Set auditingrep = '',
  805. auditingdate = :null_dt,
  806. flag = 0
  807. Where u_outware_move.outwareid = :outwareid
  808. And flag = 1
  809. And d_auditflag = 0;
  810. If sqlca.SQLCode <> 0 Then
  811. rslt = 0
  812. arg_msg = "因网络或其它原因导致调出撤审单据操作失败"+"~n"+sqlca.SQLErrText
  813. Goto ext
  814. ElseIf sqlca.SQLNRows = 0 Then
  815. rslt = 0
  816. arg_msg = "调仓单据正在调出撤审,请稍后查询。"+"~n"+sqlca.SQLErrText
  817. Goto ext
  818. End If
  819. Select scid Into :s_scid
  820. From u_storage
  821. Where storageid = :sstorageid;
  822. If sqlca.SQLCode <> 0 Then
  823. arg_msg = '查询调出仓库所属分部资料失败'
  824. rslt = 0
  825. Goto ext
  826. End If
  827. //查询调仓单相关的入仓单,出仓单
  828. Select outwareid Into :rst_outwareid
  829. From u_outware
  830. Where scid = :s_scid
  831. And relid = :outwareid
  832. And billtype = 12;
  833. If sqlca.SQLCode <> 0 Then
  834. arg_msg = '查询该调仓单相关出仓单失败,'+sqlca.SQLErrText
  835. rslt = 0
  836. Goto ext
  837. End If
  838. //撤审出仓单,再删除
  839. If uo_out.getinfo(s_scid,rst_outwareid,arg_msg) = 0 Then
  840. rslt = 0
  841. Goto ext
  842. End If
  843. If uo_out.c_auditing(False,arg_msg) = 0 Then
  844. rslt = 0
  845. Goto ext
  846. End If
  847. If uo_out.del(s_scid,rst_outwareid,0,arg_msg,False) = 0 Then
  848. rslt = 0
  849. Goto ext
  850. End If
  851. //增加已开单数
  852. If uof_noauditingqty_add(arg_msg) = 0 Then
  853. rslt = 0
  854. Goto ext
  855. End If
  856. //完成分部需求单
  857. FOR i = 1 To it_mxbt
  858. IF outwaremx[i].relid > 0 THEN
  859. IF uo_task.addmxcmpl(sscid,outwaremx[i].relid,outwaremx[i].relprintid,0 - outwaremx[i].uqty,arg_msg,False) <> 1 THEN
  860. arg_msg = '行:'+String(i)+','+arg_msg
  861. rslt = 0
  862. GOTO ext
  863. END IF
  864. IF uo_task.trycmplsaletask(sscid,outwaremx[i].relid,arg_msg,False) = 0 THEN
  865. arg_msg = '行:'+String(i)+','+arg_msg
  866. rslt = 0
  867. GOTO ext
  868. END IF
  869. END IF
  870. NEXT
  871. flag = 0
  872. ext:
  873. If rslt = 0 Then
  874. Rollback;
  875. ElseIf rslt = 1 And arg_ifcommit Then
  876. Commit;
  877. End If
  878. Destroy uo_out
  879. Destroy uo_task
  880. Return rslt
  881. end function
  882. public function integer ds_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);//调仓单调入审核
  883. Int rslt = 1
  884. Long cnt = 0,i,j
  885. Long rst_inwareid //调拨进仓id
  886. Long o_scid
  887. Int li_outtype
  888. Long mx_barcode_cnt
  889. uo_inware uo_in
  890. uo_in = Create uo_inware
  891. uo_in.commit_transaction = sqlca
  892. uo_in.if_getid_ture = False
  893. IF outwareid = 0 THEN
  894. rslt = 0
  895. arg_msg = "没有审核对象"
  896. GOTO ext
  897. END IF
  898. IF flag = 0 THEN
  899. rslt = 0
  900. arg_msg = "单据还未调出审核"
  901. GOTO ext
  902. END IF
  903. IF d_auditflag = 1 THEN
  904. rslt = 0
  905. arg_msg = "单据已经调入审核"
  906. GOTO ext
  907. END IF
  908. SELECT scid,outtype INTO :o_scid,:li_outtype
  909. FROM u_storage
  910. Where storageid = :dstorageid;
  911. IF sqlca.SQLCode <> 0 THEN
  912. arg_msg = '查询调入仓库所属分部资料,出仓类型失败,'+sqlca.SQLErrText
  913. rslt = 0
  914. GOTO ext
  915. END IF
  916. FOR i = 1 To it_mxbt
  917. IF outwaremx[i].inqty <> outwaremx[i].outqty THEN
  918. arg_msg = '明细行:'+String(i)+',调出数与调入数不相符,请检查'
  919. rslt = 0
  920. GOTO ext
  921. END IF
  922. NEXT
  923. UPDATE u_outware_move
  924. SET d_auditingrep = :arg_auditingrep,
  925. d_auditingdate = getdate(),
  926. d_auditflag = 1
  927. WHERE u_outware_move.outwareid = :outwareid
  928. AND d_auditflag = 0
  929. And flag = 1;
  930. IF sqlca.SQLCode <> 0 THEN
  931. rslt = 0
  932. arg_msg = "因网络或其它原因导致审核单据操作失败"+"~n"+sqlca.SQLErrText
  933. GOTO ext
  934. ELSEIF sqlca.SQLNRows = 0 THEN
  935. rslt = 0
  936. arg_msg = "调仓单据正在审核,请稍后查询。"+"~n"+sqlca.SQLErrText
  937. GOTO ext
  938. END IF
  939. //3.目标事务建立进仓单
  940. DateTime server_datetime
  941. SELECT Top 1 getdate() Into :server_datetime From u_user;
  942. //取得系统时间,借用操作员表
  943. IF sqlca.SQLCode <> 0 THEN
  944. rslt = 0
  945. arg_msg = "查询目标仓库日期失败"
  946. GOTO ext
  947. END IF
  948. IF uo_in.newbegin(o_scid,12,arg_msg) = 0 THEN
  949. rslt = 0
  950. GOTO ext
  951. END IF
  952. uo_in.relid = outwareid
  953. uo_in.indate = indate
  954. uo_in.inrep = outrep
  955. uo_in.part = outwarecode
  956. uo_in.dscrp = dscrp
  957. uo_in.storageid = dstorageid
  958. uo_in.sptname = '调拨进仓'
  959. Decimal ld_uprice
  960. FOR i = 1 To it_mxbt
  961. ld_uprice = 0
  962. ld_uprice = outwaremx[i].price * outwaremx[i].rate
  963. IF uo_in.acceptmx(outwaremx[i].printid,&
  964. outwaremx[i].mtrlid,&
  965. outwaremx[i].mtrlcode,&
  966. outwaremx[i].plancode,&
  967. outwaremx[i].status,&
  968. outwaremx[i].uqty,&
  969. ld_uprice,&
  970. 1,&
  971. outwaremx[i].mxdscrp,&
  972. arg_msg,&
  973. 0,0,0,outwaremx[i].woodcode,&
  974. outwaremx[i].pcode,&
  975. outwaremx[i].sptid,&
  976. outwaremx[i].unit,&
  977. outwaremx[i].rate,&
  978. outwaremx[i].qty,0,0,'','',0,0,&
  979. outwaremx[i].mtrlcuscode,&
  980. outwaremx[i].newlocation,&
  981. outwaremx[i].uqty,&
  982. 0) = 0 THEN
  983. rslt = 0
  984. GOTO ext
  985. END IF
  986. NEXT
  987. IF uo_in.Save(False,arg_msg) = 0 THEN
  988. rslt = 0
  989. GOTO ext
  990. END IF
  991. rst_inwareid = uo_in.inwareid
  992. //条码
  993. //条码
  994. IF li_outtype = 2 Or li_outtype = 3 THEN
  995. IF uo_option_barcode_outwaremove_paudit = 0 THEN
  996. FOR j = 1 To it_mxbt_barcode
  997. IF uo_in.uof_inbarcode_add(12,o_scid,rst_inwareid,0,&
  998. s_mx_barcode[j].barcode,s_mx_barcode[j].qty,arg_msg,False) = 0 THEN
  999. rslt = 0
  1000. GOTO ext
  1001. END IF
  1002. NEXT
  1003. ELSE
  1004. FOR j = 1 To it_mxbt_barcode_in
  1005. IF uo_in.uof_inbarcode_add(12,o_scid,rst_inwareid,0,&
  1006. s_mx_barcode_in[j].barcode,s_mx_barcode_in[j].qty,arg_msg,False) = 0 THEN
  1007. rslt = 0
  1008. GOTO ext
  1009. END IF
  1010. NEXT
  1011. END IF
  1012. END IF
  1013. //
  1014. //4.原事务审核进仓单
  1015. IF uo_in.getinfo(o_scid,rst_inwareid,arg_msg) = 0 THEN
  1016. rslt = 0
  1017. GOTO ext
  1018. END IF
  1019. IF uo_in.auditing(False,arg_msg) = 0 THEN
  1020. rslt = 0
  1021. GOTO ext
  1022. END IF
  1023. IF uof_update_waredate(False,arg_msg) = 0 THEN
  1024. rslt = 0
  1025. GOTO ext
  1026. END IF
  1027. d_auditflag = 1
  1028. ext:
  1029. IF rslt = 0 THEN
  1030. ROLLBACK;
  1031. ELSEIF rslt = 1 And arg_ifcommit THEN
  1032. COMMIT;
  1033. END IF
  1034. Destroy uo_in
  1035. RETURN rslt
  1036. end function
  1037. public function integer cancel (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);//cancel()
  1038. //如果单据还没有审核删除单据极其明细
  1039. //0 FAIL, 1 SUCCESS
  1040. Int rslt = 1
  1041. If arg_outwareid <= 0 Then
  1042. rslt = 0
  1043. arG_MSG = "没有删除对象,操作取消"
  1044. Goto ext
  1045. End If
  1046. rslt = p_getinfo(arg_outwareid,arG_MSG)
  1047. If rslt = 0 Then Goto ext
  1048. If priceflag = 1 Then
  1049. rslt = 0
  1050. arG_MSG = "单据已经确认,不可以删除"
  1051. Goto ext
  1052. End If
  1053. If flag = 1 Then
  1054. rslt = 0
  1055. arG_MSG = "单据已经调出审核,不可以删除"
  1056. Goto ext
  1057. End If
  1058. If d_auditflag = 1 Then
  1059. rslt = 0
  1060. arG_MSG = "单据已经调入审核,不可以删除"
  1061. Goto ext
  1062. End If
  1063. //更新库存已开单数(减)
  1064. If uof_noauditingqty_del(arg_outwareid,arG_MSG) = 0 Then
  1065. rslt = 0
  1066. Goto ext
  1067. End If
  1068. Delete From u_outwaremx_mx_barcode
  1069. Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid
  1070. And u_outwaremx_mx_barcode.scid = 0
  1071. And u_outwaremx_mx_barcode.billtype = 50;
  1072. If sqlca.SQLCode <> 0 Then
  1073. rslt = 0
  1074. arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
  1075. Goto ext
  1076. End If
  1077. Delete From u_outwaremx_mx_barcode
  1078. Where u_outwaremx_mx_barcode.outwareid = :arg_outwareid
  1079. And u_outwaremx_mx_barcode.scid = 0
  1080. And u_outwaremx_mx_barcode.billtype = 53;
  1081. If sqlca.SQLCode <> 0 Then
  1082. rslt = 0
  1083. arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
  1084. Goto ext
  1085. End If
  1086. Delete From u_outwaremovemx
  1087. Where u_outwaremovemx.outwareid = :arg_outwareid;
  1088. If sqlca.SQLCode <> 0 Then
  1089. rslt = 0
  1090. arG_MSG = "删除进仓单明细操作失败"+"~n"+sqlca.SQLErrText
  1091. Rollback;
  1092. Goto ext
  1093. End If
  1094. Delete From u_outware_move
  1095. Where u_outware_move.outwareid = :arg_outwareid;
  1096. If sqlca.SQLCode <> 0 Then
  1097. rslt = 0
  1098. arG_MSG = "删除进仓单操作失败"+"~n"+sqlca.SQLErrText
  1099. Rollback;
  1100. Goto ext
  1101. End If
  1102. Commit;
  1103. it_newbegin = False
  1104. it_updatebegin = False
  1105. ext:
  1106. If rslt = 0 Then
  1107. Rollback;
  1108. ElseIf rslt = 1 And arg_ifcommit Then
  1109. Commit;
  1110. End If
  1111. p_reset()
  1112. Return (rslt)
  1113. end function
  1114. public function integer save (ref string arg_msg, boolean arg_ifcommit);Integer rslt = 1
  1115. Long cnt = 0,i
  1116. DateTime server_datetime
  1117. Long ls_newid
  1118. Decimal ld_inqty,ld_outqty
  1119. Int li_outtype_storage_s
  1120. If uo_option_barcode_outwaremove_paudit = -1000 Then
  1121. rslt = 0
  1122. arg_msg = '选项:[204]仓库使用条码流程,仓库调拨单使用先确认扫描后审核流程,读取初始默认值失败,操作取消!'
  1123. Goto ext
  1124. End If
  1125. If IsNull(dscrp) Then dscrp = ''
  1126. If IsNull(outrep) Then outrep = ''
  1127. If IsNull(relcode) Then relcode = ''
  1128. If IsNull(ifauto) Then ifauto = 0
  1129. If it_newbegin = False And it_updatebegin = False Then
  1130. rslt = 0
  1131. arg_msg = "非编辑状态不可以提交"
  1132. Goto ext
  1133. End If
  1134. Select Top 1 getdate() Into :server_datetime From u_user ;
  1135. //取得系统时间,借用操作员表
  1136. If sqlca.SQLCode <> 0 Then
  1137. rslt = 0
  1138. arg_msg = "查询操作失败,日期 "
  1139. Goto ext
  1140. End If
  1141. If it_mxbt = 0 Then //如果输入库存物料资料错则已经清空
  1142. rslt = 0
  1143. arg_msg = "没有正确出仓内容"
  1144. Goto ext
  1145. End If
  1146. If outrep = '' Then
  1147. rslt = 0
  1148. arg_msg = '请输入经手人'
  1149. Goto ext
  1150. End If
  1151. If f_rst_storage_outtype(sstorageid,li_outtype_storage_s) = 0 Then
  1152. arg_msg = '查询调出仓库出仓策略失败,请检查'
  1153. rslt = 0
  1154. Goto ext
  1155. End If
  1156. If f_check_inoutdate(sstorageid,outdate,True,arg_msg) = 0 Then
  1157. rslt = 0
  1158. Goto ext
  1159. End If
  1160. If f_check_inoutdate(dstorageid,outdate,True,arg_msg) = 0 Then
  1161. rslt = 0
  1162. Goto ext
  1163. End If
  1164. //检查仓位
  1165. cnt = 0
  1166. Select count(*) Into :cnt From u_storage Where storageid = :sstorageid;
  1167. If sqlca.SQLCode <> 0 Then
  1168. rslt = 0
  1169. arg_msg = "查询操作失败,调出仓库"
  1170. Goto ext
  1171. End If
  1172. If cnt = 0 Then
  1173. rslt = 0
  1174. arg_msg = "调出仓库未登记或已取消"
  1175. Goto ext
  1176. End If
  1177. cnt = 0
  1178. Select count(*) Into :cnt From u_storage Where storageid = :dstorageid;
  1179. If sqlca.SQLCode <> 0 Then
  1180. rslt = 0
  1181. arg_msg = "查询操作失败,调入仓库"
  1182. Goto ext
  1183. End If
  1184. If cnt = 0 Then
  1185. rslt = 0
  1186. arg_msg = "调入仓库未登记或已取消"
  1187. Goto ext
  1188. End If
  1189. opdate = server_datetime //填写单据建立时间(最近修改时间)
  1190. ////////////////////////////////////////////// //开始区分:新建/更新 处理
  1191. If outwareid = 0 Then //新建
  1192. ls_newid = f_sys_scidentity(0,"u_outware_move","outwareid",arg_msg,True,id_sqlca)
  1193. If ls_newid <= 0 Then
  1194. rslt = 0
  1195. Goto ext
  1196. End If
  1197. outwarecode = getid(0,"MV",Date(server_datetime),if_getid_ture,sqlca) //取得新单据编号
  1198. If outwarecode = "err" Then
  1199. outwarecode = ''
  1200. rslt = 0
  1201. arg_msg = "无法获取出仓单编号"
  1202. Goto ext
  1203. End If
  1204. Insert Into u_outware_move (
  1205. outwareid,
  1206. outwarecode,
  1207. sstorageid,
  1208. dstorageid,
  1209. opdate,
  1210. operator,
  1211. flag,
  1212. outdate,
  1213. indate,
  1214. outrep,
  1215. dscrp,
  1216. relcode,
  1217. ifauto)
  1218. Values ( :ls_newid,
  1219. :outwarecode,
  1220. :sstorageid,
  1221. :dstorageid,
  1222. getdate(),
  1223. :publ_operator,
  1224. :flag,
  1225. :outdate,
  1226. :indate,
  1227. :outrep,
  1228. :dscrp,
  1229. :relcode,
  1230. :ifauto) ;
  1231. If sqlca.SQLCode <> 0 Then
  1232. rslt = 0
  1233. arg_msg = "因网络或其它原因导致插入操作失败"+"~n"+sqlca.SQLErrText
  1234. Goto ext
  1235. End If
  1236. outwareid = ls_newid
  1237. For i = 1 To it_mxbt
  1238. If uo_option_barcode_outwaremove_paudit = 0 Then
  1239. ld_inqty = outwaremx[i].qty
  1240. ld_outqty = outwaremx[i].qty
  1241. Else
  1242. If li_outtype_storage_s = 2 And outwaremx[i].outtype_mtrl = 2 Then
  1243. ld_inqty = 0
  1244. ld_outqty = 0
  1245. Else
  1246. ld_inqty = outwaremx[i].qty
  1247. ld_outqty = outwaremx[i].qty
  1248. End If
  1249. End If
  1250. Insert Into u_outwaremovemx
  1251. (outwareid,
  1252. mtrlwareid,
  1253. mtrlid,
  1254. storageid,
  1255. qty,
  1256. cost,
  1257. price,
  1258. printid,
  1259. mxdscrp,
  1260. scid,
  1261. status,
  1262. plancode,
  1263. dxflag,
  1264. sptid,
  1265. woodcode,
  1266. pcode,
  1267. unit,
  1268. uqty,
  1269. rate,
  1270. mtrlcuscode,
  1271. location,
  1272. newlocation,
  1273. inqty,
  1274. outqty,
  1275. ifrel,
  1276. relid,
  1277. relprintid,
  1278. relcode)
  1279. Values (:ls_newid,
  1280. :outwaremx[i].mtrlwareid,
  1281. :outwaremx[i].mtrlid,
  1282. :outwaremx[i].storageid,
  1283. :outwaremx[i].qty,
  1284. :outwaremx[i].cost,
  1285. :outwaremx[i].price,
  1286. :outwaremx[i].printid,
  1287. :outwaremx[i].mxdscrp,
  1288. :outwaremx[i].scid,
  1289. :outwaremx[i].status,
  1290. :outwaremx[i].plancode,
  1291. :outwaremx[i].dxflag,
  1292. :outwaremx[i].sptid,
  1293. :outwaremx[i].woodcode,
  1294. :outwaremx[i].pcode,
  1295. :outwaremx[i].unit,
  1296. :outwaremx[i].uqty,
  1297. :outwaremx[i].rate,
  1298. :outwaremx[i].mtrlcuscode,
  1299. :outwaremx[i].location,
  1300. :outwaremx[i].newlocation,
  1301. :ld_inqty,
  1302. :ld_outqty,
  1303. :outwaremx[i].ifrel,
  1304. :outwaremx[i].relid,
  1305. :outwaremx[i].relprintid,
  1306. :outwaremx[i].relcode);
  1307. If sqlca.SQLCode <> 0 Then
  1308. outwareid = 0 //还原outwareid
  1309. rslt = 0
  1310. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
  1311. Goto ext
  1312. End If
  1313. Next
  1314. //更新库存已开单数
  1315. If uof_noauditingqty_add(arg_msg) = 0 Then
  1316. rslt = 0
  1317. Goto ext
  1318. End If
  1319. Else //////////////////////////////////////////////// //更新
  1320. Update u_outware_move
  1321. Set outdate = :outdate,
  1322. indate = :indate,
  1323. outrep = :outrep,
  1324. dscrp = :dscrp,
  1325. sstorageid = :sstorageid,
  1326. dstorageid = :dstorageid,
  1327. relcode = :relcode,
  1328. moddate = getdate(),
  1329. modrep = :publ_operator
  1330. Where u_outware_move.outwareid = :outwareid And flag = 0;
  1331. If sqlca.SQLCode <> 0 Or sqlca.SQLNRows <= 0 Then
  1332. rslt = 0
  1333. arg_msg = "因网络或其它原因导致更新单据操作失败"+"~n"+sqlca.SQLErrText
  1334. Goto ext
  1335. End If
  1336. //更新库存已开单数(减)
  1337. If uof_noauditingqty_del(outwareid,arg_msg) = 0 Then
  1338. rslt = 0
  1339. Goto ext
  1340. End If
  1341. //删除原有明细
  1342. Delete From u_outwaremovemx
  1343. Where u_outwaremovemx.outwareid = :outwareid;
  1344. If sqlca.SQLCode <> 0 Then
  1345. rslt = 0
  1346. arg_msg = "删除旧有明细操作失败"+"~n"+sqlca.SQLErrText
  1347. Goto ext
  1348. End If
  1349. For i = 1 To it_mxbt
  1350. If uo_option_barcode_outwaremove_paudit = 0 Then
  1351. ld_inqty = outwaremx[i].qty
  1352. ld_outqty = outwaremx[i].qty
  1353. Else
  1354. If li_outtype_storage_s = 2 And outwaremx[i].outtype_mtrl = 2 Then
  1355. ld_inqty = 0
  1356. ld_outqty = 0
  1357. Else
  1358. ld_inqty = outwaremx[i].qty
  1359. ld_outqty = outwaremx[i].qty
  1360. End If
  1361. End If
  1362. Insert Into u_outwaremovemx
  1363. ( outwareid,
  1364. mtrlwareid,
  1365. mtrlid,
  1366. storageid,
  1367. qty,
  1368. cost,
  1369. price,
  1370. printid,
  1371. mxdscrp,
  1372. scid,
  1373. status,
  1374. plancode,
  1375. dxflag,
  1376. sptid,
  1377. woodcode,
  1378. pcode,
  1379. unit,
  1380. uqty,
  1381. rate,
  1382. mtrlcuscode,
  1383. location,
  1384. newlocation,
  1385. inqty,
  1386. outqty,
  1387. ifrel,
  1388. relid,
  1389. relprintid,
  1390. relcode)
  1391. Values (:outwareid,
  1392. :outwaremx[i].mtrlwareid,
  1393. :outwaremx[i].mtrlid,
  1394. :outwaremx[i].storageid,
  1395. :outwaremx[i].qty,
  1396. :outwaremx[i].cost,
  1397. :outwaremx[i].price,
  1398. :outwaremx[i].printid,
  1399. :outwaremx[i].mxdscrp,
  1400. :outwaremx[i].scid,
  1401. :outwaremx[i].status,
  1402. :outwaremx[i].plancode,
  1403. :outwaremx[i].dxflag,
  1404. :outwaremx[i].sptid,
  1405. :outwaremx[i].woodcode,
  1406. :outwaremx[i].pcode,
  1407. :outwaremx[i].unit,
  1408. :outwaremx[i].uqty,
  1409. :outwaremx[i].rate,
  1410. :outwaremx[i].mtrlcuscode,
  1411. :outwaremx[i].location,
  1412. :outwaremx[i].newlocation,
  1413. :ld_inqty,
  1414. :ld_outqty,
  1415. :outwaremx[i].ifrel,
  1416. :outwaremx[i].relid,
  1417. :outwaremx[i].relprintid,
  1418. :outwaremx[i].relcode);
  1419. If sqlca.SQLCode <> 0 Then
  1420. rslt = 0
  1421. arg_msg = "因网络或其它原因导致插入明细操作失败"+"~n"+sqlca.SQLErrText
  1422. Goto ext
  1423. End If
  1424. Next
  1425. If uof_noauditingqty_add(arg_msg) = 0 Then
  1426. rslt = 0
  1427. Goto ext
  1428. End If
  1429. End If
  1430. it_newbegin = False
  1431. it_updatebegin = False
  1432. ext:
  1433. If rslt = 0 Then
  1434. Rollback;
  1435. p_clearmx()
  1436. ElseIf arg_ifcommit And rslt = 1 Then
  1437. Commit;
  1438. End If
  1439. Return(rslt)
  1440. end function
  1441. public function integer p_update_cost (long arg_mtrlwareid, long arg_printid, string arg_mtrlcode, ref decimal arg_ref_cost, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1442. Decimal ld_cost
  1443. Long ll_storagescid
  1444. SELECT scid INTO :ll_storagescid
  1445. FROM u_storage
  1446. Where storageid = :sstorageid;
  1447. IF sqlca.SQLCode <> 0 THEN
  1448. rslt = 0
  1449. arg_msg = '查询仓库分部失败'+ sqlca.SQLErrText
  1450. GOTO ext
  1451. END IF
  1452. SELECT cost INTO :ld_cost
  1453. FROM u_mtrlware
  1454. WHERE storageid = :sstorageid
  1455. AND mtrlwareid = :arg_mtrlwareid
  1456. AND scid = :ll_storagescid;
  1457. IF sqlca.SQLCode <> 0 THEN
  1458. arg_msg = '查询行:'+string(arg_printid)+',物料:'+arg_mtrlcode+'库存成本价失败,'+sqlca.SQLErrText
  1459. rslt = 0
  1460. GOTO ext
  1461. END IF
  1462. arg_ref_cost = ld_cost
  1463. UPDATE u_outwaremovemx
  1464. SET cost = :ld_cost,
  1465. price = :ld_cost
  1466. WHERE outwareid = :outwareid
  1467. and scid = :ll_storagescid
  1468. AND mtrlwareid = :arg_mtrlwareid;
  1469. IF sqlca.SQLCode <> 0 THEN
  1470. arg_msg = '查询行:'+string(arg_printid)+',物料:'+arg_mtrlcode+'出仓成本价失败,'+sqlca.SQLErrText
  1471. rslt = 0
  1472. GOTO ext
  1473. END IF
  1474. ext:
  1475. IF rslt = 0 THEN
  1476. ROLLBACK;
  1477. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1478. COMMIT;
  1479. END IF
  1480. RETURN rslt
  1481. end function
  1482. public function integer uof_update_waredate (boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  1483. DateTime ld_waredate,ld_auditingdate,ld_waradate_mx
  1484. String ls_auditdate,ls_waredate
  1485. Long i
  1486. Long ll_mtrlid,ll_sptid,ll_mtrlwareid
  1487. String ls_status,ls_woodcode ,ls_pcode,ls_plancode
  1488. String ls_mtrlcuscode,ls_location
  1489. DateTime ld_waredate_max
  1490. Long o_scid,s_scid
  1491. Int li_ifout_notfind_ware,li_o_storagetype
  1492. Int li_ifpack,li_ifpackpro
  1493. Select d_Auditingdate Into :ld_auditingdate
  1494. From u_outware_move
  1495. Where outwareid = :outwareid;
  1496. If sqlca.SQLCode <> 0 Then
  1497. rslt = 0
  1498. arg_msg = '查询单据审核时间失败,'+sqlca.SQLErrText
  1499. Goto ext
  1500. End If
  1501. ls_auditdate = String(ld_auditingdate,'yyyy-mm-dd hh:mm')
  1502. Select scid,storagetype Into :o_scid,:li_o_storagetype
  1503. From u_storage
  1504. Where storageid = :dstorageid;
  1505. If sqlca.SQLCode <> 0 Then
  1506. arg_msg = '查询调入仓库所属分部资料失败'
  1507. rslt = 0
  1508. Goto ext
  1509. End If
  1510. Select scid Into :s_scid
  1511. From u_storage
  1512. Where storageid = :sstorageid;
  1513. If sqlca.SQLCode <> 0 Then
  1514. arg_msg = '查询调出仓库所属分部资料失败'
  1515. rslt = 0
  1516. Goto ext
  1517. End If
  1518. For i = 1 To it_mxbt
  1519. If outwaremx[i].uqty = 0 Or outwaremx[i].qty = 0 Then Continue
  1520. ll_mtrlid = outwaremx[i].mtrlid
  1521. ll_sptid = outwaremx[i].sptid
  1522. ls_status = outwaremx[i].status
  1523. ls_woodcode = outwaremx[i].woodcode
  1524. ls_pcode = outwaremx[i].pcode
  1525. ls_plancode = outwaremx[i].plancode
  1526. ls_mtrlcuscode = outwaremx[i].mtrlcuscode
  1527. ls_location = outwaremx[i].newlocation
  1528. ll_mtrlwareid = outwaremx[i].mtrlwareid
  1529. Select waredate Into :ld_waredate
  1530. From u_mtrlware
  1531. Where scid = :s_scid
  1532. And mtrlwareid = :ll_mtrlwareid;
  1533. If sqlca.SQLCode = -1 Then
  1534. rslt = 0
  1535. arg_msg = '明细行:'+String(i)+',查询调出库存最近进仓日期失败,'+sqlca.SQLErrText
  1536. Goto ext
  1537. ElseIf sqlca.SQLCode = 100 Then
  1538. li_ifout_notfind_ware = 1
  1539. End If
  1540. Select ifpack,ifpackpro
  1541. Into :li_ifpack,:li_ifpackpro
  1542. From u_mtrldef
  1543. Where mtrlid = :ll_mtrlid;
  1544. If sqlca.SQLCode <> 0 Then
  1545. rslt = 0
  1546. arg_msg = '明细行:'+String(i)+',查询物料属性失败,'+sqlca.SQLErrText
  1547. Goto ext
  1548. End If
  1549. If li_o_storagetype = 1 and li_ifpack <> 2 and li_ifpackpro <> 2 and li_ifpackpro <> 4 Then
  1550. ll_sptid = 0
  1551. ls_mtrlcuscode = ''
  1552. End If
  1553. Select waredate Into :ld_waradate_mx
  1554. From u_mtrlware
  1555. Where scid = :o_scid
  1556. And storageid = :dstorageid
  1557. And mtrlid = :ll_mtrlid
  1558. And sptid = :ll_sptid
  1559. And status = :ls_status
  1560. And woodcode = :ls_woodcode
  1561. And pcode = :ls_pcode
  1562. And plancode = :ls_plancode
  1563. And mtrlcuscode = :ls_mtrlcuscode
  1564. And Location = :ls_location;
  1565. If sqlca.SQLCode <> 0 Then
  1566. rslt = 0
  1567. arg_msg = '明细行:'+String(i)+',查询调入新库存最近进仓日期失败,错误:'+String(sqlca.SQLCode)+','+sqlca.SQLErrText
  1568. Goto ext
  1569. End If
  1570. ls_waredate = String(ld_waradate_mx,'yyyy-mm-dd hh:mm')
  1571. If ls_auditdate = ls_waredate Or li_ifout_notfind_ware = 1 Then
  1572. Update u_mtrlware
  1573. Set waredate = :ld_waredate
  1574. Where scid = :o_scid
  1575. And storageid = :dstorageid
  1576. And mtrlid = :ll_mtrlid
  1577. And sptid = :ll_sptid
  1578. And status = :ls_status
  1579. And woodcode = :ls_woodcode
  1580. And pcode = :ls_pcode
  1581. And plancode = :ls_plancode
  1582. And mtrlcuscode = :ls_mtrlcuscode
  1583. And Location = :ls_location;
  1584. If sqlca.SQLCode <> 0 Then
  1585. rslt = 0
  1586. arg_msg = '明细行:'+String(i)+',更新调入库存最近进仓日期失败,'+sqlca.SQLErrText
  1587. Goto ext
  1588. End If
  1589. End If
  1590. Next
  1591. ext:
  1592. If rslt = 0 Then
  1593. Rollback;
  1594. ElseIf rslt = 1 And arg_ifcommit Then
  1595. Commit;
  1596. End If
  1597. Return rslt
  1598. end function
  1599. public function integer p_auditing (string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1600. IF outwareid = 0 THEN
  1601. rslt = 0
  1602. arg_msg = "没有审核对象"
  1603. GOTO ext
  1604. END IF
  1605. IF priceflag = 1 THEN
  1606. arg_msg = '单据已确认,请检查'
  1607. rslt = 0
  1608. GOTO ext
  1609. END IF
  1610. UPDATE u_outware_move
  1611. SET priceemp = :arg_auditingrep,
  1612. pricedate = getdate(),
  1613. priceflag = 1
  1614. WHERE u_outware_move.outwareid = :outwareid
  1615. AND priceflag = 0;
  1616. IF sqlca.SQLCode <> 0 THEN
  1617. rslt = 0
  1618. arg_msg = "因网络或其它原因导致确认单据操作失败"+"~n"+sqlca.SQLErrText
  1619. GOTO ext
  1620. ELSEIF sqlca.SQLNRows = 0 THEN
  1621. rslt = 0
  1622. arg_msg = "调仓单据正在确认,请稍后查询。"+"~n"+sqlca.SQLErrText
  1623. GOTO ext
  1624. END IF
  1625. priceflag = 1
  1626. ext:
  1627. IF rslt = 0 THEN
  1628. ROLLBACK;
  1629. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1630. COMMIT;
  1631. END IF
  1632. RETURN rslt
  1633. end function
  1634. public function integer c_p_auditing (ref string arg_msg, boolean arg_ifcommit);Long rslt = 1
  1635. DateTime null_dt
  1636. SetNull(null_dt)
  1637. IF outwareid = 0 THEN
  1638. rslt = 0
  1639. arg_msg = "没有撤审对象"
  1640. GOTO ext
  1641. END IF
  1642. IF flag = 1 THEN
  1643. rslt = 0
  1644. arg_msg = "单据已调出审核"
  1645. GOTO ext
  1646. END IF
  1647. UPDATE u_outware_move
  1648. SET priceemp = '',
  1649. pricedate = :null_dt,
  1650. priceflag = 0
  1651. WHERE u_outware_move.outwareid = :outwareid
  1652. AND priceflag = 1
  1653. AND flag = 0;
  1654. IF sqlca.SQLCode <> 0 THEN
  1655. rslt = 0
  1656. arg_msg = "因网络或其它原因导致取消确认单据操作失败"+"~n"+sqlca.SQLErrText
  1657. GOTO ext
  1658. ELSEIF sqlca.SQLNRows = 0 THEN
  1659. rslt = 0
  1660. arg_msg = "调仓单据正在取消确认,请稍后查询。"+"~n"+sqlca.SQLErrText
  1661. GOTO ext
  1662. END IF
  1663. DELETE FROM u_outwaremx_mx_barcode
  1664. WHERE u_outwaremx_mx_barcode.outwareid = :outwareid
  1665. AND u_outwaremx_mx_barcode.scid = 0
  1666. AND u_outwaremx_mx_barcode.billtype = 50;
  1667. IF sqlca.SQLCode <> 0 THEN
  1668. rslt = 0
  1669. arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
  1670. GOTO ext
  1671. END IF
  1672. DELETE FROM u_outwaremx_mx_barcode
  1673. WHERE u_outwaremx_mx_barcode.outwareid = :outwareid
  1674. AND u_outwaremx_mx_barcode.scid = 0
  1675. AND u_outwaremx_mx_barcode.billtype = 53;
  1676. IF sqlca.SQLCode <> 0 THEN
  1677. rslt = 0
  1678. arG_MSG = "删除单据条码明细操作失败"+"~n"+sqlca.SQLErrText
  1679. GOTO ext
  1680. END IF
  1681. priceflag = 0
  1682. ext:
  1683. IF rslt = 0 THEN
  1684. ROLLBACK;
  1685. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1686. COMMIT;
  1687. END IF
  1688. RETURN rslt
  1689. end function
  1690. public function integer uof_set_qty_equal_bqty (long arg_outwareid, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1691. Int li_ref_outtype
  1692. IF arg_outwareid <= 0 THEN
  1693. arg_msg = '错误的单据id'
  1694. rslt = 0
  1695. GOTO ext
  1696. END IF
  1697. IF p_getinfo(arg_outwareid,arg_msg) = 0 THEN
  1698. rslt = 0
  1699. GOTO ext
  1700. END IF
  1701. IF f_rst_storage_outtype(sstorageid,li_ref_outtype) = 0 THEN
  1702. arg_msg = '查询仓库出仓策略失败,请检查仓库资料'
  1703. rslt = 0
  1704. GOTO ext
  1705. END IF
  1706. IF li_ref_outtype <> 2 THEN
  1707. arg_msg = '仓库出仓策略不是使用条码出仓,操作取消,请检查仓库资料'
  1708. rslt = 0
  1709. GOTO ext
  1710. END IF
  1711. IF priceflag = 0 THEN
  1712. arg_msg = '单据未确认,操作取消'
  1713. rslt = 0
  1714. GOTO ext
  1715. END IF
  1716. IF flag = 1 THEN
  1717. arg_msg = '单据已仓审,操作取消'
  1718. rslt = 0
  1719. GOTO ext
  1720. END IF
  1721. UPDATE u_outwaremovemx
  1722. SET u_outwaremovemx.uqty = u_outwaremovemx.outqty,
  1723. u_outwaremovemx.qty = u_outwaremovemx.outqty
  1724. FROM u_outwaremovemx,u_mtrldef
  1725. WHERE u_outwaremovemx.mtrlid = u_mtrldef.mtrlid
  1726. AND u_outwaremovemx.outwareid = :arg_outwareid
  1727. AND u_mtrldef.outtype = 2;
  1728. IF sqlca.SQLCode <> 0 THEN
  1729. arg_msg = '更新明细条码调拨数到明细调出数失败,'+sqlca.SQLErrText
  1730. rslt = 0
  1731. GOTO ext
  1732. END IF
  1733. ext:
  1734. IF rslt = 0 THEN
  1735. ROLLBACK;
  1736. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1737. COMMIT;
  1738. END IF
  1739. RETURN rslt
  1740. end function
  1741. public function integer uof_mod_indate (long arg_outwareid, datetime arg_indate, ref string arg_msg);Int rslt = 1
  1742. rslt = p_getinfo(arg_outwareid,arg_msg)
  1743. IF rslt = 0 THEN GOTO ext
  1744. IF flag = 0 THEN
  1745. rslt = 0
  1746. arg_msg = '单据未调出审核,不可以操作'
  1747. GOTO ext
  1748. END IF
  1749. IF d_auditflag = 1 THEN
  1750. rslt = 0
  1751. arg_msg = '单据已经调入审核,不可以操作'
  1752. GOTO ext
  1753. END IF
  1754. IF Date(arg_indate) < Date(outdate) THEN
  1755. arg_msg = '不合理调出日期,调出日期大于调入日期'
  1756. rslt = 0
  1757. GOTO ext
  1758. END IF
  1759. UPDATE u_outware_move
  1760. SET indate = :arg_indate
  1761. Where u_outware_move.outwareid = :arg_outwareid;
  1762. IF sqlca.SQLCode <> 0 THEN
  1763. ROLLBACK ;
  1764. rslt = 0
  1765. arg_msg = "因网络或其它原因导致更新调入日期操作失败"+"~n"+sqlca.SQLErrText
  1766. GOTO ext
  1767. END IF
  1768. COMMIT;
  1769. ext:
  1770. Return (rslt)
  1771. end function
  1772. public function integer uof_noauditingqty_add (ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
  1773. Int rslt = 1
  1774. Long i
  1775. For i = 1 To it_mxbt
  1776. Update u_mtrlware
  1777. Set noauditingqty = noauditingqty + :outwaremx[i].qty,
  1778. noauditinguqty = noauditingqty + :outwaremx[i].uqty
  1779. Where scid = :outwaremx[i].scid
  1780. And mtrlwareid = :outwaremx[i].mtrlwareid;
  1781. If sqlca.SQLCode <> 0 Then
  1782. rslt = 0
  1783. arg_msg = '物料:'+String(outwaremx[i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
  1784. Goto ext
  1785. End If
  1786. Next
  1787. ext:
  1788. Return rslt
  1789. end function
  1790. public function integer uof_noauditingqty_del (long arg_outwareid, ref string arg_msg);If uo_option_noauditingqty_mode = 0 Then Return 1
  1791. Int rslt = 1
  1792. Long i,ll_i
  1793. i = 1
  1794. s_outwaremx arg_s_mx[]
  1795. Declare cur_outwaremx Cursor For
  1796. Select u_outwaremovemx.scid,
  1797. u_outwaremovemx.mtrlwareid,
  1798. u_outwaremovemx.qty,
  1799. u_outwaremovemx.uqty,
  1800. u_mtrldef.mtrlcode
  1801. From u_outwaremovemx,u_mtrldef
  1802. Where u_outwaremovemx.outwareid = :arg_outwareid And
  1803. u_outwaremovemx.mtrlid = u_mtrldef.mtrlid
  1804. Order By u_outwaremovemx.printid;
  1805. Open cur_outwaremx;
  1806. Fetch cur_outwaremx Into :arg_s_mx[i].scid,:arg_s_mx[i].mtrlwareid,
  1807. :arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode;
  1808. Do While sqlca.SQLCode = 0
  1809. i++
  1810. Fetch cur_outwaremx Into :arg_s_mx[i].scid,:arg_s_mx[i].mtrlwareid,
  1811. :arg_s_mx[i].qty,:arg_s_mx[i].uqty,:arg_s_mx[i].mtrlcode;
  1812. Loop
  1813. Close cur_outwaremx;
  1814. For ll_i = 1 To i - 1
  1815. Update u_mtrlware
  1816. Set noauditingqty = noauditingqty - :arg_s_mx[ll_i].qty,
  1817. noauditinguqty = noauditingqty - :arg_s_mx[ll_i].uqty
  1818. Where scid = :arg_s_mx[ll_i].scid
  1819. And mtrlwareid = :arg_s_mx[ll_i].mtrlwareid;
  1820. If sqlca.SQLCode <> 0 Then
  1821. rslt = 0
  1822. arg_msg = '物料:'+String(arg_s_mx[ll_i].mtrlcode)+',更新明细库存已开单数失败 '+sqlca.SQLErrText
  1823. Goto ext
  1824. End If
  1825. Next
  1826. ext:
  1827. Return rslt
  1828. end function
  1829. public function integer acceptmx (long arg_mtrlwareid, decimal arg_qty, decimal arg_price, ref string arg_msg, long arg_printid, string arg_mxdscrp, string arg_unit, decimal arg_uqty, decimal arg_rate, string arg_newlocation, integer arg_ifrel, long arg_relid, long arg_relprintid, string arg_relcode);Long rslt = 1,cnt = 0,ls_i,j
  1830. Long i_mtrlid,i_storageid,i_scid
  1831. String i_mtrlcode,i_status,i_plancode,i_woodcode,i_pcode
  1832. String ls_mtrlcuscode,ls_location
  1833. Decimal i_cost
  1834. Int i_dxflag
  1835. Long i_sptid
  1836. Decimal i_notauditqty,i_allouseqty
  1837. String ls_unit
  1838. String ls_relcode
  1839. Decimal lde_noconqty, ld_saletqty_task, ld_consignedqty_task, lde_mx_qty, lde_notauditqty
  1840. Long ll_mtrlid_task
  1841. String ls_status_task, ls_woodcode_task, ls_pcode_task
  1842. Int li_status_ck, li_woodcode_ck, li_pcode_ck
  1843. IF uo_option_barcodelocation_use_inwaremx_location = -1000 THEN
  1844. rslt = 0
  1845. arg_msg = '选项:[287]条码进仓仓位使用进仓单扫描仓位,读取初始默认值失败,操作取消!'
  1846. GOTO ext
  1847. END IF
  1848. IF it_newbegin = False And it_updatebegin = False THEN
  1849. rslt = 0
  1850. arg_msg = "非编辑状态不可以使用,操作取消"
  1851. GOTO ext
  1852. END IF
  1853. //清除空值
  1854. IF IsNull(arg_mtrlwareid) THEN arg_mtrlwareid = 0
  1855. IF IsNull(arg_qty) THEN arg_qty = 0
  1856. IF IsNull(arg_mxdscrp) THEN arg_mxdscrp = ''
  1857. IF IsNull(arg_unit) THEN arg_unit = ''
  1858. IF IsNull(arg_printid) THEN arg_printid = 0
  1859. IF IsNull(arg_price) THEN arg_price = 0
  1860. IF IsNull(arg_uqty) THEN arg_uqty = 0
  1861. IF IsNull(arg_rate) THEN arg_rate = 0
  1862. IF IsNull(arg_newlocation) THEN arg_newlocation = ''
  1863. IF IsNull(arg_ifrel) THEN arg_ifrel = 0
  1864. IF IsNull(arg_relid) THEN arg_relid = 0
  1865. IF IsNull(arg_relprintid) THEN arg_relprintid = 0
  1866. IF IsNull(arg_relcode) THEN arg_relcode = ''
  1867. IF arg_mtrlwareid = 0 Or arg_qty = 0 THEN // 如果出仓数量为 0,或物料编号为空,则不作任何处理
  1868. rslt = 1
  1869. GOTO ext
  1870. END IF
  1871. IF arg_uqty = 0 And arg_rate = 0 THEN
  1872. rslt = 1
  1873. GOTO ext
  1874. END IF
  1875. IF arg_uqty = 0 THEN
  1876. arg_rate = 1
  1877. ELSE
  1878. arg_rate = arg_qty / arg_uqty
  1879. END IF
  1880. //检查物料库存id
  1881. SELECT u_mtrlware.mtrlid,
  1882. u_mtrlware.storageid,
  1883. u_mtrlware.cost,
  1884. u_mtrldef.mtrlcode,
  1885. u_mtrlware.plancode,
  1886. u_mtrlware.status,
  1887. u_mtrlware.scid,
  1888. u_mtrlware.dxflag,
  1889. u_mtrlware.sptid,
  1890. u_mtrlware.woodcode,
  1891. u_mtrlware.pcode,
  1892. u_mtrlware.noauditingqty,
  1893. u_mtrlware.noallocqty,
  1894. u_mtrldef.unit,
  1895. u_mtrlware.mtrlcuscode,
  1896. u_mtrlware.location
  1897. INTO :i_mtrlid,
  1898. :i_storageid,
  1899. :i_cost,
  1900. :i_mtrlcode,
  1901. :i_plancode,
  1902. :i_status,
  1903. :i_scid,
  1904. :i_dxflag,
  1905. :i_sptid,
  1906. :i_woodcode,
  1907. :i_pcode,
  1908. :i_notauditqty,
  1909. :i_allouseqty,
  1910. :ls_unit,
  1911. :ls_mtrlcuscode,
  1912. :ls_location
  1913. FROM u_mtrlware ,u_mtrldef
  1914. WHERE ( u_mtrlware.mtrlwareid = :arg_mtrlwareid )
  1915. AND ( u_mtrlware.mtrlid = u_mtrldef.mtrlid )
  1916. And ( u_mtrlware.storageid = :sstorageid );
  1917. IF sqlca.SQLCode <> 0 THEN
  1918. rslt = 0
  1919. arg_msg = "查询操作失败,库存编号(仓库调拨单)错误,仓库:"+String(sstorageid)+'库存:'+String(arg_mtrlwareid)+',~n'+sqlca.SQLErrText
  1920. GOTO ext
  1921. END IF
  1922. IF IsNull(i_cost) THEN i_cost = 0
  1923. IF IsNull(i_mtrlid) THEN i_mtrlid = 0
  1924. IF IsNull(i_storageid) THEN i_storageid = 0
  1925. IF IsNull(i_status) THEN i_status = ''
  1926. IF IsNull(i_woodcode) THEN i_woodcode = ''
  1927. IF IsNull(i_pcode) THEN i_pcode = ''
  1928. IF IsNull(i_plancode) THEN i_plancode = ''
  1929. IF IsNull(i_scid) THEN i_scid = 0
  1930. IF IsNull(i_dxflag) THEN i_dxflag = 0
  1931. IF IsNull(i_sptid) THEN i_sptid = 0
  1932. IF IsNull(ls_mtrlcuscode) THEN ls_mtrlcuscode = ''
  1933. IF IsNull(ls_location) THEN ls_location = ''
  1934. //IF ls_unit <> arg_unit AND arg_rate = 1 THEN
  1935. // arg_msg = '行:'+String(arg_printid)+',物料库存单位与采购单位不同,但转换率为1,请检查'
  1936. // rslt = 0
  1937. // GOTO ext
  1938. //END IF
  1939. IF ls_unit = arg_unit And arg_rate <> 1 THEN
  1940. arg_msg = '行:'+String(arg_printid)+',物料库存单位与采购单位相同,但转换率不为1,请检查'
  1941. rslt = 0
  1942. GOTO ext
  1943. END IF
  1944. IF arg_price * arg_rate < 0 THEN
  1945. rslt = 0
  1946. arg_msg = '行:'+String(arg_printid)+",单价错误"
  1947. GOTO ext
  1948. END IF
  1949. //*****检查大于未开数不可以开单
  1950. IF flag = 0 THEN
  1951. Int ls_noallocflag
  1952. SELECT noallocflag INTO :ls_noallocflag
  1953. FROM u_storage
  1954. Where storageid = :sstorageid;
  1955. IF sqlca.SQLCode <> 0 THEN
  1956. rslt = 0
  1957. arg_msg = '查询仓库允许使用未开单库存属性失败'+sqlca.SQLErrText
  1958. GOTO ext
  1959. END IF
  1960. Decimal ol_mtrl_qty = 0
  1961. IF ls_noallocflag = 1 THEN
  1962. IF it_updatebegin THEN
  1963. SELECT sum(u_outwaremovemx.qty)
  1964. INTO :ol_mtrl_qty
  1965. FROM u_outwaremovemx
  1966. WHERE u_outwaremovemx.outwareid = :outwareid
  1967. And u_outwaremovemx.mtrlwareid = :arg_mtrlwareid;
  1968. IF sqlca.SQLCode = -1 THEN
  1969. rslt = 0
  1970. arg_msg = '查询原开单数量失败'
  1971. GOTO ext
  1972. END IF
  1973. END IF
  1974. IF IsNull(ol_mtrl_qty) THEN ol_mtrl_qty = 0
  1975. IF arg_qty > ( i_allouseqty - i_notauditqty + ol_mtrl_qty ) THEN
  1976. rslt = 0
  1977. arg_msg = String(i_mtrlcode)+"库存未开单数不够,不能开单.未开单数{"+String(i_allouseqty - i_notauditqty + ol_mtrl_qty,'#####,0.00##')+"}"
  1978. GOTO ext
  1979. END IF
  1980. END IF
  1981. END IF
  1982. FOR ls_i = 1 To it_mxbt
  1983. IF outwaremx[ls_i].mtrlwareid = arg_mtrlwareid And &
  1984. outwaremx[ls_i].newlocation <> arg_newlocation THEN
  1985. rslt = 0
  1986. arg_msg = '第'+String(arg_printid)+'行存在相同的库存,但调入仓位下相同,不能在同1张单建立,请检查'
  1987. GOTO ext
  1988. END IF
  1989. IF outwaremx[ls_i].mtrlwareid = arg_mtrlwareid THEN
  1990. outwaremx[ls_i].qty = outwaremx[ls_i].qty + arg_qty
  1991. outwaremx[ls_i].uqty = outwaremx[ls_i].uqty + arg_uqty
  1992. rslt = 1
  1993. GOTO ext
  1994. END IF
  1995. NEXT
  1996. IF arg_ifrel = 0 THEN
  1997. arg_relid = 0
  1998. arg_relprintid = 0
  1999. arg_relcode = ''
  2000. ELSE
  2001. IF arg_relid = 0 THEN
  2002. rslt = 0
  2003. arg_msg = '第'+String(arg_printid)+'行,请选择相应分部需求单'
  2004. GOTO ext
  2005. END IF
  2006. SELECT u_saletask.taskcode,
  2007. u_saletaskmx.saleqty - u_saletaskmx.consignedqty ,
  2008. u_saletaskmx.mtrlid,
  2009. u_saletaskmx.status,
  2010. u_saletaskmx.woodcode,
  2011. u_saletaskmx.pcode,
  2012. u_saletaskmx.saleqty,
  2013. u_saletaskmx.consignedqty
  2014. INTO :ls_relcode,
  2015. :lde_noconqty,
  2016. :ll_mtrlid_task,
  2017. :ls_status_task,
  2018. :ls_woodcode_task,
  2019. :ls_pcode_task,
  2020. :ld_saletqty_task,
  2021. :ld_consignedqty_task
  2022. FROM u_saletaskmx,u_saletask
  2023. WHERE u_saletaskmx.taskid = :arg_relid
  2024. AND u_saletaskmx.scid = :i_scid
  2025. AND u_saletaskmx.scid = u_saletask.scid
  2026. AND u_saletaskmx.printid = :arg_relprintid
  2027. And u_saletaskmx.taskid = u_saletask.taskid ;
  2028. IF sqlca.SQLCode <> 0 THEN
  2029. arg_msg = '查询分部需求单是否有物料:'+i_mtrlcode+'失败'
  2030. rslt = 0
  2031. GOTO ext
  2032. END IF
  2033. IF ll_mtrlid_task <> i_mtrlid THEN
  2034. arg_msg = '第'+String(arg_printid)+'行,分部需求单:'+ls_relcode+',产品:'+i_mtrlcode+' 与库存信息(物料id)不匹配,不允许保存,请检查相关分部需求单与库存信息'
  2035. rslt = 0
  2036. GOTO ext
  2037. END IF
  2038. SELECT Top 1 CASE when ltrim(rtrim(:i_status)) = ltrim(rtrim(:ls_status_task)) THEN 0 ELSE 1 END,
  2039. CASE when ltrim(rtrim(:i_woodcode)) = ltrim(rtrim(:ls_woodcode_task)) THEN 0 ELSE 1 END,
  2040. CASE when ltrim(rtrim(:i_pcode)) = ltrim(rtrim(:ls_pcode_task)) THEN 0 ELSE 1 END
  2041. Into :li_status_ck,:li_woodcode_ck,:li_pcode_ck
  2042. From u_user Using sqlca;
  2043. IF sqlca.SQLCode <> 0 THEN
  2044. arg_msg = '第'+String(arg_printid)+'行,分部需求单:'+ls_relcode+',产品:'+i_mtrlcode+',3个配置信息与库存3个配置信息是否相同失败,'+sqlca.SQLErrText
  2045. rslt = 0
  2046. GOTO ext
  2047. END IF
  2048. IF li_status_ck + li_woodcode_ck + li_pcode_ck > 0 THEN
  2049. arg_msg = '第'+String(arg_printid)+'行,分部需求单:'+ls_relcode+',产品:'+i_mtrlcode+' 与库存信息不匹配,不允许保存,请检查相关分部需求单与库存信息'
  2050. rslt = 0
  2051. GOTO ext
  2052. END IF
  2053. lde_mx_qty = 0
  2054. FOR ls_i = 1 To it_mxbt
  2055. IF i_mtrlid = outwaremx[ls_i].mtrlid And &
  2056. arg_relid = outwaremx[ls_i].relid And &
  2057. arg_relprintid = outwaremx[ls_i].relprintid And &
  2058. i_status = outwaremx[ls_i].status And &
  2059. i_woodcode = outwaremx[ls_i].woodcode And &
  2060. i_pcode = outwaremx[ls_i].pcode THEN
  2061. lde_mx_qty = lde_mx_qty + outwaremx[ls_i].qty
  2062. END IF
  2063. NEXT
  2064. lde_mx_qty = lde_mx_qty + arg_qty
  2065. //查询相关订单已开发货单未审核数量
  2066. SELECT isnull(sum(qty),0)
  2067. INTO :lde_notauditqty
  2068. FROM u_outwaremovemx,u_outware_move
  2069. WHERE u_outwaremovemx.relid = :arg_relid
  2070. AND u_outwaremovemx.relprintid = :arg_relprintid
  2071. AND u_outware_move.flag = 0
  2072. AND u_outwaremovemx.outwareid = u_outware_move.outwareid
  2073. AND u_outware_move.outwareid <> :outwareid
  2074. Using sqlca;
  2075. IF sqlca.SQLCode <> 0 THEN
  2076. arg_msg = '查询分部需求单:'+ls_relcode+'产品:'+i_mtrlcode+'已开单未审核数量失败'
  2077. rslt = 0
  2078. GOTO ext
  2079. END IF
  2080. IF lde_notauditqty + lde_mx_qty > lde_noconqty THEN
  2081. arg_msg = '分部需求单:'+ls_relcode+' 产品:'+i_mtrlcode+'未完成数:'+String(lde_noconqty,'#,##0.##########')+',已开单未审核数:'+String(lde_notauditqty,'#,##0.##########')+'不能再开单:'+String(lde_mx_qty,'#,##0.##########')
  2082. rslt = 0
  2083. GOTO ext
  2084. END IF
  2085. END IF
  2086. //***********************************************
  2087. //yyx20150428
  2088. IF uo_option_barcodelocation_use_inwaremx_location = 1 THEN
  2089. IF it_mxbt = 0 THEN
  2090. il_newlocation_cnt = 1
  2091. ELSE
  2092. FOR j = 1 To it_mxbt
  2093. IF trim(arg_newlocation) <> trim(outwaremx[j].newlocation) THEN
  2094. il_newlocation_cnt++
  2095. END IF
  2096. NEXT
  2097. END IF
  2098. if il_newlocation_cnt <> 1 then
  2099. arg_msg = '系统开启了[287]条码进仓仓位使用进仓单扫描仓位 系统选项,调拨明细的新仓位多于1个,不能保存单据。~n'
  2100. arg_msg += '如果调拨明细的新仓位多于1个,请分开建立调拨单。~n'
  2101. rslt = 0
  2102. goto ext
  2103. end if
  2104. END IF
  2105. //写入内容
  2106. it_mxbt++
  2107. outwaremx[it_mxbt].scid = i_scid
  2108. outwaremx[it_mxbt].mtrlwareid = arg_mtrlwareid
  2109. outwaremx[it_mxbt].mtrlid = i_mtrlid
  2110. outwaremx[it_mxbt].qty = arg_qty
  2111. outwaremx[it_mxbt].unit = arg_unit
  2112. outwaremx[it_mxbt].uqty = arg_uqty
  2113. outwaremx[it_mxbt].rate = arg_rate
  2114. outwaremx[it_mxbt].storageid = i_storageid
  2115. outwaremx[it_mxbt].cost = i_cost
  2116. outwaremx[it_mxbt].mtrlcode = i_mtrlcode
  2117. outwaremx[it_mxbt].printid = arg_printid
  2118. outwaremx[it_mxbt].mxdscrp = arg_mxdscrp
  2119. outwaremx[it_mxbt].status = i_status
  2120. outwaremx[it_mxbt].plancode = i_plancode
  2121. outwaremx[it_mxbt].dxflag = i_dxflag
  2122. outwaremx[it_mxbt].sptid = i_sptid
  2123. outwaremx[it_mxbt].woodcode = i_woodcode
  2124. outwaremx[it_mxbt].pcode = i_pcode
  2125. outwaremx[it_mxbt].price = arg_price
  2126. outwaremx[it_mxbt].mtrlcuscode = ls_mtrlcuscode
  2127. outwaremx[it_mxbt].Location = ls_location
  2128. outwaremx[it_mxbt].newlocation = arg_newlocation
  2129. outwaremx[it_mxbt].ifrel = arg_ifrel
  2130. outwaremx[it_mxbt].relid = arg_relid
  2131. outwaremx[it_mxbt].relprintid = arg_relprintid
  2132. outwaremx[it_mxbt].relcode = arg_relcode
  2133. ext:
  2134. IF rslt = 0 THEN p_clearmx()
  2135. Return(rslt)
  2136. end function
  2137. on uo_outware_move.create
  2138. call super::create
  2139. TriggerEvent( this, "constructor" )
  2140. end on
  2141. on uo_outware_move.destroy
  2142. TriggerEvent( this, "destructor" )
  2143. call super::destroy
  2144. end on
  2145. event constructor;String str_optionvalue,arg_msg
  2146. f_get_sys_option_value('204',str_optionvalue,arg_msg)
  2147. uo_option_barcode_outwaremove_paudit = Long(str_optionvalue)
  2148. f_get_sys_option_value('142',str_optionvalue,arg_msg)
  2149. uo_option_inout_type = Long(str_optionvalue)
  2150. f_get_sys_option_value('390',str_optionvalue,arg_msg)
  2151. uo_option_noauditingqty_mode = Long(str_optionvalue)
  2152. f_get_sys_option_value('287',str_optionvalue,arg_msg)
  2153. uo_option_barcodelocation_use_inwaremx_location = Long(str_optionvalue)
  2154. end event