nm_controller.go 58KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840
  1. package nm
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/controllers"
  7. "gdyb/enums"
  8. "gdyb/models"
  9. "gdyb/service"
  10. "gdyb/utils"
  11. "github.com/astaxie/beego"
  12. "github.com/axgle/mahonia"
  13. "github.com/gorilla/websocket"
  14. "golang.org/x/text/encoding/simplifiedchinese"
  15. "io/ioutil"
  16. "log"
  17. "net/http"
  18. "net/url"
  19. "os"
  20. "regexp"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type NmController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func NmybRegistRouters() {
  31. beego.Router("/nmyb/1101", &NmController{}, "get:Post1101")
  32. beego.Router("/nmyb/2401", &NmController{}, "post:Post2401")
  33. beego.Router("/nmyb/2402", &NmController{}, "post:Post2402")
  34. beego.Router("/nmyb/2404", &NmController{}, "get:Post2404")
  35. beego.Router("/nmyb/2405", &NmController{}, "get:Post2405")
  36. beego.Router("/nmyb/2301", &NmController{}, "post:Post2301")
  37. beego.Router("/nmyb/2302", &NmController{}, "get:Post2302")
  38. beego.Router("/nmyb/2303", &NmController{}, "get:Post2303")
  39. beego.Router("/nmyb/2304", &NmController{}, "get:Post2304")
  40. beego.Router("/nmyb/2305", &NmController{}, "get:Post2305")
  41. beego.Router("/nmyb/5203", &NmController{}, "get:Post5203")
  42. beego.Router("/nmyb/readcard", &NmController{}, "get:ReadCard")
  43. beego.Router("/nmyb/3201", &NmController{}, "get:Get3201")
  44. beego.Router("/nmyb/4101", &NmController{}, "post:Post4101")
  45. beego.Router("/nmyb/2601", &NmController{}, "get:Get2601")
  46. beego.Router("/api/token", &NmController{}, "get:GetToken")
  47. beego.Router("/api/eleinfo", &NmController{}, "get:GetNewELeInfo")
  48. beego.Router("/nmyb/4102", &NmController{}, "get:Post4102")
  49. beego.Router("/nmyb/4103", &NmController{}, "get:Post4103")
  50. beego.Router("/nmyb/2201", &NmController{}, "get:Post2201")
  51. beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
  52. beego.Router("/nmyb/2203", &NmController{}, "post:Post2203")
  53. beego.Router("/nmyb/2203C", &NmController{}, "post:Post2203C")
  54. beego.Router("/nmyb/2204", &NmController{}, "post:Post2204")
  55. beego.Router("/nmyb/2205", &NmController{}, "get:Post2205")
  56. beego.Router("/nmyb/2206", &NmController{}, "get:Post2206")
  57. beego.Router("/nmyb/2207", &NmController{}, "get:Post2207")
  58. beego.Router("/nmyb/2208", &NmController{}, "get:Post2208")
  59. beego.Router("/nmyb/2503", &NmController{}, "get:Post2503")
  60. }
  61. func (c *NmController) Post2201() {
  62. psnNo := c.GetString("psn_no")
  63. insutype := c.GetString("insutype")
  64. certNo := c.GetString("cert_no")
  65. org_name := c.GetString("org_name")
  66. ipt_otp_no := c.GetString("ipt_otp_no")
  67. dept := c.GetString("dept")
  68. verify_number := c.GetString("verify_number")
  69. fixmedins_code := c.GetString("fixmedins_code")
  70. dept_code := c.GetString("dept_code")
  71. doctor_id := c.GetString("doctor_id")
  72. insuplc_admdvs := c.GetString("insuplc_admdvs")
  73. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  74. secret_key := c.GetString("secret_key")
  75. id_card_type, _ := c.GetInt64("id_card_type")
  76. doctor_name := c.GetString("doctor_name")
  77. cainfo := c.GetString("cainfo")
  78. opter := c.GetString("opter")
  79. result, request_log := service.Nmyb2201(psnNo, insutype, certNo, org_name, opter, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, verify_number, cainfo)
  80. saveJsLog(result, request_log, "2201", "挂号", org_name)
  81. var dat map[string]interface{}
  82. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  83. } else {
  84. }
  85. var dat2 map[string]interface{}
  86. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  87. } else {
  88. }
  89. c.ServeSuccessJSON(map[string]interface{}{
  90. "pre": dat,
  91. "request_log": dat2,
  92. })
  93. }
  94. func (c *NmController) Post2202() {
  95. psnNo := c.GetString("psn_no")
  96. mdtrtId := c.GetString("mdtrt_id")
  97. iptOtpNo := c.GetString("ipt_otp_no")
  98. org_name := c.GetString("org_name")
  99. doctor := c.GetString("doctor")
  100. insuplc_admdvs := c.GetString("insuplc_admdvs")
  101. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  102. secret_key := c.GetString("secret_key")
  103. fixmedins_code := c.GetString("fixmedins_code")
  104. cainfo := c.GetString("cainfo")
  105. result, request_log := service.Nmyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, cainfo)
  106. saveJsLog(result, request_log, "2202", "退号", org_name)
  107. var dat map[string]interface{}
  108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  109. } else {
  110. }
  111. var dat2 map[string]interface{}
  112. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  113. } else {
  114. }
  115. c.ServeSuccessJSON(map[string]interface{}{
  116. "pre": dat,
  117. "request_log": dat2,
  118. })
  119. }
  120. func (c *NmController) Post2203() {
  121. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  122. var respJSON map[string]interface{}
  123. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  124. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  125. return
  126. }
  127. userJSONBytes, _ := json.Marshal(respJSON["config"])
  128. var config []*models.HisXtDiagnoseConfig
  129. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  130. utils.ErrorLog("解析失败:%v", err)
  131. return
  132. }
  133. fmt.Println(respJSON["psn_no"].(string))
  134. fmt.Println(respJSON["mdtrt_id"].(string))
  135. psnNo := respJSON["psn_no"].(string)
  136. mdtrtId := respJSON["mdtrt_id"].(string)
  137. doctor := respJSON["doctor"].(string)
  138. department := respJSON["department"].(string)
  139. org_name := respJSON["org_name"].(string)
  140. med_type := respJSON["med_type"].(string)
  141. doctor_id := respJSON["doctor_id"].(string)
  142. fixmedins_code := respJSON["fixmedins_code"].(string)
  143. sick_code := respJSON["sick_code"].(string)
  144. sick_name := respJSON["sick_name"].(string)
  145. dept := respJSON["dept"].(string)
  146. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  147. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  148. secret_key := respJSON["secret_key"].(string)
  149. begin_time := respJSON["begin_time"].(string)
  150. cainfo := respJSON["cainfo"].(string)
  151. //cainfo := c.GetString("cainfo")
  152. result, request_log := service.Nmyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, begin_time, cainfo)
  153. saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
  154. var dat2 map[string]interface{}
  155. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  156. } else {
  157. }
  158. var dat map[string]interface{}
  159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  160. } else {
  161. }
  162. c.ServeSuccessJSON(map[string]interface{}{
  163. "pre": dat,
  164. "request_log": dat2,
  165. })
  166. }
  167. func (c *NmController) Post2203C() {
  168. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  169. var respJSON map[string]interface{}
  170. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  172. return
  173. }
  174. userJSONBytes, _ := json.Marshal(respJSON["config"])
  175. var config []*models.HisXtDiagnoseConfig
  176. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  177. utils.ErrorLog("解析失败:%v", err)
  178. return
  179. }
  180. fmt.Println(respJSON["psn_no"].(string))
  181. fmt.Println(respJSON["mdtrt_id"].(string))
  182. psnNo := respJSON["psn_no"].(string)
  183. mdtrtId := respJSON["mdtrt_id"].(string)
  184. doctor := respJSON["doctor"].(string)
  185. department := respJSON["department"].(string)
  186. org_name := respJSON["org_name"].(string)
  187. med_type := respJSON["med_type"].(string)
  188. doctor_id := respJSON["doctor_id"].(string)
  189. fixmedins_code := respJSON["fixmedins_code"].(string)
  190. sick_code := respJSON["sick_code"].(string)
  191. sick_name := respJSON["sick_name"].(string)
  192. dept := respJSON["dept"].(string)
  193. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  194. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  195. secret_key := respJSON["secret_key"].(string)
  196. begin_time := respJSON["begin_time"].(string)
  197. cainfo := respJSON["cainfo"].(string)
  198. //is_vaild := respJSON["is_vaild"].(string)
  199. //cainfo := c.GetString("cainfo")
  200. result, request_log := service.Nmyb2203C(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, begin_time, cainfo)
  201. saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
  202. var dat2 map[string]interface{}
  203. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  204. } else {
  205. }
  206. var dat map[string]interface{}
  207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  208. } else {
  209. }
  210. c.ServeSuccessJSON(map[string]interface{}{
  211. "pre": dat,
  212. "request_log": dat2,
  213. })
  214. }
  215. func (c *NmController) Post2204() {
  216. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  217. var respJSON map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. return
  221. }
  222. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  223. var hp []*models.HisPrescription
  224. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. return
  227. }
  228. //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
  229. result, request_log := service.Nmyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  230. 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))
  231. saveJsLog(result, request_log, "2204", "上传明细", respJSON["org_name"].(string))
  232. var dat map[string]interface{}
  233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  234. fmt.Println(dat)
  235. } else {
  236. fmt.Println(err)
  237. }
  238. var dat2 map[string]interface{}
  239. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  240. fmt.Println(dat2)
  241. } else {
  242. fmt.Println(err)
  243. }
  244. c.ServeSuccessJSON(map[string]interface{}{
  245. "pre": dat,
  246. "request_log": dat2,
  247. })
  248. }
  249. func (c *NmController) Post2205() {
  250. psnNo := c.GetString("psn_no")
  251. mdtrtId := c.GetString("mdtrt_id")
  252. chrgBchno := c.GetString("chrg_bchno")
  253. org_name := c.GetString("org_name")
  254. doctor := c.GetString("doctor")
  255. insuplc_admdvs := c.GetString("insuplc_admdvs")
  256. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  257. secret_key := c.GetString("secret_key")
  258. fixmedins_code := c.GetString("fixmedins_code")
  259. url := c.GetString("url")
  260. ak := c.GetString("ak")
  261. cainfo := c.GetString("cainfo")
  262. result, request_log := service.Nmyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  263. fmt.Println(request_log)
  264. saveJsLog(result, request_log, "2205", "撤销明细", org_name)
  265. var dat map[string]interface{}
  266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  267. fmt.Println(dat)
  268. } else {
  269. fmt.Println(err)
  270. }
  271. var dat2 map[string]interface{}
  272. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  273. fmt.Println(dat2)
  274. } else {
  275. fmt.Println(err)
  276. }
  277. c.ServeSuccessJSON(map[string]interface{}{
  278. "pre": dat,
  279. "request_log": dat2,
  280. })
  281. }
  282. func (c *NmController) Post2206() {
  283. psnNo := c.GetString("psn_no")
  284. mdtrtId := c.GetString("mdtrt_id")
  285. chrgBchno := c.GetString("chrg_bchno")
  286. certNo := c.GetString("cert_no")
  287. insutype := c.GetString("insutype")
  288. total := c.GetString("total")
  289. org_name := c.GetString("org_name")
  290. doctor := c.GetString("doctor")
  291. fixmedins_code := c.GetString("fixmedins_code")
  292. insuplc_admdvs := c.GetString("insuplc_admdvs")
  293. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  294. secret_key := c.GetString("secret_key")
  295. med_type := c.GetString("med_type")
  296. id_card_type, _ := c.GetInt64("id_card_type")
  297. certificates, _ := c.GetInt64("certificates")
  298. verify_number := c.GetString("verify_number")
  299. cainfo := c.GetString("cainfo")
  300. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  301. url := c.GetString("url")
  302. ak := c.GetString("ak")
  303. var result string
  304. var request_log string
  305. result, request_log = service.Nmyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, 0, 0, 0, 0, certificates, url, ak, verify_number, cainfo, mdtrt_grp_type)
  306. saveJsLog(result, request_log, "2206", "预结算", org_name)
  307. var dat map[string]interface{}
  308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  309. fmt.Println(dat)
  310. } else {
  311. fmt.Println(err)
  312. }
  313. var dat2 map[string]interface{}
  314. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  315. fmt.Println(dat2)
  316. } else {
  317. fmt.Println(err)
  318. }
  319. c.ServeSuccessJSON(map[string]interface{}{
  320. "pre": dat,
  321. "request_log": dat2,
  322. })
  323. }
  324. func (c *NmController) Post2207() {
  325. psnNo := c.GetString("psn_no")
  326. mdtrtId := c.GetString("mdtrt_id")
  327. chrgBchno := c.GetString("chrg_bchno")
  328. certNo := c.GetString("cert_no")
  329. insutype := c.GetString("insutype")
  330. total := c.GetString("total")
  331. org_name := c.GetString("org_name")
  332. doctor := c.GetString("doctor")
  333. fixmedins_code := c.GetString("fixmedins_code")
  334. insuplc_admdvs := c.GetString("insuplc_admdvs")
  335. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  336. secret_key := c.GetString("secret_key")
  337. med_type := c.GetString("med_type")
  338. id_card_type, _ := c.GetInt64("id_card_type")
  339. certificates, _ := c.GetInt64("certificates")
  340. fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
  341. overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
  342. preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
  343. inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
  344. acct_used_flag := c.GetString("acct_used_flag")
  345. url := c.GetString("url")
  346. ak := c.GetString("ak")
  347. verify_number := c.GetString("verify_number")
  348. cainfo := c.GetString("cainfo")
  349. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  350. var result string
  351. var request_log string
  352. result, request_log = service.Nmyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, fulamt_ownpay_amt, overlmt_selfpay, preselfpay_amt, inscp_scp_amt, certificates, acct_used_flag, url, ak, verify_number, cainfo, mdtrt_grp_type)
  353. saveJsLog(result, request_log, "2207", "结算", org_name)
  354. var dat map[string]interface{}
  355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  356. fmt.Println(dat)
  357. } else {
  358. fmt.Println(err)
  359. }
  360. var dat2 map[string]interface{}
  361. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  362. fmt.Println(dat2)
  363. } else {
  364. fmt.Println(err)
  365. }
  366. c.ServeSuccessJSON(map[string]interface{}{
  367. "pre": dat,
  368. "request_log": dat2,
  369. })
  370. }
  371. func (c *NmController) Post2208() {
  372. psnNo := c.GetString("psn_no")
  373. mdtrtId := c.GetString("mdtrt_id")
  374. setlId := c.GetString("setl_id")
  375. org_name := c.GetString("org_name")
  376. doctor := c.GetString("doctor")
  377. secret_key := c.GetString("secret_key")
  378. fixmedins_code := c.GetString("fixmedins_code")
  379. insuplc_admdvs := c.GetString("insuplc_admdvs")
  380. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  381. url := c.GetString("url")
  382. ak := c.GetString("ak")
  383. cainfo := c.GetString("cainfo")
  384. result, request_log := service.Nmyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  385. saveJsLog(result, request_log, "2208", "退费", org_name)
  386. fmt.Println(request_log)
  387. var dat map[string]interface{}
  388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  389. fmt.Println(dat)
  390. } else {
  391. fmt.Println(err)
  392. }
  393. var dat2 map[string]interface{}
  394. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  395. fmt.Println(dat2)
  396. } else {
  397. fmt.Println(err)
  398. }
  399. c.ServeSuccessJSON(map[string]interface{}{
  400. "pre": dat,
  401. "request_log": dat2,
  402. })
  403. }
  404. func (c *NmController) Post2503() {
  405. psnNo := c.GetString("psn_no")
  406. insutype := c.GetString("insutype")
  407. opera := c.GetString("opera")
  408. org_name := c.GetString("org_name")
  409. doctor := c.GetString("doctor")
  410. doctor_id := c.GetString("doctor_id")
  411. secret_key := c.GetString("secret_key")
  412. fixmedins_code := c.GetString("fixmedins_code")
  413. insuplc_admdvs := c.GetString("insuplc_admdvs")
  414. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  415. sick_name := c.GetString("sick_name")
  416. sick_code := c.GetString("sick_code")
  417. start_time := c.GetString("start_time")
  418. end_time := c.GetString("end_time")
  419. check_time := c.GetString("check_time")
  420. hospital_name := c.GetString("hospital_name")
  421. hospital_code := c.GetString("hospital_code")
  422. result := service.Nmyb2503(psnNo, insutype, org_name, opera, doctor, fixmedins_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_name, sick_code, start_time, end_time, check_time, hospital_code, hospital_name)
  423. var dat map[string]interface{}
  424. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  425. fmt.Println(dat)
  426. } else {
  427. fmt.Println(err)
  428. }
  429. c.ServeSuccessJSON(map[string]interface{}{
  430. "pre": dat,
  431. })
  432. }
  433. func (c *NmController) GetNewELeInfo() {
  434. token := c.GetString("token")
  435. user_name := c.GetString("user_name")
  436. id_card_no := c.GetString("id_card_no")
  437. result, _ := service.Gdyb1101ForEleCert("赤峰费森血液透析中心", "关学丽", "H15049901371", "150499", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", token, user_name, id_card_no)
  438. var dat map[string]interface{}
  439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  440. fmt.Println(dat)
  441. } else {
  442. fmt.Println(err)
  443. }
  444. userJSONBytes, _ := json.Marshal(dat)
  445. var res ResultTwo
  446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  447. utils.ErrorLog("解析失败:%v", err)
  448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  449. return
  450. }
  451. infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  452. if infocode == 0 {
  453. data := make(map[string]interface{})
  454. data["token"] = token
  455. data["result"] = dat
  456. var req *http.Request
  457. bytesData, _ := json.Marshal(data)
  458. req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/ele/info", bytes.NewReader(bytesData))
  459. client := &http.Client{}
  460. resp, _ := client.Do(req)
  461. defer resp.Body.Close()
  462. body, ioErr := ioutil.ReadAll(resp.Body)
  463. if ioErr != nil {
  464. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  466. return
  467. }
  468. var respJSON map[string]interface{}
  469. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  470. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  472. return
  473. }
  474. c.ServeSuccessJSON(map[string]interface{}{
  475. "msg": "成功",
  476. })
  477. }
  478. }
  479. func (c *NmController) GetToken() {
  480. token := c.GetString("token")
  481. results := strings.Split(token, "-")
  482. fmt.Println(token)
  483. result_code := results[0]
  484. result_info := results[1]
  485. if result_code == "0000" {
  486. var ele2 ELeData2
  487. err := json.Unmarshal([]byte(result_info), &ele2)
  488. if err != nil {
  489. utils.ErrorLog("解析失败:%v", err)
  490. }
  491. if ele2.Code != -2 {
  492. var ele ELeData
  493. err := json.Unmarshal([]byte(result_info), &ele)
  494. if err != nil {
  495. utils.ErrorLog("解析失败:%v", err)
  496. }
  497. token := ele.Data.EcToken
  498. if len(token) > 0 {
  499. data := make(map[string]interface{})
  500. data["token"] = token
  501. data["id_card_no"] = ele.Data.IdNo
  502. fmt.Println(data)
  503. var req *http.Request
  504. fmt.Println(req)
  505. bytesData, _ := json.Marshal(data)
  506. fmt.Println(bytesData)
  507. req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/token/get", bytes.NewReader(bytesData))
  508. fmt.Println(req)
  509. client := &http.Client{}
  510. resp, _ := client.Do(req)
  511. fmt.Println(resp)
  512. defer resp.Body.Close()
  513. body, ioErr := ioutil.ReadAll(resp.Body)
  514. fmt.Println(resp.Body)
  515. fmt.Println(body)
  516. fmt.Println(ioErr)
  517. if ioErr != nil {
  518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  520. return
  521. }
  522. var respJSON map[string]interface{}
  523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  526. return
  527. }
  528. } else {
  529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  530. return
  531. }
  532. }
  533. } else {
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  535. return
  536. }
  537. }
  538. type ReadCardResult struct {
  539. Output struct {
  540. CardInfo string `json:"cardInfo"`
  541. RegionCode string `json:"regionCode"`
  542. } `json:"output"`
  543. Code string `json:"CODE"`
  544. ErrMsg string `json:"ERRMSG"`
  545. }
  546. type ELeData2 struct {
  547. Code int `json:"code"`
  548. Message string `json:"message"`
  549. }
  550. type ELeData struct {
  551. Data struct {
  552. IdNo string `json:"idNo"`
  553. IdType string `json:"idType"`
  554. UserName string `json:"userName"`
  555. EcToken string `json:"ecToken"`
  556. InsuOrg string `json:"insuOrg"`
  557. Gender string `json:"gender"`
  558. Birthday string `json:"birthday"`
  559. Nationality string `json:"nationality"`
  560. Email string `json:"email"`
  561. Extra string `json:"extra"`
  562. } `json:"data"`
  563. Code int `json:"code"`
  564. Message string `json:"message"`
  565. }
  566. type ResultTwo struct {
  567. ErrMsg string `json:"err_msg"`
  568. InfRefmsgid string `json:"inf_refmsgid"`
  569. Infcode string `json:"infcode"`
  570. Output struct {
  571. Baseinfo struct {
  572. Age float64 `json:"age"`
  573. Brdy string `json:"brdy"`
  574. Certno string `json:"certno"`
  575. Gend string `json:"gend"`
  576. Naty string `json:"naty"`
  577. PsnCertType string `json:"psn_cert_type"`
  578. PsnName string `json:"psn_name"`
  579. PsnNo string `json:"psn_no"`
  580. } `json:"baseinfo"`
  581. Idetinfo []interface{} `json:"idetinfo"`
  582. Iinfo []struct {
  583. Balc float64 `json:"balc"`
  584. CvlservFlag string `json:"cvlserv_flag"`
  585. EmpName string `json:"emp_name"`
  586. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  587. Insutype string `json:"insutype"`
  588. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  589. PausInsuDate string `json:"paus_insu_date"`
  590. PsnInsuDate string `json:"psn_insu_date"`
  591. PsnInsuStas string `json:"psn_insu_stas"`
  592. PsnType string `json:"psn_type"`
  593. } `json:"insuinfo"`
  594. } `json:"output"`
  595. RefmsgTime string `json:"refmsg_time"`
  596. RespondTime string `json:"respond_time"`
  597. Signtype interface{} `json:"signtype"`
  598. WarnInfo interface{} `json:"warn_info"`
  599. }
  600. type ResultTwo10265 struct {
  601. ErrMsg string `json:"err_msg"`
  602. InfRefmsgid string `json:"inf_refmsgid"`
  603. Infcode string `json:"infcode"`
  604. Output struct {
  605. Baseinfo struct {
  606. Age float64 `json:"age"`
  607. Brdy string `json:"brdy"`
  608. Certno string `json:"certno"`
  609. Gend string `json:"gend"`
  610. Naty string `json:"naty"`
  611. PsnCertType string `json:"psn_cert_type"`
  612. PsnName string `json:"psn_name"`
  613. PsnNo string `json:"psn_no"`
  614. } `json:"baseinfo"`
  615. Idetinfo []interface{} `json:"idetinfo"`
  616. Iinfo []struct {
  617. Balc float64 `json:"balc"`
  618. CvlservFlag string `json:"cvlserv_flag"`
  619. EmpName string `json:"emp_name"`
  620. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  621. Insutype string `json:"insutype"`
  622. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  623. PausInsuDate string `json:"paus_insu_date"`
  624. PsnInsuDate string `json:"psn_insu_date"`
  625. PsnInsuStas string `json:"psn_insu_stas"`
  626. PsnType string `json:"psn_type"`
  627. } `json:"insuinfo"`
  628. } `json:"output"`
  629. RefmsgTime string `json:"refmsg_time"`
  630. RespondTime string `json:"respond_time"`
  631. Signtype interface{} `json:"signtype"`
  632. WarnInfo interface{} `json:"warn_info"`
  633. }
  634. func (c *NmController) Post4101() {
  635. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  636. var respJSON map[string]interface{}
  637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  639. return
  640. }
  641. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  642. var struct4101 service.Struct4101
  643. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  644. utils.ErrorLog("解析失败:%v", err)
  645. return
  646. }
  647. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  648. var pp models.PublicParams
  649. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  650. utils.ErrorLog("解析失败:%v", err)
  651. return
  652. }
  653. result, _ := service.Gdyb4101(struct4101, pp.SecretKey, pp.FixmedinsName, pp.OpterName, pp.FixmedinsCode, pp.InsuplcAdmdvs, pp.MdtrtareaAdmvs, 0)
  654. var dat map[string]interface{}
  655. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  656. fmt.Println(dat)
  657. } else {
  658. fmt.Println(err)
  659. }
  660. saveJsLog(result, "", "4101", "上传明细清单", pp.FixmedinsName)
  661. c.ServeSuccessJSON(map[string]interface{}{
  662. "pre": dat,
  663. })
  664. }
  665. func (c *NmController) Post5203() {
  666. fmt.Println("------")
  667. org_name := c.GetString("org_name")
  668. doctor := c.GetString("doctor")
  669. fixmedins_code := c.GetString("fixmedins_code")
  670. insuplc_admdvs := c.GetString("insuplc_admdvs")
  671. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  672. secret_key := c.GetString("secret_key")
  673. psn_no := c.GetString("psn_no")
  674. mdtrt_id := c.GetString("mdtrt_id")
  675. setl_id := c.GetString("setl_id")
  676. fmt.Println("------")
  677. bp := models.BaseParams{
  678. SecretKey: secret_key,
  679. FixmedinsCode: fixmedins_code,
  680. InsuplcAdmdvs: insuplc_admdvs,
  681. MdtrtareaAdmvs: mdtrtarea_admvs,
  682. OrgName: org_name,
  683. Doctor: doctor,
  684. }
  685. bps := models.BusinessParams{
  686. PsnNo: psn_no,
  687. MdtrtId: mdtrt_id,
  688. SetlId: setl_id,
  689. }
  690. result := service.ZHyb5203(bp, bps)
  691. saveJsLog(result, "", "5203", "结算单", org_name)
  692. var dat map[string]interface{}
  693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  694. } else {
  695. }
  696. c.ServeSuccessJSON(map[string]interface{}{
  697. "pre": dat,
  698. })
  699. }
  700. func (c *NmController) Post4102() {
  701. org_name := c.GetString("org_name")
  702. doctor := c.GetString("doctor")
  703. fixmedins_code := c.GetString("fixmedins_code")
  704. insuplc_admdvs := c.GetString("insuplc_admdvs")
  705. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  706. secret_key := c.GetString("secret_key")
  707. psn_no := c.GetString("psn_no")
  708. mdtrt_id := c.GetString("mdtrt_id")
  709. setl_id := c.GetString("setl_id")
  710. stas_type := c.GetString("stas_type")
  711. bp := models.BaseParams{
  712. SecretKey: secret_key,
  713. FixmedinsCode: fixmedins_code,
  714. InsuplcAdmdvs: insuplc_admdvs,
  715. MdtrtareaAdmvs: mdtrtarea_admvs,
  716. OrgName: org_name,
  717. Doctor: doctor,
  718. }
  719. bps := models.BusinessParams{
  720. PsnNo: psn_no,
  721. MdtrtId: mdtrt_id,
  722. SetlId: setl_id,
  723. StasType: stas_type,
  724. }
  725. result := service.ZHyb4102(bp, bps)
  726. saveJsLog(result, "", "4102", "确认结算清单", org_name)
  727. var dat map[string]interface{}
  728. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  729. } else {
  730. }
  731. c.ServeSuccessJSON(map[string]interface{}{
  732. "pre": dat,
  733. })
  734. }
  735. func (c *NmController) Post4103() {
  736. org_name := c.GetString("org_name")
  737. doctor := c.GetString("doctor")
  738. fixmedins_code := c.GetString("fixmedins_code")
  739. insuplc_admdvs := c.GetString("insuplc_admdvs")
  740. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  741. secret_key := c.GetString("secret_key")
  742. psn_no := c.GetString("psn_no")
  743. mdtrt_id := c.GetString("mdtrt_id")
  744. setl_id := c.GetString("setl_id")
  745. bp := models.BaseParams{
  746. SecretKey: secret_key,
  747. FixmedinsCode: fixmedins_code,
  748. InsuplcAdmdvs: insuplc_admdvs,
  749. MdtrtareaAdmvs: mdtrtarea_admvs,
  750. OrgName: org_name,
  751. Doctor: doctor,
  752. }
  753. bps := models.BusinessParams{
  754. PsnNo: psn_no,
  755. MdtrtId: mdtrt_id,
  756. SetlId: setl_id,
  757. }
  758. result := service.ZHyb4103(bp, bps)
  759. result2 := service.ZHyb4104(bp, bps)
  760. saveJsLog(result, "", "4103", "查询结算清单", org_name)
  761. saveJsLog(result2, "", "4104", "指控结算清单", org_name)
  762. var dat map[string]interface{}
  763. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  764. } else {
  765. }
  766. c.ServeSuccessJSON(map[string]interface{}{
  767. "pre": dat,
  768. })
  769. }
  770. func (c *NmController) Post4104() {
  771. org_name := c.GetString("org_name")
  772. doctor := c.GetString("doctor")
  773. fixmedins_code := c.GetString("fixmedins_code")
  774. insuplc_admdvs := c.GetString("insuplc_admdvs")
  775. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  776. secret_key := c.GetString("secret_key")
  777. psn_no := c.GetString("psn_no")
  778. mdtrt_id := c.GetString("mdtrt_id")
  779. setl_id := c.GetString("setl_id")
  780. bp := models.BaseParams{
  781. SecretKey: secret_key,
  782. FixmedinsCode: fixmedins_code,
  783. InsuplcAdmdvs: insuplc_admdvs,
  784. MdtrtareaAdmvs: mdtrtarea_admvs,
  785. OrgName: org_name,
  786. Doctor: doctor,
  787. }
  788. bps := models.BusinessParams{
  789. PsnNo: psn_no,
  790. MdtrtId: mdtrt_id,
  791. SetlId: setl_id,
  792. }
  793. result := service.ZHyb4104(bp, bps)
  794. saveJsLog(result, "", "4104", "质控结算清单结果", org_name)
  795. var dat map[string]interface{}
  796. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  797. } else {
  798. }
  799. c.ServeSuccessJSON(map[string]interface{}{
  800. "pre": dat,
  801. })
  802. }
  803. func (c *NmController) Post1101() {
  804. certNo := c.GetString("cert_no")
  805. org_name := c.GetString("org_name")
  806. doctor := c.GetString("doctor")
  807. fixmedins_code := c.GetString("fixmedins_code")
  808. insuplc_admdvs := c.GetString("insuplc_admdvs")
  809. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  810. secret_key := c.GetString("secret_key")
  811. id_card_type, _ := c.GetInt64("id_card_type")
  812. card_sn := c.GetString("card_sn")
  813. certificates := c.GetString("certificates")
  814. name := c.GetString("name")
  815. certificate, _ := strconv.ParseInt(certificates, 10, 64)
  816. result, request_log, result_log := service.ZHGdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificate, name)
  817. saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
  818. var dat map[string]interface{}
  819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  820. } else {
  821. }
  822. var dat2 map[string]interface{}
  823. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  824. } else {
  825. }
  826. c.ServeSuccessJSON(map[string]interface{}{
  827. "pre": dat,
  828. "log": dat2,
  829. })
  830. }
  831. func (c *NmController) Post2401() {
  832. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  833. var respJSON map[string]interface{}
  834. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  836. return
  837. }
  838. userJSONBytes, _ := json.Marshal(respJSON["struct_2401"])
  839. var struct2401 service.Struct2401
  840. if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
  841. utils.ErrorLog("解析失败:%v", err)
  842. return
  843. }
  844. org_name := respJSON["org_name"].(string)
  845. fixmedins_code := respJSON["fixmedins_code"].(string)
  846. doctor := respJSON["doctor"].(string)
  847. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  848. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  849. secret_key := respJSON["secret_key"].(string)
  850. result, request_log := service.ZHGdyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  851. saveJsLog(result, request_log, "2401", "入院登记", org_name)
  852. var dat2 map[string]interface{}
  853. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  854. } else {
  855. }
  856. var dat map[string]interface{}
  857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  858. } else {
  859. }
  860. c.ServeSuccessJSON(map[string]interface{}{
  861. "pre": dat,
  862. "request_log": dat2,
  863. })
  864. }
  865. func (c *NmController) Post2404() {
  866. mdtrt_id := c.GetString("mdtrt_id")
  867. psn_no := c.GetString("psn_no")
  868. doctor := c.GetString("doctor")
  869. fixmedins_code := c.GetString("fixmedins_code")
  870. insuplc_admdvs := c.GetString("insuplc_admdvs")
  871. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  872. secret_key := c.GetString("secret_key")
  873. org_name := c.GetString("org_name")
  874. result, requestLog := service.ZHGdyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  875. saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
  876. var dat map[string]interface{}
  877. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  878. } else {
  879. }
  880. var dat2 map[string]interface{}
  881. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  882. } else {
  883. }
  884. c.ServeSuccessJSON(map[string]interface{}{
  885. "pre": dat,
  886. "log": dat2,
  887. })
  888. }
  889. func (c *NmController) Post2405() {
  890. mdtrt_id := c.GetString("mdtrt_id")
  891. psn_no := c.GetString("psn_no")
  892. doctor := c.GetString("doctor")
  893. fixmedins_code := c.GetString("fixmedins_code")
  894. insuplc_admdvs := c.GetString("insuplc_admdvs")
  895. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  896. secret_key := c.GetString("secret_key")
  897. org_name := c.GetString("org_name")
  898. result, requestLog := service.ZHGdyb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  899. saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
  900. var dat map[string]interface{}
  901. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  902. } else {
  903. }
  904. var dat2 map[string]interface{}
  905. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  906. } else {
  907. }
  908. c.ServeSuccessJSON(map[string]interface{}{
  909. "pre": dat,
  910. "log": dat2,
  911. })
  912. }
  913. func (c *NmController) Post2402() {
  914. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  915. var respJSON map[string]interface{}
  916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  918. return
  919. }
  920. userJSONBytes, _ := json.Marshal(respJSON["struct_2402"])
  921. var struct2402 service.Struct2402
  922. if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
  923. utils.ErrorLog("解析失败:%v", err)
  924. return
  925. }
  926. org_name := respJSON["org_name"].(string)
  927. fixmedins_code := respJSON["fixmedins_code"].(string)
  928. doctor := respJSON["doctor"].(string)
  929. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  930. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  931. secret_key := respJSON["secret_key"].(string)
  932. result, request_log := service.ZHGdyb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  933. saveJsLog(result, request_log, "2402", "出院", org_name)
  934. var dat2 map[string]interface{}
  935. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  936. } else {
  937. }
  938. var dat map[string]interface{}
  939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  940. } else {
  941. }
  942. c.ServeSuccessJSON(map[string]interface{}{
  943. "pre": dat,
  944. "request_log": dat2,
  945. })
  946. }
  947. func (c *NmController) Post2301() {
  948. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  949. var respJSON map[string]interface{}
  950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  952. return
  953. }
  954. userJSONBytes, _ := json.Marshal(respJSON["customs"])
  955. var customs []*models.NewCustom
  956. if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
  957. utils.ErrorLog("解析失败:%v", err)
  958. return
  959. }
  960. number := respJSON["number"].(string)
  961. chrg_bchno := respJSON["chrg_bchno"].(string)
  962. dept := respJSON["dept"].(string)
  963. dept_code := respJSON["dept_code"].(string)
  964. doctor_code := respJSON["doctor_code"].(string)
  965. doctor_name := respJSON["doctor_name"].(string)
  966. opertor := respJSON["opertor"].(string)
  967. org_name := respJSON["org_name"].(string)
  968. fixmedins_code := respJSON["fixmedins_code"].(string)
  969. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  970. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  971. secret_key := respJSON["secret_key"].(string)
  972. med_type := respJSON["med_type"].(string)
  973. //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
  974. psn_no := respJSON["psn_no"].(string)
  975. result, requestLog := service.ZHGdyb2301A(psn_no, number, customs, chrg_bchno, org_name, doctor_name, dept, fixmedins_code, dept_code, doctor_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, opertor)
  976. saveJsLog(result, requestLog, "2301", "上传明细", org_name)
  977. var dat2 map[string]interface{}
  978. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  979. } else {
  980. }
  981. var dat map[string]interface{}
  982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  983. } else {
  984. }
  985. c.ServeSuccessJSON(map[string]interface{}{
  986. "pre": dat,
  987. "request_log": dat2,
  988. })
  989. }
  990. func (c *NmController) Post2302() {
  991. mdtrt_id := c.GetString("mdtrtId")
  992. psn_no := c.GetString("psn_no")
  993. number := c.GetString("feedetl_sn")
  994. doctor := c.GetString("doctor")
  995. fixmedins_code := c.GetString("fixmedins_code")
  996. insuplc_admdvs := c.GetString("insuplc_admdvs")
  997. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  998. secret_key := c.GetString("secret_key")
  999. org_name := c.GetString("org_name")
  1000. refund_type, _ := c.GetInt64("refund_type")
  1001. result, requestLog := service.Gdyb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
  1002. saveJsLog(result, requestLog, "2302", "退明细", org_name)
  1003. var dat2 map[string]interface{}
  1004. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1005. } else {
  1006. }
  1007. var dat map[string]interface{}
  1008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1009. } else {
  1010. }
  1011. c.ServeSuccessJSON(map[string]interface{}{
  1012. "pre": dat,
  1013. "request_log": dat2,
  1014. })
  1015. }
  1016. func (c *NmController) Post2303() {
  1017. mdtrt_id := c.GetString("mdtrt_id")
  1018. psn_no := c.GetString("psn_no")
  1019. chrg_bchno := c.GetString("chrg_bchno")
  1020. cert_no := c.GetString("cert_no")
  1021. insutype_type := c.GetString("insutype_type")
  1022. allTotal := c.GetString("total")
  1023. id_card_type, _ := c.GetInt64("id_card_type")
  1024. doctor := c.GetString("doctor")
  1025. certificates, _ := c.GetInt64("certificates")
  1026. fixmedins_code := c.GetString("fixmedins_code")
  1027. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1028. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1029. secret_key := c.GetString("secret_key")
  1030. org_name := c.GetString("org_name")
  1031. result, src_resquest := service.ZHGdyb2303(psn_no, mdtrt_id, chrg_bchno, cert_no, insutype_type, allTotal, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, "0", id_card_type, 0, 0, 0, 0, certificates)
  1032. saveJsLog(result, src_resquest, "2303", "预结算", org_name)
  1033. var dat2 map[string]interface{}
  1034. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1035. } else {
  1036. }
  1037. var dat map[string]interface{}
  1038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1039. } else {
  1040. }
  1041. c.ServeSuccessJSON(map[string]interface{}{
  1042. "pre": dat,
  1043. "request_log": dat2,
  1044. })
  1045. }
  1046. func (c *NmController) Post2304() {
  1047. mdtrt_id := c.GetString("mdtrt_id")
  1048. psn_no := c.GetString("psn_no")
  1049. chrg_bchno := c.GetString("chrg_bchno")
  1050. cert_no := c.GetString("cert_no")
  1051. insutype_type := c.GetString("insutype_type")
  1052. allTotal := c.GetString("total")
  1053. id_card_type, _ := c.GetInt64("id_card_type")
  1054. doctor := c.GetString("doctor")
  1055. certificates, _ := c.GetInt64("certificates")
  1056. fixmedins_code := c.GetString("fixmedins_code")
  1057. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1058. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1059. secret_key := c.GetString("secret_key")
  1060. org_name := c.GetString("org_name")
  1061. fapiao_number := c.GetString("fapiao_number")
  1062. acct_used_flag := c.GetString("acct_used_flag")
  1063. result, src_resquest := service.ZHGdyb2304(psn_no, mdtrt_id, chrg_bchno, cert_no, insutype_type, allTotal, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, "0", id_card_type, 0, 0, 0, 0, certificates, fapiao_number, acct_used_flag)
  1064. saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
  1065. var dat2 map[string]interface{}
  1066. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1067. } else {
  1068. }
  1069. var dat map[string]interface{}
  1070. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1071. } else {
  1072. }
  1073. c.ServeSuccessJSON(map[string]interface{}{
  1074. "pre": dat,
  1075. "request_log": dat2,
  1076. })
  1077. }
  1078. func (c *NmController) Post2305() {
  1079. mdtrt_id := c.GetString("mdtrt_id")
  1080. psn_no := c.GetString("psn_no")
  1081. doctor := c.GetString("doctor")
  1082. setl_id := c.GetString("setl_id")
  1083. fixmedins_code := c.GetString("fixmedins_code")
  1084. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1085. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1086. secret_key := c.GetString("secret_key")
  1087. org_name := c.GetString("org_name")
  1088. result, requestLog := service.Gdyb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1089. saveJsLog(result, requestLog, "2305", "退费", org_name)
  1090. var dat2 map[string]interface{}
  1091. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1092. } else {
  1093. }
  1094. var dat map[string]interface{}
  1095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1096. } else {
  1097. }
  1098. c.ServeSuccessJSON(map[string]interface{}{
  1099. "pre": dat,
  1100. "request_log": dat2,
  1101. })
  1102. }
  1103. func (c *NmController) Get2503() {
  1104. }
  1105. func (c *NmController) ReadCard() {
  1106. fixmedins_code := c.GetString("fixmedins_code")
  1107. secret_key := c.GetString("secret_key")
  1108. org_name := c.GetString("org_name")
  1109. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1110. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1111. id_card_type := c.GetString("id_card_type")
  1112. operator_id := c.GetString("operator_id")
  1113. operator := c.GetString("operator")
  1114. is_settle := c.GetString("is_settle")
  1115. switch id_card_type {
  1116. case "1":
  1117. if initFlag == 0 {
  1118. c.TestGetBasBaseInit()
  1119. }
  1120. pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
  1121. basStr := Remove0000(pBusiCardInfo)
  1122. if len(basStr) == 0 {
  1123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1124. return
  1125. }
  1126. var dat2 map[string]interface{}
  1127. if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
  1128. fmt.Println(dat2)
  1129. } else {
  1130. fmt.Println(err)
  1131. }
  1132. userJSONBytes, _ := json.Marshal(dat2)
  1133. var res ReadCardResult
  1134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1135. utils.ErrorLog("解析失败:%v", err)
  1136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1137. return
  1138. }
  1139. fmt.Println(basStr)
  1140. bas := strings.Split(res.Output.CardInfo, "|")
  1141. basNumber := bas[1]
  1142. fmt.Println(basNumber)
  1143. card_sn := bas[3]
  1144. fmt.Println(card_sn)
  1145. cardNumber := bas[2]
  1146. name := bas[4]
  1147. result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
  1148. var dat map[string]interface{}
  1149. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1150. fmt.Println(dat)
  1151. } else {
  1152. fmt.Println(err)
  1153. }
  1154. userJSONBytes2, _ := json.Marshal(dat)
  1155. var res2 ResultTwo
  1156. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1157. utils.ErrorLog("解析失败:%v", err)
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1159. return
  1160. }
  1161. infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
  1162. if infocode == 0 {
  1163. c.ServeSuccessJSON(map[string]interface{}{
  1164. "status": "0",
  1165. "card_info": res.Output.CardInfo,
  1166. "busi_card_info": pBusiCardInfo,
  1167. "result": res2,
  1168. "type": "1",
  1169. })
  1170. } else {
  1171. c.ServeSuccessJSON(map[string]interface{}{
  1172. "status": "-1",
  1173. })
  1174. }
  1175. break
  1176. case "4": //电子凭证
  1177. //c.GetELeInfo()
  1178. var result_info string
  1179. if len(is_settle) > 0 {
  1180. _, result_info = c.GetELeInfo(fixmedins_code, operator_id, operator)
  1181. } else {
  1182. _, result_info = c.GetELeInfoThree(fixmedins_code, operator_id, operator)
  1183. }
  1184. //if result_code == "0000" {
  1185. var ele ELeData
  1186. err := json.Unmarshal([]byte(result_info), &ele)
  1187. if err != nil {
  1188. utils.ErrorLog("解析失败:%v", err)
  1189. }
  1190. token := ele.Data.EcToken
  1191. fmt.Println(token)
  1192. if len(token) > 0 {
  1193. result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.UserName, ele.Data.IdNo)
  1194. var dat map[string]interface{}
  1195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1196. fmt.Println(dat)
  1197. } else {
  1198. fmt.Println(err)
  1199. }
  1200. userJSONBytes, _ := json.Marshal(dat)
  1201. var res ResultTwo
  1202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1203. utils.ErrorLog("解析失败:%v", err)
  1204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1205. return
  1206. }
  1207. infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1208. if infocode == 0 {
  1209. c.ServeSuccessJSON(map[string]interface{}{
  1210. "status": "0",
  1211. "card_info": result_info,
  1212. "busi_card_info": result_info,
  1213. "token": token,
  1214. "result": dat,
  1215. })
  1216. } else {
  1217. c.ServeSuccessJSON(map[string]interface{}{
  1218. "status": "-1",
  1219. })
  1220. }
  1221. } else {
  1222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1223. return
  1224. }
  1225. break
  1226. case "5": //电子凭证
  1227. //c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1228. //_, pBusiCardInfo := c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1229. //var ele ELeData
  1230. //err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  1231. //if err != nil {
  1232. // utils.ErrorLog("解析失败:%v", err)
  1233. //}
  1234. //token := ele.Data.EcToken
  1235. //fmt.Println(token)
  1236. //if len(token) > 0 {
  1237. // result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.IdNo, ele.Data.UserName)
  1238. // var dat map[string]interface{}
  1239. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1240. // fmt.Println(dat)
  1241. // } else {
  1242. // fmt.Println(err)
  1243. // }
  1244. // userJSONBytes, _ := json.Marshal(dat)
  1245. // var res ResultTwo
  1246. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1247. // utils.ErrorLog("解析失败:%v", err)
  1248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1249. // return
  1250. // }
  1251. //
  1252. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1253. //
  1254. // if infocode == 0 {
  1255. //
  1256. // c.ServeSuccessJSON(map[string]interface{}{
  1257. // "status": "0",
  1258. // "card_info": pBusiCardInfo,
  1259. // "busi_card_info": pBusiCardInfo,
  1260. // "token": token,
  1261. // "result": dat,
  1262. // })
  1263. //
  1264. // } else {
  1265. // c.ServeSuccessJSON(map[string]interface{}{
  1266. // "status": "-1",
  1267. // })
  1268. //
  1269. // }
  1270. //} else {
  1271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1272. // return
  1273. //}
  1274. //break
  1275. }
  1276. }
  1277. var initFlag int64 = 0
  1278. func (c *NmController) GetELeInfoTwo(code string, operator_id string, operator_name string) (string, string) {
  1279. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  1280. readCard := DllDef.MustFindProc("NationEcTrans")
  1281. fmt.Println(readCard)
  1282. fmt.Println("!!!!!")
  1283. pBusiCardInfo := make([]byte, 1024*10)
  1284. input := make(map[string]interface{})
  1285. inputData := make(map[string]interface{})
  1286. inputData["orgId"] = code
  1287. inputData["businessType"] = "01101"
  1288. inputData["operatorId"] = operator_id
  1289. inputData["operatorName"] = operator_name
  1290. inputData["officeId"] = "001"
  1291. inputData["officeName"] = "血透室"
  1292. inputData["deviceType"] = ""
  1293. input["data"] = inputData
  1294. input["orgId"] = code
  1295. input["transType"] = "ec.query"
  1296. bytesData, _ := json.Marshal(input)
  1297. //gdyb_url := beego.AppConfig.String("gdyb_url")
  1298. fmt.Println(string(bytesData))
  1299. url := "http://10.38.22.15:8081" + "/localcfc/api/hsecfc/localQrCodeQuery"
  1300. ret2, aa, bb := readCard.Call(StrPtr(url), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1301. fmt.Println(aa)
  1302. fmt.Println(bb)
  1303. fmt.Println(ret2)
  1304. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1305. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1306. if ret2 != 0 {
  1307. return "", ""
  1308. }
  1309. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1310. }
  1311. func (c *NmController) TestGetBasBaseInit() {
  1312. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1313. Iinit := DllDef.MustFindProc("Init")
  1314. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1315. str := make([]byte, 2048)
  1316. inputData := make(map[string]interface{})
  1317. inputData["IP"] = "tyjk.nm.hsip.gov.cn"
  1318. inputData["PORT"] = 8090
  1319. inputData["TIMEOUT"] = 180
  1320. inputData["LOG_PATH"] = "C:\\log\\"
  1321. //inputData["SFZ_DRIVER_TYPE"] = 0
  1322. inputData["URL"] = "/uif-hsaf-med-api/api/medical/service"
  1323. bytesData, _ := json.Marshal(inputData)
  1324. fmt.Println(inputData)
  1325. fmt.Println(bytesData)
  1326. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  1327. if ret != 0 {
  1328. fmt.Println("SSCard的报错原因:", err)
  1329. fmt.Println("SSCard的运算结果为:", ret)
  1330. fmt.Println("SSCard的返回结果为:", string(str))
  1331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1332. return
  1333. }
  1334. fmt.Println("SSCard的返回结果为:", string(str))
  1335. result := int(ret)
  1336. fmt.Println("SSCard的运算结果为1:", result)
  1337. //initFlag = 1
  1338. return
  1339. }
  1340. func (c *NmController) GetSFZBaseInfo() string {
  1341. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1342. readCard := DllDef.MustFindProc("ReadSFZ")
  1343. if readCard == nil {
  1344. fmt.Println("readcard is nil")
  1345. readCard = DllDef.MustFindProc("ReadSFZ")
  1346. }
  1347. str := make([]byte, 256)
  1348. str1 := make([]byte, 256)
  1349. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1350. fmt.Println(r)
  1351. return string(str)
  1352. }
  1353. func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  1354. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1355. readCard := DllDef.MustFindProc("ReadCardBas")
  1356. fmt.Println(readCard)
  1357. fmt.Println("!!!!!")
  1358. month := time.Unix(1557042972, 0).Format("1")
  1359. year := time.Now().Format("2006")
  1360. month = time.Now().Format("01")
  1361. day := time.Now().Format("02")
  1362. hour := time.Now().Format("15")
  1363. min := time.Now().Format("04")
  1364. sec := time.Now().Format("05")
  1365. msec := time.Now().Format("000")
  1366. timestamp := time.Now().Unix()
  1367. tempTime := time.Unix(timestamp, 0)
  1368. //timeFormat := tempTime.Format("20060102150405")
  1369. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1370. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  1371. inputData := make(map[string]interface{})
  1372. inputData["infno"] = "1199"
  1373. //inputData["msgid"] = "7021"
  1374. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  1375. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  1376. inputData["insuplc_admdvs"] = "" // 发送方报文 ID
  1377. // 发送方报文 ID
  1378. inputData["recer_sys_code"] = "01"
  1379. inputData["dev_no"] = ""
  1380. inputData["dev_safe_info"] = ""
  1381. inputData["cainfo"] = ""
  1382. inputData["signtype"] = "SM3"
  1383. inputData["infver"] = "V1.0"
  1384. inputData["opter_type"] = "1"
  1385. inputData["opter"] = opter_id
  1386. inputData["opter_name"] = opter_name
  1387. inputData["inf_time"] = timeFormatOne
  1388. inputData["fixmedins_code"] = fixmedins_code
  1389. inputData["fixmedins_name"] = fixmedins_name
  1390. inputData["sign_no"] = ""
  1391. bytesData, _ := json.Marshal(inputData)
  1392. fmt.Println(string(bytesData))
  1393. pBusiCardInfo := make([]byte, 8192)
  1394. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1395. fmt.Println(ret2)
  1396. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1397. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1398. if ret2 != 0 {
  1399. return ""
  1400. }
  1401. return DeleteExtraSpace(string(pBusiCardInfo))
  1402. }
  1403. func (c *NmController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  1404. // WebSocket服务器地址
  1405. serverURL := "ws://127.0.0.1:8899"
  1406. // 解析WebSocket服务器地址
  1407. u, err := url.Parse(serverURL)
  1408. if err != nil {
  1409. log.Fatal(err)
  1410. }
  1411. // 建立WebSocket连接
  1412. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1413. if err != nil {
  1414. log.Fatal(err)
  1415. }
  1416. defer conn.Close()
  1417. input2 := make(map[string]interface{})
  1418. input := make(map[string]interface{})
  1419. inputData := make(map[string]interface{})
  1420. inputData["orgId"] = code
  1421. inputData["businessType"] = "01101"
  1422. inputData["operatorId"] = operator_id
  1423. inputData["operatorName"] = operator_name
  1424. inputData["officeId"] = "001"
  1425. inputData["officeName"] = "血透室"
  1426. inputData["deviceType"] = ""
  1427. input["data"] = inputData
  1428. input["orgId"] = code
  1429. input["transType"] = "ec.query"
  1430. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1431. input2["indata"] = input
  1432. bytesData, _ := json.Marshal(input2)
  1433. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1434. if err != nil {
  1435. fmt.Println(err)
  1436. }
  1437. // 接收消息
  1438. _, receivedMessage, err := conn.ReadMessage()
  1439. if err != nil {
  1440. fmt.Println(err)
  1441. }
  1442. return "", string(receivedMessage)
  1443. }
  1444. func (c *NmController) GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  1445. // WebSocket服务器地址
  1446. serverURL := "ws://127.0.0.1:8899"
  1447. // 解析WebSocket服务器地址
  1448. u, err := url.Parse(serverURL)
  1449. if err != nil {
  1450. log.Fatal(err)
  1451. }
  1452. // 建立WebSocket连接
  1453. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1454. if err != nil {
  1455. log.Fatal(err)
  1456. }
  1457. defer conn.Close()
  1458. input2 := make(map[string]interface{})
  1459. input := make(map[string]interface{})
  1460. inputData := make(map[string]interface{})
  1461. inputData["orgId"] = code
  1462. inputData["businessType"] = "01301"
  1463. inputData["operatorId"] = operator_id
  1464. inputData["operatorName"] = operator_name
  1465. inputData["officeId"] = "001"
  1466. inputData["officeName"] = "血透室"
  1467. inputData["deviceType"] = ""
  1468. input["data"] = inputData
  1469. input["orgId"] = code
  1470. input["transType"] = "ec.query"
  1471. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1472. input2["indata"] = input
  1473. bytesData, _ := json.Marshal(input2)
  1474. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1475. if err != nil {
  1476. fmt.Println(err)
  1477. }
  1478. // 接收消息
  1479. _, receivedMessage, err := conn.ReadMessage()
  1480. if err != nil {
  1481. fmt.Println(err)
  1482. }
  1483. return "", string(receivedMessage)
  1484. }
  1485. func IntPtr(n int) uintptr {
  1486. return uintptr(n)
  1487. }
  1488. func StrPtr(s string) uintptr {
  1489. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1490. }
  1491. type Charset string
  1492. const (
  1493. UTF8 = Charset("UTF-8")
  1494. GB18030 = Charset("GB18030")
  1495. )
  1496. func ConvertToString(src string, srcCode string, tagCode string) string {
  1497. srcCoder := mahonia.NewDecoder(srcCode)
  1498. srcResult := srcCoder.ConvertString(src)
  1499. tagCoder := mahonia.NewDecoder(tagCode)
  1500. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1501. result := string(cdata)
  1502. return result
  1503. }
  1504. func DeleteExtraSpace(s string) string {
  1505. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1506. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1507. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1508. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1509. s2 := make([]byte, len(s1)) //定义字符数组切片
  1510. copy(s2, s1) //将字符串复制到切片
  1511. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1512. for len(spc_index) > 0 { //找到适配项
  1513. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1514. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1515. }
  1516. return string(s2)
  1517. }
  1518. func Remove0000(s string) string {
  1519. str := make([]rune, 0, len(s))
  1520. for _, v := range []rune(s) {
  1521. if v == 0 {
  1522. continue
  1523. }
  1524. str = append(str, v)
  1525. }
  1526. return string(str)
  1527. }
  1528. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1529. //org_id, _ := beego.AppConfig.Int64("org_id")
  1530. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1531. dir := org_name + "日志"
  1532. utils.Mkdir(dir)
  1533. month := time.Unix(1557042972, 0).Format("1")
  1534. year := time.Now().Format("2006")
  1535. month = time.Now().Format("01")
  1536. day := time.Now().Format("02")
  1537. hour := time.Now().Format("15")
  1538. min := time.Now().Format("04")
  1539. sec := time.Now().Format("05")
  1540. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1541. file := org_name + "_" + year + month + day + "_log"
  1542. file_name := file + ".txt"
  1543. file_path := org_name + "日志" + "/" + file_name
  1544. exist, _ := utils.PathExists(file_path)
  1545. if exist { //存在
  1546. fmt.Println("存在")
  1547. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1548. if err != nil {
  1549. fmt.Println("read fail")
  1550. }
  1551. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1552. n, _ := f.Seek(0, 2)
  1553. _, err = f.WriteAt([]byte(content), n)
  1554. } else { //不存在
  1555. fmt.Println("文件不存在,创建文件")
  1556. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1557. defer f.Close()
  1558. if err != nil {
  1559. } else {
  1560. _, err = f.Write([]byte("记录日志"))
  1561. }
  1562. }
  1563. }
  1564. func (c *NmController) Get3201() {
  1565. insutype := c.GetString("insutype")
  1566. clrType := c.GetString("clr_type")
  1567. setlOptins := c.GetString("setl_optins")
  1568. stmtBegndate := c.GetString("stmt_begndate")
  1569. stmtEnddate := c.GetString("stm_enddate")
  1570. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  1571. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  1572. acctPay, _ := c.GetFloat("acct_pay", 0)
  1573. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  1574. fixmedins_code := c.GetString("fixmedins_code")
  1575. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1576. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1577. secret_key := c.GetString("secret_key")
  1578. org_name := c.GetString("org_name")
  1579. doctor := c.GetString("doctor")
  1580. baseParams := models.BaseParams{
  1581. SecretKey: secret_key,
  1582. FixmedinsCode: fixmedins_code,
  1583. InsuplcAdmdvs: insuplc_admdvs,
  1584. MdtrtareaAdmvs: mdtrtarea_admvs,
  1585. OrgName: org_name,
  1586. Doctor: doctor,
  1587. }
  1588. businessParams := models.BusinessParams{
  1589. Insutype: insutype,
  1590. ClrType: clrType,
  1591. SetlOptins: setlOptins,
  1592. StmtBegndate: stmtBegndate,
  1593. StmtEnddate: stmtEnddate,
  1594. MedfeeSumamt: medfeeSumamt,
  1595. FundPaySumamt: fundPaySumamt,
  1596. AcctPay: acctPay,
  1597. FixmedinsSetlCnt: fixmedinsSetlCnt,
  1598. }
  1599. result := service.Gdyb3201(baseParams, businessParams)
  1600. saveJsLog(result, "", "3201", "对总账", org_name)
  1601. var dat map[string]interface{}
  1602. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1603. fmt.Println(dat)
  1604. } else {
  1605. fmt.Println(err)
  1606. }
  1607. c.ServeSuccessJSON(map[string]interface{}{
  1608. "pre": dat,
  1609. })
  1610. }
  1611. func (c *NmController) Get2601() {
  1612. result := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202210111721190000", "2305", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1613. var dat map[string]interface{}
  1614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1615. fmt.Println(dat)
  1616. } else {
  1617. fmt.Println(err)
  1618. }
  1619. result2 := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202209281143070000", "2304", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1620. var dat2 map[string]interface{}
  1621. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  1622. fmt.Println(dat2)
  1623. } else {
  1624. fmt.Println(err)
  1625. }
  1626. c.ServeSuccessJSON(map[string]interface{}{
  1627. "pre": dat,
  1628. })
  1629. }
  1630. func ConvertByte2String(byte []byte, charset Charset) string {
  1631. var str string
  1632. switch charset {
  1633. case GB18030:
  1634. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1635. str = string(decodeBytes)
  1636. case UTF8:
  1637. fallthrough
  1638. default:
  1639. str = string(byte)
  1640. }
  1641. return str
  1642. }