uo_workpricetable.sru 64 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577
  1. $PBExportHeader$uo_workpricetable.sru
  2. forward
  3. global type uo_workpricetable from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_workpricetable from nonvisualobject
  7. end type
  8. global uo_workpricetable uo_workpricetable
  9. type variables
  10. long mtrlid //产品id
  11. long wrkid
  12. string wpcode
  13. long wpmtrlid
  14. int if_hourpay
  15. decimal eoq
  16. decimal wprate
  17. s_workpricetable workpricemx[] //明细结构数组
  18. long it_mxbt=0 //明细结构数组末指针
  19. boolean it_updatebegin=false//修改标志
  20. Long deep_count = 0
  21. long il_printid = 0
  22. int uo_option_orderrqwp_auditgj
  23. end variables
  24. forward prototypes
  25. public function integer p_clearmx ()
  26. public function integer p_reset ()
  27. public function integer c_auditing (long arg_mtrlid, ref string arg_msg, boolean arg_ifcommit)
  28. public function integer acceptsumrec (long arg_mtrlid, ref string arg_msg, boolean arg_ifcommit)
  29. public function integer save (boolean arg_ifcommit, ref string arg_msg)
  30. public function integer uof_del_action (long arg_mtrlid, string arg_procode, boolean arg_ifcommit, ref string arg_msg)
  31. public function integer uof_add_action (long arg_mtrlid, string arg_procode, long arg_actionid, string arg_actionname, decimal arg_qty, decimal arg_actiontime, string arg_dscrp, boolean arg_ifcommit, ref string arg_msg)
  32. public function integer uof_workhour_update (long arg_mtrlid, string arg_procode, decimal arg_workhour, boolean arg_ifcommit, ref string arg_msg)
  33. public function integer uof_add_list (long arg_mtrlid, string arg_wpcode, long arg_wrkid, integer arg_templet, string arg_dscrp, integer arg_ifdft, string arg_opemp, ref string arg_msg, boolean arg_ifcommit)
  34. public function integer updatebegin (long arg_mtrlid, string arg_wpcode, long arg_wrkid, ref string arg_msg)
  35. public function integer f_clearpfmx (long arg_mtrlid, string arg_wpcode, ref string arg_msg, boolean arg_ifcommit)
  36. public function integer uof_del_list (long arg_mtrlid, string arg_wpcode, ref string arg_msg, boolean arg_ifcommit)
  37. public function integer uof_set_templet (long arg_mtrlid, string arg_wpcode, integer arg_templet, ref string arg_msg, boolean arg_ifcommit)
  38. public function integer update_auditflag (long arg_mtrlid, string arg_wpcode, datetime arg_auditdate, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  39. public function integer auditing (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  40. public function integer c_auditing (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, ref string arg_msg, boolean arg_ifcommit)
  41. public function integer auditing_gs (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  42. public function integer c_auditing_gs (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, ref string arg_msg, boolean arg_ifcommit)
  43. public function integer f_addworkprice (long arg_mtrlid, string arg_wpcode, ref string arg_msg, boolean arg_ifcommit)
  44. public function integer uof_setdft (long arg_mtrlid, string arg_wpcode, integer arg_dft, ref string arg_msg, boolean arg_ifcommit)
  45. public function integer auditing_gj (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  46. public function integer c_auditing_gj (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, ref string arg_msg, boolean arg_ifcommit)
  47. public function integer auditing_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  48. public function integer auditing_gj_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  49. public function integer c_auditing_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], ref string arg_msg, boolean arg_ifcommit)
  50. public function integer c_auditing_gj_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], ref string arg_msg, boolean arg_ifcommit)
  51. public function integer auditing_gs_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit)
  52. public function integer c_auditing_gs_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], ref string arg_msg, boolean arg_ifcommit)
  53. public function integer acceptmx (long arg_proid, string arg_procode, string arg_proname, decimal arg_workqty, decimal arg_workprice, long arg_wrkgrpid, string arg_worklevel, string arg_techlevel, decimal arg_workhour_minute, string arg_dscrp, integer arg_lastflag, long arg_proorder, integer arg_ifownpro, integer arg_lsxtype, integer arg_ifstandard, string arg_status, integer arg_ifjd, string arg_utcode, integer arg_sctype, long arg_equipmentid, decimal arg_workdays, decimal arg_beforehour_minute, decimal arg_afterhour_minute, string arg_pricestr, string arg_partname, decimal arg_eqworkhour_minute, string arg_worktype, decimal arg_arg1, decimal arg_arg2, decimal arg_arg3, decimal arg_arg4, decimal arg_arg5, decimal arg_arg6, decimal arg_arg7, decimal arg_arg8, decimal arg_arg9, decimal arg_eq_empnum, decimal arg_fzrate, decimal arg_factor, string arg_workqtystr, integer arg_ifgroup, decimal arg_u_workqty, decimal arg_u_workprice, string arg_u_workqtystr, string arg_u_pricestr, string arg_rpcode, integer arg_ifdftpg, integer arg_ifdftjj, decimal arg_waittime, decimal arg_lasthour, ref string arg_msg)
  54. public function integer uof_update_workprice_zl (long arg_mtrlid, string arg_wpcode, string arg_procode, ref string arg_msg, boolean arg_ifcommit)
  55. public function integer f_addpfmx (long arg_mtrlid, string arg_wpcode, string arg_pfcode, decimal arg_qty, long arg_lp, ref string arg_msg, boolean arg_ifcommit, integer arg_protype)
  56. end prototypes
  57. public function integer p_clearmx ();//INT p_clearmx()
  58. //清除明细
  59. it_mxbt=0
  60. RETURN 1
  61. end function
  62. public function integer p_reset ();//INT p_RESET()
  63. //清除对象及其明细
  64. wpmtrlid = 0
  65. wprate = 0
  66. it_updatebegin=FALSE
  67. //清除明细
  68. P_CLEARMX()
  69. RETURN 1
  70. end function
  71. public function integer c_auditing (long arg_mtrlid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  72. DateTime serdate
  73. IF IsNull(arg_mtrlid) THEN
  74. rslt = 0
  75. arg_msg = '没有撤核对象!'
  76. GOTO ext
  77. END IF
  78. SELECT Auditflag INTO :ll_Auditflag FROM u_mtrldef Where mtrlid = :arg_mtrlid;
  79. IF sqlca.SQLCode <> 0 THEN
  80. rslt = 0
  81. arg_msg = '该产品没有审核!'
  82. GOTO ext
  83. END IF
  84. SetNull(serdate)
  85. UPDATE u_mtrldef
  86. SET Auditflag = 0,
  87. Audit_emp = '',
  88. Audit_date = :serdate
  89. Where mtrlid = :arg_mtrlid;
  90. IF sqlca.SQLCode <> 0 THEN
  91. rslt = 0
  92. arg_msg = '撤核失败!原因:'+sqlca.SQLErrText
  93. ROLLBACK;
  94. GOTO ext
  95. END IF
  96. ext:
  97. IF rslt = 0 THEN
  98. ROLLBACK;
  99. ELSEIF rslt = 1 And arg_ifcommit THEN
  100. COMMIT;
  101. END IF
  102. RETURN rslt
  103. end function
  104. public function integer acceptsumrec (long arg_mtrlid, ref string arg_msg, boolean arg_ifcommit);////acceptsumrec(long arg_mtrlid,string arg_msg, boolean arg_ifcommit)
  105. //s_workpricetable s_pricetable[]
  106. //dec ls_sumhour,ls_sumprice
  107. //long ls_wrkgrpid,i=1,k,ls_mxid,ls_proid,procount
  108. //int rslt=1
  109. //string ls_procode
  110. //
  111. //declare getworkprosum cursor for
  112. // SELECT SUM(u_sc_workprice.Workhour), SUM(u_sc_workprice.workPrice),
  113. // u_sc_workgroup.wrkgrpid
  114. // FROM u_sc_workprice, u_sc_workprocedure, u_sc_workgroup
  115. // WHERE (u_sc_workprice.proid = u_sc_workprocedure.proid) AND
  116. // (u_sc_workprocedure.wrkgrpid = u_sc_workgroup.wrkgrpid) AND
  117. // ((u_sc_workprice.Mtrlid = :arg_mtrlid)) AND u_sc_workprice.sumflag = 0
  118. // GROUP BY u_sc_workgroup.wrkgrpid;
  119. //open getworkprosum;
  120. //Do While sqlca.sqlcode=0
  121. // Fetch getworkprosum into :ls_sumhour,:ls_sumprice,:ls_wrkgrpid;
  122. // if sqlca.sqlcode<>0 then exit;
  123. // s_pricetable[i].wrkgrpid=ls_wrkgrpid
  124. // s_pricetable[i].workhour=ls_sumhour
  125. // s_pricetable[i].workprice=ls_sumprice
  126. // i++
  127. //loop
  128. //Close getworkprosum;
  129. //delete from u_sc_workprice where mtrlid=:arg_mtrlid and sumflag=1;
  130. //if sqlca.sqlcode=-1 then
  131. // rslt=0
  132. // arg_msg='删除工序失败!'
  133. // goto ext
  134. //end if
  135. //
  136. //for k= 1 to upperbound(s_pricetable)
  137. //// ls_mxid=f_sys_scidentity(0,"u_sc_workprice","mxid",arg_msg,false)
  138. //// if ls_mxid<0 then
  139. //// rslt=0
  140. //// goto ext
  141. //// end if
  142. //
  143. // select proid,code into :ls_proid,:ls_procode from u_sc_workprocedure where wrkgrpid=:s_pricetable[K].wrkgrpid and sysflag=1;
  144. // if sqlca.sqlcode=-1 then
  145. // arg_msg='查询工序资料失败,原因:'+sqlca.sqlerrtext
  146. // rslt=0
  147. // goto ext
  148. // end if
  149. //
  150. // SELECT count(*) into :procount FROM u_sc_workprice INNER JOIN
  151. // u_sc_workprocedure ON u_sc_workprice.proid = u_sc_workprocedure.proid AND
  152. // u_sc_workprocedure.wrkgrpid = :s_pricetable[k].wrkgrpid AND u_sc_workprice.mtrlid = :arg_mtrlid AND
  153. // u_sc_workprice.sumflag = 0;
  154. // if sqlca.sqlcode=-1 then
  155. // arg_msg='查询该产品工序资料失败,原因:'+sqlca.sqlerrtext
  156. // rslt=0
  157. // goto ext
  158. // end if
  159. //
  160. // if procount>1 then
  161. //
  162. // insert into u_sc_workprice
  163. // (mtrlid,
  164. // proid,
  165. // Procode,
  166. // workPrice,
  167. // Workhour,
  168. // sumflag)
  169. // values(:arg_mtrlid,
  170. // :ls_proid,
  171. // :ls_Procode,
  172. // :s_pricetable[K].workPrice,
  173. // :s_pricetable[K].Workhour,
  174. // 1);
  175. //
  176. // if sqlca.sqlcode<>0 then
  177. // rslt=0
  178. // arg_msg="插入工序明细表错误!原因:"+sqlca.sqlerrtext
  179. // rollback;
  180. // goto ext
  181. // end if
  182. // end if
  183. //next
  184. //
  185. //
  186. //ext:
  187. //if rslt=1 and arg_ifcommit then
  188. // commit;
  189. //end if
  190. //
  191. //if rslt=0 then
  192. // rollback;
  193. //end if
  194. //return rslt
  195. return 1
  196. end function
  197. public function integer save (boolean arg_ifcommit, ref string arg_msg);Long rslt = 1,i
  198. Long cnt
  199. DateTime serdate
  200. String ls_newemp
  201. DateTime ldt_newdate,ldt_nulldt
  202. Decimal ld_lastprice
  203. Int li_auditflag,li_auditflag_gj
  204. String ls_auditrep,ls_auditrep_gs
  205. DateTime ldt_auditdate,ldt_auditdate_gs
  206. int li_changeflag,li_ifchangebill
  207. SetNull(ldt_nulldt)
  208. If it_updatebegin = True Then
  209. If IsNull(mtrlid) Or mtrlid = 0 Then
  210. arg_msg = '产品错误,没有对应的产品'
  211. rslt = 0
  212. Goto ext
  213. End If
  214. If wpmtrlid > 0 Then
  215. cnt = 0
  216. Select count(*) Into :cnt
  217. From u_mtrldef
  218. Where mtrlid = :wpmtrlid;
  219. If sqlca.SQLCode <> 0 Then
  220. arg_msg = '查询标准产品资料失败'
  221. rslt = 0
  222. Goto ext
  223. End If
  224. If cnt <> 1 Then
  225. arg_msg = '不存在标准产品资料或资料重复'
  226. rslt = 0
  227. Goto ext
  228. End If
  229. If wprate <= 0 Then
  230. arg_msg = '请正确输入标准产品工价的比率'
  231. rslt = 0
  232. Goto ext
  233. End If
  234. End If
  235. Select Top 1 getdate() Into :serdate From u_user;
  236. If sqlca.SQLCode <> 0 Then
  237. arg_msg = '取服务器时间失败'
  238. rslt = 0
  239. Goto ext
  240. End If
  241. //先读取原明细信息
  242. For i = 1 To it_mxbt
  243. Select newemp,
  244. newdate,
  245. lastprice,
  246. auditflag,
  247. auditflag_gj,
  248. auditrep,
  249. auditrep_gs,
  250. auditdate,
  251. auditdate_gs,
  252. changeflag,
  253. ifchangebill
  254. Into :ls_newemp,
  255. :ldt_newdate,
  256. :ld_lastprice,
  257. :li_auditflag,
  258. :li_auditflag_gj,
  259. :ls_auditrep,
  260. :ls_auditrep_gs,
  261. :ldt_auditdate,
  262. :ldt_auditdate_gs,
  263. :li_changeflag,
  264. :li_ifchangebill
  265. From u_sc_workprice
  266. Where mtrlid = :mtrlid
  267. And wpcode = :wpcode
  268. And procode = :workpricemx[i].procode;
  269. If sqlca.SQLCode <> 0 Then
  270. workpricemx[i].newemp = publ_operator
  271. workpricemx[i].newdate = serdate
  272. workpricemx[i].modemp = ''
  273. workpricemx[i].moddate = ldt_nulldt
  274. workpricemx[i].lastprice = 0
  275. workpricemx[i].auditflag = 0
  276. workpricemx[i].auditflag_gj = 0
  277. workpricemx[i].auditrep = ''
  278. workpricemx[i].auditrep_gs = ''
  279. workpricemx[i].auditdate = ldt_nulldt
  280. workpricemx[i].auditdate_gs = ldt_nulldt
  281. workpricemx[i].changeflag = 0
  282. workpricemx[i].ifchangebill = 0
  283. Else
  284. workpricemx[i].newemp = ls_newemp
  285. workpricemx[i].newdate = ldt_newdate
  286. workpricemx[i].modemp = publ_operator
  287. workpricemx[i].moddate = serdate
  288. workpricemx[i].lastprice = ld_lastprice
  289. workpricemx[i].auditflag = li_auditflag
  290. workpricemx[i].auditflag_gj = li_auditflag_gj
  291. workpricemx[i].auditrep = ls_auditrep
  292. workpricemx[i].auditrep_gs = ls_auditrep_gs
  293. workpricemx[i].auditdate = ldt_auditdate
  294. workpricemx[i].auditdate_gs = ldt_auditdate_gs
  295. workpricemx[i].changeflag = li_changeflag
  296. workpricemx[i].ifchangebill = li_ifchangebill
  297. End If
  298. Next
  299. Update u_mtrldef
  300. Set popdate = :serdate,
  301. popemp = :publ_operator,
  302. wpmtrlid = :wpmtrlid,
  303. wprate = :wprate
  304. Where mtrlid = :mtrlid;
  305. If sqlca.SQLCode <> 0 Then
  306. rslt = 0
  307. arg_msg = '写入操作日期和操作人失败!'+sqlca.SQLErrText
  308. Goto ext
  309. End If
  310. Update u_mtrl_workprice
  311. Set u_mtrl_workprice.opdate = :serdate,
  312. u_mtrl_workprice.opemp = :publ_operator
  313. Where mtrlid = :mtrlid
  314. And wpcode = :wpcode;
  315. If sqlca.SQLCode <> 0 Then
  316. rslt = 0
  317. arg_msg = '写入操作日期和操作人失败!'+sqlca.SQLErrText
  318. Goto ext
  319. End If
  320. Delete From u_sc_workprice
  321. Where mtrlid = :mtrlid
  322. And wpcode = :wpcode
  323. And (auditflag = 0 Or auditflag_gj = 0 );
  324. If sqlca.SQLCode <> 0 Then
  325. rslt = 0
  326. arg_msg = '删除工价表明细失败!'
  327. Goto ext
  328. End If
  329. For i = 1 To it_mxbt
  330. Insert Into u_sc_workprice
  331. (mtrlid,
  332. wpcode,
  333. wrkid,
  334. proid,
  335. proname,
  336. procode,
  337. workprice,
  338. worklevel,
  339. techlevel,
  340. workhour,
  341. dscrp,
  342. lastflag,
  343. proorder,
  344. workqty,
  345. wrkgrpid,
  346. ifownpro,
  347. lsxtype,
  348. ifstandard,
  349. status,
  350. ifjd,
  351. utcode,
  352. sctype,
  353. equipmentid,
  354. workdays,
  355. beforehour,
  356. afterhour,
  357. pricestr,
  358. partname,
  359. eqworkhour,
  360. worktype,
  361. arg1,
  362. arg2,
  363. arg3,
  364. arg4,
  365. arg5,
  366. arg6,
  367. arg7,
  368. arg8,
  369. arg9,
  370. workhour_minute,
  371. beforehour_minute,
  372. afterhour_minute,
  373. eqworkhour_minute,
  374. totalhour,
  375. eq_empnum,
  376. fzrate,
  377. factor,
  378. workqtystr,
  379. ifgroup,
  380. u_workqty,
  381. u_workprice,
  382. u_workqtystr,
  383. u_pricestr,
  384. newemp,
  385. newdate,
  386. modemp,
  387. moddate,
  388. lastprice,
  389. auditflag,
  390. auditflag_gj,
  391. auditrep,
  392. auditrep_gs,
  393. auditdate,
  394. auditdate_gs,
  395. changeflag,
  396. rpcode,
  397. ifdftpg,
  398. ifdftjj,
  399. waittime,
  400. lasthour,
  401. ifchangebill)
  402. Values(:mtrlid,
  403. :wpcode,
  404. :wrkid,
  405. :workpricemx[i].proid,
  406. :workpricemx[i].proname,
  407. :workpricemx[i].procode,
  408. :workpricemx[i].workprice,
  409. :workpricemx[i].worklevel,
  410. :workpricemx[i].techlevel,
  411. :workpricemx[i].workhour,
  412. :workpricemx[i].dscrp,
  413. :workpricemx[i].lastflag,
  414. :workpricemx[i].proorder,
  415. :workpricemx[i].workqty,
  416. :workpricemx[i].wrkgrpid,
  417. :workpricemx[i].ifownpro,
  418. :workpricemx[i].lsxtype,
  419. :workpricemx[i].ifstandard,
  420. :workpricemx[i].status,
  421. :workpricemx[i].ifjd,
  422. :workpricemx[i].utcode,
  423. :workpricemx[i].sctype,
  424. :workpricemx[i].equipmentid,
  425. :workpricemx[i].workdays,
  426. :workpricemx[i].beforehour,
  427. :workpricemx[i].afterhour,
  428. :workpricemx[i].pricestr,
  429. :workpricemx[i].partname,
  430. :workpricemx[i].eqworkhour,
  431. :workpricemx[i].worktype,
  432. :workpricemx[i].arg1,
  433. :workpricemx[i].arg2,
  434. :workpricemx[i].arg3,
  435. :workpricemx[i].arg4,
  436. :workpricemx[i].arg5,
  437. :workpricemx[i].arg6,
  438. :workpricemx[i].arg7,
  439. :workpricemx[i].arg8,
  440. :workpricemx[i].arg9,
  441. :workpricemx[i].workhour_minute,
  442. :workpricemx[i].beforehour_minute,
  443. :workpricemx[i].afterhour_minute,
  444. :workpricemx[i].eqworkhour_minute,
  445. :workpricemx[i].totalhour,
  446. :workpricemx[i].eq_empnum,
  447. :workpricemx[i].fzrate,
  448. :workpricemx[i].factor,
  449. :workpricemx[i].workqtystr,
  450. :workpricemx[i].ifgroup,
  451. :workpricemx[i].u_workqty,
  452. :workpricemx[i].u_workprice,
  453. :workpricemx[i].u_workqtystr,
  454. :workpricemx[i].u_pricestr,
  455. :workpricemx[i].newemp,
  456. :workpricemx[i].newdate,
  457. :workpricemx[i].modemp,
  458. :workpricemx[i].moddate,
  459. :workpricemx[i].lastprice,
  460. :workpricemx[i].auditflag,
  461. :workpricemx[i].auditflag_gj,
  462. :workpricemx[i].auditrep,
  463. :workpricemx[i].auditrep_gs,
  464. :workpricemx[i].auditdate,
  465. :workpricemx[i].auditdate_gs,
  466. :workpricemx[i].changeflag,
  467. :workpricemx[i].rpcode,
  468. :workpricemx[i].ifdftpg,
  469. :workpricemx[i].ifdftjj,
  470. :workpricemx[i].waittime,
  471. :workpricemx[i].lasthour,
  472. :workpricemx[i].ifchangebill);
  473. If sqlca.SQLCode <> 0 Then
  474. rslt = 0
  475. arg_msg = "插入工序明细表错误!原因:"+sqlca.SQLErrText
  476. Goto ext
  477. End If
  478. Next
  479. End If
  480. If update_auditflag(mtrlid,wpcode,serdate,publ_operator,arg_msg,False) = 0 Then
  481. rslt = 0
  482. Goto ext
  483. End If
  484. it_updatebegin = False
  485. ext:
  486. If rslt = 0 Then
  487. Rollback;
  488. mtrlid = 0
  489. p_clearmx()
  490. ElseIf rslt = 1 And arg_ifcommit Then
  491. Commit;
  492. End If
  493. Return rslt
  494. end function
  495. public function integer uof_del_action (long arg_mtrlid, string arg_procode, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  496. DELETE FROM u_sc_workprice_action_mx
  497. WHERE mtrlid = :arg_mtrlid
  498. AND procode = :arg_procode;
  499. IF sqlca.SQLCode <> 0 THEN
  500. arg_msg = sqlca.SQLErrText
  501. rslt = 0
  502. GOTO ext
  503. END IF
  504. ext:
  505. IF rslt = 0 THEN
  506. ROLLBACK;
  507. ELSEIF rslt = 1 AND arg_ifcommit THEN
  508. COMMIT;
  509. END IF
  510. RETURN rslt
  511. end function
  512. public function integer uof_add_action (long arg_mtrlid, string arg_procode, long arg_actionid, string arg_actionname, decimal arg_qty, decimal arg_actiontime, string arg_dscrp, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  513. Long cnt
  514. SELECT count(*) INTO :cnt
  515. FROM u_sc_workprice_action
  516. Where actionid = :arg_actionid;
  517. IF sqlca.SQLCode <> 0 THEN
  518. arg_msg = '查询动作:'+arg_actionname+',资料失败,'+sqlca.SQLErrText
  519. rslt = 0
  520. GOTO ext
  521. END IF
  522. IF cnt = 0 THEN
  523. arg_msg = '查询动作:'+arg_actionname+',资料未定义,请检查'
  524. rslt = 0
  525. GOTO ext
  526. END IF
  527. INSERT INTO u_sc_workprice_action_mx
  528. (mtrlid,procode,actionid,qty,actiontime,dscrp)
  529. Values(:arg_mtrlid,:arg_procode,:arg_actionid,:arg_qty,:arg_actiontime,:arg_dscrp);
  530. IF sqlca.SQLCode <> 0 THEN
  531. arg_msg = '建立动作:'+arg_actionname+',资料失败,'+sqlca.SQLErrText
  532. rslt = 0
  533. GOTO ext
  534. END IF
  535. ext:
  536. IF rslt = 0 THEN
  537. ROLLBACK;
  538. ELSEIF rslt = 1 AND arg_ifcommit THEN
  539. COMMIT;
  540. END IF
  541. RETURN rslt
  542. end function
  543. public function integer uof_workhour_update (long arg_mtrlid, string arg_procode, decimal arg_workhour, boolean arg_ifcommit, ref string arg_msg);Int rslt = 1
  544. UPDATE u_sc_workprice
  545. SET Workhour = :arg_workhour
  546. WHERE mtrlid = :arg_mtrlid
  547. AND procode = :arg_procode;
  548. IF sqlca.SQLCode <> 0 THEN
  549. arg_msg = '更新工序工时失败,'+sqlca.SQLErrText
  550. rslt = 0
  551. GOTO ext
  552. END IF
  553. ext:
  554. IF rslt = 0 THEN
  555. ROLLBACK;
  556. ELSEIF rslt = 1 AND arg_ifcommit THEN
  557. COMMIT;
  558. END IF
  559. RETURN rslt
  560. end function
  561. public function integer uof_add_list (long arg_mtrlid, string arg_wpcode, long arg_wrkid, integer arg_templet, string arg_dscrp, integer arg_ifdft, string arg_opemp, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  562. Long cnt
  563. String ls_wrkGrpName
  564. SELECT wrkGrpName INTO :ls_wrkGrpName
  565. FROM u_sc_wkp
  566. Where wrkgrpid = :arg_wrkid;
  567. IF sqlca.SQLCode <> 0 THEN
  568. rslt = 0
  569. arg_msg = '查询车间信息失败,'+sqlca.SQLErrText
  570. GOTO ext
  571. END IF
  572. //SELECT count(*)
  573. // INTO :cnt
  574. // FROM u_mtrl_workprice
  575. // WHERE mtrlid = :arg_mtrlid
  576. // And wrkid = :arg_wrkid;
  577. //IF sqlca.SQLCode <> 0 THEN
  578. // rslt = 0
  579. // arg_msg = '查询该产品车间是否已存在工价表失败,'+sqlca.SQLErrText
  580. // GOTO ext
  581. //END IF
  582. //
  583. //IF cnt > 0 THEN
  584. // rslt = 0
  585. // arg_msg = '该产品在'+ls_wrkGrpName+'中已存在工价表,不能重复建立'
  586. // GOTO ext
  587. //END IF
  588. INSERT INTO u_mtrl_workprice
  589. (mtrlid,
  590. wrkid,
  591. templet,
  592. opdate,
  593. opemp,
  594. dscrp,
  595. wpcode,
  596. ifdft)
  597. VALUES (:arg_mtrlid,
  598. :arg_wrkid,
  599. :arg_templet,
  600. getdate(),
  601. :arg_opemp,
  602. :arg_dscrp,
  603. :arg_wpcode,
  604. :arg_ifdft);
  605. IF sqlca.SQLCode <> 0 THEN
  606. rslt = 0
  607. arg_msg = '新建产品工价表失败,'+sqlca.SQLErrText
  608. GOTO ext
  609. END IF
  610. ext:
  611. IF rslt = 0 THEN
  612. ROLLBACK;
  613. ELSEIF rslt = 1 And arg_ifcommit THEN
  614. COMMIT;
  615. END IF
  616. RETURN rslt
  617. end function
  618. public function integer updatebegin (long arg_mtrlid, string arg_wpcode, long arg_wrkid, ref string arg_msg);Long ll_auditflag,rslt = 1,ll_mtrlid,ll_count,ll_auditflag_gj
  619. //SELECT mtrlid,flag
  620. // INTO :ll_mtrlid,:ll_auditflag
  621. // FROM u_mtrl_workprice
  622. // WHERE mtrlid = :arg_mtrlid
  623. // And wpcode = :arg_wpcode;
  624. //IF sqlca.SQLCode <> 0 THEN
  625. // rslt = 0
  626. // arg_msg = '查询该产品的车间工价表资料失败! 原因:['+String(sqlca.SQLCode)+']'+sqlca.SQLErrText
  627. // GOTO ext
  628. //END IF
  629. //
  630. //IF ll_auditflag = 1 THEN
  631. // rslt = 0
  632. // arg_msg = '该工价表已审核,不能修改!'
  633. // GOTO ext
  634. //END IF
  635. SELECT if_hourpay,eoq
  636. INTO :if_hourpay,:eoq
  637. FROM u_mtrldef
  638. Where mtrlid = :arg_mtrlid;
  639. IF sqlca.SQLCode <> 0 THEN
  640. rslt = 0
  641. arg_msg = '查询产品资料失败! 原因:['+String(sqlca.SQLCode)+']'+sqlca.SQLErrText
  642. GOTO ext
  643. END IF
  644. IF eoq <= 0 THEN eoq = 1
  645. //SELECT count(*)
  646. // INTO :ll_count
  647. // From u_sc_workprice
  648. // Where mtrlid = :arg_mtrlid
  649. // and wrkid = :arg_wrkid;
  650. //IF sqlca.SQLCode <> 0 THEN
  651. // rslt = 0
  652. // arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  653. // GOTO ext
  654. //END IF
  655. //
  656. mtrlid = ll_mtrlid
  657. wrkid = arg_wrkid
  658. wpcode = arg_wpcode
  659. p_clearmx()
  660. it_updatebegin = True
  661. ext:
  662. IF rslt = 0 THEN p_reset()
  663. RETURN rslt
  664. end function
  665. public function integer f_clearpfmx (long arg_mtrlid, string arg_wpcode, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1
  666. DELETE FROM u_sc_workprice_mx
  667. WHERE parentmtrlid = :arg_mtrlid
  668. and wpcode = :arg_wpcode;
  669. IF sqlca.SQLCode <> 0 THEN
  670. arg_msg = "删除下级工价表失败,"+sqlca.SQLErrText
  671. rslt = 0
  672. GOTO ext
  673. END IF
  674. ext:
  675. if rslt = 0 then
  676. rollback;
  677. elseif rslt = 1 and arg_ifcommit then
  678. commit;
  679. end if
  680. RETURN rslt
  681. end function
  682. public function integer uof_del_list (long arg_mtrlid, string arg_wpcode, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  683. Int li_flag
  684. Long cnt
  685. SELECT flag INTO :li_flag
  686. FROM u_mtrl_workprice
  687. WHERE mtrlid = :arg_mtrlid
  688. And wpcode = :arg_wpcode;
  689. IF sqlca.SQLCode <> 0 THEN
  690. rslt = 0
  691. arg_msg = '查询产品工价表信息失败,'+sqlca.SQLErrText
  692. GOTO ext
  693. END IF
  694. IF li_flag = 1 THEN
  695. rslt = 0
  696. arg_msg = '产品工价表已审核,不能删除'
  697. GOTO ext
  698. END IF
  699. SELECT count(*)
  700. INTO :cnt
  701. FROM u_sc_workprice
  702. WHERE mtrlid = :arg_mtrlid
  703. AND wpcode = :arg_wpcode
  704. And ( (auditflag = 1) Or (auditflag_gj = 1));
  705. IF sqlca.SQLCode <> 0 THEN
  706. rslt = 0
  707. arg_msg = '查询产品工价表工序明细信息失败,'+sqlca.SQLErrText
  708. GOTO ext
  709. END IF
  710. IF cnt > 0 THEN
  711. rslt = 0
  712. arg_msg = '产品工价表工序明细存在已工序审核或已工价审核明细,不能删除'
  713. GOTO ext
  714. END IF
  715. DELETE FROM u_sc_workprice
  716. WHERE mtrlid = :arg_mtrlid
  717. And wpcode = :arg_wpcode;
  718. IF sqlca.SQLCode <> 0 THEN
  719. rslt = 0
  720. arg_msg = '删除产品工价表信息失败,'+sqlca.SQLErrText
  721. GOTO ext
  722. END IF
  723. DELETE FROM u_mtrl_workprice
  724. WHERE mtrlid = :arg_mtrlid
  725. And wpcode = :arg_wpcode;
  726. IF sqlca.SQLCode <> 0 THEN
  727. rslt = 0
  728. arg_msg = '删除产品工价表信息失败,'+sqlca.SQLErrText
  729. GOTO ext
  730. END IF
  731. DELETE FROM u_sc_workprice_mx
  732. WHERE parentMtrlid = :arg_mtrlid
  733. And wpcode = :arg_wpcode;
  734. IF sqlca.SQLCode <> 0 THEN
  735. rslt = 0
  736. arg_msg = '删除产品工价表全套工价信息失败,'+sqlca.SQLErrText
  737. GOTO ext
  738. END IF
  739. ext:
  740. IF rslt = 0 THEN
  741. ROLLBACK;
  742. ELSEIF rslt = 1 And arg_ifcommit THEN
  743. COMMIT;
  744. END IF
  745. RETURN rslt
  746. end function
  747. public function integer uof_set_templet (long arg_mtrlid, string arg_wpcode, integer arg_templet, ref string arg_msg, boolean arg_ifcommit);Int rslt
  748. rslt = 1
  749. Int li_templet
  750. SELECT templet
  751. INTO :li_templet
  752. FROM u_mtrl_workprice
  753. WHERE mtrlid = :arg_mtrlid
  754. And wpcode = :arg_wpcode;
  755. IF sqlca.SQLCode <> 0 THEN
  756. rslt = 0
  757. arg_msg = '查询车间工价表信息失败,'+sqlca.SQLErrText
  758. GOTO ext
  759. END IF
  760. IF arg_templet = li_templet THEN
  761. IF arg_templet = 1 THEN
  762. rslt = 0
  763. arg_msg = '工价表已经是模板,不能重复设置'
  764. GOTO ext
  765. ELSEIF arg_templet = 0 THEN
  766. rslt = 0
  767. arg_msg = '工价表还不是模板,不能取消设置'
  768. GOTO ext
  769. END IF
  770. END IF
  771. UPDATE u_mtrl_workprice
  772. SET templet = :arg_templet
  773. WHERE mtrlid = :arg_mtrlid
  774. And wpcode = :arg_wpcode;
  775. IF sqlca.SQLCode <> 0 THEN
  776. rslt = 0
  777. arg_msg = '更新车间工价表模板属性失败,'+sqlca.SQLErrText
  778. GOTO ext
  779. END IF
  780. ext:
  781. IF rslt = 0 THEN
  782. ROLLBACK;
  783. ELSEIF rslt = 1 And arg_ifcommit THEN
  784. COMMIT;
  785. END IF
  786. RETURN rslt
  787. end function
  788. public function integer update_auditflag (long arg_mtrlid, string arg_wpcode, datetime arg_auditdate, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  789. Long cnt,cnt_all
  790. SELECT count(*) INTO :cnt_all
  791. FROM u_sc_workprice
  792. WHERE mtrlid = :arg_mtrlid
  793. and wpcode = :arg_wpcode;
  794. IF sqlca.SQLCode <> 0 THEN
  795. arg_msg = '查询工价表明细工序数失败'
  796. rslt = 0
  797. GOTO ext
  798. END IF
  799. SELECT count(*) INTO :cnt
  800. FROM u_sc_workprice
  801. WHERE auditflag = 0
  802. AND mtrlid = :arg_mtrlid
  803. and wpcode = :arg_wpcode;
  804. IF sqlca.SQLCode <> 0 THEN
  805. arg_msg = '查询工价表明细未审核工序数失败'
  806. rslt = 0
  807. GOTO ext
  808. END IF
  809. IF cnt = 0 and cnt_all > 0 THEN
  810. UPDATE u_mtrl_workprice
  811. SET flag = 1,
  812. auditemp = :arg_auditingrep,
  813. auditdate = :arg_auditdate
  814. Where mtrlid = :arg_mtrlid
  815. and wpcode = :arg_wpcode;
  816. ELSE
  817. UPDATE u_mtrl_workprice
  818. SET flag = 0,
  819. auditemp = :arg_auditingrep,
  820. auditdate = :arg_auditdate
  821. Where mtrlid = :arg_mtrlid
  822. and wpcode = :arg_wpcode;
  823. END IF
  824. IF sqlca.SQLCode <> 0 THEN
  825. rslt = 0
  826. arg_msg = '更新工价表审核标记失败,原因:'+sqlca.SQLErrText
  827. GOTO ext
  828. END IF
  829. ext:
  830. IF rslt = 0 THEN
  831. ROLLBACK;
  832. ELSEIF rslt = 1 AND arg_ifcommit THEN
  833. COMMIT;
  834. END IF
  835. RETURN rslt
  836. end function
  837. public function integer auditing (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);//====================================================================
  838. // Function: auditing()
  839. //--------------------------------------------------------------------
  840. // Description: 审核工价表
  841. //--------------------------------------------------------------------
  842. // Arguments:
  843. // value long arg_mtrlid
  844. // value string arg_auditingrep
  845. // reference string arg_msg
  846. // value boolean arg_ifcommit
  847. //--------------------------------------------------------------------
  848. // Returns: integer
  849. //--------------------------------------------------------------------
  850. // Author: yyx Date: 2003.11.01
  851. //--------------------------------------------------------------------
  852. // Modify History:
  853. //
  854. //====================================================================
  855. Long rslt = 1,ll_count,ll_Auditflag
  856. DateTime serdate
  857. IF IsNull(arg_mtrlid) THEN
  858. rslt = 0
  859. arg_msg = '没有审核对象!'
  860. GOTO ext
  861. END IF
  862. ll_count = 0
  863. SELECT count(*)
  864. Into :ll_count
  865. From u_sc_workprice
  866. Where mtrlid = :arg_mtrlid
  867. and wpcode = :arg_wpcode;
  868. IF sqlca.SQLCode <> 0 THEN
  869. rslt = 0
  870. arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  871. GOTO ext
  872. END IF
  873. IF ll_count = 0 THEN
  874. rslt = 0
  875. arg_msg = '该产品工价表没有工序,不能审核'
  876. GOTO ext
  877. END IF
  878. SELECT Top 1 getdate() Into :serdate From u_user;
  879. IF sqlca.SQLCode <> 0 THEN
  880. arg_msg = '查询服务器时间失败'
  881. rslt = 0
  882. GOTO ext
  883. END IF
  884. ll_count = 0
  885. IF arg_wrkGrpid > 0 THEN
  886. SELECT count(*) INTO :ll_count
  887. FROM u_sc_workgroup
  888. Where wrkGrpid = :arg_wrkGrpid;
  889. IF sqlca.SQLCode <> 0 Or ll_count <> 1 THEN
  890. arg_msg = '查询工组资料失败,或者不存在工组资料'
  891. rslt = 0
  892. GOTO ext
  893. END IF
  894. END IF
  895. UPDATE u_sc_workprice
  896. SET auditflag = 1,
  897. auditrep = :arg_auditingrep,
  898. auditdate = :serdate
  899. WHERE (mtrlid = :arg_mtrlid)
  900. and (wpcode = :arg_wpcode)
  901. And (wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  902. IF sqlca.SQLCode <> 0 THEN
  903. arg_msg = '更新工价表明细审核标记失败,'+sqlca.SQLErrText
  904. rslt = 0
  905. GOTO ext
  906. END IF
  907. IF update_auditflag(arg_mtrlid,arg_wpcode,serdate,arg_auditingrep,arg_msg,False) = 0 THEN
  908. rslt = 0
  909. GOTO ext
  910. END IF
  911. ext:
  912. IF rslt = 0 THEN
  913. ROLLBACK;
  914. ELSEIF rslt = 1 And arg_ifcommit THEN
  915. COMMIT;
  916. END IF
  917. RETURN rslt
  918. end function
  919. public function integer c_auditing (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  920. DateTime serdate,null_dt
  921. SetNull(null_dt)
  922. Long cnt
  923. If IsNull(arg_mtrlid) Then
  924. rslt = 0
  925. arg_msg = '没有审核对象!'
  926. Goto ext
  927. End If
  928. //ll_count = 0
  929. //SELECT count(*)
  930. //INTO :ll_count
  931. //FROM u_sc_workprice
  932. //Where mtrlid = :arg_mtrlid
  933. //and wpcode = :arg_wpcode;
  934. //IF sqlca.SQLCode <> 0 THEN
  935. // rslt = 0
  936. // arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  937. // GOTO ext
  938. //END IF
  939. //
  940. //IF ll_count = 0 THEN
  941. // rslt = 0
  942. // arg_msg = '该产品工价表没有工序,不能撤审'
  943. // GOTO ext
  944. //END IF
  945. //
  946. //ll_count = 0
  947. //IF arg_wrkGrpid > 0 THEN
  948. // SELECT count(*) INTO :ll_count
  949. // FROM u_sc_workgroup
  950. // Where wrkGrpid = :arg_wrkGrpid;
  951. // IF sqlca.SQLCode <> 0 OR ll_count <> 1 THEN
  952. // arg_msg = '查询工组资料失败,或者不存在工组资料'
  953. // rslt = 0
  954. // GOTO ext
  955. // END IF
  956. //END IF
  957. If sys_option_if_oa_workprice_change = 1 And sys_option_workprice_change_secaudit = 1 Then
  958. Select count(*)
  959. Into :cnt
  960. From u_workprice_changemx Inner JOIN
  961. u_workprice_change ON
  962. u_workprice_changemx.billid = u_workprice_change.billid
  963. Where (u_workprice_change.priceflag = 1)
  964. And (u_workprice_change.flag = 0)
  965. And (u_workprice_changemx.rsltflag = 0)
  966. And (u_workprice_changemx.mtrlid = :arg_mtrlid)
  967. And (u_workprice_changemx.wpcode = :arg_wpcode)
  968. And (u_workprice_changemx.wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  969. If sqlca.SQLCode <> 0 Then
  970. arg_msg = '查询工序是否有在进行审批流程的工价变更单失败,'+sqlca.SQLErrText
  971. rslt = 0
  972. Goto ext
  973. End If
  974. If cnt > 0 Then
  975. arg_msg = '工价表有在进行审批流程的工价变更单,不能撤审'
  976. rslt = 0
  977. Goto ext
  978. End If
  979. End If
  980. Update u_sc_workprice
  981. Set auditflag = 0,
  982. auditrep = '',
  983. auditdate = :null_dt
  984. Where (mtrlid = :arg_mtrlid)
  985. And (wpcode = :arg_wpcode)
  986. And (wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  987. If sqlca.SQLCode <> 0 Then
  988. arg_msg = '更新工价表明细审核标记失败,'+sqlca.SQLErrText
  989. rslt = 0
  990. Goto ext
  991. End If
  992. If update_auditflag(arg_mtrlid,arg_wpcode,null_dt,'',arg_msg,False) = 0 Then
  993. rslt = 0
  994. Goto ext
  995. End If
  996. ext:
  997. If rslt = 0 Then
  998. Rollback;
  999. ElseIf rslt = 1 And arg_ifcommit Then
  1000. Commit;
  1001. End If
  1002. Return rslt
  1003. end function
  1004. public function integer auditing_gs (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1005. DateTime serdate
  1006. IF IsNull(arg_mtrlid) THEN
  1007. rslt = 0
  1008. arg_msg = '没有审核对象!'
  1009. GOTO ext
  1010. END IF
  1011. ll_count = 0
  1012. SELECT count(*)
  1013. INTO :ll_count
  1014. FROM u_sc_workprice
  1015. Where mtrlid = :arg_mtrlid
  1016. and wpcode = :arg_wpcode;
  1017. IF sqlca.SQLCode <> 0 THEN
  1018. rslt = 0
  1019. arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  1020. GOTO ext
  1021. END IF
  1022. IF ll_count = 0 THEN
  1023. rslt = 0
  1024. arg_msg = '该产品工价表没有工序,不能审核'
  1025. GOTO ext
  1026. END IF
  1027. SELECT Top 1 getdate() INTO :serdate FROM u_user;
  1028. IF sqlca.SQLCode <> 0 THEN
  1029. arg_msg = '查询服务器时间失败'
  1030. rslt = 0
  1031. GOTO ext
  1032. END IF
  1033. ll_count = 0
  1034. IF arg_wrkGrpid > 0 THEN
  1035. SELECT count(*) INTO :ll_count
  1036. FROM u_sc_workgroup
  1037. Where wrkGrpid = :arg_wrkGrpid;
  1038. IF sqlca.SQLCode <> 0 OR ll_count <> 1 THEN
  1039. arg_msg = '查询工组资料失败,或者不存在工组资料'
  1040. rslt = 0
  1041. GOTO ext
  1042. END IF
  1043. END IF
  1044. UPDATE u_sc_workprice
  1045. SET auditflag_gs = 1,
  1046. auditrep_gs = :arg_auditingrep,
  1047. auditdate_gs = :serdate
  1048. WHERE (mtrlid = :arg_mtrlid)
  1049. and (wpcode = :arg_wpcode)
  1050. And (wrkGrpid = :arg_wrkGrpid OR :arg_wrkGrpid = -1 );
  1051. IF sqlca.SQLCode <> 0 THEN
  1052. arg_msg = '更新工价表明细工时审核标记失败,'+sqlca.SQLErrText
  1053. rslt = 0
  1054. GOTO ext
  1055. END IF
  1056. ext:
  1057. IF rslt = 0 THEN
  1058. ROLLBACK;
  1059. ELSEIF rslt = 1 And arg_ifcommit THEN
  1060. COMMIT;
  1061. END IF
  1062. RETURN rslt
  1063. end function
  1064. public function integer c_auditing_gs (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1065. DateTime serdate,null_dt
  1066. SetNull(null_dt)
  1067. IF IsNull(arg_mtrlid) THEN
  1068. rslt = 0
  1069. arg_msg = '没有审核对象!'
  1070. GOTO ext
  1071. END IF
  1072. ll_count = 0
  1073. SELECT count(*)
  1074. INTO :ll_count
  1075. FROM u_sc_workprice
  1076. WHERE mtrlid = :arg_mtrlid
  1077. And wpcode = :arg_wpcode;
  1078. IF sqlca.SQLCode <> 0 THEN
  1079. rslt = 0
  1080. arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  1081. GOTO ext
  1082. END IF
  1083. IF ll_count = 0 THEN
  1084. rslt = 0
  1085. arg_msg = '该产品没有工序,不能审核'
  1086. GOTO ext
  1087. END IF
  1088. ll_count = 0
  1089. IF arg_wrkGrpid > 0 THEN
  1090. SELECT count(*) INTO :ll_count
  1091. FROM u_sc_workgroup
  1092. Where wrkGrpid = :arg_wrkGrpid;
  1093. IF sqlca.SQLCode <> 0 Or ll_count <> 1 THEN
  1094. arg_msg = '查询工组资料失败,或者不存在工组资料'
  1095. rslt = 0
  1096. GOTO ext
  1097. END IF
  1098. END IF
  1099. UPDATE u_sc_workprice
  1100. SET auditflag_gs = 0,
  1101. auditrep_gs = '',
  1102. auditdate_gs = :null_dt
  1103. WHERE mtrlid = :arg_mtrlid
  1104. AND wpcode = :arg_wpcode
  1105. And (wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  1106. IF sqlca.SQLCode <> 0 THEN
  1107. arg_msg = '更新工价表明细工时审核标记失败,'+sqlca.SQLErrText
  1108. rslt = 0
  1109. GOTO ext
  1110. END IF
  1111. ext:
  1112. IF rslt = 0 THEN
  1113. ROLLBACK;
  1114. ELSEIF rslt = 1 And arg_ifcommit THEN
  1115. COMMIT;
  1116. END IF
  1117. RETURN rslt
  1118. end function
  1119. public function integer f_addworkprice (long arg_mtrlid, string arg_wpcode, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1120. Long ll_j
  1121. Long proid
  1122. Long proorder
  1123. String procode
  1124. String proname
  1125. Long wrkgrpid
  1126. Decimal workprice
  1127. Decimal workqty
  1128. String worklevel
  1129. Decimal workhour
  1130. String dscrp
  1131. Long auditflag
  1132. String auditrep
  1133. DateTime auditdate
  1134. Long lastflag
  1135. string status
  1136. int ifjd
  1137. long ll_wrkid
  1138. datastore ds_workprice
  1139. ds_workprice = CREATE datastore
  1140. ds_workprice.DataObject = 'dw_sc_workpricetable_mx_ds'
  1141. ds_workprice.SetTransObject(sqlca)
  1142. ds_workprice.Retrieve(arg_mtrlid,arg_wpcode)
  1143. FOR ll_j = 1 TO ds_workprice.RowCount()
  1144. il_printid++
  1145. proid = ds_workprice.Object.proid[ll_j]
  1146. proorder = ds_workprice.Object.proorder[ll_j]
  1147. procode = ds_workprice.Object.procode[ll_j]
  1148. proname = ds_workprice.Object.u_sc_workprice_proname[ll_j]
  1149. wrkgrpid = ds_workprice.Object.wrkgrpid[ll_j]
  1150. workprice = ds_workprice.Object.workprice[ll_j]
  1151. workqty = ds_workprice.Object.workqty[ll_j]
  1152. worklevel = ds_workprice.Object.worklevel[ll_j]
  1153. workhour = ds_workprice.Object.workhour[ll_j]
  1154. dscrp = ds_workprice.Object.dscrp[ll_j]
  1155. auditflag = ds_workprice.Object.auditflag[ll_j]
  1156. auditrep = ds_workprice.Object.auditrep[ll_j]
  1157. auditdate = ds_workprice.Object.auditdate[ll_j]
  1158. status = ds_workprice.Object.u_sc_workprice_status[ll_j]
  1159. ifjd = ds_workprice.Object.u_sc_workprice_ifjd[ll_j]
  1160. ll_wrkid = ds_workprice.Object.u_sc_workprice_wrkid[ll_j]
  1161. INSERT INTO u_sc_workprice_mx
  1162. (parentmtrlid,
  1163. printid,
  1164. mtrlid,
  1165. proid,
  1166. proorder,
  1167. procode,
  1168. proname,
  1169. wrkgrpid,
  1170. workprice,
  1171. workqty,
  1172. worklevel,
  1173. workhour,
  1174. dscrp,
  1175. auditflag,
  1176. auditrep,
  1177. auditdate,
  1178. lastflag,
  1179. lp,
  1180. status,
  1181. ifjd,
  1182. wrkid,
  1183. wpcode)
  1184. VALUES
  1185. (:arg_mtrlid,
  1186. :il_printid,
  1187. :arg_mtrlid,
  1188. :proid,
  1189. :proorder,
  1190. :procode,
  1191. :proname,
  1192. :wrkgrpid,
  1193. :workprice,
  1194. :workqty,
  1195. :worklevel,
  1196. :workhour,
  1197. :dscrp,
  1198. :auditflag,
  1199. :auditrep,
  1200. :auditdate,
  1201. :lastflag,
  1202. 0,
  1203. :status,
  1204. :ifjd,
  1205. :ll_wrkid,
  1206. :arg_wpcode);
  1207. IF sqlca.SQLCode <> 0 THEN
  1208. arg_msg = '插入下级自制部件工价表失败'+sqlca.SQLErrText
  1209. rslt = 0
  1210. GOTO ext
  1211. END IF
  1212. NEXT
  1213. ext:
  1214. IF rslt = 0 THEN
  1215. ROLLBACK;
  1216. ELSEIF rslt = 1 AND arg_ifcommit THEN
  1217. COMMIT;
  1218. END IF
  1219. destroy ds_workprice
  1220. RETURN rslt
  1221. end function
  1222. public function integer uof_setdft (long arg_mtrlid, string arg_wpcode, integer arg_dft, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1223. Int li_ifdft,li_di
  1224. Long cnt = 0
  1225. SELECT ifdft
  1226. INTO :li_ifdft
  1227. FROM u_mtrl_workprice
  1228. WHERE mtrlid = :arg_mtrlid
  1229. And wpcode = :arg_wpcode;
  1230. IF sqlca.SQLCode <> 0 THEN
  1231. arg_msg = '查询工价表失败,'+sqlca.SQLErrText
  1232. rslt = 0
  1233. GOTO ext
  1234. END IF
  1235. IF li_ifdft = 1 THEN
  1236. IF arg_dft = 1 THEN
  1237. arg_msg = '工价表已设置为默认,不能再设置'
  1238. rslt = 0
  1239. GOTO ext
  1240. END IF
  1241. ELSE
  1242. IF arg_dft = 0 THEN
  1243. arg_msg = '工价表未设置为默认,不能取消设置'
  1244. rslt = 0
  1245. GOTO ext
  1246. END IF
  1247. SELECT count(*) INTO :cnt
  1248. FROM u_mtrl_workprice
  1249. WHERE mtrlid = :arg_mtrlid
  1250. AND wpcode <> :arg_wpcode
  1251. And ifdft = 1;
  1252. IF sqlca.SQLCode <> 0 THEN
  1253. arg_msg = '查询物料默认工价表数量失败,'+sqlca.SQLErrText
  1254. rslt = 0
  1255. GOTO ext
  1256. END IF
  1257. IF cnt > 0 THEN
  1258. arg_msg = '工价表只能设置一个默认工价表'
  1259. rslt = 0
  1260. GOTO ext
  1261. END IF
  1262. END IF
  1263. UPDATE u_mtrl_workprice
  1264. SET ifdft = :arg_dft
  1265. WHERE mtrlid = :arg_mtrlid
  1266. And wpcode = :arg_wpcode;
  1267. IF sqlca.SQLCode <> 0 THEN
  1268. arg_msg = '更新工价表默认标记失败,'+sqlca.SQLErrText
  1269. rslt = 0
  1270. GOTO ext
  1271. END IF
  1272. ext:
  1273. IF rslt = 0 THEN
  1274. ROLLBACK;
  1275. ELSEIF rslt = 1 And arg_ifcommit THEN
  1276. COMMIT;
  1277. END IF
  1278. RETURN rslt
  1279. end function
  1280. public function integer auditing_gj (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1281. String ls_procode_arr[]
  1282. Long ll_cnt = 1,ll_i
  1283. DateTime serdate
  1284. If IsNull(arg_mtrlid) Then
  1285. rslt = 0
  1286. arg_msg = '没有审核对象!'
  1287. Goto ext
  1288. End If
  1289. ll_count = 0
  1290. Select count(*)
  1291. Into :ll_count
  1292. From u_sc_workprice
  1293. Where mtrlid = :arg_mtrlid
  1294. And wpcode = :arg_wpcode;
  1295. If sqlca.SQLCode <> 0 Then
  1296. rslt = 0
  1297. arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  1298. Goto ext
  1299. End If
  1300. If ll_count = 0 Then
  1301. rslt = 0
  1302. arg_msg = '该产品工价表没有工序,不能审核'
  1303. Goto ext
  1304. End If
  1305. Select Top 1 getdate() Into :serdate From u_user;
  1306. If sqlca.SQLCode <> 0 Then
  1307. arg_msg = '查询服务器时间失败'
  1308. rslt = 0
  1309. Goto ext
  1310. End If
  1311. ll_count = 0
  1312. If arg_wrkGrpid > 0 Then
  1313. Select count(*) Into :ll_count
  1314. From u_sc_workgroup
  1315. Where wrkGrpid = :arg_wrkGrpid;
  1316. If sqlca.SQLCode <> 0 Or ll_count <> 1 Then
  1317. arg_msg = '查询工组资料失败,或者不存在工组资料'
  1318. rslt = 0
  1319. Goto ext
  1320. End If
  1321. End If
  1322. Update u_sc_workprice
  1323. Set auditflag_gj = 1,
  1324. auditrep_gj = :arg_auditingrep,
  1325. auditdate_gj = :serdate
  1326. Where (mtrlid = :arg_mtrlid)
  1327. And (wpcode = :arg_wpcode)
  1328. And (wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  1329. If sqlca.SQLCode <> 0 Then
  1330. arg_msg = '更新工价表明细工价审核标记失败,'+sqlca.SQLErrText
  1331. rslt = 0
  1332. Goto ext
  1333. End If
  1334. If arg_wrkGrpid = -1 Then
  1335. If uof_update_workprice_zl(arg_mtrlid,arg_wpcode,'',arg_msg,False) = 0 Then
  1336. rslt = 0
  1337. Goto ext
  1338. End If
  1339. Else
  1340. Declare cur_procode Cursor For
  1341. Select procode
  1342. From u_sc_workprice
  1343. Where (mtrlid = :arg_mtrlid)
  1344. And (wpcode = :arg_wpcode)
  1345. And (wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  1346. Open cur_procode;
  1347. Fetch cur_procode Into :ls_procode_arr[ll_cnt];
  1348. Do While sqlca.SQLCode = 0
  1349. ll_cnt++
  1350. Fetch cur_procode Into :ls_procode_arr[ll_cnt];
  1351. Loop
  1352. Close cur_procode;
  1353. For ll_i = 1 To ll_cnt - 1
  1354. If uof_update_workprice_zl(arg_mtrlid,arg_wpcode,ls_procode_arr[ll_i],arg_msg,False) = 0 Then
  1355. rslt = 0
  1356. Goto ext
  1357. End If
  1358. Next
  1359. End If
  1360. ext:
  1361. If rslt = 0 Then
  1362. Rollback;
  1363. ElseIf rslt = 1 And arg_ifcommit Then
  1364. Commit;
  1365. End If
  1366. Return rslt
  1367. end function
  1368. public function integer c_auditing_gj (long arg_mtrlid, string arg_wpcode, long arg_wrkgrpid, ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1369. DateTime serdate,null_dt
  1370. SetNull(null_dt)
  1371. IF IsNull(arg_mtrlid) THEN
  1372. rslt = 0
  1373. arg_msg = '没有审核对象!'
  1374. GOTO ext
  1375. END IF
  1376. ll_count = 0
  1377. SELECT count(*)
  1378. INTO :ll_count
  1379. FROM u_sc_workprice
  1380. WHERE mtrlid = :arg_mtrlid
  1381. And wpcode = :arg_wpcode;
  1382. IF sqlca.SQLCode <> 0 THEN
  1383. rslt = 0
  1384. arg_msg = '查询该产品的工价表失败,原因:'+sqlca.SQLErrText
  1385. GOTO ext
  1386. END IF
  1387. IF ll_count = 0 THEN
  1388. rslt = 0
  1389. arg_msg = '该产品没有工序,不能审核'
  1390. GOTO ext
  1391. END IF
  1392. ll_count = 0
  1393. IF arg_wrkGrpid > 0 THEN
  1394. SELECT count(*) INTO :ll_count
  1395. FROM u_sc_workgroup
  1396. Where wrkGrpid = :arg_wrkGrpid;
  1397. IF sqlca.SQLCode <> 0 Or ll_count <> 1 THEN
  1398. arg_msg = '查询工组资料失败,或者不存在工组资料'
  1399. rslt = 0
  1400. GOTO ext
  1401. END IF
  1402. END IF
  1403. UPDATE u_sc_workprice
  1404. SET auditflag_gj = 0,
  1405. auditrep_gj = '',
  1406. auditdate_gj = :null_dt
  1407. WHERE mtrlid = :arg_mtrlid
  1408. AND wpcode = :arg_wpcode
  1409. And (wrkGrpid = :arg_wrkGrpid Or :arg_wrkGrpid = -1 );
  1410. IF sqlca.SQLCode <> 0 THEN
  1411. arg_msg = '更新工价表明细工价审核标记失败,'+sqlca.SQLErrText
  1412. rslt = 0
  1413. GOTO ext
  1414. END IF
  1415. ext:
  1416. IF rslt = 0 THEN
  1417. ROLLBACK;
  1418. ELSEIF rslt = 1 And arg_ifcommit THEN
  1419. COMMIT;
  1420. END IF
  1421. RETURN rslt
  1422. end function
  1423. public function integer auditing_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);
  1424. Long rslt = 1,ll_count,ll_Auditflag
  1425. Long ll_i
  1426. DateTime serdate
  1427. IF IsNull(arg_mtrlid) THEN
  1428. rslt = 0
  1429. arg_msg = '没有审核对象!'
  1430. GOTO ext
  1431. END IF
  1432. SELECT Top 1 getdate() Into :serdate From u_user;
  1433. IF sqlca.SQLCode <> 0 THEN
  1434. arg_msg = '查询服务器时间失败'
  1435. rslt = 0
  1436. GOTO ext
  1437. END IF
  1438. FOR ll_i = 1 To UpperBound(arg_procode)
  1439. UPDATE u_sc_workprice
  1440. SET auditflag = 1,
  1441. auditrep = :arg_auditingrep,
  1442. auditdate = :serdate
  1443. WHERE (mtrlid = :arg_mtrlid)
  1444. AND (wpcode = :arg_wpcode)
  1445. And (procode = :arg_procode[ll_i]);
  1446. IF sqlca.SQLCode <> 0 THEN
  1447. arg_msg = '更新工价表明细审核标记失败,'+sqlca.SQLErrText
  1448. rslt = 0
  1449. GOTO ext
  1450. END IF
  1451. NEXT
  1452. IF update_auditflag(arg_mtrlid,arg_wpcode,serdate,arg_auditingrep,arg_msg,False) = 0 THEN
  1453. rslt = 0
  1454. GOTO ext
  1455. END IF
  1456. ext:
  1457. IF rslt = 0 THEN
  1458. ROLLBACK;
  1459. ELSEIF rslt = 1 And arg_ifcommit THEN
  1460. COMMIT;
  1461. END IF
  1462. RETURN rslt
  1463. end function
  1464. public function integer auditing_gj_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);
  1465. Long rslt = 1,ll_count,ll_Auditflag
  1466. Long ll_i
  1467. DateTime serdate
  1468. IF IsNull(arg_mtrlid) THEN
  1469. rslt = 0
  1470. arg_msg = '没有审核对象!'
  1471. GOTO ext
  1472. END IF
  1473. SELECT Top 1 getdate() Into :serdate From u_user;
  1474. IF sqlca.SQLCode <> 0 THEN
  1475. arg_msg = '查询服务器时间失败'
  1476. rslt = 0
  1477. GOTO ext
  1478. END IF
  1479. FOR ll_i = 1 To UpperBound(arg_procode)
  1480. UPDATE u_sc_workprice
  1481. SET auditflag_gj = 1,
  1482. auditrep_gj = :arg_auditingrep,
  1483. auditdate_gj = :serdate
  1484. WHERE (mtrlid = :arg_mtrlid)
  1485. AND (wpcode = :arg_wpcode)
  1486. And (procode = :arg_procode[ll_i]);
  1487. IF sqlca.SQLCode <> 0 THEN
  1488. arg_msg = '更新工价表明细工价审核标记失败,'+sqlca.SQLErrText
  1489. rslt = 0
  1490. GOTO ext
  1491. END IF
  1492. if uof_update_workprice_zl(arg_mtrlid,arg_wpcode,arg_procode[ll_i],arg_msg,false) = 0 then
  1493. rslt = 0
  1494. goto ext
  1495. end if
  1496. NEXT
  1497. ext:
  1498. IF rslt = 0 THEN
  1499. ROLLBACK;
  1500. ELSEIF rslt = 1 And arg_ifcommit THEN
  1501. COMMIT;
  1502. END IF
  1503. RETURN rslt
  1504. end function
  1505. public function integer c_auditing_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1506. Long ll_i
  1507. DateTime serdate,null_dt
  1508. Long cnt
  1509. SetNull(null_dt)
  1510. If IsNull(arg_mtrlid) Then
  1511. rslt = 0
  1512. arg_msg = '没有审核对象!'
  1513. Goto ext
  1514. End If
  1515. If sys_option_if_oa_workprice_change = 1 And sys_option_workprice_change_secaudit = 1 Then
  1516. For ll_i = 1 To UpperBound(arg_procode)
  1517. Select count(*)
  1518. Into :cnt
  1519. From u_workprice_changemx Inner JOIN
  1520. u_workprice_change ON
  1521. u_workprice_changemx.billid = u_workprice_change.billid
  1522. Where (u_workprice_change.priceflag = 1)
  1523. And (u_workprice_change.flag = 0)
  1524. And (u_workprice_changemx.rsltflag = 0)
  1525. And (u_workprice_changemx.mtrlid = :arg_mtrlid)
  1526. And (u_workprice_changemx.wpcode = :arg_wpcode)
  1527. And (u_workprice_changemx.procode = :arg_procode[ll_i]);
  1528. If sqlca.SQLCode <> 0 Then
  1529. arg_msg = '查询工序是否有在进行审批流程的工价变更单失败,'+sqlca.SQLErrText
  1530. rslt = 0
  1531. Goto ext
  1532. End If
  1533. If cnt > 0 Then
  1534. arg_msg = '工序:'+arg_procode[ll_i]+' 有在进行审批流程的工价变更单,不能撤审'
  1535. rslt = 0
  1536. Goto ext
  1537. End If
  1538. Next
  1539. End If
  1540. For ll_i = 1 To UpperBound(arg_procode)
  1541. Update u_sc_workprice
  1542. Set auditflag = 0,
  1543. auditrep = '',
  1544. auditdate = :null_dt
  1545. Where (mtrlid = :arg_mtrlid)
  1546. And (wpcode = :arg_wpcode)
  1547. And (procode = :arg_procode[ll_i] );
  1548. If sqlca.SQLCode <> 0 Then
  1549. arg_msg = '更新工价表明细审核标记失败,'+sqlca.SQLErrText
  1550. rslt = 0
  1551. Goto ext
  1552. End If
  1553. Next
  1554. If update_auditflag(arg_mtrlid,arg_wpcode,null_dt,'',arg_msg,False) = 0 Then
  1555. rslt = 0
  1556. Goto ext
  1557. End If
  1558. ext:
  1559. If rslt = 0 Then
  1560. Rollback;
  1561. ElseIf rslt = 1 And arg_ifcommit Then
  1562. Commit;
  1563. End If
  1564. Return rslt
  1565. end function
  1566. public function integer c_auditing_gj_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1567. Long ll_i
  1568. DateTime serdate,null_dt
  1569. SetNull(null_dt)
  1570. IF IsNull(arg_mtrlid) THEN
  1571. rslt = 0
  1572. arg_msg = '没有审核对象!'
  1573. GOTO ext
  1574. END IF
  1575. FOR ll_i = 1 To UpperBound(arg_procode)
  1576. UPDATE u_sc_workprice
  1577. SET auditflag_gj = 0,
  1578. auditrep_gj = '',
  1579. auditdate_gj = :null_dt
  1580. WHERE (mtrlid = :arg_mtrlid)
  1581. AND (wpcode = :arg_wpcode)
  1582. And (procode = :arg_procode[ll_i] );
  1583. IF sqlca.SQLCode <> 0 THEN
  1584. arg_msg = '更新工价表明细工价审核标记失败,'+sqlca.SQLErrText
  1585. rslt = 0
  1586. GOTO ext
  1587. END IF
  1588. NEXT
  1589. ext:
  1590. IF rslt = 0 THEN
  1591. ROLLBACK;
  1592. ELSEIF rslt = 1 And arg_ifcommit THEN
  1593. COMMIT;
  1594. END IF
  1595. RETURN rslt
  1596. end function
  1597. public function integer auditing_gs_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], string arg_auditingrep, ref string arg_msg, boolean arg_ifcommit);
  1598. Long rslt = 1,ll_count,ll_Auditflag
  1599. Long ll_i
  1600. DateTime serdate
  1601. IF IsNull(arg_mtrlid) THEN
  1602. rslt = 0
  1603. arg_msg = '没有审核对象!'
  1604. GOTO ext
  1605. END IF
  1606. SELECT Top 1 getdate() Into :serdate From u_user;
  1607. IF sqlca.SQLCode <> 0 THEN
  1608. arg_msg = '查询服务器时间失败'
  1609. rslt = 0
  1610. GOTO ext
  1611. END IF
  1612. FOR ll_i = 1 To UpperBound(arg_procode)
  1613. UPDATE u_sc_workprice
  1614. SET auditflag_gs = 1,
  1615. auditrep_gs = :arg_auditingrep,
  1616. auditdate_gs = :serdate
  1617. WHERE (mtrlid = :arg_mtrlid)
  1618. AND (wpcode = :arg_wpcode)
  1619. And (procode = :arg_procode[ll_i]);
  1620. IF sqlca.SQLCode <> 0 THEN
  1621. arg_msg = '更新工价表明细工时审核标记失败,'+sqlca.SQLErrText
  1622. rslt = 0
  1623. GOTO ext
  1624. END IF
  1625. NEXT
  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_auditing_gs_mx (long arg_mtrlid, string arg_wpcode, string arg_procode[], ref string arg_msg, boolean arg_ifcommit);Long rslt = 1,ll_count,ll_Auditflag
  1635. Long ll_i
  1636. DateTime serdate,null_dt
  1637. SetNull(null_dt)
  1638. IF IsNull(arg_mtrlid) THEN
  1639. rslt = 0
  1640. arg_msg = '没有审核对象!'
  1641. GOTO ext
  1642. END IF
  1643. FOR ll_i = 1 To UpperBound(arg_procode)
  1644. UPDATE u_sc_workprice
  1645. SET auditflag_gs = 0,
  1646. auditrep_gs = '',
  1647. auditdate_gs = :null_dt
  1648. WHERE (mtrlid = :arg_mtrlid)
  1649. AND (wpcode = :arg_wpcode)
  1650. And (procode = :arg_procode[ll_i] );
  1651. IF sqlca.SQLCode <> 0 THEN
  1652. arg_msg = '更新工价表明细工时审核标记失败,'+sqlca.SQLErrText
  1653. rslt = 0
  1654. GOTO ext
  1655. END IF
  1656. NEXT
  1657. ext:
  1658. IF rslt = 0 THEN
  1659. ROLLBACK;
  1660. ELSEIF rslt = 1 And arg_ifcommit THEN
  1661. COMMIT;
  1662. END IF
  1663. RETURN rslt
  1664. end function
  1665. public function integer acceptmx (long arg_proid, string arg_procode, string arg_proname, decimal arg_workqty, decimal arg_workprice, long arg_wrkgrpid, string arg_worklevel, string arg_techlevel, decimal arg_workhour_minute, string arg_dscrp, integer arg_lastflag, long arg_proorder, integer arg_ifownpro, integer arg_lsxtype, integer arg_ifstandard, string arg_status, integer arg_ifjd, string arg_utcode, integer arg_sctype, long arg_equipmentid, decimal arg_workdays, decimal arg_beforehour_minute, decimal arg_afterhour_minute, string arg_pricestr, string arg_partname, decimal arg_eqworkhour_minute, string arg_worktype, decimal arg_arg1, decimal arg_arg2, decimal arg_arg3, decimal arg_arg4, decimal arg_arg5, decimal arg_arg6, decimal arg_arg7, decimal arg_arg8, decimal arg_arg9, decimal arg_eq_empnum, decimal arg_fzrate, decimal arg_factor, string arg_workqtystr, integer arg_ifgroup, decimal arg_u_workqty, decimal arg_u_workprice, string arg_u_workqtystr, string arg_u_pricestr, string arg_rpcode, integer arg_ifdftpg, integer arg_ifdftjj, decimal arg_waittime, decimal arg_lasthour, ref string arg_msg);Long rslt = 1,ll_proid
  1666. String ll_procode
  1667. Decimal ld_hourpay
  1668. IF it_updatebegin = False THEN
  1669. rslt = 0
  1670. arG_MSG = "非编辑状态不可以使用,操作取消"
  1671. GOTO ext
  1672. END IF
  1673. //清空值
  1674. IF IsNull(arg_workqty) THEN arg_workqty = 1
  1675. IF IsNull(arg_workPrice) THEN arg_workPrice = 0
  1676. IF IsNull(arg_workhour_minute) THEN arg_workhour_minute = 0
  1677. IF IsNull(arg_lastflag) THEN arg_lastflag = 0
  1678. IF IsNull(arg_proid) THEN arg_proid = 0
  1679. IF IsNull(arg_procode) THEN arg_procode = ''
  1680. IF IsNull(arg_proname) THEN arg_proname = ''
  1681. IF IsNull(arg_techlevel) THEN arg_techlevel = ''
  1682. IF IsNull(arg_worklevel) THEN arg_worklevel = ''
  1683. IF IsNull(arg_proorder) THEN arg_proorder = 0
  1684. IF IsNull(arg_wrkgrpid) THEN arg_wrkgrpid = 0
  1685. IF IsNull(arg_ifownpro) THEN arg_ifownpro = 0
  1686. IF IsNull(arg_lsxtype) THEN arg_lsxtype = 0
  1687. IF IsNull(arg_ifstandard) THEN arg_ifstandard = 0
  1688. IF IsNull(arg_ifjd) THEN arg_ifjd = 0
  1689. IF IsNull(arg_utcode) THEN arg_utcode = ''
  1690. IF IsNull(arg_sctype) THEN arg_sctype = 0
  1691. IF IsNull(arg_equipmentid) THEN arg_equipmentid = 0
  1692. IF IsNull(arg_workdays) THEN arg_workdays = 0
  1693. IF IsNull(arg_partname) THEN arg_partname = ''
  1694. IF IsNull(arg_beforehour_minute) THEN arg_beforehour_minute = 0
  1695. IF IsNull(arg_afterhour_minute) THEN arg_afterhour_minute = 0
  1696. IF IsNull(arg_pricestr) THEN arg_pricestr = ''
  1697. IF IsNull(arg_eqworkhour_minute) THEN arg_eqworkhour_minute = 0
  1698. IF IsNull(arg_worktype) THEN arg_worktype = ''
  1699. IF IsNull(arg_fzrate) THEN arg_fzrate = 1
  1700. if isnull(arg_factor) then arg_factor = 0
  1701. if isnull(arg_ifgroup) then arg_ifgroup = 0
  1702. IF IsNull(arg_arg1) THEN arg_arg1 = 0
  1703. IF IsNull(arg_arg2) THEN arg_arg2 = 0
  1704. IF IsNull(arg_arg3) THEN arg_arg3 = 0
  1705. IF IsNull(arg_arg4) THEN arg_arg4 = 0
  1706. IF IsNull(arg_arg5) THEN arg_arg5 = 0
  1707. IF IsNull(arg_arg6) THEN arg_arg6 = 0
  1708. IF IsNull(arg_arg7) THEN arg_arg7 = 0
  1709. IF IsNull(arg_arg8) THEN arg_arg8 = 0
  1710. IF IsNull(arg_arg9) THEN arg_arg9 = 0
  1711. if isnull(arg_workqtystr) then arg_workqtystr = ''
  1712. if isnull(arg_u_workqty) then arg_u_workqty = 0
  1713. if isnull(arg_u_workprice) then arg_u_workprice = 0
  1714. if isnull(arg_u_workqtystr) then arg_u_workqtystr = ''
  1715. if isnull(arg_u_pricestr) then arg_u_pricestr = ''
  1716. if isnull(arg_rpcode) then arg_rpcode = ''
  1717. if isnull(arg_ifdftpg) then arg_ifdftpg = 0
  1718. if isnull(arg_ifdftjj) then arg_ifdftjj = 0
  1719. if isnull(arg_waittime) then arg_waittime = 0
  1720. if isnull(arg_lasthour) then arg_lasthour = 0
  1721. IF Trim(arg_procode) = '' And Trim(arg_proname) = '' THEN
  1722. rslt = 1
  1723. GOTO ext
  1724. END IF
  1725. IF Trim(arg_procode) = '' THEN
  1726. rslt = 0
  1727. arG_MSG = "工序号不能为空"
  1728. GOTO ext
  1729. END IF
  1730. IF Trim(arg_proname) = '' THEN
  1731. rslt = 0
  1732. arG_MSG = "工序名称不能为空"
  1733. GOTO ext
  1734. END IF
  1735. IF arg_workqty <= 0 THEN
  1736. rslt = 0
  1737. arG_MSG = "数量不能少于1"
  1738. GOTO ext
  1739. END IF
  1740. IF arg_wrkgrpid = 0 THEN
  1741. rslt = 0
  1742. arG_MSG = "请选择工序所属工组"
  1743. GOTO ext
  1744. END IF
  1745. IF if_hourpay > 0 And Trim(arg_worktype) = '' THEN
  1746. rslt = 0
  1747. arG_MSG = '请选择工种'
  1748. GOTO ext
  1749. END IF
  1750. IF if_hourpay = 1 And eoq > 0 THEN
  1751. SELECT hourpay INTO :ld_hourpay
  1752. FROM u_worktype
  1753. Where worktype = :arg_worktype;
  1754. IF sqlca.SQLCode <> 0 THEN
  1755. rslt = 0
  1756. arG_MSG = '查询工种标准时薪失败,'+sqlca.SQLErrText
  1757. GOTO ext
  1758. END IF
  1759. arg_workPrice = (eoq * (arg_workhour_minute / 60 + arg_eqworkhour_minute / 60 * arg_eq_empnum) + arg_beforehour_minute / 60 + arg_afterhour_minute / 60) / eoq * ld_hourpay
  1760. END IF
  1761. //写入内容
  1762. it_mxbt++
  1763. workpricemx[it_mxbt].proid = arg_proid
  1764. workpricemx[it_mxbt].Procode = arg_procode
  1765. workpricemx[it_mxbt].proname = arg_proname
  1766. workpricemx[it_mxbt].workqty = arg_workqty
  1767. workpricemx[it_mxbt].workPrice = arg_workPrice
  1768. workpricemx[it_mxbt].worklevel = arg_worklevel
  1769. workpricemx[it_mxbt].Techlevel = arg_techlevel
  1770. workpricemx[it_mxbt].Dscrp = arg_Dscrp
  1771. workpricemx[it_mxbt].lastflag = arg_lastflag
  1772. workpricemx[it_mxbt].proorder = arg_proorder
  1773. workpricemx[it_mxbt].wrkgrpid = arg_wrkgrpid
  1774. workpricemx[it_mxbt].ifownpro = arg_ifownpro
  1775. workpricemx[it_mxbt].lsxtype = arg_lsxtype
  1776. workpricemx[it_mxbt].ifstandard = arg_ifstandard
  1777. workpricemx[it_mxbt].status = arg_status
  1778. workpricemx[it_mxbt].ifjd = arg_ifjd
  1779. workpricemx[it_mxbt].utcode = arg_utcode
  1780. workpricemx[it_mxbt].sctype = arg_sctype
  1781. workpricemx[it_mxbt].equipmentid = arg_equipmentid
  1782. workpricemx[it_mxbt].workdays = arg_workdays
  1783. workpricemx[it_mxbt].Workhour = arg_workhour_minute / 60
  1784. workpricemx[it_mxbt].beforehour = arg_beforehour_minute / 60
  1785. workpricemx[it_mxbt].afterhour = arg_afterhour_minute / 60
  1786. workpricemx[it_mxbt].eqworkhour = arg_eqworkhour_minute / 60
  1787. workpricemx[it_mxbt].pricestr = arg_pricestr
  1788. workpricemx[it_mxbt].partname = arg_partname
  1789. workpricemx[it_mxbt].eqworkhour_minute = arg_eqworkhour_minute
  1790. workpricemx[it_mxbt].worktype = arg_worktype
  1791. workpricemx[it_mxbt].workhour_minute = arg_workhour_minute
  1792. workpricemx[it_mxbt].beforehour_minute = arg_beforehour_minute
  1793. workpricemx[it_mxbt].afterhour_minute = arg_afterhour_minute
  1794. workpricemx[it_mxbt].arg1 = arg_arg1
  1795. workpricemx[it_mxbt].arg2 = arg_arg2
  1796. workpricemx[it_mxbt].arg3 = arg_arg3
  1797. workpricemx[it_mxbt].arg4 = arg_arg4
  1798. workpricemx[it_mxbt].arg5 = arg_arg5
  1799. workpricemx[it_mxbt].arg6 = arg_arg6
  1800. workpricemx[it_mxbt].arg7 = arg_arg7
  1801. workpricemx[it_mxbt].arg8 = arg_arg8
  1802. workpricemx[it_mxbt].arg9 = arg_arg9
  1803. workpricemx[it_mxbt].eq_empnum = arg_eq_empnum
  1804. workpricemx[it_mxbt].fzrate = arg_fzrate
  1805. workpricemx[it_mxbt].totalhour = (workpricemx[it_mxbt].beforehour + workpricemx[it_mxbt].afterhour + (workpricemx[it_mxbt].Workhour + workpricemx[it_mxbt].eqworkhour * workpricemx[it_mxbt].eq_empnum) * eoq) / eoq
  1806. workpricemx[it_mxbt].factor = arg_factor
  1807. workpricemx[it_mxbt].workqtystr = arg_workqtystr
  1808. workpricemx[it_mxbt].ifgroup = arg_ifgroup
  1809. workpricemx[it_mxbt].u_workqty = arg_u_workqty
  1810. workpricemx[it_mxbt].u_workprice = arg_u_workprice
  1811. workpricemx[it_mxbt].u_workqtystr = arg_u_workqtystr
  1812. workpricemx[it_mxbt].u_pricestr = arg_u_pricestr
  1813. workpricemx[it_mxbt].rpcode = arg_rpcode
  1814. workpricemx[it_mxbt].ifdftpg = arg_ifdftpg
  1815. workpricemx[it_mxbt].ifdftjj = arg_ifdftjj
  1816. workpricemx[it_mxbt].waittime = arg_waittime
  1817. workpricemx[it_mxbt].lasthour = arg_lasthour
  1818. ext:
  1819. IF rslt = 0 THEN p_clearmx()
  1820. Return(rslt)
  1821. end function
  1822. public function integer uof_update_workprice_zl (long arg_mtrlid, string arg_wpcode, string arg_procode, ref string arg_msg, boolean arg_ifcommit);Int rslt = 1
  1823. If uo_option_orderrqwp_auditgj = 0 Then
  1824. rslt = 1
  1825. Goto ext
  1826. End If
  1827. //完工单 常规模式
  1828. Update u_finishmx
  1829. Set u_finishmx.workprice = u_sc_workprice.workPrice
  1830. FROM u_finishmx INNER JOIN
  1831. u_sc_task ON u_finishmx.taskid = u_sc_task.taskid INNER JOIN
  1832. u_Order_ml ON u_Order_ml.OrderID = u_sc_task.orderid AND
  1833. u_Order_ml.scid = u_sc_task.scid INNER JOIN
  1834. U_OrderRqwp ON u_Order_ml.scid = U_OrderRqwp.scid AND
  1835. u_Order_ml.OrderID = U_OrderRqwp.orderid AND
  1836. u_sc_task.procode = U_OrderRqwp.Procode INNER JOIN
  1837. u_sc_workprice ON U_OrderRqwp.Mtrlid = u_sc_workprice.Mtrlid AND
  1838. U_OrderRqwp.Procode = u_sc_workprice.procode AND
  1839. u_Order_ml.wpcode = u_sc_workprice.wpcode INNER JOIN
  1840. u_finish ON u_finishmx.finishid = u_finish.finishid
  1841. Where U_OrderRqwp.auditflag_gj = 0
  1842. And ( U_OrderRqwp.mtrlid = :arg_mtrlid And u_Order_ml.wpcode = :arg_wpcode)
  1843. And (U_OrderRqwp.procode = :arg_procode Or :arg_procode = '')
  1844. and U_OrderRqwp.sonmtrlid = 0
  1845. and u_finish.thrflag = 0;
  1846. If sqlca.SQLCode <> 0 Then
  1847. rslt = 0
  1848. arg_msg = '更新相关未工价审的工序完工单工价失败(常规模式),'+sqlca.SQLErrText
  1849. Goto ext
  1850. End If
  1851. //完工单 合并下级虚拟部件模式
  1852. Update u_finishmx
  1853. Set u_finishmx.workprice = u_sc_workprice.workPrice
  1854. FROM u_finishmx INNER JOIN
  1855. u_sc_task ON u_finishmx.taskid = u_sc_task.taskid INNER JOIN
  1856. u_Order_ml ON u_Order_ml.OrderID = u_sc_task.orderid AND
  1857. u_Order_ml.scid = u_sc_task.scid INNER JOIN
  1858. U_OrderRqwp ON u_Order_ml.scid = U_OrderRqwp.scid AND
  1859. u_Order_ml.OrderID = U_OrderRqwp.orderid AND
  1860. u_sc_task.procode = U_OrderRqwp.Procode INNER JOIN
  1861. u_sc_workprice ON U_OrderRqwp.procode_ori = u_sc_workprice.procode AND
  1862. U_OrderRqwp.sonmtrlid = u_sc_workprice.Mtrlid INNER JOIN
  1863. (SELECT mtrlid, wpcode
  1864. FROM u_mtrl_workprice
  1865. WHERE (Ifdft = 1)) v_wpcode_dft ON
  1866. u_sc_workprice.Mtrlid = v_wpcode_dft.mtrlid AND
  1867. u_sc_workprice.wpcode = v_wpcode_dft.wpcode COLLATE Chinese_PRC_CI_AS INNER
  1868. JOIN
  1869. u_finish ON u_finishmx.finishid = u_finish.finishid
  1870. Where U_OrderRqwp.auditflag_gj = 0
  1871. And (U_OrderRqwp.sonmtrlid = :arg_mtrlid And v_wpcode_dft.wpcode = :arg_wpcode)
  1872. And (U_OrderRqwp.procode_ori = :arg_procode Or :arg_procode = '')
  1873. and U_OrderRqwp.sonmtrlid <> 0
  1874. and u_finish.thrflag = 0;
  1875. If sqlca.SQLCode <> 0 Then
  1876. rslt = 0
  1877. arg_msg = '更新相关未工价审的工序完工单工价失败(合并下级虚拟部件模式),'+sqlca.SQLErrText
  1878. Goto ext
  1879. End If
  1880. //常规模式
  1881. Update U_OrderRqwp
  1882. Set U_OrderRqwp.workPrice = u_sc_workprice.workPrice,
  1883. U_OrderRqwp.ori_workprice = u_sc_workprice.workPrice,
  1884. U_OrderRqwp.auditflag_gj = 1
  1885. FROM U_OrderRqwp INNER JOIN
  1886. u_Order_ml ON U_OrderRqwp.scid = u_Order_ml.scid AND
  1887. U_OrderRqwp.orderid = u_Order_ml.OrderID INNER JOIN
  1888. u_sc_workprice ON U_OrderRqwp.Mtrlid = u_sc_workprice.Mtrlid AND
  1889. U_OrderRqwp.procode_ori = u_sc_workprice.procode AND
  1890. u_Order_ml.wpcode = u_sc_workprice.wpcode
  1891. Where U_OrderRqwp.auditflag_gj = 0
  1892. And (U_OrderRqwp.mtrlid = :arg_mtrlid And u_Order_ml.wpcode = :arg_wpcode)
  1893. And (U_OrderRqwp.procode = :arg_procode Or :arg_procode = '')
  1894. and U_OrderRqwp.sonmtrlid = 0;
  1895. If sqlca.SQLCode <> 0 Then
  1896. rslt = 0
  1897. arg_msg = '更新相关未工价审的工序进度工价失败(常规模式),'+sqlca.SQLErrText
  1898. Goto ext
  1899. End If
  1900. //合并下级虚拟部件模式
  1901. Update U_OrderRqwp
  1902. Set U_OrderRqwp.workPrice = u_sc_workprice.workPrice,
  1903. U_OrderRqwp.ori_workprice = u_sc_workprice.workPrice,
  1904. U_OrderRqwp.auditflag_gj = 1
  1905. FROM (SELECT mtrlid, wpcode
  1906. FROM u_mtrl_workprice
  1907. WHERE (Ifdft = 1)) v_wpcode_dft INNER JOIN
  1908. u_sc_workprice ON
  1909. v_wpcode_dft.wpcode COLLATE Chinese_PRC_CI_AS = u_sc_workprice.wpcode INNER
  1910. JOIN
  1911. U_OrderRqwp ON u_sc_workprice.Mtrlid = U_OrderRqwp.sonmtrlid AND
  1912. u_sc_workprice.procode = U_OrderRqwp.procode_ori AND
  1913. v_wpcode_dft.mtrlid = U_OrderRqwp.sonmtrlid
  1914. Where U_OrderRqwp.auditflag_gj = 0
  1915. And (U_OrderRqwp.sonmtrlid = :arg_mtrlid And v_wpcode_dft.wpcode = :arg_wpcode)
  1916. And (U_OrderRqwp.procode_ori = :arg_procode Or :arg_procode = '')
  1917. and U_OrderRqwp.sonmtrlid <> 0;
  1918. If sqlca.SQLCode <> 0 Then
  1919. rslt = 0
  1920. arg_msg = '更新相关未工价审的工序进度工价失败(合并下级虚拟部件模式),'+sqlca.SQLErrText
  1921. Goto ext
  1922. End If
  1923. ext:
  1924. IF rslt = 0 THEN
  1925. ROLLBACK;
  1926. ELSEIF rslt = 1 And arg_ifcommit THEN
  1927. COMMIT;
  1928. END IF
  1929. RETURN rslt
  1930. end function
  1931. public function integer f_addpfmx (long arg_mtrlid, string arg_wpcode, string arg_pfcode, decimal arg_qty, long arg_lp, ref string arg_msg, boolean arg_ifcommit, integer arg_protype);Int rslt = 1
  1932. Long ll_i,cnt,ll_j
  1933. String ls_pfcode
  1934. Decimal ld_qty
  1935. Long count = 0
  1936. Long proid
  1937. Long proorder
  1938. String procode
  1939. String proname
  1940. Long wrkgrpid
  1941. Decimal workprice
  1942. Decimal workqty
  1943. String worklevel
  1944. Decimal workhour
  1945. String dscrp
  1946. Long auditflag
  1947. String auditrep
  1948. DateTime auditdate
  1949. Long lastflag
  1950. String status
  1951. string ls_retr_wpcode,ls_wpcode_top1
  1952. long ll_wrkid
  1953. Long ll_cnt_wp_wrkgrpid,ll_retr_wrkgrpid,ll_dftwrkgrpid_top1
  1954. IF IsNull(mtrlid) Or mtrlid = 0 THEN
  1955. arg_msg = '产品错误,没有对应的产品'
  1956. rslt = 0
  1957. GOTO ext
  1958. END IF
  1959. s_pfmx ls_s_pfmx[]
  1960. //查询默认清单
  1961. deep_count++
  1962. datastore ds_workprice
  1963. ds_workprice = Create datastore
  1964. ds_workprice.DataObject = 'dw_sc_workpricetable_mx_ds'
  1965. ds_workprice.SetTransObject(sqlca)
  1966. IF deep_count > 2000 THEN //防止死递归
  1967. arg_msg = '递归太深'+String(deep_count)
  1968. rslt = 0
  1969. GOTO ext
  1970. END IF
  1971. DECLARE pf_cur CURSOR FOR
  1972. SELECT u_PrdPF.Sonscale,
  1973. u_PrdPF.SonLoss,
  1974. u_PrdPF.SonDECLosS,
  1975. u_PrdPF.SonMtrlid,
  1976. u_mtrldef.mtrlcode,
  1977. u_mtrldef.mtrlorigin,
  1978. u_PrdPF.sonpfcode,
  1979. u_mtrldef.dftwrkgrpid,
  1980. u_mtrldef.protype
  1981. FROM u_PrdPF INNER JOIN
  1982. u_mtrldef ON u_PrdPF.SonMtrlid = u_mtrldef.mtrlid INNER JOIN
  1983. u_mtrldef u_mtrldef_p ON u_PrdPF.mtrlid = u_mtrldef_p.mtrlid
  1984. where ( u_PrdPF.mtrlid = :arg_mtrlid )
  1985. AND ( u_PrdPF.pfcode = :arg_pfcode )
  1986. and ((u_mtrldef.ifselforder <> 0 or u_mtrldef.mtrlorigin <> 0) and :arg_protype = 0 or :arg_protype = 1 );
  1987. // and (u_mtrldef.mtrlorigin = 0);
  1988. OPEN pf_cur;
  1989. count = 1
  1990. FETCH pf_cur INTO :ls_s_pfmx[count].Sonscale,:ls_s_pfmx[count].SonLoss,&
  1991. :ls_s_pfmx[count].SonDECLosS,:ls_s_pfmx[count].SonMtrlid,&
  1992. :ls_s_pfmx[count].mtrlcode,:ls_s_pfmx[count].mtrlorigin,:ls_s_pfmx[count].sonpfcode,&
  1993. :ls_s_pfmx[count].dftwrkgrpid,:ls_s_pfmx[count].protype;
  1994. DO WHILE sqlca.SQLCode = 0
  1995. count++
  1996. FETCH pf_cur INTO :ls_s_pfmx[count].Sonscale,:ls_s_pfmx[count].SonLoss,&
  1997. :ls_s_pfmx[count].SonDECLosS,:ls_s_pfmx[count].SonMtrlid,&
  1998. :ls_s_pfmx[count].mtrlcode,:ls_s_pfmx[count].mtrlorigin,:ls_s_pfmx[count].sonpfcode,&
  1999. :ls_s_pfmx[count].dftwrkgrpid,:ls_s_pfmx[count].protype;
  2000. LOOP
  2001. count = count - 1
  2002. CLOSE pf_cur;
  2003. FOR ll_i = 1 To count
  2004. SELECT count(*) INTO :cnt
  2005. FROM u_PrdPF
  2006. WHERE ( u_PrdPF.mtrlid = :ls_s_pfmx[ll_i].SonMtrlid ) AND
  2007. ( u_PrdPF.pfcode = :ls_s_pfmx[ll_i].sonpfcode );
  2008. IF sqlca.SQLCode <> 0 THEN
  2009. arg_msg = '查询物料:'+ls_s_pfmx[ll_i].mtrlcode+'物料清单失败,'+sqlca.SQLErrText
  2010. rslt = 0
  2011. GOTO ext
  2012. END IF
  2013. ld_qty = arg_qty * (ls_s_pfmx[ll_i].Sonscale/(1 - ls_s_pfmx[ll_i].SonLoss)+ls_s_pfmx[ll_i].SonDECLosS)
  2014. //如果自制,将其工价表插入
  2015. IF ls_s_pfmx[ll_i].mtrlorigin = 0 THEN
  2016. //yyx20120903
  2017. ll_cnt_wp_wrkgrpid = 0
  2018. SELECT count(*)
  2019. INTO :ll_cnt_wp_wrkgrpid
  2020. FROM u_mtrl_workprice
  2021. Where u_mtrl_workprice.mtrlid = :ls_s_pfmx[ll_i].SonMtrlid;
  2022. IF sqlca.SQLCode <> 0 THEN
  2023. arg_msg = '查询物料:'+ls_s_pfmx[ll_i].mtrlcode+'车间工价表数目失败,'+sqlca.SQLErrText
  2024. rslt = 0
  2025. GOTO ext
  2026. END IF
  2027. IF ll_cnt_wp_wrkgrpid > 0 THEN
  2028. SELECT top 1 u_mtrl_workprice.wrkid,u_mtrl_workprice.wpcode
  2029. INTO :ll_dftwrkgrpid_top1,:ls_wpcode_top1
  2030. FROM u_mtrl_workprice
  2031. Where u_mtrl_workprice.mtrlid = :ls_s_pfmx[ll_i].SonMtrlid
  2032. order by u_mtrl_workprice.ifdft desc;
  2033. IF sqlca.SQLCode <> 0 THEN
  2034. arg_msg = '查询物料:'+ls_s_pfmx[ll_i].mtrlcode+'车间工价表id失败,'+sqlca.SQLErrText
  2035. rslt = 0
  2036. GOTO ext
  2037. END IF
  2038. ls_retr_wpcode = ls_wpcode_top1
  2039. ll_retr_wrkgrpid = ll_dftwrkgrpid_top1
  2040. ELSE
  2041. ls_retr_wpcode = ''
  2042. ll_retr_wrkgrpid = ls_s_pfmx[ll_i].dftwrkgrpid
  2043. END IF
  2044. //
  2045. ds_workprice.Retrieve(ls_s_pfmx[ll_i].SonMtrlid,ls_retr_wpcode)
  2046. FOR ll_j = 1 To ds_workprice.RowCount()
  2047. il_printid++
  2048. proid = ds_workprice.Object.proid[ll_j]
  2049. proorder = ds_workprice.Object.proorder[ll_j]
  2050. procode = ds_workprice.Object.procode[ll_j]
  2051. proname = ds_workprice.Object.u_sc_workprice_proname[ll_j]
  2052. wrkgrpid = ds_workprice.Object.wrkgrpid[ll_j]
  2053. workprice = ds_workprice.Object.workprice[ll_j]
  2054. workqty = ds_workprice.Object.workqty[ll_j] * ld_qty
  2055. worklevel = ds_workprice.Object.worklevel[ll_j]
  2056. workhour = ds_workprice.Object.workhour[ll_j] * ld_qty
  2057. dscrp = ds_workprice.Object.dscrp[ll_j]
  2058. auditflag = ds_workprice.Object.auditflag[ll_j]
  2059. auditrep = ds_workprice.Object.auditrep[ll_j]
  2060. auditdate = ds_workprice.Object.auditdate[ll_j]
  2061. status = ds_workprice.Object.u_sc_workprice_status[ll_j]
  2062. ll_wrkid = ds_workprice.Object.u_sc_workprice_wrkid[ll_j]
  2063. INSERT INTO u_sc_workprice_mx
  2064. (parentmtrlid,
  2065. printid,
  2066. mtrlid,
  2067. proid,
  2068. proorder,
  2069. procode,
  2070. proname,
  2071. wrkgrpid,
  2072. workprice,
  2073. workqty,
  2074. worklevel,
  2075. workhour,
  2076. dscrp,
  2077. auditflag,
  2078. auditrep,
  2079. auditdate,
  2080. lastflag,
  2081. lp,
  2082. status,
  2083. wrkid,
  2084. wpcode)
  2085. VALUES
  2086. (:mtrlid,
  2087. :il_printid,
  2088. :ls_s_pfmx[ll_i].SonMtrlid,
  2089. :proid,
  2090. :proorder,
  2091. :procode,
  2092. :proname,
  2093. :wrkgrpid,
  2094. :workprice,
  2095. :workqty,
  2096. :worklevel,
  2097. :workhour,
  2098. :dscrp,
  2099. :auditflag,
  2100. :auditrep,
  2101. :auditdate,
  2102. :lastflag,
  2103. :arg_lp,
  2104. :status,
  2105. :ll_wrkid,
  2106. :arg_wpcode);
  2107. IF sqlca.SQLCode <> 0 THEN
  2108. arg_msg = '插入下级自制部件工价表失败'+sqlca.SQLErrText
  2109. rslt = 0
  2110. GOTO ext
  2111. END IF
  2112. NEXT
  2113. END IF
  2114. IF f_addpfmx(ls_s_pfmx[ll_i].SonMtrlid,arg_wpcode,ls_s_pfmx[ll_i].sonpfcode,ld_qty,arg_lp + 1 ,arg_msg,arg_ifcommit,ls_s_pfmx[ll_i].protype) = 0 THEN
  2115. rslt = 0
  2116. GOTO ext
  2117. END IF
  2118. NEXT
  2119. ext:
  2120. IF rslt = 0 THEN
  2121. ROLLBACK;
  2122. ELSEIF rslt = 1 And arg_ifcommit THEN
  2123. COMMIT;
  2124. END IF
  2125. destroy ds_workprice
  2126. RETURN rslt
  2127. end function
  2128. on uo_workpricetable.create
  2129. call super::create
  2130. TriggerEvent( this, "constructor" )
  2131. end on
  2132. on uo_workpricetable.destroy
  2133. TriggerEvent( this, "destructor" )
  2134. call super::destroy
  2135. end on
  2136. event constructor;String str_optionvalue,arg_msg
  2137. str_optionvalue = ''
  2138. f_get_sys_option_value('398',str_optionvalue,arg_msg)
  2139. uo_option_orderrqwp_auditgj = Long(str_optionvalue)
  2140. end event