nm_controller.go 59KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836
  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. //
  438. // result, _ := service.Gdyb1101ForEleCert("赤峰费森血液透析中心", "关学丽", "H15049901371", "150499", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", token, user_name, id_card_no)
  439. // var dat map[string]interface{}
  440. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  441. // fmt.Println(dat)
  442. // } else {
  443. // fmt.Println(err)
  444. // }
  445. // userJSONBytes, _ := json.Marshal(dat)
  446. // var res ResultTwo
  447. //
  448. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  449. // utils.ErrorLog("解析失败:%v", err)
  450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  451. // return
  452. // }
  453. //
  454. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  455. // if infocode == 0 {
  456. // data := make(map[string]interface{})
  457. // data["token"] = token
  458. // data["result"] = dat
  459. // var req *http.Request
  460. // bytesData, _ := json.Marshal(data)
  461. // req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/ele/info", bytes.NewReader(bytesData))
  462. // client := &http.Client{}
  463. // resp, _ := client.Do(req)
  464. // defer resp.Body.Close()
  465. // body, ioErr := ioutil.ReadAll(resp.Body)
  466. // if ioErr != nil {
  467. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  468. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. // return
  470. // }
  471. // var respJSON map[string]interface{}
  472. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  475. // return
  476. // }
  477. // c.ServeSuccessJSON(map[string]interface{}{
  478. // "msg": "成功",
  479. // })
  480. //
  481. // }
  482. //}
  483. func (c *NmController) GetToken() {
  484. token := c.GetString("token")
  485. results := strings.Split(token, "-")
  486. fmt.Println(token)
  487. result_code := results[0]
  488. result_info := results[1]
  489. if result_code == "0000" {
  490. var ele2 ELeData2
  491. err := json.Unmarshal([]byte(result_info), &ele2)
  492. if err != nil {
  493. utils.ErrorLog("解析失败:%v", err)
  494. }
  495. if ele2.Code != -2 {
  496. var ele ELeData
  497. err := json.Unmarshal([]byte(result_info), &ele)
  498. if err != nil {
  499. utils.ErrorLog("解析失败:%v", err)
  500. }
  501. token := ele.Data.EcToken
  502. if len(token) > 0 {
  503. data := make(map[string]interface{})
  504. data["token"] = token
  505. data["id_card_no"] = ele.Data.IdNo
  506. fmt.Println(data)
  507. var req *http.Request
  508. fmt.Println(req)
  509. bytesData, _ := json.Marshal(data)
  510. fmt.Println(bytesData)
  511. req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/token/get", bytes.NewReader(bytesData))
  512. fmt.Println(req)
  513. client := &http.Client{}
  514. resp, _ := client.Do(req)
  515. fmt.Println(resp)
  516. defer resp.Body.Close()
  517. body, ioErr := ioutil.ReadAll(resp.Body)
  518. fmt.Println(resp.Body)
  519. fmt.Println(body)
  520. fmt.Println(ioErr)
  521. if ioErr != nil {
  522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  524. return
  525. }
  526. var respJSON map[string]interface{}
  527. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  530. return
  531. }
  532. } else {
  533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  534. return
  535. }
  536. }
  537. } else {
  538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  539. return
  540. }
  541. }
  542. type ReadCardResult struct {
  543. Output struct {
  544. CardInfo string `json:"cardInfo"`
  545. RegionCode string `json:"regionCode"`
  546. } `json:"output"`
  547. Code string `json:"CODE"`
  548. ErrMsg string `json:"ERRMSG"`
  549. }
  550. type ELeData2 struct {
  551. Code int `json:"code"`
  552. Message string `json:"message"`
  553. }
  554. type ELeData struct {
  555. Data struct {
  556. IdNo string `json:"idNo"`
  557. IdType string `json:"idType"`
  558. UserName string `json:"userName"`
  559. EcToken string `json:"ecToken"`
  560. InsuOrg string `json:"insuOrg"`
  561. Gender string `json:"gender"`
  562. Birthday string `json:"birthday"`
  563. Nationality string `json:"nationality"`
  564. Email string `json:"email"`
  565. Extra string `json:"extra"`
  566. } `json:"data"`
  567. Code int `json:"code"`
  568. Message string `json:"message"`
  569. }
  570. type ResultTwo struct {
  571. ErrMsg string `json:"err_msg"`
  572. InfRefmsgid string `json:"inf_refmsgid"`
  573. Infcode string `json:"infcode"`
  574. Output struct {
  575. Baseinfo struct {
  576. Age float64 `json:"age"`
  577. Brdy string `json:"brdy"`
  578. Certno string `json:"certno"`
  579. Gend string `json:"gend"`
  580. Naty string `json:"naty"`
  581. PsnCertType string `json:"psn_cert_type"`
  582. PsnName string `json:"psn_name"`
  583. PsnNo string `json:"psn_no"`
  584. } `json:"baseinfo"`
  585. Idetinfo []interface{} `json:"idetinfo"`
  586. Iinfo []struct {
  587. Balc float64 `json:"balc"`
  588. CvlservFlag string `json:"cvlserv_flag"`
  589. EmpName string `json:"emp_name"`
  590. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  591. Insutype string `json:"insutype"`
  592. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  593. PausInsuDate string `json:"paus_insu_date"`
  594. PsnInsuDate string `json:"psn_insu_date"`
  595. PsnInsuStas string `json:"psn_insu_stas"`
  596. PsnType string `json:"psn_type"`
  597. } `json:"insuinfo"`
  598. } `json:"output"`
  599. RefmsgTime string `json:"refmsg_time"`
  600. RespondTime string `json:"respond_time"`
  601. Signtype interface{} `json:"signtype"`
  602. WarnInfo interface{} `json:"warn_info"`
  603. }
  604. type ResultTwo10265 struct {
  605. ErrMsg string `json:"err_msg"`
  606. InfRefmsgid string `json:"inf_refmsgid"`
  607. Infcode string `json:"infcode"`
  608. Output struct {
  609. Baseinfo struct {
  610. Age float64 `json:"age"`
  611. Brdy string `json:"brdy"`
  612. Certno string `json:"certno"`
  613. Gend string `json:"gend"`
  614. Naty string `json:"naty"`
  615. PsnCertType string `json:"psn_cert_type"`
  616. PsnName string `json:"psn_name"`
  617. PsnNo string `json:"psn_no"`
  618. } `json:"baseinfo"`
  619. Idetinfo []interface{} `json:"idetinfo"`
  620. Iinfo []struct {
  621. Balc float64 `json:"balc"`
  622. CvlservFlag string `json:"cvlserv_flag"`
  623. EmpName string `json:"emp_name"`
  624. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  625. Insutype string `json:"insutype"`
  626. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  627. PausInsuDate string `json:"paus_insu_date"`
  628. PsnInsuDate string `json:"psn_insu_date"`
  629. PsnInsuStas string `json:"psn_insu_stas"`
  630. PsnType string `json:"psn_type"`
  631. } `json:"insuinfo"`
  632. } `json:"output"`
  633. RefmsgTime string `json:"refmsg_time"`
  634. RespondTime string `json:"respond_time"`
  635. Signtype interface{} `json:"signtype"`
  636. WarnInfo interface{} `json:"warn_info"`
  637. }
  638. func (c *NmController) Post4101() {
  639. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  640. var respJSON map[string]interface{}
  641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  643. return
  644. }
  645. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  646. var struct4101 service.Struct4101
  647. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  648. utils.ErrorLog("解析失败:%v", err)
  649. return
  650. }
  651. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  652. var pp models.PublicParams
  653. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  654. utils.ErrorLog("解析失败:%v", err)
  655. return
  656. }
  657. result, _ := service.Gdyb4101fornm(struct4101, pp.SecretKey, pp.FixmedinsName, pp.OpterName, pp.FixmedinsCode, pp.InsuplcAdmdvs, pp.MdtrtareaAdmvs, 0,0)
  658. var dat map[string]interface{}
  659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  660. fmt.Println(dat)
  661. } else {
  662. fmt.Println(err)
  663. }
  664. saveJsLog(result, "", "4101", "上传明细清单", pp.FixmedinsName)
  665. c.ServeSuccessJSON(map[string]interface{}{
  666. "pre": dat,
  667. })
  668. }
  669. func (c *NmController) Post5203() {
  670. fmt.Println("------")
  671. org_name := c.GetString("org_name")
  672. doctor := c.GetString("doctor")
  673. fixmedins_code := c.GetString("fixmedins_code")
  674. insuplc_admdvs := c.GetString("insuplc_admdvs")
  675. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  676. secret_key := c.GetString("secret_key")
  677. psn_no := c.GetString("psn_no")
  678. mdtrt_id := c.GetString("mdtrt_id")
  679. setl_id := c.GetString("setl_id")
  680. fmt.Println("------")
  681. bp := models.BaseParams{
  682. SecretKey: secret_key,
  683. FixmedinsCode: fixmedins_code,
  684. InsuplcAdmdvs: insuplc_admdvs,
  685. MdtrtareaAdmvs: mdtrtarea_admvs,
  686. OrgName: org_name,
  687. Doctor: doctor,
  688. }
  689. bps := models.BusinessParams{
  690. PsnNo: psn_no,
  691. MdtrtId: mdtrt_id,
  692. SetlId: setl_id,
  693. }
  694. result := service.ZHyb5203(bp, bps)
  695. saveJsLog(result, "", "5203", "结算单", org_name)
  696. var dat map[string]interface{}
  697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  698. } else {
  699. }
  700. c.ServeSuccessJSON(map[string]interface{}{
  701. "pre": dat,
  702. })
  703. }
  704. func (c *NmController) Post4102() {
  705. org_name := c.GetString("org_name")
  706. doctor := c.GetString("doctor")
  707. fixmedins_code := c.GetString("fixmedins_code")
  708. insuplc_admdvs := c.GetString("insuplc_admdvs")
  709. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  710. secret_key := c.GetString("secret_key")
  711. psn_no := c.GetString("psn_no")
  712. mdtrt_id := c.GetString("mdtrt_id")
  713. setl_id := c.GetString("setl_id")
  714. stas_type := c.GetString("stas_type")
  715. bp := models.BaseParams{
  716. SecretKey: secret_key,
  717. FixmedinsCode: fixmedins_code,
  718. InsuplcAdmdvs: insuplc_admdvs,
  719. MdtrtareaAdmvs: mdtrtarea_admvs,
  720. OrgName: org_name,
  721. Doctor: doctor,
  722. }
  723. bps := models.BusinessParams{
  724. PsnNo: psn_no,
  725. MdtrtId: mdtrt_id,
  726. SetlId: setl_id,
  727. StasType: stas_type,
  728. }
  729. result := service.ZHyb4102(bp, bps)
  730. saveJsLog(result, "", "4102", "确认结算清单", org_name)
  731. var dat map[string]interface{}
  732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  733. } else {
  734. }
  735. c.ServeSuccessJSON(map[string]interface{}{
  736. "pre": dat,
  737. })
  738. }
  739. func (c *NmController) Post4103() {
  740. org_name := c.GetString("org_name")
  741. doctor := c.GetString("doctor")
  742. fixmedins_code := c.GetString("fixmedins_code")
  743. insuplc_admdvs := c.GetString("insuplc_admdvs")
  744. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  745. secret_key := c.GetString("secret_key")
  746. psn_no := c.GetString("psn_no")
  747. mdtrt_id := c.GetString("mdtrt_id")
  748. setl_id := c.GetString("setl_id")
  749. bp := models.BaseParams{
  750. SecretKey: secret_key,
  751. FixmedinsCode: fixmedins_code,
  752. InsuplcAdmdvs: insuplc_admdvs,
  753. MdtrtareaAdmvs: mdtrtarea_admvs,
  754. OrgName: org_name,
  755. Doctor: doctor,
  756. }
  757. bps := models.BusinessParams{
  758. PsnNo: psn_no,
  759. MdtrtId: mdtrt_id,
  760. SetlId: setl_id,
  761. }
  762. result := service.ZHyb4103(bp, bps)
  763. result2 := service.ZHyb4104(bp, bps)
  764. saveJsLog(result, "", "4103", "查询结算清单", org_name)
  765. saveJsLog(result2, "", "4104", "指控结算清单", org_name)
  766. var dat map[string]interface{}
  767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  768. } else {
  769. }
  770. c.ServeSuccessJSON(map[string]interface{}{
  771. "pre": dat,
  772. })
  773. }
  774. func (c *NmController) Post4104() {
  775. org_name := c.GetString("org_name")
  776. doctor := c.GetString("doctor")
  777. fixmedins_code := c.GetString("fixmedins_code")
  778. insuplc_admdvs := c.GetString("insuplc_admdvs")
  779. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  780. secret_key := c.GetString("secret_key")
  781. psn_no := c.GetString("psn_no")
  782. mdtrt_id := c.GetString("mdtrt_id")
  783. setl_id := c.GetString("setl_id")
  784. bp := models.BaseParams{
  785. SecretKey: secret_key,
  786. FixmedinsCode: fixmedins_code,
  787. InsuplcAdmdvs: insuplc_admdvs,
  788. MdtrtareaAdmvs: mdtrtarea_admvs,
  789. OrgName: org_name,
  790. Doctor: doctor,
  791. }
  792. bps := models.BusinessParams{
  793. PsnNo: psn_no,
  794. MdtrtId: mdtrt_id,
  795. SetlId: setl_id,
  796. }
  797. result := service.ZHyb4104(bp, bps)
  798. saveJsLog(result, "", "4104", "质控结算清单结果", org_name)
  799. var dat map[string]interface{}
  800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  801. } else {
  802. }
  803. c.ServeSuccessJSON(map[string]interface{}{
  804. "pre": dat,
  805. })
  806. }
  807. func (c *NmController) Post1101() {
  808. certNo := c.GetString("cert_no")
  809. org_name := c.GetString("org_name")
  810. doctor := c.GetString("doctor")
  811. fixmedins_code := c.GetString("fixmedins_code")
  812. insuplc_admdvs := c.GetString("insuplc_admdvs")
  813. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  814. secret_key := c.GetString("secret_key")
  815. id_card_type, _ := c.GetInt64("id_card_type")
  816. card_sn := c.GetString("card_sn")
  817. certificates := c.GetString("certificates")
  818. name := c.GetString("name")
  819. certificate, _ := strconv.ParseInt(certificates, 10, 64)
  820. 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,0)
  821. saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
  822. var dat map[string]interface{}
  823. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  824. } else {
  825. }
  826. var dat2 map[string]interface{}
  827. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  828. } else {
  829. }
  830. c.ServeSuccessJSON(map[string]interface{}{
  831. "pre": dat,
  832. "log": dat2,
  833. })
  834. }
  835. func (c *NmController) Post2401() {
  836. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  837. var respJSON map[string]interface{}
  838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  840. return
  841. }
  842. userJSONBytes, _ := json.Marshal(respJSON["struct_2401"])
  843. var struct2401 service.Struct2401
  844. if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
  845. utils.ErrorLog("解析失败:%v", err)
  846. return
  847. }
  848. org_name := respJSON["org_name"].(string)
  849. fixmedins_code := respJSON["fixmedins_code"].(string)
  850. doctor := respJSON["doctor"].(string)
  851. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  852. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  853. secret_key := respJSON["secret_key"].(string)
  854. result, request_log := service.Hbyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  855. saveJsLog(result, request_log, "2401", "入院登记", org_name)
  856. var dat2 map[string]interface{}
  857. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  858. } else {
  859. }
  860. var dat map[string]interface{}
  861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  862. } else {
  863. }
  864. c.ServeSuccessJSON(map[string]interface{}{
  865. "pre": dat,
  866. "request_log": dat2,
  867. })
  868. }
  869. func (c *NmController) Post2404() {
  870. mdtrt_id := c.GetString("mdtrt_id")
  871. psn_no := c.GetString("psn_no")
  872. doctor := c.GetString("doctor")
  873. fixmedins_code := c.GetString("fixmedins_code")
  874. insuplc_admdvs := c.GetString("insuplc_admdvs")
  875. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  876. secret_key := c.GetString("secret_key")
  877. org_name := c.GetString("org_name")
  878. result, requestLog := service.Hbyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  879. saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
  880. var dat map[string]interface{}
  881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  882. } else {
  883. }
  884. var dat2 map[string]interface{}
  885. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  886. } else {
  887. }
  888. c.ServeSuccessJSON(map[string]interface{}{
  889. "pre": dat,
  890. "log": dat2,
  891. })
  892. }
  893. func (c *NmController) Post2405() {
  894. mdtrt_id := c.GetString("mdtrt_id")
  895. psn_no := c.GetString("psn_no")
  896. doctor := c.GetString("doctor")
  897. fixmedins_code := c.GetString("fixmedins_code")
  898. insuplc_admdvs := c.GetString("insuplc_admdvs")
  899. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  900. secret_key := c.GetString("secret_key")
  901. org_name := c.GetString("org_name")
  902. result, requestLog := service.Hb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  903. saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
  904. var dat map[string]interface{}
  905. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  906. } else {
  907. }
  908. var dat2 map[string]interface{}
  909. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  910. } else {
  911. }
  912. c.ServeSuccessJSON(map[string]interface{}{
  913. "pre": dat,
  914. "log": dat2,
  915. })
  916. }
  917. func (c *NmController) Post2402() {
  918. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  919. var respJSON map[string]interface{}
  920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  922. return
  923. }
  924. userJSONBytes, _ := json.Marshal(respJSON["struct_2402"])
  925. var struct2402 service.Struct2402
  926. if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
  927. utils.ErrorLog("解析失败:%v", err)
  928. return
  929. }
  930. org_name := respJSON["org_name"].(string)
  931. fixmedins_code := respJSON["fixmedins_code"].(string)
  932. doctor := respJSON["doctor"].(string)
  933. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  934. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  935. secret_key := respJSON["secret_key"].(string)
  936. result, request_log := service.Hb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  937. saveJsLog(result, request_log, "2402", "出院", org_name)
  938. var dat2 map[string]interface{}
  939. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  940. } else {
  941. }
  942. var dat map[string]interface{}
  943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  944. } else {
  945. }
  946. c.ServeSuccessJSON(map[string]interface{}{
  947. "pre": dat,
  948. "request_log": dat2,
  949. })
  950. }
  951. func (c *NmController) Post2301() {
  952. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  953. var respJSON map[string]interface{}
  954. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  956. return
  957. }
  958. userJSONBytes, _ := json.Marshal(respJSON["customs"])
  959. var customs []*models.NewCustom
  960. if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
  961. utils.ErrorLog("解析失败:%v", err)
  962. return
  963. }
  964. number := respJSON["number"].(string)
  965. chrg_bchno := respJSON["chrg_bchno"].(string)
  966. dept := respJSON["dept"].(string)
  967. dept_code := respJSON["dept_code"].(string)
  968. doctor_code := respJSON["doctor_code"].(string)
  969. doctor_name := respJSON["doctor_name"].(string)
  970. opertor := respJSON["opertor"].(string)
  971. org_name := respJSON["org_name"].(string)
  972. fixmedins_code := respJSON["fixmedins_code"].(string)
  973. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  974. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  975. secret_key := respJSON["secret_key"].(string)
  976. med_type := respJSON["med_type"].(string)
  977. //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
  978. psn_no := respJSON["psn_no"].(string)
  979. result, requestLog := service.Hb2301A(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)
  980. saveJsLog(result, requestLog, "2301", "上传明细", org_name)
  981. var dat2 map[string]interface{}
  982. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  983. } else {
  984. }
  985. var dat map[string]interface{}
  986. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  987. } else {
  988. }
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "pre": dat,
  991. "request_log": dat2,
  992. })
  993. }
  994. func (c *NmController) Post2302() {
  995. mdtrt_id := c.GetString("mdtrtId")
  996. psn_no := c.GetString("psn_no")
  997. number := c.GetString("feedetl_sn")
  998. doctor := c.GetString("doctor")
  999. fixmedins_code := c.GetString("fixmedins_code")
  1000. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1001. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1002. secret_key := c.GetString("secret_key")
  1003. org_name := c.GetString("org_name")
  1004. refund_type, _ := c.GetInt64("refund_type")
  1005. result, requestLog := service.Hb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
  1006. saveJsLog(result, requestLog, "2302", "退明细", org_name)
  1007. var dat2 map[string]interface{}
  1008. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1009. } else {
  1010. }
  1011. var dat map[string]interface{}
  1012. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1013. } else {
  1014. }
  1015. c.ServeSuccessJSON(map[string]interface{}{
  1016. "pre": dat,
  1017. "request_log": dat2,
  1018. })
  1019. }
  1020. func (c *NmController) Post2303() {
  1021. mdtrt_id := c.GetString("mdtrt_id")
  1022. psn_no := c.GetString("psn_no")
  1023. chrg_bchno := c.GetString("chrg_bchno")
  1024. cert_no := c.GetString("cert_no")
  1025. insutype_type := c.GetString("insutype_type")
  1026. allTotal := c.GetString("total")
  1027. id_card_type, _ := c.GetInt64("id_card_type")
  1028. doctor := c.GetString("doctor")
  1029. certificates, _ := c.GetInt64("certificates")
  1030. fixmedins_code := c.GetString("fixmedins_code")
  1031. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1032. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1033. secret_key := c.GetString("secret_key")
  1034. org_name := c.GetString("org_name")
  1035. result, src_resquest := service.Hb2303(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)
  1036. saveJsLog(result, src_resquest, "2303", "预结算", org_name)
  1037. var dat2 map[string]interface{}
  1038. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1039. } else {
  1040. }
  1041. var dat map[string]interface{}
  1042. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1043. } else {
  1044. }
  1045. c.ServeSuccessJSON(map[string]interface{}{
  1046. "pre": dat,
  1047. "request_log": dat2,
  1048. })
  1049. }
  1050. func (c *NmController) Post2304() {
  1051. mdtrt_id := c.GetString("mdtrt_id")
  1052. psn_no := c.GetString("psn_no")
  1053. chrg_bchno := c.GetString("chrg_bchno")
  1054. cert_no := c.GetString("cert_no")
  1055. insutype_type := c.GetString("insutype_type")
  1056. allTotal := c.GetString("total")
  1057. id_card_type, _ := c.GetInt64("id_card_type")
  1058. doctor := c.GetString("doctor")
  1059. certificates, _ := c.GetInt64("certificates")
  1060. fixmedins_code := c.GetString("fixmedins_code")
  1061. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1062. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1063. secret_key := c.GetString("secret_key")
  1064. org_name := c.GetString("org_name")
  1065. fapiao_number := c.GetString("fapiao_number")
  1066. acct_used_flag := c.GetString("acct_used_flag")
  1067. result, src_resquest := service.Hb2304(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)
  1068. saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
  1069. var dat2 map[string]interface{}
  1070. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1071. } else {
  1072. }
  1073. var dat map[string]interface{}
  1074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1075. } else {
  1076. }
  1077. c.ServeSuccessJSON(map[string]interface{}{
  1078. "pre": dat,
  1079. "request_log": dat2,
  1080. })
  1081. }
  1082. func (c *NmController) Post2305() {
  1083. mdtrt_id := c.GetString("mdtrt_id")
  1084. psn_no := c.GetString("psn_no")
  1085. doctor := c.GetString("doctor")
  1086. setl_id := c.GetString("setl_id")
  1087. fixmedins_code := c.GetString("fixmedins_code")
  1088. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1089. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1090. secret_key := c.GetString("secret_key")
  1091. org_name := c.GetString("org_name")
  1092. result, requestLog := service.Hb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1093. saveJsLog(result, requestLog, "2305", "退费", org_name)
  1094. var dat2 map[string]interface{}
  1095. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1096. } else {
  1097. }
  1098. var dat map[string]interface{}
  1099. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1100. } else {
  1101. }
  1102. c.ServeSuccessJSON(map[string]interface{}{
  1103. "pre": dat,
  1104. "request_log": dat2,
  1105. })
  1106. }
  1107. func (c *NmController) Get2503() {
  1108. }
  1109. func (c *NmController) ReadCard() {
  1110. fixmedins_code := c.GetString("fixmedins_code")
  1111. secret_key := c.GetString("secret_key")
  1112. org_name := c.GetString("org_name")
  1113. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1114. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1115. id_card_type := c.GetString("id_card_type")
  1116. operator_id := c.GetString("operator_id")
  1117. operator := c.GetString("operator")
  1118. is_settle := c.GetString("is_settle")
  1119. switch id_card_type {
  1120. case "1":
  1121. if initFlag == 0 {
  1122. c.TestGetBasBaseInit()
  1123. }
  1124. pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
  1125. basStr := Remove0000(pBusiCardInfo)
  1126. if len(basStr) == 0 {
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1128. return
  1129. }
  1130. var dat2 map[string]interface{}
  1131. if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
  1132. fmt.Println(dat2)
  1133. } else {
  1134. fmt.Println(err)
  1135. }
  1136. userJSONBytes, _ := json.Marshal(dat2)
  1137. var res ReadCardResult
  1138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1139. utils.ErrorLog("解析失败:%v", err)
  1140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1141. return
  1142. }
  1143. fmt.Println(basStr)
  1144. bas := strings.Split(res.Output.CardInfo, "|")
  1145. basNumber := bas[1]
  1146. fmt.Println(basNumber)
  1147. card_sn := bas[3]
  1148. fmt.Println(card_sn)
  1149. cardNumber := bas[2]
  1150. name := bas[4]
  1151. result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
  1152. var dat map[string]interface{}
  1153. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1154. fmt.Println(dat)
  1155. } else {
  1156. fmt.Println(err)
  1157. }
  1158. userJSONBytes2, _ := json.Marshal(dat)
  1159. var res2 ResultTwo
  1160. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1161. utils.ErrorLog("解析失败:%v", err)
  1162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1163. return
  1164. }
  1165. infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
  1166. if infocode == 0 {
  1167. c.ServeSuccessJSON(map[string]interface{}{
  1168. "status": "0",
  1169. "card_info": res.Output.CardInfo,
  1170. "busi_card_info": pBusiCardInfo,
  1171. "result": res2,
  1172. "type": "1",
  1173. })
  1174. } else {
  1175. c.ServeSuccessJSON(map[string]interface{}{
  1176. "status": "-1",
  1177. })
  1178. }
  1179. break
  1180. case "4": //电子凭证
  1181. //c.GetELeInfo()
  1182. var result_info string
  1183. if len(is_settle) > 0 {
  1184. _, result_info = c.GetELeInfo(fixmedins_code, operator_id, operator)
  1185. } else {
  1186. _, result_info = c.GetELeInfoThree(fixmedins_code, operator_id, operator)
  1187. }
  1188. //if result_code == "0000" {
  1189. var ele ELeData
  1190. err := json.Unmarshal([]byte(result_info), &ele)
  1191. if err != nil {
  1192. utils.ErrorLog("解析失败:%v", err)
  1193. }
  1194. token := ele.Data.EcToken
  1195. fmt.Println(token)
  1196. if len(token) > 0 {
  1197. result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.UserName, ele.Data.IdNo)
  1198. var dat map[string]interface{}
  1199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1200. fmt.Println(dat)
  1201. } else {
  1202. fmt.Println(err)
  1203. }
  1204. userJSONBytes, _ := json.Marshal(dat)
  1205. var res ResultTwo
  1206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1207. utils.ErrorLog("解析失败:%v", err)
  1208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1209. return
  1210. }
  1211. infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1212. if infocode == 0 {
  1213. c.ServeSuccessJSON(map[string]interface{}{
  1214. "status": "0",
  1215. "card_info": result_info,
  1216. "busi_card_info": result_info,
  1217. "token": token,
  1218. "result": dat,
  1219. })
  1220. } else {
  1221. c.ServeSuccessJSON(map[string]interface{}{
  1222. "status": "-1",
  1223. })
  1224. }
  1225. } else {
  1226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1227. return
  1228. }
  1229. break
  1230. case "5": //电子凭证
  1231. //c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1232. //_, pBusiCardInfo := c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1233. //var ele ELeData
  1234. //err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  1235. //if err != nil {
  1236. // utils.ErrorLog("解析失败:%v", err)
  1237. //}
  1238. //token := ele.Data.EcToken
  1239. //fmt.Println(token)
  1240. //if len(token) > 0 {
  1241. // result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.IdNo, ele.Data.UserName)
  1242. // var dat map[string]interface{}
  1243. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1244. // fmt.Println(dat)
  1245. // } else {
  1246. // fmt.Println(err)
  1247. // }
  1248. // userJSONBytes, _ := json.Marshal(dat)
  1249. // var res ResultTwo
  1250. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1251. // utils.ErrorLog("解析失败:%v", err)
  1252. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1253. // return
  1254. // }
  1255. //
  1256. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1257. //
  1258. // if infocode == 0 {
  1259. //
  1260. // c.ServeSuccessJSON(map[string]interface{}{
  1261. // "status": "0",
  1262. // "card_info": pBusiCardInfo,
  1263. // "busi_card_info": pBusiCardInfo,
  1264. // "token": token,
  1265. // "result": dat,
  1266. // })
  1267. //
  1268. // } else {
  1269. // c.ServeSuccessJSON(map[string]interface{}{
  1270. // "status": "-1",
  1271. // })
  1272. //
  1273. // }
  1274. //} else {
  1275. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1276. // return
  1277. //}
  1278. //break
  1279. }
  1280. }
  1281. var initFlag int64 = 0
  1282. func (c *NmController) GetELeInfoTwo(code string, operator_id string, operator_name string) (string, string) {
  1283. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  1284. readCard := DllDef.MustFindProc("NationEcTrans")
  1285. fmt.Println(readCard)
  1286. fmt.Println("!!!!!")
  1287. pBusiCardInfo := make([]byte, 1024*10)
  1288. input := make(map[string]interface{})
  1289. inputData := make(map[string]interface{})
  1290. inputData["orgId"] = code
  1291. inputData["businessType"] = "01101"
  1292. inputData["operatorId"] = operator_id
  1293. inputData["operatorName"] = operator_name
  1294. inputData["officeId"] = "001"
  1295. inputData["officeName"] = "血透室"
  1296. inputData["deviceType"] = ""
  1297. input["data"] = inputData
  1298. input["orgId"] = code
  1299. input["transType"] = "ec.query"
  1300. bytesData, _ := json.Marshal(input)
  1301. //gdyb_url := beego.AppConfig.String("gdyb_url")
  1302. fmt.Println(string(bytesData))
  1303. url := "http://10.38.22.15:8081" + "/localcfc/api/hsecfc/localQrCodeQuery"
  1304. ret2, aa, bb := readCard.Call(StrPtr(url), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1305. fmt.Println(aa)
  1306. fmt.Println(bb)
  1307. fmt.Println(ret2)
  1308. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1309. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1310. if ret2 != 0 {
  1311. return "", ""
  1312. }
  1313. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1314. }
  1315. func (c *NmController) TestGetBasBaseInit() {
  1316. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1317. Iinit := DllDef.MustFindProc("Init")
  1318. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1319. str := make([]byte, 2048)
  1320. inputData := make(map[string]interface{})
  1321. inputData["IP"] = "tyjk.nm.hsip.gov.cn"
  1322. inputData["PORT"] = 8090
  1323. inputData["TIMEOUT"] = 180
  1324. inputData["LOG_PATH"] = "C:\\log\\"
  1325. //inputData["SFZ_DRIVER_TYPE"] = 0
  1326. inputData["URL"] = "/uif-hsaf-med-api/api/medical/service"
  1327. bytesData, _ := json.Marshal(inputData)
  1328. fmt.Println(inputData)
  1329. fmt.Println(bytesData)
  1330. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  1331. if ret != 0 {
  1332. fmt.Println("SSCard的报错原因:", err)
  1333. fmt.Println("SSCard的运算结果为:", ret)
  1334. fmt.Println("SSCard的返回结果为:", string(str))
  1335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1336. return
  1337. }
  1338. fmt.Println("SSCard的返回结果为:", string(str))
  1339. result := int(ret)
  1340. fmt.Println("SSCard的运算结果为1:", result)
  1341. //initFlag = 1
  1342. return
  1343. }
  1344. func (c *NmController) GetSFZBaseInfo() string {
  1345. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1346. readCard := DllDef.MustFindProc("ReadSFZ")
  1347. if readCard == nil {
  1348. fmt.Println("readcard is nil")
  1349. readCard = DllDef.MustFindProc("ReadSFZ")
  1350. }
  1351. str := make([]byte, 256)
  1352. str1 := make([]byte, 256)
  1353. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1354. fmt.Println(r)
  1355. return string(str)
  1356. }
  1357. func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  1358. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1359. readCard := DllDef.MustFindProc("ReadCardBas")
  1360. fmt.Println(readCard)
  1361. fmt.Println("!!!!!")
  1362. month := time.Unix(1557042972, 0).Format("1")
  1363. year := time.Now().Format("2006")
  1364. month = time.Now().Format("01")
  1365. day := time.Now().Format("02")
  1366. hour := time.Now().Format("15")
  1367. min := time.Now().Format("04")
  1368. sec := time.Now().Format("05")
  1369. msec := time.Now().Format("000")
  1370. timestamp := time.Now().Unix()
  1371. tempTime := time.Unix(timestamp, 0)
  1372. //timeFormat := tempTime.Format("20060102150405")
  1373. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1374. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  1375. inputData := make(map[string]interface{})
  1376. inputData["infno"] = "1199"
  1377. //inputData["msgid"] = "7021"
  1378. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  1379. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  1380. inputData["insuplc_admdvs"] = "" // 发送方报文 ID
  1381. // 发送方报文 ID
  1382. inputData["recer_sys_code"] = "01"
  1383. inputData["dev_no"] = ""
  1384. inputData["dev_safe_info"] = ""
  1385. inputData["cainfo"] = ""
  1386. inputData["signtype"] = "SM3"
  1387. inputData["infver"] = "V1.0"
  1388. inputData["opter_type"] = "1"
  1389. inputData["opter"] = opter_id
  1390. inputData["opter_name"] = opter_name
  1391. inputData["inf_time"] = timeFormatOne
  1392. inputData["fixmedins_code"] = fixmedins_code
  1393. inputData["fixmedins_name"] = fixmedins_name
  1394. inputData["sign_no"] = ""
  1395. bytesData, _ := json.Marshal(inputData)
  1396. fmt.Println(string(bytesData))
  1397. pBusiCardInfo := make([]byte, 8192)
  1398. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1399. fmt.Println(ret2)
  1400. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1401. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1402. if ret2 != 0 {
  1403. return ""
  1404. }
  1405. return DeleteExtraSpace(string(pBusiCardInfo))
  1406. }
  1407. func (c *NmController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  1408. // WebSocket服务器地址
  1409. serverURL := "ws://127.0.0.1:8899"
  1410. // 解析WebSocket服务器地址
  1411. u, err := url.Parse(serverURL)
  1412. if err != nil {
  1413. log.Fatal(err)
  1414. }
  1415. // 建立WebSocket连接
  1416. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1417. if err != nil {
  1418. log.Fatal(err)
  1419. }
  1420. defer conn.Close()
  1421. input2 := make(map[string]interface{})
  1422. input := make(map[string]interface{})
  1423. inputData := make(map[string]interface{})
  1424. inputData["orgId"] = code
  1425. inputData["businessType"] = "01101"
  1426. inputData["operatorId"] = operator_id
  1427. inputData["operatorName"] = operator_name
  1428. inputData["officeId"] = "001"
  1429. inputData["officeName"] = "血透室"
  1430. inputData["deviceType"] = ""
  1431. input["data"] = inputData
  1432. input["orgId"] = code
  1433. input["transType"] = "ec.query"
  1434. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1435. input2["indata"] = input
  1436. bytesData, _ := json.Marshal(input2)
  1437. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1438. if err != nil {
  1439. fmt.Println(err)
  1440. }
  1441. // 接收消息
  1442. _, receivedMessage, err := conn.ReadMessage()
  1443. if err != nil {
  1444. fmt.Println(err)
  1445. }
  1446. return "", string(receivedMessage)
  1447. }
  1448. func (c *NmController) GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  1449. // WebSocket服务器地址
  1450. serverURL := "ws://127.0.0.1:8899"
  1451. // 解析WebSocket服务器地址
  1452. u, err := url.Parse(serverURL)
  1453. if err != nil {
  1454. log.Fatal(err)
  1455. }
  1456. // 建立WebSocket连接
  1457. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1458. if err != nil {
  1459. log.Fatal(err)
  1460. }
  1461. defer conn.Close()
  1462. input2 := make(map[string]interface{})
  1463. input := make(map[string]interface{})
  1464. inputData := make(map[string]interface{})
  1465. inputData["orgId"] = code
  1466. inputData["businessType"] = "01301"
  1467. inputData["operatorId"] = operator_id
  1468. inputData["operatorName"] = operator_name
  1469. inputData["officeId"] = "001"
  1470. inputData["officeName"] = "血透室"
  1471. inputData["deviceType"] = ""
  1472. input["data"] = inputData
  1473. input["orgId"] = code
  1474. input["transType"] = "ec.query"
  1475. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1476. input2["indata"] = input
  1477. bytesData, _ := json.Marshal(input2)
  1478. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1479. if err != nil {
  1480. fmt.Println(err)
  1481. }
  1482. // 接收消息
  1483. _, receivedMessage, err := conn.ReadMessage()
  1484. if err != nil {
  1485. fmt.Println(err)
  1486. }
  1487. return "", string(receivedMessage)
  1488. }
  1489. func IntPtr(n int) uintptr {
  1490. return uintptr(n)
  1491. }
  1492. func StrPtr(s string) uintptr {
  1493. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1494. }
  1495. type Charset string
  1496. const (
  1497. UTF8 = Charset("UTF-8")
  1498. GB18030 = Charset("GB18030")
  1499. )
  1500. func ConvertToString(src string, srcCode string, tagCode string) string {
  1501. srcCoder := mahonia.NewDecoder(srcCode)
  1502. srcResult := srcCoder.ConvertString(src)
  1503. tagCoder := mahonia.NewDecoder(tagCode)
  1504. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1505. result := string(cdata)
  1506. return result
  1507. }
  1508. func DeleteExtraSpace(s string) string {
  1509. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1510. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1511. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1512. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1513. s2 := make([]byte, len(s1)) //定义字符数组切片
  1514. copy(s2, s1) //将字符串复制到切片
  1515. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1516. for len(spc_index) > 0 { //找到适配项
  1517. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1518. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1519. }
  1520. return string(s2)
  1521. }
  1522. func Remove0000(s string) string {
  1523. str := make([]rune, 0, len(s))
  1524. for _, v := range []rune(s) {
  1525. if v == 0 {
  1526. continue
  1527. }
  1528. str = append(str, v)
  1529. }
  1530. return string(str)
  1531. }
  1532. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1533. //org_id, _ := beego.AppConfig.Int64("org_id")
  1534. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1535. dir := org_name + "日志"
  1536. utils.Mkdir(dir)
  1537. month := time.Unix(1557042972, 0).Format("1")
  1538. year := time.Now().Format("2006")
  1539. month = time.Now().Format("01")
  1540. day := time.Now().Format("02")
  1541. hour := time.Now().Format("15")
  1542. min := time.Now().Format("04")
  1543. sec := time.Now().Format("05")
  1544. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1545. file := org_name + "_" + year + month + day + "_log"
  1546. file_name := file + ".txt"
  1547. file_path := org_name + "日志" + "/" + file_name
  1548. exist, _ := utils.PathExists(file_path)
  1549. if exist { //存在
  1550. fmt.Println("存在")
  1551. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1552. if err != nil {
  1553. fmt.Println("read fail")
  1554. }
  1555. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1556. n, _ := f.Seek(0, 2)
  1557. _, err = f.WriteAt([]byte(content), n)
  1558. } else { //不存在
  1559. fmt.Println("文件不存在,创建文件")
  1560. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1561. defer f.Close()
  1562. if err != nil {
  1563. } else {
  1564. _, err = f.Write([]byte("记录日志"))
  1565. }
  1566. }
  1567. }
  1568. func (c *NmController) Get3201() {
  1569. insutype := c.GetString("insutype")
  1570. clrType := c.GetString("clr_type")
  1571. setlOptins := c.GetString("setl_optins")
  1572. stmtBegndate := c.GetString("stmt_begndate")
  1573. stmtEnddate := c.GetString("stm_enddate")
  1574. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  1575. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  1576. acctPay, _ := c.GetFloat("acct_pay", 0)
  1577. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  1578. fixmedins_code := c.GetString("fixmedins_code")
  1579. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1580. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1581. secret_key := c.GetString("secret_key")
  1582. org_name := c.GetString("org_name")
  1583. doctor := c.GetString("doctor")
  1584. baseParams := models.BaseParams{
  1585. SecretKey: secret_key,
  1586. FixmedinsCode: fixmedins_code,
  1587. InsuplcAdmdvs: insuplc_admdvs,
  1588. MdtrtareaAdmvs: mdtrtarea_admvs,
  1589. OrgName: org_name,
  1590. Doctor: doctor,
  1591. }
  1592. businessParams := models.BusinessParams{
  1593. Insutype: insutype,
  1594. ClrType: clrType,
  1595. SetlOptins: setlOptins,
  1596. StmtBegndate: stmtBegndate,
  1597. StmtEnddate: stmtEnddate,
  1598. MedfeeSumamt: medfeeSumamt,
  1599. FundPaySumamt: fundPaySumamt,
  1600. AcctPay: acctPay,
  1601. FixmedinsSetlCnt: fixmedinsSetlCnt,
  1602. }
  1603. result := service.Gdyb3201(baseParams, businessParams,0)
  1604. saveJsLog(result, "", "3201", "对总账", org_name)
  1605. var dat map[string]interface{}
  1606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1607. fmt.Println(dat)
  1608. } else {
  1609. fmt.Println(err)
  1610. }
  1611. c.ServeSuccessJSON(map[string]interface{}{
  1612. "pre": dat,
  1613. })
  1614. }
  1615. func (c *NmController) Get2601() {
  1616. result := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202210111721190000", "2305", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1617. var dat map[string]interface{}
  1618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1619. fmt.Println(dat)
  1620. } else {
  1621. fmt.Println(err)
  1622. }
  1623. result2 := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202209281143070000", "2304", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1624. var dat2 map[string]interface{}
  1625. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  1626. fmt.Println(dat2)
  1627. } else {
  1628. fmt.Println(err)
  1629. }
  1630. c.ServeSuccessJSON(map[string]interface{}{
  1631. "pre": dat,
  1632. })
  1633. }
  1634. func ConvertByte2String(byte []byte, charset Charset) string {
  1635. var str string
  1636. switch charset {
  1637. case GB18030:
  1638. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1639. str = string(decodeBytes)
  1640. case UTF8:
  1641. fallthrough
  1642. default:
  1643. str = string(byte)
  1644. }
  1645. return str
  1646. }