uo_oa_flow_fj_downsave.sru 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. $PBExportHeader$uo_oa_flow_fj_downsave.sru
  2. forward
  3. global type uo_oa_flow_fj_downsave from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_oa_flow_fj_downsave from nonvisualobject
  7. end type
  8. global uo_oa_flow_fj_downsave uo_oa_flow_fj_downsave
  9. type variables
  10. transaction ins_tran //数据commit事务
  11. end variables
  12. forward prototypes
  13. public function integer f_down_fj (long arg_fjid, string arg_fjname, ref blob arg_fjdata, ref string arg_msg)
  14. public function integer f_del_fj (long arg_fjid, string arg_fjname, ref string arg_msg)
  15. public function integer f_update_fj (long arg_flowid, long arg_fjid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, decimal arg_filesize, ref string arg_msg, boolean arg_ifcommit)
  16. public function integer f_update_blob_fj (long arg_fjid, string arg_fjname, blob arg_fjbody, ref string arg_msg, boolean arg_ifcommit)
  17. public function integer f_save_fj (long arg_flowid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, ref string arg_msg, boolean arg_ifcommit, decimal arg_filesize, integer arg_ifmain)
  18. public function integer getflowannex (long arg_flowid, ref s_oa_doc_annex arg_s_oda[])
  19. end prototypes
  20. public function integer f_down_fj (long arg_fjid, string arg_fjname, ref blob arg_fjdata, ref string arg_msg);Long rslt = 1,cnt
  21. Blob ls_filedata
  22. IF arg_fjid <= 0 THEN
  23. rslt = 0
  24. arg_msg = '下载附件失败(错误附件ID)'
  25. GOTO ext
  26. END IF
  27. IF arg_fjname = '' THEN
  28. rslt = 0
  29. arg_msg = '下载附件失败(错误附件名)'
  30. GOTO ext
  31. END IF
  32. SELECT count(*)
  33. INTO :cnt
  34. FROM oa_flow_annex
  35. WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND
  36. (oa_flow_annex.Filename = :arg_fjname)
  37. USING ins_tran;
  38. IF ins_tran.SQLCode <> 0 THEN
  39. rslt = 0
  40. arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText
  41. GOTO ext
  42. END IF
  43. SELECTBLOB Fileblob
  44. INTO :ls_filedata
  45. FROM oa_flow_annex
  46. Where (oa_flow_annex.AnnexNO = :arg_fjid) AND
  47. (oa_flow_annex.Filename = :arg_fjname)
  48. USING ins_tran;
  49. IF ins_tran.SQLCode <> 0 THEN
  50. rslt = 0
  51. arg_msg = '下载附件失败>>'+ins_tran.SQLErrText
  52. GOTO ext
  53. END IF
  54. arg_fjdata = ls_filedata
  55. ext:
  56. RETURN rslt
  57. end function
  58. public function integer f_del_fj (long arg_fjid, string arg_fjname, ref string arg_msg);Long rslt = 1,cnt
  59. IF arg_fjid <= 0 THEN
  60. rslt = 0
  61. arg_msg = '删除附件失败(错误附件ID)'
  62. GOTO ext
  63. END IF
  64. IF arg_fjname = '' THEN
  65. rslt = 0
  66. arg_msg = '删除附件失败(错误附件名)'
  67. GOTO ext
  68. END IF
  69. //SELECT count(*)
  70. // INTO :cnt
  71. // FROM oa_flow_annex
  72. // WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND
  73. // (oa_flow_annex.Filename = :arg_fjname)
  74. // USING ins_tran;
  75. //IF ins_tran.SQLCode <> 0 THEN
  76. // rslt = 0
  77. // arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText
  78. // GOTO ext
  79. //END IF
  80. delete
  81. FROM oa_flow_annex
  82. Where (oa_flow_annex.AnnexNO = :arg_fjid) AND
  83. (oa_flow_annex.Filename = :arg_fjname)
  84. USING ins_tran;
  85. IF ins_tran.SQLCode <> 0 THEN
  86. rslt = 0
  87. arg_msg = '删除附件失败>>'+ins_tran.SQLErrText
  88. GOTO ext
  89. END IF
  90. ext:
  91. RETURN rslt
  92. end function
  93. public function integer f_update_fj (long arg_flowid, long arg_fjid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, decimal arg_filesize, ref string arg_msg, boolean arg_ifcommit);//保存附件
  94. Long rslt = 1, cnt
  95. Long ls_newid
  96. IF arg_flowid <= 0 THEN
  97. rslt = 0
  98. arg_msg = '保存附件失败(公文模板ID)'
  99. GOTO ext
  100. END IF
  101. IF IsNull(arg_fjname) Or arg_fjname = '' THEN
  102. rslt = 0
  103. arg_msg = '保存附件失败(附件名)'
  104. GOTO ext
  105. END IF
  106. SELECT count(*)
  107. INTO :cnt
  108. FROM oa_flow_annex
  109. WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND
  110. (oa_flow_annex.Filename = :arg_fjname)
  111. Using ins_tran;
  112. IF ins_tran.SQLCode <> 0 THEN
  113. rslt = 0
  114. arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText
  115. GOTO ext
  116. END IF
  117. UPDATE oa_flow_annex
  118. SET annextype = :arg_annextype,
  119. Filename = :arg_fjname,
  120. Opdate = getdate(),
  121. Opemp = :publ_operator,
  122. Filetype = :arg_fjtype,
  123. IFDOWNFJ = :ARG_IFDOWNFJ,
  124. IFLOOKFJ = :ARG_IFLOOKFJ,
  125. filesize = :arg_filesize
  126. WHERE (AnnexNO = :arg_fjid)
  127. Using ins_tran;
  128. IF ins_tran.SQLCode <> 0 THEN
  129. rslt = 0
  130. arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText
  131. GOTO ext
  132. END IF
  133. UpdateBlob oa_flow_annex
  134. Set Fileblob = :arg_fjbody
  135. Where AnnexNO = :arg_fjid Using ins_tran;
  136. IF ins_tran.SQLCode <> 0 THEN
  137. rslt = 0
  138. arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText
  139. GOTO ext
  140. END IF
  141. ext:
  142. IF rslt = 0 THEN
  143. ROLLBACK Using ins_tran;
  144. ELSEIF arg_ifcommit THEN
  145. COMMIT Using ins_tran;
  146. END IF
  147. RETURN rslt
  148. end function
  149. public function integer f_update_blob_fj (long arg_fjid, string arg_fjname, blob arg_fjbody, ref string arg_msg, boolean arg_ifcommit);//保存附件
  150. Long rslt = 1, cnt
  151. Long ls_newid
  152. //IF arg_flowid <= 0 THEN
  153. // rslt = 0
  154. // arg_msg = '保存附件失败(公文模板ID)'
  155. // GOTO ext
  156. //END IF
  157. IF IsNull(arg_fjname) Or arg_fjname = '' THEN
  158. rslt = 0
  159. arg_msg = '保存附件失败(附件名)'
  160. GOTO ext
  161. END IF
  162. SELECT count(*)
  163. INTO :cnt
  164. FROM oa_flow_annex
  165. WHERE (oa_flow_annex.AnnexNO = :arg_fjid) AND
  166. (oa_flow_annex.Filename = :arg_fjname)
  167. Using ins_tran;
  168. IF ins_tran.SQLCode <> 0 THEN
  169. rslt = 0
  170. arg_msg = '查询附件信息失败>>'+ins_tran.SQLErrText
  171. GOTO ext
  172. END IF
  173. UpdateBlob oa_flow_annex
  174. Set Fileblob = :arg_fjbody
  175. Where AnnexNO = :arg_fjid Using ins_tran;
  176. IF ins_tran.SQLCode <> 0 THEN
  177. rslt = 0
  178. arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText
  179. GOTO ext
  180. END IF
  181. ext:
  182. IF rslt = 0 THEN
  183. ROLLBACK Using ins_tran;
  184. ELSEIF arg_ifcommit THEN
  185. COMMIT Using ins_tran;
  186. END IF
  187. RETURN rslt
  188. end function
  189. public function integer f_save_fj (long arg_flowid, long arg_annextype, string arg_fjname, blob arg_fjbody, long arg_fjtype, long arg_ifdownfj, long arg_iflookfj, ref string arg_msg, boolean arg_ifcommit, decimal arg_filesize, integer arg_ifmain);//保存附件
  190. Long rslt = 1
  191. Long ls_newid,cnt
  192. If arg_flowid <= 0 Then
  193. rslt = 0
  194. arg_msg = '保存附件失败(公文模板ID)'
  195. Goto ext
  196. End If
  197. If IsNull(arg_fjname) Or arg_fjname = '' Then
  198. rslt = 0
  199. arg_msg = '保存附件失败(附件名)'
  200. Goto ext
  201. End If
  202. //检查流程是否已存在主附件
  203. If arg_ifmain = 1 Then
  204. Select count(*)
  205. Into :cnt
  206. From oa_flow_annex
  207. Where FlowID = :arg_flowid
  208. And ifmain = 1;
  209. If sqlca.SQLCode <> 0 Then
  210. rslt = 0
  211. arg_msg = '查询是否已存在主附件失败,'+sqlca.SQLErrText
  212. Goto ext
  213. End If
  214. If cnt > 0 Then
  215. rslt = 0
  216. arg_msg = '本流程已存在主附件,不能重复上传'
  217. Goto ext
  218. End If
  219. End If
  220. ls_newid = f_sys_scidentity(0,"oa_flow_annex","AnnexNO",arg_msg,True,id_sqlca)
  221. If ls_newid <= 0 Then
  222. rslt = 0
  223. Goto ext
  224. End If
  225. Insert Into oa_flow_annex
  226. ( FlowID,
  227. annextype,
  228. AnnexNO,
  229. Filename,
  230. Opdate,
  231. Opemp,
  232. Filetype,
  233. IFDOWNFJ,
  234. IFLOOKFJ,
  235. filesize,
  236. ifmain)
  237. Values ( :arg_flowid,
  238. :arg_annextype,
  239. :ls_newid,
  240. :arg_fjname,
  241. getdate(),
  242. :publ_operator,
  243. :arg_fjtype,
  244. :ARG_IFDOWNFJ,
  245. :ARG_IFLOOKFJ,
  246. :arg_filesize,
  247. :arg_ifmain)
  248. Using ins_tran;
  249. If ins_tran.SQLCode <> 0 Then
  250. rslt = 0
  251. arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText
  252. Goto ext
  253. Else
  254. Commit Using ins_tran;
  255. End If
  256. UpdateBlob oa_flow_annex
  257. Set Fileblob = :arg_fjbody
  258. Where AnnexNO = :ls_newid Using ins_tran;
  259. If ins_tran.SQLCode <> 0 Then
  260. rslt = 0
  261. arg_msg = '因网络或其它原因保存附件失败>>'+ins_tran.SQLErrText
  262. Goto ext
  263. End If
  264. Commit Using ins_tran;
  265. ext:
  266. Return rslt
  267. end function
  268. public function integer getflowannex (long arg_flowid, ref s_oa_doc_annex arg_s_oda[]);//GetFlowAnnex
  269. Integer rslt = 1
  270. String arg_msg
  271. Long i,ll_i,ll_row
  272. Blob lb_FileData
  273. s_oa_doc_annex s_oda[]
  274. i = 1
  275. Declare cur_mx Cursor For
  276. Select AnnexNo,
  277. Filename,
  278. Filetype,
  279. annextype,
  280. IFDOWNFJ,
  281. IFLOOKFJ,
  282. Filesize,
  283. ifmain
  284. From oa_flow_annex
  285. Where flowid = :arg_flowid;
  286. Open cur_mx;
  287. Fetch cur_mx Into :s_oda[i].AnnexNo,
  288. :s_oda[i].FileName,
  289. :s_oda[i].Filetype,
  290. :s_oda[i].annextype,
  291. :s_oda[i].IFDOWNFJ,
  292. :s_oda[i].IFLOOKFJ,
  293. :s_oda[i].Filesize,
  294. :s_oda[i].ifmain;
  295. Do While sqlca.SQLCode = 0
  296. If f_down_fj( s_oda[i].AnnexNo, s_oda[i].Filename, lb_FileData, arg_msg) = 0 Then
  297. rslt = 0
  298. Goto ext
  299. End If
  300. s_oda[i].FileBlob = lb_FileData
  301. i++
  302. Fetch cur_mx Into :s_oda[i].AnnexNo,
  303. :s_oda[i].FileName,
  304. :s_oda[i].FileType,
  305. :s_oda[i].annextype,
  306. :s_oda[i].IFDOWNFJ,
  307. :s_oda[i].IFLOOKFJ,
  308. :s_oda[i].Filesize,
  309. :s_oda[i].ifmain;
  310. Loop
  311. Close cur_mx;
  312. For i = 1 To UpperBound(s_oda) - 1
  313. arg_s_oda[i] = s_oda[i]
  314. Next
  315. ext:
  316. Return rslt
  317. end function
  318. on uo_oa_flow_fj_downsave.create
  319. call super::create
  320. TriggerEvent( this, "constructor" )
  321. end on
  322. on uo_oa_flow_fj_downsave.destroy
  323. TriggerEvent( this, "destructor" )
  324. call super::destroy
  325. end on