nm_controller.go 57KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800
  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. saveJsLog(result, "", "4103", "查询结算清单", org_name)
  760. var dat map[string]interface{}
  761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  762. } else {
  763. }
  764. c.ServeSuccessJSON(map[string]interface{}{
  765. "pre": dat,
  766. })
  767. }
  768. func (c *NmController) Post1101() {
  769. certNo := c.GetString("cert_no")
  770. org_name := c.GetString("org_name")
  771. doctor := c.GetString("doctor")
  772. fixmedins_code := c.GetString("fixmedins_code")
  773. insuplc_admdvs := c.GetString("insuplc_admdvs")
  774. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  775. secret_key := c.GetString("secret_key")
  776. id_card_type, _ := c.GetInt64("id_card_type")
  777. card_sn := c.GetString("card_sn")
  778. certificates := c.GetString("certificates")
  779. name := c.GetString("name")
  780. certificate, _ := strconv.ParseInt(certificates, 10, 64)
  781. 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)
  782. saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
  783. var dat map[string]interface{}
  784. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  785. } else {
  786. }
  787. var dat2 map[string]interface{}
  788. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  789. } else {
  790. }
  791. c.ServeSuccessJSON(map[string]interface{}{
  792. "pre": dat,
  793. "log": dat2,
  794. })
  795. }
  796. func (c *NmController) Post2401() {
  797. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  798. var respJSON map[string]interface{}
  799. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  801. return
  802. }
  803. userJSONBytes, _ := json.Marshal(respJSON["struct_2401"])
  804. var struct2401 service.Struct2401
  805. if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
  806. utils.ErrorLog("解析失败:%v", err)
  807. return
  808. }
  809. org_name := respJSON["org_name"].(string)
  810. fixmedins_code := respJSON["fixmedins_code"].(string)
  811. doctor := respJSON["doctor"].(string)
  812. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  813. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  814. secret_key := respJSON["secret_key"].(string)
  815. result, request_log := service.ZHGdyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  816. saveJsLog(result, request_log, "2401", "入院登记", org_name)
  817. var dat2 map[string]interface{}
  818. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  819. } else {
  820. }
  821. var dat map[string]interface{}
  822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  823. } else {
  824. }
  825. c.ServeSuccessJSON(map[string]interface{}{
  826. "pre": dat,
  827. "request_log": dat2,
  828. })
  829. }
  830. func (c *NmController) Post2404() {
  831. mdtrt_id := c.GetString("mdtrt_id")
  832. psn_no := c.GetString("psn_no")
  833. doctor := c.GetString("doctor")
  834. fixmedins_code := c.GetString("fixmedins_code")
  835. insuplc_admdvs := c.GetString("insuplc_admdvs")
  836. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  837. secret_key := c.GetString("secret_key")
  838. org_name := c.GetString("org_name")
  839. result, requestLog := service.ZHGdyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  840. saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
  841. var dat map[string]interface{}
  842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  843. } else {
  844. }
  845. var dat2 map[string]interface{}
  846. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  847. } else {
  848. }
  849. c.ServeSuccessJSON(map[string]interface{}{
  850. "pre": dat,
  851. "log": dat2,
  852. })
  853. }
  854. func (c *NmController) Post2405() {
  855. mdtrt_id := c.GetString("mdtrt_id")
  856. psn_no := c.GetString("psn_no")
  857. doctor := c.GetString("doctor")
  858. fixmedins_code := c.GetString("fixmedins_code")
  859. insuplc_admdvs := c.GetString("insuplc_admdvs")
  860. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  861. secret_key := c.GetString("secret_key")
  862. org_name := c.GetString("org_name")
  863. result, requestLog := service.ZHGdyb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  864. saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
  865. var dat map[string]interface{}
  866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  867. } else {
  868. }
  869. var dat2 map[string]interface{}
  870. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  871. } else {
  872. }
  873. c.ServeSuccessJSON(map[string]interface{}{
  874. "pre": dat,
  875. "log": dat2,
  876. })
  877. }
  878. func (c *NmController) Post2402() {
  879. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  880. var respJSON map[string]interface{}
  881. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  883. return
  884. }
  885. userJSONBytes, _ := json.Marshal(respJSON["struct_2402"])
  886. var struct2402 service.Struct2402
  887. if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
  888. utils.ErrorLog("解析失败:%v", err)
  889. return
  890. }
  891. org_name := respJSON["org_name"].(string)
  892. fixmedins_code := respJSON["fixmedins_code"].(string)
  893. doctor := respJSON["doctor"].(string)
  894. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  895. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  896. secret_key := respJSON["secret_key"].(string)
  897. result, request_log := service.ZHGdyb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  898. saveJsLog(result, request_log, "2402", "出院", org_name)
  899. var dat2 map[string]interface{}
  900. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  901. } else {
  902. }
  903. var dat map[string]interface{}
  904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  905. } else {
  906. }
  907. c.ServeSuccessJSON(map[string]interface{}{
  908. "pre": dat,
  909. "request_log": dat2,
  910. })
  911. }
  912. func (c *NmController) Post2301() {
  913. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  914. var respJSON map[string]interface{}
  915. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  917. return
  918. }
  919. userJSONBytes, _ := json.Marshal(respJSON["customs"])
  920. var customs []*models.NewCustom
  921. if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
  922. utils.ErrorLog("解析失败:%v", err)
  923. return
  924. }
  925. number := respJSON["number"].(string)
  926. chrg_bchno := respJSON["chrg_bchno"].(string)
  927. dept := respJSON["dept"].(string)
  928. dept_code := respJSON["dept_code"].(string)
  929. doctor_code := respJSON["doctor_code"].(string)
  930. doctor_name := respJSON["doctor_name"].(string)
  931. opertor := respJSON["opertor"].(string)
  932. org_name := respJSON["org_name"].(string)
  933. fixmedins_code := respJSON["fixmedins_code"].(string)
  934. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  935. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  936. secret_key := respJSON["secret_key"].(string)
  937. med_type := respJSON["med_type"].(string)
  938. //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
  939. psn_no := respJSON["psn_no"].(string)
  940. 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)
  941. saveJsLog(result, requestLog, "2301", "上传明细", org_name)
  942. var dat2 map[string]interface{}
  943. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  944. } else {
  945. }
  946. var dat map[string]interface{}
  947. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  948. } else {
  949. }
  950. c.ServeSuccessJSON(map[string]interface{}{
  951. "pre": dat,
  952. "request_log": dat2,
  953. })
  954. }
  955. func (c *NmController) Post2302() {
  956. mdtrt_id := c.GetString("mdtrtId")
  957. psn_no := c.GetString("psn_no")
  958. number := c.GetString("feedetl_sn")
  959. doctor := c.GetString("doctor")
  960. fixmedins_code := c.GetString("fixmedins_code")
  961. insuplc_admdvs := c.GetString("insuplc_admdvs")
  962. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  963. secret_key := c.GetString("secret_key")
  964. org_name := c.GetString("org_name")
  965. refund_type, _ := c.GetInt64("refund_type")
  966. result, requestLog := service.Gdyb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
  967. saveJsLog(result, requestLog, "2302", "退明细", org_name)
  968. var dat2 map[string]interface{}
  969. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  970. } else {
  971. }
  972. var dat map[string]interface{}
  973. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  974. } else {
  975. }
  976. c.ServeSuccessJSON(map[string]interface{}{
  977. "pre": dat,
  978. "request_log": dat2,
  979. })
  980. }
  981. func (c *NmController) Post2303() {
  982. mdtrt_id := c.GetString("mdtrt_id")
  983. psn_no := c.GetString("psn_no")
  984. chrg_bchno := c.GetString("chrg_bchno")
  985. cert_no := c.GetString("cert_no")
  986. insutype_type := c.GetString("insutype_type")
  987. allTotal := c.GetString("total")
  988. id_card_type, _ := c.GetInt64("id_card_type")
  989. doctor := c.GetString("doctor")
  990. certificates, _ := c.GetInt64("certificates")
  991. fixmedins_code := c.GetString("fixmedins_code")
  992. insuplc_admdvs := c.GetString("insuplc_admdvs")
  993. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  994. secret_key := c.GetString("secret_key")
  995. org_name := c.GetString("org_name")
  996. 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)
  997. saveJsLog(result, src_resquest, "2303", "预结算", org_name)
  998. var dat2 map[string]interface{}
  999. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1000. } else {
  1001. }
  1002. var dat map[string]interface{}
  1003. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1004. } else {
  1005. }
  1006. c.ServeSuccessJSON(map[string]interface{}{
  1007. "pre": dat,
  1008. "request_log": dat2,
  1009. })
  1010. }
  1011. func (c *NmController) Post2304() {
  1012. mdtrt_id := c.GetString("mdtrt_id")
  1013. psn_no := c.GetString("psn_no")
  1014. chrg_bchno := c.GetString("chrg_bchno")
  1015. cert_no := c.GetString("cert_no")
  1016. insutype_type := c.GetString("insutype_type")
  1017. allTotal := c.GetString("total")
  1018. id_card_type, _ := c.GetInt64("id_card_type")
  1019. doctor := c.GetString("doctor")
  1020. certificates, _ := c.GetInt64("certificates")
  1021. fixmedins_code := c.GetString("fixmedins_code")
  1022. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1023. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1024. secret_key := c.GetString("secret_key")
  1025. org_name := c.GetString("org_name")
  1026. fapiao_number := c.GetString("fapiao_number")
  1027. acct_used_flag := c.GetString("acct_used_flag")
  1028. 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)
  1029. saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
  1030. var dat2 map[string]interface{}
  1031. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1032. } else {
  1033. }
  1034. var dat map[string]interface{}
  1035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1036. } else {
  1037. }
  1038. c.ServeSuccessJSON(map[string]interface{}{
  1039. "pre": dat,
  1040. "request_log": dat2,
  1041. })
  1042. }
  1043. func (c *NmController) Post2305() {
  1044. mdtrt_id := c.GetString("mdtrt_id")
  1045. psn_no := c.GetString("psn_no")
  1046. doctor := c.GetString("doctor")
  1047. setl_id := c.GetString("setl_id")
  1048. fixmedins_code := c.GetString("fixmedins_code")
  1049. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1050. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1051. secret_key := c.GetString("secret_key")
  1052. org_name := c.GetString("org_name")
  1053. result, requestLog := service.Gdyb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1054. saveJsLog(result, requestLog, "2305", "退费", org_name)
  1055. var dat2 map[string]interface{}
  1056. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1057. } else {
  1058. }
  1059. var dat map[string]interface{}
  1060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1061. } else {
  1062. }
  1063. c.ServeSuccessJSON(map[string]interface{}{
  1064. "pre": dat,
  1065. "request_log": dat2,
  1066. })
  1067. }
  1068. func (c *NmController) Get2503() {
  1069. }
  1070. func (c *NmController) ReadCard() {
  1071. fixmedins_code := c.GetString("fixmedins_code")
  1072. secret_key := c.GetString("secret_key")
  1073. org_name := c.GetString("org_name")
  1074. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1075. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1076. id_card_type := c.GetString("id_card_type")
  1077. operator_id := c.GetString("operator_id")
  1078. operator := c.GetString("operator")
  1079. is_settle := c.GetString("is_settle")
  1080. switch id_card_type {
  1081. case "1":
  1082. if initFlag == 0 {
  1083. c.TestGetBasBaseInit()
  1084. }
  1085. pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
  1086. basStr := Remove0000(pBusiCardInfo)
  1087. if len(basStr) == 0 {
  1088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1089. return
  1090. }
  1091. var dat2 map[string]interface{}
  1092. if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
  1093. fmt.Println(dat2)
  1094. } else {
  1095. fmt.Println(err)
  1096. }
  1097. userJSONBytes, _ := json.Marshal(dat2)
  1098. var res ReadCardResult
  1099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1100. utils.ErrorLog("解析失败:%v", err)
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1102. return
  1103. }
  1104. fmt.Println(basStr)
  1105. bas := strings.Split(res.Output.CardInfo, "|")
  1106. basNumber := bas[1]
  1107. fmt.Println(basNumber)
  1108. card_sn := bas[3]
  1109. fmt.Println(card_sn)
  1110. cardNumber := bas[2]
  1111. name := bas[4]
  1112. result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
  1113. var dat map[string]interface{}
  1114. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1115. fmt.Println(dat)
  1116. } else {
  1117. fmt.Println(err)
  1118. }
  1119. userJSONBytes2, _ := json.Marshal(dat)
  1120. var res2 ResultTwo
  1121. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1122. utils.ErrorLog("解析失败:%v", err)
  1123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1124. return
  1125. }
  1126. infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
  1127. if infocode == 0 {
  1128. c.ServeSuccessJSON(map[string]interface{}{
  1129. "status": "0",
  1130. "card_info": res.Output.CardInfo,
  1131. "busi_card_info": pBusiCardInfo,
  1132. "result": res2,
  1133. "type": "1",
  1134. })
  1135. } else {
  1136. c.ServeSuccessJSON(map[string]interface{}{
  1137. "status": "-1",
  1138. })
  1139. }
  1140. break
  1141. case "4": //电子凭证
  1142. //c.GetELeInfo()
  1143. var result_info string
  1144. if len(is_settle) > 0 {
  1145. _, result_info = c.GetELeInfo(fixmedins_code, operator_id, operator)
  1146. } else {
  1147. _, result_info = c.GetELeInfoThree(fixmedins_code, operator_id, operator)
  1148. }
  1149. //if result_code == "0000" {
  1150. var ele ELeData
  1151. err := json.Unmarshal([]byte(result_info), &ele)
  1152. if err != nil {
  1153. utils.ErrorLog("解析失败:%v", err)
  1154. }
  1155. token := ele.Data.EcToken
  1156. fmt.Println(token)
  1157. if len(token) > 0 {
  1158. result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.UserName, ele.Data.IdNo)
  1159. var dat map[string]interface{}
  1160. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1161. fmt.Println(dat)
  1162. } else {
  1163. fmt.Println(err)
  1164. }
  1165. userJSONBytes, _ := json.Marshal(dat)
  1166. var res ResultTwo
  1167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1168. utils.ErrorLog("解析失败:%v", err)
  1169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1170. return
  1171. }
  1172. infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1173. if infocode == 0 {
  1174. c.ServeSuccessJSON(map[string]interface{}{
  1175. "status": "0",
  1176. "card_info": result_info,
  1177. "busi_card_info": result_info,
  1178. "token": token,
  1179. "result": dat,
  1180. })
  1181. } else {
  1182. c.ServeSuccessJSON(map[string]interface{}{
  1183. "status": "-1",
  1184. })
  1185. }
  1186. } else {
  1187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1188. return
  1189. }
  1190. break
  1191. case "5": //电子凭证
  1192. //c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1193. //_, pBusiCardInfo := c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1194. //var ele ELeData
  1195. //err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  1196. //if err != nil {
  1197. // utils.ErrorLog("解析失败:%v", err)
  1198. //}
  1199. //token := ele.Data.EcToken
  1200. //fmt.Println(token)
  1201. //if len(token) > 0 {
  1202. // result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.IdNo, ele.Data.UserName)
  1203. // var dat map[string]interface{}
  1204. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1205. // fmt.Println(dat)
  1206. // } else {
  1207. // fmt.Println(err)
  1208. // }
  1209. // userJSONBytes, _ := json.Marshal(dat)
  1210. // var res ResultTwo
  1211. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1212. // utils.ErrorLog("解析失败:%v", err)
  1213. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1214. // return
  1215. // }
  1216. //
  1217. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1218. //
  1219. // if infocode == 0 {
  1220. //
  1221. // c.ServeSuccessJSON(map[string]interface{}{
  1222. // "status": "0",
  1223. // "card_info": pBusiCardInfo,
  1224. // "busi_card_info": pBusiCardInfo,
  1225. // "token": token,
  1226. // "result": dat,
  1227. // })
  1228. //
  1229. // } else {
  1230. // c.ServeSuccessJSON(map[string]interface{}{
  1231. // "status": "-1",
  1232. // })
  1233. //
  1234. // }
  1235. //} else {
  1236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1237. // return
  1238. //}
  1239. //break
  1240. }
  1241. }
  1242. var initFlag int64 = 0
  1243. func (c *NmController) GetELeInfoTwo(code string, operator_id string, operator_name string) (string, string) {
  1244. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  1245. readCard := DllDef.MustFindProc("NationEcTrans")
  1246. fmt.Println(readCard)
  1247. fmt.Println("!!!!!")
  1248. pBusiCardInfo := make([]byte, 1024*10)
  1249. input := make(map[string]interface{})
  1250. inputData := make(map[string]interface{})
  1251. inputData["orgId"] = code
  1252. inputData["businessType"] = "01101"
  1253. inputData["operatorId"] = operator_id
  1254. inputData["operatorName"] = operator_name
  1255. inputData["officeId"] = "001"
  1256. inputData["officeName"] = "血透室"
  1257. inputData["deviceType"] = ""
  1258. input["data"] = inputData
  1259. input["orgId"] = code
  1260. input["transType"] = "ec.query"
  1261. bytesData, _ := json.Marshal(input)
  1262. //gdyb_url := beego.AppConfig.String("gdyb_url")
  1263. fmt.Println(string(bytesData))
  1264. url := "http://10.38.22.15:8081" + "/localcfc/api/hsecfc/localQrCodeQuery"
  1265. ret2, aa, bb := readCard.Call(StrPtr(url), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1266. fmt.Println(aa)
  1267. fmt.Println(bb)
  1268. fmt.Println(ret2)
  1269. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1270. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1271. if ret2 != 0 {
  1272. return "", ""
  1273. }
  1274. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1275. }
  1276. func (c *NmController) TestGetBasBaseInit() {
  1277. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1278. Iinit := DllDef.MustFindProc("Init")
  1279. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1280. str := make([]byte, 2048)
  1281. inputData := make(map[string]interface{})
  1282. inputData["IP"] = "tyjk.nm.hsip.gov.cn"
  1283. inputData["PORT"] = 8090
  1284. inputData["TIMEOUT"] = 180
  1285. inputData["LOG_PATH"] = "C:\\log\\"
  1286. //inputData["SFZ_DRIVER_TYPE"] = 0
  1287. inputData["URL"] = "/uif-hsaf-med-api/api/medical/service"
  1288. bytesData, _ := json.Marshal(inputData)
  1289. fmt.Println(inputData)
  1290. fmt.Println(bytesData)
  1291. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  1292. if ret != 0 {
  1293. fmt.Println("SSCard的报错原因:", err)
  1294. fmt.Println("SSCard的运算结果为:", ret)
  1295. fmt.Println("SSCard的返回结果为:", string(str))
  1296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1297. return
  1298. }
  1299. fmt.Println("SSCard的返回结果为:", string(str))
  1300. result := int(ret)
  1301. fmt.Println("SSCard的运算结果为1:", result)
  1302. //initFlag = 1
  1303. return
  1304. }
  1305. func (c *NmController) GetSFZBaseInfo() string {
  1306. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1307. readCard := DllDef.MustFindProc("ReadSFZ")
  1308. if readCard == nil {
  1309. fmt.Println("readcard is nil")
  1310. readCard = DllDef.MustFindProc("ReadSFZ")
  1311. }
  1312. str := make([]byte, 256)
  1313. str1 := make([]byte, 256)
  1314. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1315. fmt.Println(r)
  1316. return string(str)
  1317. }
  1318. func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  1319. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1320. readCard := DllDef.MustFindProc("ReadCardBas")
  1321. fmt.Println(readCard)
  1322. fmt.Println("!!!!!")
  1323. month := time.Unix(1557042972, 0).Format("1")
  1324. year := time.Now().Format("2006")
  1325. month = time.Now().Format("01")
  1326. day := time.Now().Format("02")
  1327. hour := time.Now().Format("15")
  1328. min := time.Now().Format("04")
  1329. sec := time.Now().Format("05")
  1330. msec := time.Now().Format("000")
  1331. timestamp := time.Now().Unix()
  1332. tempTime := time.Unix(timestamp, 0)
  1333. //timeFormat := tempTime.Format("20060102150405")
  1334. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1335. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  1336. inputData := make(map[string]interface{})
  1337. inputData["infno"] = "1199"
  1338. //inputData["msgid"] = "7021"
  1339. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  1340. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  1341. inputData["insuplc_admdvs"] = "" // 发送方报文 ID
  1342. // 发送方报文 ID
  1343. inputData["recer_sys_code"] = "01"
  1344. inputData["dev_no"] = ""
  1345. inputData["dev_safe_info"] = ""
  1346. inputData["cainfo"] = ""
  1347. inputData["signtype"] = "SM3"
  1348. inputData["infver"] = "V1.0"
  1349. inputData["opter_type"] = "1"
  1350. inputData["opter"] = opter_id
  1351. inputData["opter_name"] = opter_name
  1352. inputData["inf_time"] = timeFormatOne
  1353. inputData["fixmedins_code"] = fixmedins_code
  1354. inputData["fixmedins_name"] = fixmedins_name
  1355. inputData["sign_no"] = ""
  1356. bytesData, _ := json.Marshal(inputData)
  1357. fmt.Println(string(bytesData))
  1358. pBusiCardInfo := make([]byte, 8192)
  1359. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1360. fmt.Println(ret2)
  1361. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1362. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1363. if ret2 != 0 {
  1364. return ""
  1365. }
  1366. return DeleteExtraSpace(string(pBusiCardInfo))
  1367. }
  1368. func (c *NmController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  1369. // WebSocket服务器地址
  1370. serverURL := "ws://127.0.0.1:8899"
  1371. // 解析WebSocket服务器地址
  1372. u, err := url.Parse(serverURL)
  1373. if err != nil {
  1374. log.Fatal(err)
  1375. }
  1376. // 建立WebSocket连接
  1377. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1378. if err != nil {
  1379. log.Fatal(err)
  1380. }
  1381. defer conn.Close()
  1382. input2 := make(map[string]interface{})
  1383. input := make(map[string]interface{})
  1384. inputData := make(map[string]interface{})
  1385. inputData["orgId"] = code
  1386. inputData["businessType"] = "01101"
  1387. inputData["operatorId"] = operator_id
  1388. inputData["operatorName"] = operator_name
  1389. inputData["officeId"] = "001"
  1390. inputData["officeName"] = "血透室"
  1391. inputData["deviceType"] = ""
  1392. input["data"] = inputData
  1393. input["orgId"] = code
  1394. input["transType"] = "ec.query"
  1395. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1396. input2["indata"] = input
  1397. bytesData, _ := json.Marshal(input2)
  1398. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1399. if err != nil {
  1400. fmt.Println(err)
  1401. }
  1402. // 接收消息
  1403. _, receivedMessage, err := conn.ReadMessage()
  1404. if err != nil {
  1405. fmt.Println(err)
  1406. }
  1407. return "", string(receivedMessage)
  1408. }
  1409. func (c *NmController) GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  1410. // WebSocket服务器地址
  1411. serverURL := "ws://127.0.0.1:8899"
  1412. // 解析WebSocket服务器地址
  1413. u, err := url.Parse(serverURL)
  1414. if err != nil {
  1415. log.Fatal(err)
  1416. }
  1417. // 建立WebSocket连接
  1418. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1419. if err != nil {
  1420. log.Fatal(err)
  1421. }
  1422. defer conn.Close()
  1423. input2 := make(map[string]interface{})
  1424. input := make(map[string]interface{})
  1425. inputData := make(map[string]interface{})
  1426. inputData["orgId"] = code
  1427. inputData["businessType"] = "01301"
  1428. inputData["operatorId"] = operator_id
  1429. inputData["operatorName"] = operator_name
  1430. inputData["officeId"] = "001"
  1431. inputData["officeName"] = "血透室"
  1432. inputData["deviceType"] = ""
  1433. input["data"] = inputData
  1434. input["orgId"] = code
  1435. input["transType"] = "ec.query"
  1436. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1437. input2["indata"] = input
  1438. bytesData, _ := json.Marshal(input2)
  1439. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1440. if err != nil {
  1441. fmt.Println(err)
  1442. }
  1443. // 接收消息
  1444. _, receivedMessage, err := conn.ReadMessage()
  1445. if err != nil {
  1446. fmt.Println(err)
  1447. }
  1448. return "", string(receivedMessage)
  1449. }
  1450. func IntPtr(n int) uintptr {
  1451. return uintptr(n)
  1452. }
  1453. func StrPtr(s string) uintptr {
  1454. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1455. }
  1456. type Charset string
  1457. const (
  1458. UTF8 = Charset("UTF-8")
  1459. GB18030 = Charset("GB18030")
  1460. )
  1461. func ConvertToString(src string, srcCode string, tagCode string) string {
  1462. srcCoder := mahonia.NewDecoder(srcCode)
  1463. srcResult := srcCoder.ConvertString(src)
  1464. tagCoder := mahonia.NewDecoder(tagCode)
  1465. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1466. result := string(cdata)
  1467. return result
  1468. }
  1469. func DeleteExtraSpace(s string) string {
  1470. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1471. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1472. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1473. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1474. s2 := make([]byte, len(s1)) //定义字符数组切片
  1475. copy(s2, s1) //将字符串复制到切片
  1476. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1477. for len(spc_index) > 0 { //找到适配项
  1478. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1479. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1480. }
  1481. return string(s2)
  1482. }
  1483. func Remove0000(s string) string {
  1484. str := make([]rune, 0, len(s))
  1485. for _, v := range []rune(s) {
  1486. if v == 0 {
  1487. continue
  1488. }
  1489. str = append(str, v)
  1490. }
  1491. return string(str)
  1492. }
  1493. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1494. //org_id, _ := beego.AppConfig.Int64("org_id")
  1495. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1496. dir := org_name + "日志"
  1497. utils.Mkdir(dir)
  1498. month := time.Unix(1557042972, 0).Format("1")
  1499. year := time.Now().Format("2006")
  1500. month = time.Now().Format("01")
  1501. day := time.Now().Format("02")
  1502. hour := time.Now().Format("15")
  1503. min := time.Now().Format("04")
  1504. sec := time.Now().Format("05")
  1505. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1506. file := org_name + "_" + year + month + day + "_log"
  1507. file_name := file + ".txt"
  1508. file_path := org_name + "日志" + "/" + file_name
  1509. exist, _ := utils.PathExists(file_path)
  1510. if exist { //存在
  1511. fmt.Println("存在")
  1512. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1513. if err != nil {
  1514. fmt.Println("read fail")
  1515. }
  1516. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1517. n, _ := f.Seek(0, 2)
  1518. _, err = f.WriteAt([]byte(content), n)
  1519. } else { //不存在
  1520. fmt.Println("文件不存在,创建文件")
  1521. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1522. defer f.Close()
  1523. if err != nil {
  1524. } else {
  1525. _, err = f.Write([]byte("记录日志"))
  1526. }
  1527. }
  1528. }
  1529. func (c *NmController) Get3201() {
  1530. insutype := c.GetString("insutype")
  1531. clrType := c.GetString("clr_type")
  1532. setlOptins := c.GetString("setl_optins")
  1533. stmtBegndate := c.GetString("stmt_begndate")
  1534. stmtEnddate := c.GetString("stm_enddate")
  1535. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  1536. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  1537. acctPay, _ := c.GetFloat("acct_pay", 0)
  1538. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  1539. fixmedins_code := c.GetString("fixmedins_code")
  1540. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1541. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1542. secret_key := c.GetString("secret_key")
  1543. org_name := c.GetString("org_name")
  1544. doctor := c.GetString("doctor")
  1545. baseParams := models.BaseParams{
  1546. SecretKey: secret_key,
  1547. FixmedinsCode: fixmedins_code,
  1548. InsuplcAdmdvs: insuplc_admdvs,
  1549. MdtrtareaAdmvs: mdtrtarea_admvs,
  1550. OrgName: org_name,
  1551. Doctor: doctor,
  1552. }
  1553. businessParams := models.BusinessParams{
  1554. Insutype: insutype,
  1555. ClrType: clrType,
  1556. SetlOptins: setlOptins,
  1557. StmtBegndate: stmtBegndate,
  1558. StmtEnddate: stmtEnddate,
  1559. MedfeeSumamt: medfeeSumamt,
  1560. FundPaySumamt: fundPaySumamt,
  1561. AcctPay: acctPay,
  1562. FixmedinsSetlCnt: fixmedinsSetlCnt,
  1563. }
  1564. result := service.Gdyb3201(baseParams, businessParams)
  1565. saveJsLog(result, "", "3201", "对总账", org_name)
  1566. var dat map[string]interface{}
  1567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1568. fmt.Println(dat)
  1569. } else {
  1570. fmt.Println(err)
  1571. }
  1572. c.ServeSuccessJSON(map[string]interface{}{
  1573. "pre": dat,
  1574. })
  1575. }
  1576. func (c *NmController) Get2601() {
  1577. result := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202210111721190000", "2305", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1578. var dat map[string]interface{}
  1579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1580. fmt.Println(dat)
  1581. } else {
  1582. fmt.Println(err)
  1583. }
  1584. result2 := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202209281143070000", "2304", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1585. var dat2 map[string]interface{}
  1586. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  1587. fmt.Println(dat2)
  1588. } else {
  1589. fmt.Println(err)
  1590. }
  1591. c.ServeSuccessJSON(map[string]interface{}{
  1592. "pre": dat,
  1593. })
  1594. }
  1595. func ConvertByte2String(byte []byte, charset Charset) string {
  1596. var str string
  1597. switch charset {
  1598. case GB18030:
  1599. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1600. str = string(decodeBytes)
  1601. case UTF8:
  1602. fallthrough
  1603. default:
  1604. str = string(byte)
  1605. }
  1606. return str
  1607. }