ahyb_controller.go 51KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694
  1. package ah
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "github.com/axgle/mahonia"
  12. "github.com/gorilla/websocket"
  13. "golang.org/x/text/encoding/simplifiedchinese"
  14. "io/ioutil"
  15. "log"
  16. "net/url"
  17. "os"
  18. "regexp"
  19. "strconv"
  20. "strings"
  21. "syscall"
  22. "time"
  23. "unsafe"
  24. )
  25. type AHybController struct {
  26. controllers.BaseAuthAPIController
  27. }
  28. type Body struct {
  29. ErrMsg string `json:"err_msg"`
  30. InfRefMsgID string `json:"inf_refmsgid"`
  31. InfCode int `json:"infcode"`
  32. Output map[string]interface{} `json:"output"`
  33. }
  34. type Response struct {
  35. Body Body `json:"body"`
  36. Code int `json:"code"`
  37. CSBCode int `json:"csbCode"`
  38. Message string `json:"message"`
  39. RequestID string `json:"requestId"`
  40. State struct{} `json:"state"`
  41. }
  42. func AHybRegistRouters() {
  43. beego.Router("/ahyb/1101", &AHybController{}, "get:PostOne")
  44. beego.Router("/ahyb/2201", &AHybController{}, "get:PostTwo")
  45. beego.Router("/ahyb/2202", &AHybController{}, "get:PostThree")
  46. beego.Router("/ahyb/2203", &AHybController{}, "post:PostFour")
  47. beego.Router("/ahyb/2204", &AHybController{}, "post:PostFive")
  48. beego.Router("/ahyb/2205", &AHybController{}, "get:PostSix")
  49. beego.Router("/ahyb/2206", &AHybController{}, "get:PostSeven")
  50. beego.Router("/ahyb/2207", &AHybController{}, "get:PostEight")
  51. beego.Router("/ahyb/2208", &AHybController{}, "get:PostNine")
  52. beego.Router("/ahyb/5203", &AHybController{}, "get:PostTen")
  53. beego.Router("/ahyb/5301", &AHybController{}, "get:Get5301")
  54. beego.Router("/ahyb/3201", &AHybController{}, "get:Get3201")
  55. beego.Router("/ahyb/9001", &AHybController{}, "get:Get9001")
  56. beego.Router("/ahyb/4101", &AHybController{}, "post:Get4101")
  57. beego.Router("/ahyb/readcard", &AHybController{}, "get:ReadCard")
  58. beego.Router("/ahyb/2503", &AHybController{}, "get:Get2503")
  59. beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406")
  60. beego.Router("/ahyb/readcardcharge", &AHybController{}, "get:Readcardcharge")
  61. }
  62. func (c *AHybController) Readcardcharge() {
  63. fixmedins_code := c.GetString("fixmedins_code")
  64. secret_key := c.GetString("secret_key")
  65. ak := c.GetString("ak")
  66. org_name := c.GetString("org_name")
  67. doctor := c.GetString("doctor")
  68. //insuplc_admdvs := c.GetString("insuplc_admdvs")
  69. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  70. url := c.GetString("url")
  71. cainfo := c.GetString("cainfo")
  72. operator_id := c.GetString("operator_id")
  73. operator := c.GetString("operator")
  74. _, pBusiCardInfo := c.GetELeCertInfoThree(fixmedins_code, operator_id, operator)
  75. fmt.Println(pBusiCardInfo)
  76. pBusiCardInfo = Remove0000(pBusiCardInfo)
  77. var ele ELeCertData
  78. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  79. if err != nil {
  80. utils.ErrorLog("解析失败:%v", err)
  81. }
  82. token := ele.Data.EcToken
  83. fmt.Println(token)
  84. if len(token) > 0 {
  85. userName := ele.Data.UserName
  86. fmt.Println(userName)
  87. userName = Remove0000(userName)
  88. userName = DeleteExtraSpace(userName)
  89. fmt.Println(userName)
  90. enc := mahonia.NewEncoder("gbk")
  91. fmt.Println(enc.ConvertString(userName))
  92. result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  93. var response Response
  94. if err := json.Unmarshal([]byte(result), &response); err != nil {
  95. fmt.Println("Error decoding JSON:", err)
  96. return
  97. }
  98. if response.Code == 200 {
  99. c.ServeSuccessJSON(map[string]interface{}{
  100. "status": "1",
  101. "card_info": "",
  102. "busi_card_info": pBusiCardInfo,
  103. "token": token,
  104. "result": response.Body,
  105. })
  106. } else {
  107. c.ServeSuccessJSON(map[string]interface{}{
  108. "status": "0",
  109. "msg": response.Message,
  110. })
  111. }
  112. } else {
  113. c.ServeSuccessJSON(map[string]interface{}{
  114. "status": "-1",
  115. })
  116. }
  117. }
  118. func (c *AHybController) Get9001() {
  119. url := c.GetString("url")
  120. org_name := c.GetString("org_name")
  121. opera_name := c.GetString("opera_name")
  122. opera_id := c.GetString("opera_id")
  123. fixmedins_code := c.GetString("fixmedins_code")
  124. insuplc_admdvs := c.GetString("insuplc_admdvs")
  125. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  126. secret_key := c.GetString("secret_key")
  127. cainfo := c.GetString("cainfo")
  128. result, inputLog := service.AHyb9001(org_name, opera_name, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, opera_id, url, cainfo, "")
  129. fmt.Println(result)
  130. fmt.Println(inputLog)
  131. saveJsLog(result, inputLog, "9001", "签到", org_name)
  132. var response Response
  133. if err := json.Unmarshal([]byte(result), &response); err != nil {
  134. fmt.Println("Error decoding JSON:", err)
  135. return
  136. }
  137. if response.Code == 200 {
  138. var dat2 map[string]interface{}
  139. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  140. } else {
  141. }
  142. c.ServeSuccessJSON(map[string]interface{}{
  143. "pre": response.Body,
  144. "log": dat2,
  145. "status": "1",
  146. "msg": "",
  147. })
  148. } else {
  149. c.ServeSuccessJSON(map[string]interface{}{
  150. "status": "0",
  151. "msg": response.Message,
  152. })
  153. }
  154. }
  155. func (c *AHybController) Get5301() {
  156. psn_no := c.GetString("psn_no")
  157. org_name := c.GetString("org_name")
  158. doctor := c.GetString("doctor")
  159. fixmedins_code := c.GetString("fixmedins_code")
  160. insuplc_admdvs := c.GetString("insuplc_admdvs")
  161. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  162. secret_key := c.GetString("secret_key")
  163. url := c.GetString("url")
  164. ak := c.GetString("ak")
  165. cainfo := c.GetString("cainfo")
  166. result, inputLog := service.AHyb5301(psn_no, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, cainfo)
  167. //saveJsLog()
  168. saveJsLog(result, inputLog, "5301", "查询备案", org_name)
  169. var response Response
  170. if err := json.Unmarshal([]byte(result), &response); err != nil {
  171. fmt.Println("Error decoding JSON:", err)
  172. return
  173. }
  174. if response.Code == 200 {
  175. var dat2 map[string]interface{}
  176. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  177. } else {
  178. }
  179. c.ServeSuccessJSON(map[string]interface{}{
  180. "pre": response.Body,
  181. "log": dat2,
  182. "status": "1",
  183. "msg": "",
  184. })
  185. } else {
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "status": "0",
  188. "msg": response.Message,
  189. })
  190. }
  191. }
  192. func (c *AHybController) PostOne() {
  193. certNo := c.GetString("cert_no")
  194. org_name := c.GetString("org_name")
  195. doctor := c.GetString("doctor")
  196. fixmedins_code := c.GetString("fixmedins_code")
  197. insuplc_admdvs := c.GetString("insuplc_admdvs")
  198. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  199. id_card_type, _ := c.GetInt64("id_card_type")
  200. card_sn := c.GetString("card_sn")
  201. certificates := c.GetString("certificates")
  202. url := c.GetString("url")
  203. token := c.GetString("token")
  204. name := c.GetString("name")
  205. result, inputLog := service.AHyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, id_card_type, card_sn, certificates, url, name, token)
  206. fmt.Println(result)
  207. fmt.Println(inputLog)
  208. saveJsLog(result, inputLog, "1101", "查询个人信息", org_name)
  209. var response Response
  210. if err := json.Unmarshal([]byte(result), &response); err != nil {
  211. fmt.Println("Error decoding JSON:", err)
  212. return
  213. }
  214. if response.Code == 200 {
  215. var dat2 map[string]interface{}
  216. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  217. } else {
  218. }
  219. c.ServeSuccessJSON(map[string]interface{}{
  220. "pre": response.Body,
  221. "log": dat2,
  222. "status": "1",
  223. "msg": "",
  224. })
  225. } else {
  226. c.ServeSuccessJSON(map[string]interface{}{
  227. "status": "0",
  228. "msg": response.Message,
  229. })
  230. }
  231. }
  232. func (c *AHybController) PostTwo() {
  233. psnNo := c.GetString("psn_no")
  234. insutype := c.GetString("insutype")
  235. certNo := c.GetString("cert_no")
  236. org_name := c.GetString("org_name")
  237. opera := c.GetString("opera")
  238. ipt_otp_no := c.GetString("ipt_otp_no")
  239. dept := c.GetString("dept")
  240. verify_number := c.GetString("verify_number")
  241. fixmedins_code := c.GetString("fixmedins_code")
  242. dept_code := c.GetString("dept_code")
  243. doctor_id := c.GetString("doctor_id")
  244. insuplc_admdvs := c.GetString("insuplc_admdvs")
  245. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  246. secret_key := c.GetString("secret_key")
  247. id_card_type, _ := c.GetInt64("id_card_type")
  248. url := c.GetString("url")
  249. ak := c.GetString("ak")
  250. doctor_name := c.GetString("doctor_name")
  251. cainfo := c.GetString("cainfo")
  252. card_sn := c.GetString("card_sn")
  253. result, inputLog := service.AHyb2201(psnNo, insutype, certNo, org_name, opera, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, ak, verify_number, cainfo, card_sn)
  254. var response Response
  255. if err := json.Unmarshal([]byte(result), &response); err != nil {
  256. fmt.Println("Error decoding JSON:", err)
  257. return
  258. }
  259. if response.Code == 200 {
  260. var dat2 map[string]interface{}
  261. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  262. } else {
  263. }
  264. c.ServeSuccessJSON(map[string]interface{}{
  265. "pre": response.Body,
  266. "log": dat2,
  267. "status": "1",
  268. "msg": "",
  269. })
  270. } else {
  271. c.ServeSuccessJSON(map[string]interface{}{
  272. "status": "0",
  273. "msg": response.Message,
  274. })
  275. }
  276. }
  277. func (c *AHybController) PostThree() {
  278. psnNo := c.GetString("psn_no")
  279. mdtrtId := c.GetString("mdtrt_id")
  280. iptOtpNo := c.GetString("ipt_otp_no")
  281. org_name := c.GetString("org_name")
  282. doctor := c.GetString("doctor")
  283. insuplc_admdvs := c.GetString("insuplc_admdvs")
  284. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  285. secret_key := c.GetString("secret_key")
  286. fixmedins_code := c.GetString("fixmedins_code")
  287. url := c.GetString("url")
  288. ak := c.GetString("ak")
  289. cainfo := c.GetString("cainfo")
  290. result, inputLog := service.AHyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  291. saveJsLog(result, inputLog, "2202", "退号", org_name)
  292. var response Response
  293. if err := json.Unmarshal([]byte(result), &response); err != nil {
  294. fmt.Println("Error decoding JSON:", err)
  295. return
  296. }
  297. if response.Code == 200 {
  298. var dat2 map[string]interface{}
  299. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  300. } else {
  301. }
  302. c.ServeSuccessJSON(map[string]interface{}{
  303. "pre": response.Body,
  304. "log": dat2,
  305. "status": "1",
  306. "msg": "",
  307. })
  308. } else {
  309. c.ServeSuccessJSON(map[string]interface{}{
  310. "status": "0",
  311. "msg": response.Message,
  312. })
  313. }
  314. }
  315. func (c *AHybController) PostFour() {
  316. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  317. var respJSON map[string]interface{}
  318. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  320. return
  321. }
  322. userJSONBytes, _ := json.Marshal(respJSON["config"])
  323. var config []*models.HisXtDiagnoseConfig
  324. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  325. utils.ErrorLog("解析失败:%v", err)
  326. return
  327. }
  328. fmt.Println(respJSON["psn_no"].(string))
  329. fmt.Println(respJSON["mdtrt_id"].(string))
  330. psnNo := respJSON["psn_no"].(string)
  331. mdtrtId := respJSON["mdtrt_id"].(string)
  332. operator := respJSON["operator"].(string)
  333. department := respJSON["department"].(string)
  334. org_name := respJSON["org_name"].(string)
  335. med_type := respJSON["med_type"].(string)
  336. fixmedins_code := respJSON["fixmedins_code"].(string)
  337. sick_code := respJSON["sick_code"].(string)
  338. sick_name := respJSON["sick_name"].(string)
  339. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  340. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  341. url := respJSON["url"].(string)
  342. begin_time := respJSON["begin_time"].(string)
  343. cainfo := respJSON["cainfo"].(string)
  344. doctor_name := respJSON["doctor_name"].(string)
  345. doctor_number := respJSON["doctor_number"].(string)
  346. //cainfo := c.GetString("cainfo")
  347. result, inputLog := service.AHyb2203(psnNo, mdtrtId, operator, department, org_name, med_type, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sick_code, sick_name, config, url, begin_time, cainfo, doctor_name, doctor_number)
  348. saveJsLog(result, inputLog, "2203", "上传就诊信息", org_name)
  349. var response Response
  350. if err := json.Unmarshal([]byte(result), &response); err != nil {
  351. fmt.Println("Error decoding JSON:", err)
  352. return
  353. }
  354. if response.Code == 200 {
  355. var dat2 map[string]interface{}
  356. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  357. } else {
  358. }
  359. c.ServeSuccessJSON(map[string]interface{}{
  360. "pre": response.Body,
  361. "log": dat2,
  362. "status": "1",
  363. "msg": "",
  364. })
  365. } else {
  366. c.ServeSuccessJSON(map[string]interface{}{
  367. "status": "0",
  368. "msg": response.Message,
  369. })
  370. }
  371. }
  372. func (c *AHybController) Get2406() {
  373. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  374. var respJSON map[string]interface{}
  375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  377. return
  378. }
  379. psnNo := respJSON["psn_no"].(string)
  380. mdtrtId := respJSON["mdtrt_id"].(string)
  381. operator := respJSON["operator"].(string)
  382. cert_no := respJSON["cert_no"].(string)
  383. org_name := respJSON["org_name"].(string)
  384. psn_name := respJSON["psn_name"].(string)
  385. ipt_otp_no := respJSON["ipt_otp_no"].(string)
  386. ipt_psn_sp_flag_type := respJSON["ipt_psn_sp_flag_type"].(string)
  387. ipt_psn_sp_flag := respJSON["ipt_psn_sp_flag"].(string)
  388. fixmedins_code := respJSON["fixmedins_code"].(string)
  389. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  390. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  391. url := respJSON["url"].(string)
  392. result, inputLog := service.AHyb2406(psnNo, mdtrtId, cert_no, psn_name, operator, ipt_otp_no, ipt_psn_sp_flag_type, ipt_psn_sp_flag, org_name, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url)
  393. saveJsLog(result, inputLog, "2406", "上传2406信息", org_name)
  394. var response Response
  395. if err := json.Unmarshal([]byte(result), &response); err != nil {
  396. fmt.Println("Error decoding JSON:", err)
  397. return
  398. }
  399. if response.Code == 200 {
  400. var dat2 map[string]interface{}
  401. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  402. } else {
  403. }
  404. c.ServeSuccessJSON(map[string]interface{}{
  405. "pre": response.Body,
  406. "log": dat2,
  407. "status": "1",
  408. "msg": "",
  409. })
  410. } else {
  411. c.ServeSuccessJSON(map[string]interface{}{
  412. "status": "0",
  413. "msg": response.Message,
  414. })
  415. }
  416. }
  417. type All struct {
  418. HisPrescription HisPrescription
  419. mdtrt_id string
  420. psn_no string
  421. }
  422. type HisPrescription struct {
  423. ID int64 `gorm:"column:id" json:"id" form:"id"`
  424. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  425. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  426. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  427. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  428. Status int64 `gorm:"column:status" json:"status" form:"status"`
  429. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  430. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  431. Number string `gorm:"column:number" json:"number" form:"number"`
  432. Type int64 `gorm:"column:type" json:"type" form:"type"`
  433. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  434. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  435. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  436. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  437. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  438. }
  439. func (c *AHybController) PostFive() {
  440. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  441. var respJSON map[string]interface{}
  442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  444. return
  445. }
  446. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  447. var hp []*models.HisPrescription
  448. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  449. utils.ErrorLog("解析失败:%v", err)
  450. return
  451. }
  452. //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
  453. result, inputLog := service.AHyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  454. respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string), respJSON["balance_accounts_type"].(string), respJSON["diag_code"].(string), respJSON["url"].(string), respJSON["ak"].(string), respJSON["new_doctor_name"].(string), "", respJSON["cainfo"].(string), respJSON["opter"].(string))
  455. saveJsLog(result, inputLog, "2204", "上传明细", respJSON["org_name"].(string))
  456. var response Response
  457. if err := json.Unmarshal([]byte(result), &response); err != nil {
  458. fmt.Println("Error decoding JSON:", err)
  459. return
  460. }
  461. if response.Code == 200 {
  462. var dat2 map[string]interface{}
  463. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  464. } else {
  465. }
  466. c.ServeSuccessJSON(map[string]interface{}{
  467. "pre": response.Body,
  468. "log": dat2,
  469. "status": "1",
  470. "msg": "",
  471. })
  472. } else {
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "status": "0",
  475. "msg": response.Message,
  476. })
  477. }
  478. }
  479. func (c *AHybController) PostSix() {
  480. psnNo := c.GetString("psn_no")
  481. mdtrtId := c.GetString("mdtrt_id")
  482. chrgBchno := c.GetString("chrg_bchno")
  483. org_name := c.GetString("org_name")
  484. doctor := c.GetString("doctor")
  485. insuplc_admdvs := c.GetString("insuplc_admdvs")
  486. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  487. secret_key := c.GetString("secret_key")
  488. fixmedins_code := c.GetString("fixmedins_code")
  489. url := c.GetString("url")
  490. ak := c.GetString("ak")
  491. cainfo := c.GetString("cainfo")
  492. result, inputLog := service.AHyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  493. fmt.Println(inputLog)
  494. saveJsLog(result, inputLog, "2205", "撤销明细", org_name)
  495. var response Response
  496. if err := json.Unmarshal([]byte(result), &response); err != nil {
  497. fmt.Println("Error decoding JSON:", err)
  498. return
  499. }
  500. if response.Code == 200 {
  501. var dat2 map[string]interface{}
  502. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  503. } else {
  504. }
  505. c.ServeSuccessJSON(map[string]interface{}{
  506. "pre": response.Body,
  507. "log": dat2,
  508. "status": "1",
  509. "msg": "",
  510. })
  511. } else {
  512. c.ServeSuccessJSON(map[string]interface{}{
  513. "status": "0",
  514. "msg": response.Message,
  515. })
  516. }
  517. }
  518. func (c *AHybController) PostSeven() {
  519. psnNo := c.GetString("psn_no")
  520. mdtrtId := c.GetString("mdtrt_id")
  521. chrgBchno := c.GetString("chrg_bchno")
  522. certNo := c.GetString("cert_no")
  523. insutype := c.GetString("insutype")
  524. total := c.GetString("total")
  525. org_name := c.GetString("org_name")
  526. doctor := c.GetString("doctor")
  527. fixmedins_code := c.GetString("fixmedins_code")
  528. insuplc_admdvs := c.GetString("insuplc_admdvs")
  529. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  530. secret_key := c.GetString("secret_key")
  531. med_type := c.GetString("med_type")
  532. id_card_type, _ := c.GetInt64("id_card_type")
  533. certificates, _ := c.GetInt64("certificates")
  534. verify_number := c.GetString("verify_number")
  535. cainfo := c.GetString("cainfo")
  536. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  537. url := c.GetString("url")
  538. ak := c.GetString("ak")
  539. var result string
  540. var inputLog string
  541. result, inputLog = service.AHyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, certificates, url, ak, verify_number, cainfo, mdtrt_grp_type)
  542. saveJsLog(result, inputLog, "2206", "预结算", org_name)
  543. var response Response
  544. if err := json.Unmarshal([]byte(result), &response); err != nil {
  545. fmt.Println("Error decoding JSON:", err)
  546. return
  547. }
  548. if response.Code == 200 {
  549. var dat2 map[string]interface{}
  550. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  551. } else {
  552. }
  553. c.ServeSuccessJSON(map[string]interface{}{
  554. "pre": response.Body,
  555. "log": dat2,
  556. "status": "1",
  557. "msg": "",
  558. })
  559. } else {
  560. c.ServeSuccessJSON(map[string]interface{}{
  561. "status": "0",
  562. "msg": response.Message,
  563. })
  564. }
  565. }
  566. func (c *AHybController) PostEight() {
  567. psnNo := c.GetString("psn_no")
  568. mdtrtId := c.GetString("mdtrt_id")
  569. chrgBchno := c.GetString("chrg_bchno")
  570. certNo := c.GetString("cert_no")
  571. insutype := c.GetString("insutype")
  572. total := c.GetString("total")
  573. org_name := c.GetString("org_name")
  574. doctor := c.GetString("doctor")
  575. fixmedins_code := c.GetString("fixmedins_code")
  576. insuplc_admdvs := c.GetString("insuplc_admdvs")
  577. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  578. secret_key := c.GetString("secret_key")
  579. med_type := c.GetString("med_type")
  580. id_card_type, _ := c.GetInt64("id_card_type")
  581. acct_used_flag := c.GetString("acct_used_flag")
  582. url := c.GetString("url")
  583. ak := c.GetString("ak")
  584. verify_number := c.GetString("verify_number")
  585. cainfo := c.GetString("cainfo")
  586. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  587. var result string
  588. var inputLog string
  589. result, inputLog = service.AHyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, acct_used_flag, url, ak, verify_number, cainfo, mdtrt_grp_type)
  590. saveJsLog(result, inputLog, "2207", "结算", org_name)
  591. var response Response
  592. if err := json.Unmarshal([]byte(result), &response); err != nil {
  593. fmt.Println("Error decoding JSON:", err)
  594. return
  595. }
  596. if response.Code == 200 {
  597. var dat2 map[string]interface{}
  598. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  599. } else {
  600. }
  601. c.ServeSuccessJSON(map[string]interface{}{
  602. "pre": response.Body,
  603. "log": dat2,
  604. "status": "1",
  605. "msg": "",
  606. })
  607. } else {
  608. c.ServeSuccessJSON(map[string]interface{}{
  609. "status": "0",
  610. "msg": response.Message,
  611. })
  612. }
  613. }
  614. func (c *AHybController) PostNine() {
  615. psnNo := c.GetString("psn_no")
  616. mdtrtId := c.GetString("mdtrt_id")
  617. setlId := c.GetString("setl_id")
  618. org_name := c.GetString("org_name")
  619. doctor := c.GetString("doctor")
  620. secret_key := c.GetString("secret_key")
  621. fixmedins_code := c.GetString("fixmedins_code")
  622. insuplc_admdvs := c.GetString("insuplc_admdvs")
  623. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  624. url := c.GetString("url")
  625. ak := c.GetString("ak")
  626. cainfo := c.GetString("cainfo")
  627. result, inputLog := service.AHyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  628. saveJsLog(result, inputLog, "2208", "退费", org_name)
  629. var response Response
  630. if err := json.Unmarshal([]byte(result), &response); err != nil {
  631. fmt.Println("Error decoding JSON:", err)
  632. return
  633. }
  634. if response.Code == 200 {
  635. var dat2 map[string]interface{}
  636. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  637. } else {
  638. }
  639. c.ServeSuccessJSON(map[string]interface{}{
  640. "pre": response.Body,
  641. "log": dat2,
  642. "status": "1",
  643. "msg": "",
  644. })
  645. } else {
  646. c.ServeSuccessJSON(map[string]interface{}{
  647. "status": "0",
  648. "msg": response.Message,
  649. })
  650. }
  651. }
  652. func (c *AHybController) PostTen() {
  653. psnNo := c.GetString("psn_no")
  654. mdtrtId := c.GetString("mdtrt_id")
  655. setlId := c.GetString("setl_id")
  656. org_name := c.GetString("org_name")
  657. doctor := c.GetString("doctor")
  658. secret_key := c.GetString("secret_key")
  659. fixmedins_code := c.GetString("fixmedins_code")
  660. insuplc_admdvs := c.GetString("insuplc_admdvs")
  661. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  662. url := c.GetString("url")
  663. ak := c.GetString("ak")
  664. cainfo := c.GetString("cainfo")
  665. baseParams := models.BaseParams{
  666. SecretKey: secret_key,
  667. FixmedinsCode: fixmedins_code,
  668. InsuplcAdmdvs: insuplc_admdvs,
  669. MdtrtareaAdmvs: mdtrtarea_admvs,
  670. OrgName: org_name,
  671. Doctor: doctor,
  672. RequestUrl: url,
  673. AccessKey: ak,
  674. Cainfo: cainfo,
  675. }
  676. businessParams := models.BusinessParams{
  677. PsnNo: psnNo,
  678. MdtrtId: mdtrtId,
  679. SetlId: setlId,
  680. }
  681. result, inputLog := service.AHyb5203(baseParams, businessParams)
  682. saveJsLog(result, inputLog, "5203", "结算单", org_name)
  683. var response Response
  684. if err := json.Unmarshal([]byte(result), &response); err != nil {
  685. fmt.Println("Error decoding JSON:", err)
  686. return
  687. }
  688. if response.Code == 200 {
  689. var dat2 map[string]interface{}
  690. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  691. } else {
  692. }
  693. c.ServeSuccessJSON(map[string]interface{}{
  694. "pre": response.Body,
  695. "log": dat2,
  696. "status": "1",
  697. "msg": "",
  698. })
  699. } else {
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "status": "0",
  702. "msg": response.Message,
  703. })
  704. }
  705. }
  706. func (c *AHybController) Get2503() {
  707. psnNo := c.GetString("psn_no")
  708. insutype := c.GetString("insutype")
  709. sick_code := c.GetString("sick_code")
  710. sick_name := c.GetString("sick_name")
  711. insuplc_admdvs := c.GetString("insuplc_admdvs")
  712. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  713. secret_key := c.GetString("secret_key")
  714. access_key := c.GetString("access_key")
  715. fixmedins_code := c.GetString("fixmedins_code")
  716. org_name := c.GetString("org_name")
  717. check_time := c.GetString("check_time")
  718. doctor_id := c.GetString("doctor_id")
  719. doctor := c.GetString("doctor")
  720. start_time := c.GetString("start_time")
  721. end_time := c.GetString("end_time")
  722. url := c.GetString("url")
  723. cainfo := c.GetString("cainfo")
  724. service.AHyb2503(psnNo, insutype, org_name, doctor, fixmedins_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_name, sick_code, start_time, end_time, check_time, url, access_key, cainfo)
  725. }
  726. func (c *AHybController) Get3201() {
  727. insutype := c.GetString("insutype")
  728. clrType := c.GetString("clr_type")
  729. setlOptins := c.GetString("setl_optins")
  730. stmtBegndate := c.GetString("stmt_begndate")
  731. stmtEnddate := c.GetString("stm_enddate")
  732. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  733. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  734. acctPay, _ := c.GetFloat("acct_pay", 0)
  735. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  736. fixmedins_code := c.GetString("fixmedins_code")
  737. insuplc_admdvs := c.GetString("insuplc_admdvs")
  738. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  739. secret_key := c.GetString("secret_key")
  740. org_name := c.GetString("org_name")
  741. doctor := c.GetString("doctor")
  742. url := c.GetString("url")
  743. ak := c.GetString("ak")
  744. cainfo := c.GetString("cainfo")
  745. result, inputLog := service.AHyb3201(fixmedinsSetlCnt, acctPay, fundPaySumamt, medfeeSumamt, stmtBegndate, stmtEnddate, setlOptins, clrType, insutype, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, secret_key, cainfo)
  746. saveJsLog(result, inputLog, "3201", "对总账", org_name)
  747. var response Response
  748. if err := json.Unmarshal([]byte(result), &response); err != nil {
  749. fmt.Println("Error decoding JSON:", err)
  750. return
  751. }
  752. if response.Code == 200 {
  753. var dat2 map[string]interface{}
  754. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  755. } else {
  756. }
  757. c.ServeSuccessJSON(map[string]interface{}{
  758. "pre": response.Body,
  759. "log": dat2,
  760. "status": "1",
  761. "msg": "",
  762. })
  763. } else {
  764. c.ServeSuccessJSON(map[string]interface{}{
  765. "status": "0",
  766. "msg": response.Message,
  767. })
  768. }
  769. }
  770. type ELeData struct {
  771. Data struct {
  772. SiNo string `json:"si_no"`
  773. SiCardNo string `json:"si_card_no"`
  774. SiCardIssueArea string `json:"si_card_issue_area"`
  775. Name string `json:"name"`
  776. Gender string `json:"gender"`
  777. IdType string `json:"id_type"`
  778. IdNo string `json:"id_no"`
  779. EcCardToken string `json:"ecCardToken"`
  780. } `json:"data"`
  781. Code int `json:"code"`
  782. Message string `json:"message"`
  783. }
  784. type ELeCertData struct {
  785. Data struct {
  786. Extra string `json:"extra"`
  787. IDNo string `json:"idNo"`
  788. IDType string `json:"idType"`
  789. EcToken string `json:"ecToken"`
  790. InsuOrg string `json:"insuOrg"`
  791. UserName string `json:"userName"`
  792. EcIndexNo string `json:"ecIndexNo"`
  793. Gender string `json:"gender"`
  794. Birthday string `json:"birthday"`
  795. Nationality string `json:"nationality"`
  796. Email string `json:"email"`
  797. } `json:"data"`
  798. Code int `json:"code"`
  799. Message string `json:"message"`
  800. }
  801. func (c *AHybController) ReadCard() {
  802. fixmedins_code := c.GetString("fixmedins_code")
  803. secret_key := c.GetString("secret_key")
  804. ak := c.GetString("ak")
  805. org_name := c.GetString("org_name")
  806. doctor := c.GetString("doctor")
  807. insuplc_admdvs := c.GetString("insuplc_admdvs")
  808. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  809. url := c.GetString("url")
  810. cainfo := c.GetString("cainfo")
  811. id_card_type := c.GetString("id_card_type")
  812. operator_id := c.GetString("operator_id")
  813. operator := c.GetString("operator")
  814. //result, request := service.AHyb9001(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, url, cainfo, ak)
  815. //fmt.Println(request)
  816. //fmt.Println(result)
  817. //c.TestGetBasBaseInit(fixmedins_code, secret_key, ak)
  818. switch id_card_type {
  819. case "1":
  820. pCardInfo := c.GetBasBaseInfo()
  821. pCardInfo = Remove0000(pCardInfo)
  822. fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8"))
  823. fmt.Println(pCardInfo)
  824. bas := strings.Split(pCardInfo, "|")
  825. basNumber := bas[2]
  826. id_card_no := bas[1]
  827. card_sn := bas[3]
  828. id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64)
  829. if len(pCardInfo) > 0 {
  830. result, _ := service.AHyb1101A(basNumber, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type_int, card_sn, "1", url, ak, id_card_no, cainfo)
  831. var response Response
  832. if err := json.Unmarshal([]byte(result), &response); err != nil {
  833. fmt.Println("Error decoding JSON:", err)
  834. return
  835. }
  836. if response.Code == 200 {
  837. c.ServeSuccessJSON(map[string]interface{}{
  838. "status": "0",
  839. "card_info": pCardInfo,
  840. "result": response.Body,
  841. "type": "1",
  842. })
  843. } else {
  844. c.ServeSuccessJSON(map[string]interface{}{
  845. "status": "0",
  846. "msg": response.Message,
  847. })
  848. }
  849. } else {
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "status": "-1",
  852. })
  853. }
  854. break
  855. case "3": //电子社保卡
  856. _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  857. //fmt.Println(pCardInfo)
  858. fmt.Println(pBusiCardInfo)
  859. pBusiCardInfo = Remove0000(pBusiCardInfo)
  860. //pCardInfo = Remove0000(pCardInfo)
  861. var ele ELeData
  862. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  863. if err != nil {
  864. utils.ErrorLog("解析失败:%v", err)
  865. }
  866. token := ele.Data.EcCardToken
  867. if len(token) > 0 {
  868. result, _ := service.AHyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IdNo)
  869. var dat map[string]interface{}
  870. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  871. fmt.Println(dat)
  872. } else {
  873. fmt.Println(err)
  874. }
  875. c.ServeSuccessJSON(map[string]interface{}{
  876. "status": "0",
  877. //"card_info": pCardInfo,
  878. "busi_card_info": pBusiCardInfo,
  879. "token": token,
  880. "result": dat,
  881. "type": "2",
  882. })
  883. } else {
  884. c.ServeSuccessJSON(map[string]interface{}{
  885. "status": "-1",
  886. })
  887. }
  888. break
  889. case "4": //电子凭证
  890. fmt.Println(operator_id)
  891. fmt.Println(operator)
  892. _, pBusiCardInfo := c.GetELeCertInfoTwo(fixmedins_code, operator_id, operator)
  893. fmt.Println(pBusiCardInfo)
  894. pBusiCardInfo = Remove0000(pBusiCardInfo)
  895. var ele ELeCertData
  896. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  897. if err != nil {
  898. utils.ErrorLog("解析失败:%v", err)
  899. }
  900. token := ele.Data.EcToken
  901. fmt.Println(token)
  902. if len(token) > 0 {
  903. userName := ele.Data.UserName
  904. fmt.Println(userName)
  905. userName = Remove0000(userName)
  906. userName = DeleteExtraSpace(userName)
  907. fmt.Println(userName)
  908. enc := mahonia.NewEncoder("gbk")
  909. fmt.Println(enc.ConvertString(userName))
  910. result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  911. var response Response
  912. if err := json.Unmarshal([]byte(result), &response); err != nil {
  913. fmt.Println("Error decoding JSON:", err)
  914. return
  915. }
  916. if response.Code == 200 {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "status": "1",
  919. "card_info": "",
  920. "busi_card_info": pBusiCardInfo,
  921. "token": token,
  922. "result": response.Body,
  923. })
  924. } else {
  925. c.ServeSuccessJSON(map[string]interface{}{
  926. "status": "0",
  927. "msg": response.Message,
  928. })
  929. }
  930. } else {
  931. c.ServeSuccessJSON(map[string]interface{}{
  932. "status": "-1",
  933. })
  934. }
  935. break
  936. }
  937. }
  938. func (c *AHybController) TestGetBasBaseInit(code string, secret_key string, ak string) {
  939. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  940. Iinit := DllDef.MustFindProc("Init")
  941. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  942. str := make([]byte, 2048)
  943. inputData := make(map[string]interface{})
  944. inputData["IP"] = "10.58.65.240"
  945. inputData["PORT"] = "8086"
  946. inputData["TIMEOUT"] = "180"
  947. inputData["LOG_PATH"] = "C:\\log\\"
  948. //inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  949. inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  950. inputData["CARD_PASSTYPE"] = "1"
  951. inputData["API_NAME"] = "hssServives"
  952. inputData["API_VERSION"] = "1.0.0"
  953. inputData["ACCESS_KEY"] = ak
  954. inputData["SECRETKEY"] = secret_key
  955. inputData["ORG_ID"] = code
  956. inputData["EXT"] = ""
  957. bytesData, _ := json.Marshal(inputData)
  958. fmt.Println(inputData)
  959. fmt.Println(bytesData)
  960. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  961. if ret != 0 {
  962. fmt.Println("SSCard的报错原因:", err)
  963. fmt.Println("SSCard的运算结果为:", ret)
  964. fmt.Println("SSCard的返回结果为:", string(str))
  965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  966. return
  967. }
  968. fmt.Println("SSCard的返回结果为:", string(str))
  969. result := int(ret)
  970. fmt.Println("SSCard的运算结果为1:", result)
  971. //initFlag = 1
  972. return
  973. }
  974. func (c *AHybController) GetBasBaseInfo() string {
  975. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  976. readCard := DllDef.MustFindProc("iReadCardBas")
  977. fmt.Println(readCard)
  978. fmt.Println("!!!!!")
  979. pCardInfo := make([]byte, 2048)
  980. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&pCardInfo[0])))
  981. fmt.Println(ret2)
  982. fmt.Println(DeleteExtraSpace(string(pCardInfo)))
  983. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
  984. if ret2 != 0 {
  985. return ""
  986. }
  987. return DeleteExtraSpace(string(pCardInfo))
  988. }
  989. func (c *AHybController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  990. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  991. readCard := DllDef.MustFindProc("EcCardQuery")
  992. fmt.Println(readCard)
  993. fmt.Println("!!!!!")
  994. //pCardInfo := make([]byte, 8192)
  995. pBusiCardInfo := make([]byte, 8192)
  996. //data := make(map[string]interface{})
  997. //pData := make(map[string]interface{})
  998. //inputData := make(map[string]interface{})
  999. //inputData["orgId"] = code
  1000. //inputData["businessType"] = "01101"
  1001. //inputData["operatorId"] = operator_id
  1002. //inputData["operatorName"] = operator_name
  1003. //inputData["officeId"] = "001"
  1004. //inputData["officeName"] = "血透室"
  1005. //data["data"] = inputData
  1006. //data["transType"] = "ec.query"
  1007. //data["orgId"] = code
  1008. //bytesData, _ := json.Marshal(data)
  1009. //pCardInfo = bytesData
  1010. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1011. fmt.Println(ret2)
  1012. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  1013. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1014. //fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1015. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1016. if ret2 != 0 {
  1017. return "", ""
  1018. }
  1019. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1020. }
  1021. func (c *AHybController) GetELeCertInfoFour1(code string, operator_id string, operator_name string) (string, string) {
  1022. DllDef := syscall.MustLoadDLL("NationEcCode.dll")
  1023. readCard := DllDef.MustFindProc("EcQuery")
  1024. pCardInfo := make([]byte, 8192)
  1025. pBusiCardInfo := make([]byte, 8192)
  1026. data := make(map[string]interface{})
  1027. inputData := make(map[string]interface{})
  1028. inputData["orgId"] = code
  1029. inputData["businessType"] = "01301"
  1030. inputData["operatorId"] = operator_id
  1031. inputData["operatorName"] = operator_name
  1032. inputData["officeId"] = "001"
  1033. inputData["officeName"] = "xuetou"
  1034. data["data"] = inputData
  1035. data["transType"] = "ec.query"
  1036. data["orgId"] = code
  1037. bytesData, _ := json.Marshal(data)
  1038. pCardInfo = bytesData
  1039. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1040. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1041. fmt.Println(ret2)
  1042. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1043. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1044. if ret2 != 0 {
  1045. return "", ""
  1046. }
  1047. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1048. }
  1049. func (c *AHybController) GetELeCertInfoFour(code string, operator_id string, operator_name string) (string, string) {
  1050. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1051. readCard := DllDef.MustFindProc("GetPersonInfo")
  1052. pCardInfo := make([]byte, 8192)
  1053. pBusiCardInfo := make([]byte, 8192)
  1054. data := make(map[string]interface{})
  1055. inputData := make(map[string]interface{})
  1056. inputData["orgId"] = code
  1057. inputData["businessType"] = "01301"
  1058. inputData["operatorId"] = operator_id
  1059. inputData["operatorName"] = operator_name
  1060. inputData["officeId"] = "001"
  1061. inputData["officeName"] = "xuetou"
  1062. data["data"] = inputData
  1063. data["transType"] = "ec.query"
  1064. data["orgId"] = code
  1065. bytesData, _ := json.Marshal(data)
  1066. pCardInfo = bytesData
  1067. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1068. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1069. fmt.Println(ret2)
  1070. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1071. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1072. if ret2 != 0 {
  1073. return "", ""
  1074. }
  1075. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1076. }
  1077. func (c *AHybController) GetELeCertInfoFour2223(code string, operator_id string, operator_name string) (string, string) {
  1078. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1079. readCard := DllDef.MustFindProc("GetPersonInfo")
  1080. pCardInfo := make([]byte, 8192)
  1081. pBusiCardInfo := make([]byte, 8192)
  1082. data := make(map[string]interface{})
  1083. inputData := make(map[string]interface{})
  1084. inputData["orgId"] = code
  1085. inputData["businessType"] = "01101"
  1086. inputData["operatorId"] = operator_id
  1087. inputData["operatorName"] = operator_name
  1088. inputData["officeId"] = "001"
  1089. inputData["officeName"] = "xuetou"
  1090. data["data"] = inputData
  1091. data["transType"] = "ec.query"
  1092. data["orgId"] = code
  1093. bytesData, _ := json.Marshal(data)
  1094. pCardInfo = bytesData
  1095. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1096. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1097. fmt.Println(ret2)
  1098. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1099. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1100. if ret2 != 0 {
  1101. return "", ""
  1102. }
  1103. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1104. }
  1105. func (c *AHybController) GetELeCertInfoTwo(code string, operator_id string, operator_name string) (string, string) {
  1106. // WebSocket服务器地址
  1107. serverURL := "ws://127.0.0.1:8899"
  1108. // 解析WebSocket服务器地址
  1109. u, err := url.Parse(serverURL)
  1110. if err != nil {
  1111. log.Fatal(err)
  1112. }
  1113. // 建立WebSocket连接
  1114. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1115. if err != nil {
  1116. log.Fatal(err)
  1117. }
  1118. defer conn.Close()
  1119. input2 := make(map[string]interface{})
  1120. input := make(map[string]interface{})
  1121. inputData := make(map[string]interface{})
  1122. inputData["orgId"] = code
  1123. inputData["businessType"] = "01101"
  1124. inputData["operatorId"] = operator_id
  1125. inputData["operatorName"] = operator_name
  1126. inputData["officeId"] = "001"
  1127. inputData["officeName"] = "血透室"
  1128. inputData["deviceType"] = ""
  1129. input["data"] = inputData
  1130. input["orgId"] = code
  1131. input["transType"] = "ec.query"
  1132. input2["url"] = "http://10.66.159.55:8080/localcfc/api/hsecfc/localQrCodeQuery"
  1133. input2["indata"] = input
  1134. bytesData, _ := json.Marshal(input2)
  1135. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1136. if err != nil {
  1137. fmt.Println(err)
  1138. }
  1139. // 接收消息
  1140. _, receivedMessage, err := conn.ReadMessage()
  1141. if err != nil {
  1142. fmt.Println(err)
  1143. }
  1144. return "", string(receivedMessage)
  1145. }
  1146. func (c *AHybController) GetELeCertInfoThree(code string, operator_id string, operator_name string) (string, string) {
  1147. // WebSocket服务器地址
  1148. serverURL := "ws://127.0.0.1:8899"
  1149. // 解析WebSocket服务器地址
  1150. u, err := url.Parse(serverURL)
  1151. if err != nil {
  1152. log.Fatal(err)
  1153. }
  1154. // 建立WebSocket连接
  1155. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1156. if err != nil {
  1157. log.Fatal(err)
  1158. }
  1159. defer conn.Close()
  1160. input2 := make(map[string]interface{})
  1161. input := make(map[string]interface{})
  1162. inputData := make(map[string]interface{})
  1163. inputData["orgId"] = code
  1164. inputData["businessType"] = "01301"
  1165. inputData["operatorId"] = operator_id
  1166. inputData["operatorName"] = operator_name
  1167. inputData["officeId"] = "001"
  1168. inputData["officeName"] = "血透室"
  1169. inputData["deviceType"] = ""
  1170. input["data"] = inputData
  1171. input["orgId"] = code
  1172. input["transType"] = "ec.query"
  1173. input2["url"] = "http://10.66.159.55:8080/localcfc/api/hsecfc/localQrCodeQuery"
  1174. input2["indata"] = input
  1175. bytesData, _ := json.Marshal(input2)
  1176. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1177. if err != nil {
  1178. fmt.Println(err)
  1179. }
  1180. // 接收消息
  1181. _, receivedMessage, err := conn.ReadMessage()
  1182. if err != nil {
  1183. fmt.Println(err)
  1184. }
  1185. return "", string(receivedMessage)
  1186. }
  1187. func IntPtr(n int) uintptr {
  1188. return uintptr(n)
  1189. }
  1190. func StrPtr(s string) uintptr {
  1191. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1192. }
  1193. type Charset string
  1194. const (
  1195. UTF8 = Charset("UTF-8")
  1196. GB18030 = Charset("GB18030")
  1197. )
  1198. func ConvertToString(src string, srcCode string, tagCode string) string {
  1199. srcCoder := mahonia.NewDecoder(srcCode)
  1200. srcResult := srcCoder.ConvertString(src)
  1201. tagCoder := mahonia.NewDecoder(tagCode)
  1202. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1203. result := string(cdata)
  1204. return result
  1205. }
  1206. func DeleteExtraSpace(s string) string {
  1207. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1208. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1209. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1210. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1211. s2 := make([]byte, len(s1)) //定义字符数组切片
  1212. copy(s2, s1) //将字符串复制到切片
  1213. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1214. for len(spc_index) > 0 { //找到适配项
  1215. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1216. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1217. }
  1218. return string(s2)
  1219. }
  1220. func Remove0000(s string) string {
  1221. str := make([]rune, 0, len(s))
  1222. for _, v := range []rune(s) {
  1223. if v == 0 {
  1224. continue
  1225. }
  1226. str = append(str, v)
  1227. }
  1228. return string(str)
  1229. }
  1230. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1231. //org_id, _ := beego.AppConfig.Int64("org_id")
  1232. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1233. dir := org_name + "日志"
  1234. utils.Mkdir(dir)
  1235. month := time.Unix(1557042972, 0).Format("1")
  1236. year := time.Now().Format("2006")
  1237. month = time.Now().Format("01")
  1238. day := time.Now().Format("02")
  1239. hour := time.Now().Format("15")
  1240. min := time.Now().Format("04")
  1241. sec := time.Now().Format("05")
  1242. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1243. file := org_name + "_" + year + month + day + "_log"
  1244. file_name := file + ".txt"
  1245. file_path := org_name + "日志" + "/" + file_name
  1246. exist, _ := utils.PathExists(file_path)
  1247. if exist { //存在
  1248. fmt.Println("存在")
  1249. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1250. if err != nil {
  1251. fmt.Println("read fail")
  1252. }
  1253. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1254. n, _ := f.Seek(0, 2)
  1255. _, err = f.WriteAt([]byte(content), n)
  1256. } else { //不存在
  1257. fmt.Println("文件不存在,创建文件")
  1258. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1259. defer f.Close()
  1260. if err != nil {
  1261. } else {
  1262. _, err = f.Write([]byte("记录日志"))
  1263. }
  1264. }
  1265. }
  1266. func (c *AHybController) Get3101() {
  1267. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1268. var respJSON map[string]interface{}
  1269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1271. return
  1272. }
  1273. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  1274. var pd models.PatientDtos
  1275. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  1276. utils.ErrorLog("解析失败:%v", err)
  1277. return
  1278. }
  1279. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  1280. var fed models.FsiEncounterDtos
  1281. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  1282. utils.ErrorLog("解析失败:%v", err)
  1283. return
  1284. }
  1285. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  1286. var fdd []*models.FsiDiagnoseDtos
  1287. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  1288. utils.ErrorLog("解析失败:%v", err)
  1289. return
  1290. }
  1291. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  1292. var fod []*models.FsiOrderDtos
  1293. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1294. utils.ErrorLog("解析失败:%v", err)
  1295. return
  1296. }
  1297. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1298. var fopd []*models.FsiOperationDtosData
  1299. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1300. utils.ErrorLog("解析失败:%v", err)
  1301. return
  1302. }
  1303. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1304. var pp models.PublicParams
  1305. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1306. utils.ErrorLog("解析失败:%v", err)
  1307. return
  1308. }
  1309. inputLog, result := service.AHyb3101(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1310. var response Response
  1311. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1312. fmt.Println("Error decoding JSON:", err)
  1313. return
  1314. }
  1315. if response.Code == 200 {
  1316. var dat2 map[string]interface{}
  1317. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1318. } else {
  1319. }
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "pre": response.Body,
  1322. "log": dat2,
  1323. "status": 1,
  1324. "msg": "",
  1325. })
  1326. } else {
  1327. c.ServeSuccessJSON(map[string]interface{}{
  1328. "status": 0,
  1329. "msg": response.Message,
  1330. })
  1331. }
  1332. }
  1333. func (c *AHybController) Get3102() {
  1334. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1335. var respJSON map[string]interface{}
  1336. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1337. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1338. return
  1339. }
  1340. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  1341. var pd models.PatientDtos
  1342. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  1343. utils.ErrorLog("解析失败:%v", err)
  1344. return
  1345. }
  1346. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  1347. var fed models.FsiEncounterDtos
  1348. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  1349. utils.ErrorLog("解析失败:%v", err)
  1350. return
  1351. }
  1352. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  1353. var fdd []*models.FsiDiagnoseDtos
  1354. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. return
  1357. }
  1358. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  1359. var fod []*models.FsiOrderDtos
  1360. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1361. utils.ErrorLog("解析失败:%v", err)
  1362. return
  1363. }
  1364. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1365. var fopd []*models.FsiOperationDtosData
  1366. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1367. utils.ErrorLog("解析失败:%v", err)
  1368. return
  1369. }
  1370. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1371. var pp models.PublicParams
  1372. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1373. utils.ErrorLog("解析失败:%v", err)
  1374. return
  1375. }
  1376. _, result := service.AHyb3102(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1377. var response Response
  1378. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1379. fmt.Println("Error decoding JSON:", err)
  1380. return
  1381. }
  1382. if response.Code == 200 {
  1383. c.ServeSuccessJSON(map[string]interface{}{
  1384. "pre": response.Body,
  1385. "status": 1,
  1386. "msg": "",
  1387. })
  1388. } else {
  1389. c.ServeSuccessJSON(map[string]interface{}{
  1390. "status": 0,
  1391. "msg": response.Message,
  1392. })
  1393. }
  1394. }
  1395. func (c *AHybController) Get4101() {
  1396. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1397. var respJSON map[string]interface{}
  1398. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1400. return
  1401. }
  1402. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  1403. var struct4101 service.Struct4101
  1404. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  1405. utils.ErrorLog("解析失败:%v", err)
  1406. return
  1407. }
  1408. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1409. var pp models.PublicParams
  1410. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1411. utils.ErrorLog("解析失败:%v", err)
  1412. return
  1413. }
  1414. inputLog, result := service.AHyb4101(struct4101, pp)
  1415. saveJsLog(result, inputLog, "4101", "上传明细清单", pp.FixmedinsName)
  1416. var response Response
  1417. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1418. fmt.Println("Error decoding JSON:", err)
  1419. return
  1420. }
  1421. if response.Code == 200 {
  1422. var dat2 map[string]interface{}
  1423. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1424. } else {
  1425. }
  1426. c.ServeSuccessJSON(map[string]interface{}{
  1427. "pre": response.Body,
  1428. "log": dat2,
  1429. "status": 1,
  1430. "msg": "",
  1431. })
  1432. } else {
  1433. c.ServeSuccessJSON(map[string]interface{}{
  1434. "status": 0,
  1435. "msg": response.Message,
  1436. })
  1437. }
  1438. }
  1439. func ConvertByte2String(byte []byte, charset Charset) string {
  1440. var str string
  1441. switch charset {
  1442. case GB18030:
  1443. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1444. str = string(decodeBytes)
  1445. case UTF8:
  1446. fallthrough
  1447. default:
  1448. str = string(byte)
  1449. }
  1450. return str
  1451. }