u_report_imex.sru 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. $PBExportHeader$u_report_imex.sru
  2. forward
  3. global type u_report_imex from nonvisualobject
  4. end type
  5. end forward
  6. global type u_report_imex from nonvisualobject
  7. end type
  8. global u_report_imex u_report_imex
  9. type variables
  10. public integer len_headinfo = 100
  11. end variables
  12. forward prototypes
  13. public function integer f_import_report (string arg_importfilename, boolean arg_ifupdate, long arg_rpid, long arg_billid, ref string arg_msg)
  14. public function integer f_export_report (s_rpt_imex arg_imexport, string arg_exportbfilename, ref string arg_msg)
  15. end prototypes
  16. public function integer f_import_report (string arg_importfilename, boolean arg_ifupdate, long arg_rpid, long arg_billid, ref string arg_msg);
  17. Integer rslt = 1
  18. Blob blob_rsyntax
  19. Blob blob_r_headinfo
  20. Blob blob_importfilename
  21. String bczh_headinfo
  22. String headinfo
  23. String ls_system_id
  24. String info[]
  25. Integer ls_k
  26. Integer ls_psc
  27. s_rpt_imex s_import_report
  28. Long ls_new_rpid
  29. IF f_getblobfromfile_rpt(blob_importfilename,arg_importfilename,arg_msg) = 0 THEN
  30. rslt = 0
  31. ELSE
  32. // bczh_headinfo = Left(String(blob_importfilename),len_headinfo * 3)
  33. bczh_headinfo = Lefta(String(blob_importfilename, EncodingANSI!),len_headinfo * 3)
  34. headinfo = f_psw_bczh_rpt(bczh_headinfo,1,sys_power_key)
  35. ls_k = 0
  36. ls_psc = 0
  37. ls_psc = Pos(headinfo,";")
  38. DO WHILE ls_psc > 0
  39. IF Left(headinfo,ls_psc - 1) <> "" THEN
  40. ls_k ++
  41. info[ls_k] = Left(headinfo,ls_psc - 1)
  42. ELSE
  43. ls_k ++
  44. info[ls_k] = ""
  45. END IF
  46. headinfo = Right(headinfo,Len(headinfo) - ls_psc)
  47. ls_psc = Pos(headinfo,";")
  48. LOOP
  49. IF ls_k <> 8 THEN
  50. arg_msg = "信息段检查失败,可能数据包已破坏"
  51. rslt = 0
  52. ELSE
  53. ls_system_id = info[1]
  54. s_import_report.rpid = Long(info[2])
  55. s_import_report.RpName = info[3]
  56. s_import_report.Flag = Long(info[4])
  57. s_import_report.Ifuse = Long(info[5])
  58. s_import_report.Billid = Long(info[6])
  59. s_import_report.auditprint = Long(info[7])
  60. s_import_report.descrp = info[8]
  61. // IF ls_system_id <> sys_system_id THEN
  62. // arg_msg = "导入的不是本系统的数据包,请检查"
  63. // rslt = 0
  64. // ELSE
  65. blob_rsyntax = BlobMid(blob_importfilename,Len(bczh_headinfo) + 1)
  66. IF arg_ifupdate THEN
  67. UPDATEBLOB u_report_list
  68. Set Rpsyntax = ''
  69. Where rpid = :arg_rpid
  70. USING sqlca;
  71. UPDATEBLOB u_report_list
  72. Set Rpsyntax = :blob_rsyntax
  73. Where rpid = :arg_rpid
  74. USING sqlca;
  75. IF sqlca.SQLCode = 0 THEN
  76. IF sqlca.SQLNRows = 0 THEN
  77. INSERT INTO u_report_list (
  78. rpid,
  79. RpName,
  80. Flag,
  81. Ifuse,
  82. Billid,
  83. auditprint,
  84. descrp
  85. ) VALUES (
  86. :s_import_report.rpid,
  87. :s_import_report.RpName,
  88. :s_import_report.Flag,
  89. :s_import_report.Ifuse,
  90. :arg_billid,
  91. :s_import_report.auditprint,
  92. :s_import_report.descrp) USING sqlca;
  93. IF sqlca.SQLCode <> 0 THEN
  94. arg_msg = "加入单据格式基础资料失败" + sqlca.SQLErrText
  95. rslt = 0
  96. GOTO ext
  97. END IF
  98. COMMIT USING sqlca;
  99. UPDATEBLOB u_report_list
  100. Set Rpsyntax = :blob_rsyntax
  101. Where rpid = :s_import_report.rpid USING sqlca;
  102. IF sqlca.SQLCode <> 0 THEN
  103. arg_msg = "更新单据格式数据失败" + sqlca.SQLErrText
  104. rslt = 0
  105. GOTO ext
  106. END IF
  107. ELSE
  108. UPDATE u_report_list
  109. SET
  110. RpName = :s_import_report.RpName,
  111. Flag = :s_import_report.Flag,
  112. Ifuse = :s_import_report.Ifuse,
  113. Billid = :arg_billid,
  114. auditprint = :s_import_report.auditprint,
  115. descrp = :s_import_report.descrp
  116. Where rpid = :arg_rpid USING sqlca;
  117. IF sqlca.SQLCode <> 0 THEN
  118. arg_msg = "更新打印格式基础资料失败" + sqlca.SQLErrText
  119. rslt = 0
  120. GOTO ext
  121. END IF
  122. END IF
  123. ELSE
  124. IF sqlca.SQLCode <> 0 THEN
  125. arg_msg = "导入打印格式数据失败" + sqlca.SQLErrText
  126. rslt = 0
  127. GOTO ext
  128. END IF
  129. END IF
  130. ELSE
  131. ls_new_rpid = f_sys_scidentity_rpt(0,"u_report_list","rpid",arg_msg,TRUE,sqlca)
  132. IF ls_new_rpid <= 0 THEN
  133. arg_msg = "获取打印格式ID失败" + sqlca.SQLErrText
  134. rslt = 0
  135. GOTO ext
  136. END IF
  137. INSERT INTO u_report_list (
  138. rpid,
  139. RpName,
  140. Flag,
  141. Ifuse,
  142. Billid,
  143. auditprint,
  144. descrp
  145. ) VALUES (
  146. :ls_new_rpid,
  147. :s_import_report.RpName,
  148. :s_import_report.Flag,
  149. :s_import_report.Ifuse,
  150. :arg_billid,
  151. :s_import_report.auditprint,
  152. :s_import_report.descrp
  153. ) USING sqlca;
  154. IF sqlca.SQLCode <> 0 THEN
  155. arg_msg = "新加入打印格式基础资料失败" + sqlca.SQLErrText
  156. rslt = 0
  157. ELSE
  158. COMMIT USING sqlca;
  159. UPDATEBLOB u_report_list
  160. Set Rpsyntax = :blob_rsyntax
  161. Where rpid = :ls_new_rpid USING sqlca;
  162. IF sqlca.SQLCode <> 0 THEN
  163. arg_msg = "更新打印格式数据失败" + sqlca.SQLErrText
  164. rslt = 0
  165. END IF
  166. //END IF
  167. END IF
  168. END IF
  169. END IF
  170. END IF
  171. ext:
  172. IF rslt = 0 THEN
  173. ROLLBACK USING sqlca;
  174. ELSE
  175. COMMIT USING sqlca;
  176. END IF
  177. RETURN rslt
  178. end function
  179. public function integer f_export_report (s_rpt_imex arg_imexport, string arg_exportbfilename, ref string arg_msg);
  180. integer rslt = 1
  181. blob blob_zipfile
  182. blob blob_r_headinfo
  183. blob blob_exportfilename
  184. blob blob_rsyntax
  185. string headinfo
  186. string trailinfo
  187. string r_headinfo
  188. uo_yfimex uo_export_report
  189. if arg_imexport.flag = 0 then
  190. rslt = 0
  191. arg_msg ="格式/报表:" + arg_imexport.RpName + "没有数据,导出失败"
  192. goto ext
  193. end if
  194. if fileexists(arg_exportbfilename) then
  195. if not filedelete(arg_exportbfilename) then
  196. rslt = 0
  197. arg_msg = "删除临时文件失败(" + arg_exportbfilename + "),请先手动清除!"
  198. goto ext
  199. end if
  200. end if
  201. selectblob Rpsyntax
  202. into :blob_rsyntax
  203. from u_report_list
  204. where u_report_list.rpid = :arg_imexport.rpid using sqlca;
  205. if sqlca.sqlcode <> 0 then
  206. rslt = 0
  207. arg_msg = "查询格式/报表:" + arg_imexport.RpName + " 格式失败"
  208. goto ext
  209. else
  210. headinfo = headinfo + sys_system_id + ";"
  211. headinfo = headinfo + string(arg_imexport.rpid) + ";"
  212. headinfo = headinfo + arg_imexport.RpName + ";"
  213. headinfo = headinfo + string(arg_imexport.Flag) + ";"
  214. headinfo = headinfo + string(arg_imexport.Ifuse) + ";"
  215. headinfo = headinfo + string(arg_imexport.Billid) + ";"
  216. headinfo = headinfo + string(arg_imexport.auditprint) + ";"
  217. headinfo = headinfo + arg_imexport.descrp + ";"
  218. trailinfo = fill("*",len_headinfo - len(headinfo))
  219. r_headinfo = headinfo + trailinfo
  220. r_headinfo = f_psw_bczh(r_headinfo,0,sys_power_key)
  221. blob_r_headinfo = blob(r_headinfo, EncodingANSI!)
  222. blob_exportfilename = blob_r_headinfo + blob_rsyntax
  223. if f_saveblobtofile_rpt(blob_exportfilename,arg_exportbfilename,arg_msg) = 0 then
  224. rslt = 0
  225. end if
  226. end if
  227. ext:
  228. return rslt
  229. end function
  230. on u_report_imex.create
  231. call super::create
  232. TriggerEvent( this, "constructor" )
  233. end on
  234. on u_report_imex.destroy
  235. TriggerEvent( this, "destructor" )
  236. call super::destroy
  237. end on