ahyb_controller.go 51KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747
  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, pBusiCardInfo := c.GetBasBaseInfo()
  821. pBusiCardInfo = Remove0000(pBusiCardInfo)
  822. pCardInfo = Remove0000(pCardInfo)
  823. fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8"))
  824. fmt.Println(pBusiCardInfo)
  825. fmt.Println(pCardInfo)
  826. bas := strings.Split(pCardInfo, "|")
  827. basNumber := bas[2]
  828. id_card_no := bas[1]
  829. card_sn := bas[3]
  830. id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64)
  831. if len(pCardInfo) > 0 && len(pBusiCardInfo) > 0 {
  832. result, _ := service.AHyb1101A(basNumber, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type_int, card_sn, "1", url, ak, pBusiCardInfo, id_card_no, cainfo)
  833. var dat map[string]interface{}
  834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  835. fmt.Println(dat)
  836. } else {
  837. fmt.Println(err)
  838. }
  839. c.ServeSuccessJSON(map[string]interface{}{
  840. "status": "0",
  841. "card_info": pCardInfo,
  842. "busi_card_info": pBusiCardInfo,
  843. "result": dat,
  844. "type": "1",
  845. })
  846. } else {
  847. c.ServeSuccessJSON(map[string]interface{}{
  848. "status": "-1",
  849. })
  850. }
  851. break
  852. case "3": //电子社保卡
  853. _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  854. //fmt.Println(pCardInfo)
  855. fmt.Println(pBusiCardInfo)
  856. pBusiCardInfo = Remove0000(pBusiCardInfo)
  857. //pCardInfo = Remove0000(pCardInfo)
  858. var ele ELeData
  859. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  860. if err != nil {
  861. utils.ErrorLog("解析失败:%v", err)
  862. }
  863. token := ele.Data.EcCardToken
  864. if len(token) > 0 {
  865. result, _ := service.AHyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IdNo)
  866. var dat map[string]interface{}
  867. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  868. fmt.Println(dat)
  869. } else {
  870. fmt.Println(err)
  871. }
  872. c.ServeSuccessJSON(map[string]interface{}{
  873. "status": "0",
  874. //"card_info": pCardInfo,
  875. "busi_card_info": pBusiCardInfo,
  876. "token": token,
  877. "result": dat,
  878. "type": "2",
  879. })
  880. } else {
  881. c.ServeSuccessJSON(map[string]interface{}{
  882. "status": "-1",
  883. })
  884. }
  885. break
  886. case "4": //电子凭证
  887. fmt.Println(operator_id)
  888. fmt.Println(operator)
  889. _, pBusiCardInfo := c.GetELeCertInfoTwo(fixmedins_code, operator_id, operator)
  890. fmt.Println(pBusiCardInfo)
  891. pBusiCardInfo = Remove0000(pBusiCardInfo)
  892. var ele ELeCertData
  893. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  894. if err != nil {
  895. utils.ErrorLog("解析失败:%v", err)
  896. }
  897. token := ele.Data.EcToken
  898. fmt.Println(token)
  899. if len(token) > 0 {
  900. userName := ele.Data.UserName
  901. fmt.Println(userName)
  902. userName = Remove0000(userName)
  903. userName = DeleteExtraSpace(userName)
  904. fmt.Println(userName)
  905. enc := mahonia.NewEncoder("gbk")
  906. fmt.Println(enc.ConvertString(userName))
  907. result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  908. var response Response
  909. if err := json.Unmarshal([]byte(result), &response); err != nil {
  910. fmt.Println("Error decoding JSON:", err)
  911. return
  912. }
  913. if response.Code == 200{
  914. c.ServeSuccessJSON(map[string]interface{}{
  915. "status":"1",
  916. "card_info": "",
  917. "busi_card_info": pBusiCardInfo,
  918. "token": token,
  919. "result": response.Body,
  920. })
  921. }else{
  922. c.ServeSuccessJSON(map[string]interface{}{
  923. "status":"0",
  924. "msg":response.Message,
  925. })
  926. }
  927. } else {
  928. c.ServeSuccessJSON(map[string]interface{}{
  929. "status": "-1",
  930. })
  931. }
  932. break
  933. }
  934. }
  935. func (c *AHybController) TestGetBasBaseInit(code string, secret_key string, ak string) {
  936. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  937. Iinit := DllDef.MustFindProc("Init")
  938. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  939. str := make([]byte, 2048)
  940. inputData := make(map[string]interface{})
  941. inputData["IP"] = "10.58.65.240"
  942. inputData["PORT"] = "8086"
  943. inputData["TIMEOUT"] = "180"
  944. inputData["LOG_PATH"] = "C:\\log\\"
  945. //inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  946. inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  947. inputData["CARD_PASSTYPE"] = "1"
  948. inputData["API_NAME"] = "hssServives"
  949. inputData["API_VERSION"] = "1.0.0"
  950. inputData["ACCESS_KEY"] = ak
  951. inputData["SECRETKEY"] = secret_key
  952. inputData["ORG_ID"] = code
  953. inputData["EXT"] = ""
  954. bytesData, _ := json.Marshal(inputData)
  955. fmt.Println(inputData)
  956. fmt.Println(bytesData)
  957. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  958. if ret != 0 {
  959. fmt.Println("SSCard的报错原因:", err)
  960. fmt.Println("SSCard的运算结果为:", ret)
  961. fmt.Println("SSCard的返回结果为:", string(str))
  962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  963. return
  964. }
  965. fmt.Println("SSCard的返回结果为:", string(str))
  966. result := int(ret)
  967. fmt.Println("SSCard的运算结果为1:", result)
  968. //initFlag = 1
  969. return
  970. }
  971. func (c *AHybController) GetBasBaseInfo() (string, string) {
  972. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  973. readCard := DllDef.MustFindProc("ReadCardBas")
  974. fmt.Println(readCard)
  975. fmt.Println("!!!!!")
  976. pCardInfo := make([]byte, 2048)
  977. pBusiCardInfo := make([]byte, 8192)
  978. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  979. fmt.Println(ret2)
  980. fmt.Println(DeleteExtraSpace(string(pCardInfo)))
  981. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  982. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
  983. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  984. if ret2 != 0 {
  985. return "", ""
  986. }
  987. return DeleteExtraSpace(string(pCardInfo)), DeleteExtraSpace(string(pBusiCardInfo))
  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. }