jsyb_controller.go 47KB

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