jsyb_controller.go 49KB

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