jsyb_controller.go 49KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  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)
  124. saveJsLog(result, request_log, "3503", "库存采购", struct3503.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. var result string
  564. var request_log string
  565. 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)
  566. saveJsLog(result, request_log, "2206", "预结算", org_name)
  567. var dat map[string]interface{}
  568. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  569. fmt.Println(dat)
  570. } else {
  571. fmt.Println(err)
  572. }
  573. var dat2 map[string]interface{}
  574. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  575. fmt.Println(dat2)
  576. } else {
  577. fmt.Println(err)
  578. }
  579. c.ServeSuccessJSON(map[string]interface{}{
  580. "pre": dat,
  581. "request_log": dat2,
  582. })
  583. }
  584. func (c *JSybController) PostEight() {
  585. psnNo := c.GetString("psn_no")
  586. mdtrtId := c.GetString("mdtrt_id")
  587. chrgBchno := c.GetString("chrg_bchno")
  588. certNo := c.GetString("cert_no")
  589. insutype := c.GetString("insutype")
  590. total := c.GetString("total")
  591. org_name := c.GetString("org_name")
  592. doctor := c.GetString("doctor")
  593. fixmedins_code := c.GetString("fixmedins_code")
  594. insuplc_admdvs := c.GetString("insuplc_admdvs")
  595. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  596. secret_key := c.GetString("secret_key")
  597. med_type := c.GetString("med_type")
  598. id_card_type, _ := c.GetInt64("id_card_type")
  599. certificates, _ := c.GetInt64("certificates")
  600. fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
  601. overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
  602. preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
  603. inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
  604. acct_used_flag := c.GetString("acct_used_flag")
  605. url := c.GetString("url")
  606. ak := c.GetString("ak")
  607. verify_number := c.GetString("verify_number")
  608. cainfo := c.GetString("cainfo")
  609. var result string
  610. var request_log string
  611. if id_card_type == 4 {
  612. //_, pBusiCardInfo := GetELeCertInfoSettle(fixmedins_code, "", "")
  613. //pBusiCardInfo = Remove0000(pBusiCardInfo)
  614. //var ele ELeData
  615. //err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  616. //if err != nil {
  617. // utils.ErrorLog("解析失败:%v", err)
  618. //}
  619. //token := ele.Data.EcCardToken
  620. //if len(token) > 0 {
  621. 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)
  622. //}
  623. } else {
  624. 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)
  625. }
  626. saveJsLog(result, request_log, "2207", "结算", org_name)
  627. var dat map[string]interface{}
  628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  629. fmt.Println(dat)
  630. } else {
  631. fmt.Println(err)
  632. }
  633. var dat2 map[string]interface{}
  634. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  635. fmt.Println(dat2)
  636. } else {
  637. fmt.Println(err)
  638. }
  639. c.ServeSuccessJSON(map[string]interface{}{
  640. "pre": dat,
  641. "request_log": dat2,
  642. })
  643. }
  644. func (c *JSybController) PostNine() {
  645. psnNo := c.GetString("psn_no")
  646. mdtrtId := c.GetString("mdtrt_id")
  647. setlId := c.GetString("setl_id")
  648. org_name := c.GetString("org_name")
  649. doctor := c.GetString("doctor")
  650. secret_key := c.GetString("secret_key")
  651. fixmedins_code := c.GetString("fixmedins_code")
  652. insuplc_admdvs := c.GetString("insuplc_admdvs")
  653. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  654. url := c.GetString("url")
  655. ak := c.GetString("ak")
  656. cainfo := c.GetString("cainfo")
  657. result, request_log := service.Jsyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  658. saveJsLog(result, request_log, "2208", "退费", org_name)
  659. fmt.Println(request_log)
  660. var dat map[string]interface{}
  661. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  662. fmt.Println(dat)
  663. } else {
  664. fmt.Println(err)
  665. }
  666. var dat2 map[string]interface{}
  667. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  668. fmt.Println(dat2)
  669. } else {
  670. fmt.Println(err)
  671. }
  672. c.ServeSuccessJSON(map[string]interface{}{
  673. "pre": dat,
  674. "request_log": dat2,
  675. })
  676. }
  677. func (c *JSybController) PostTen() {
  678. psnNo := c.GetString("psn_no")
  679. mdtrtId := c.GetString("mdtrt_id")
  680. setlId := c.GetString("setl_id")
  681. org_name := c.GetString("org_name")
  682. doctor := c.GetString("doctor")
  683. secret_key := c.GetString("secret_key")
  684. fixmedins_code := c.GetString("fixmedins_code")
  685. insuplc_admdvs := c.GetString("insuplc_admdvs")
  686. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  687. url := c.GetString("url")
  688. ak := c.GetString("ak")
  689. cainfo := c.GetString("cainfo")
  690. baseParams := models.BaseParams{
  691. SecretKey: secret_key,
  692. FixmedinsCode: fixmedins_code,
  693. InsuplcAdmdvs: insuplc_admdvs,
  694. MdtrtareaAdmvs: mdtrtarea_admvs,
  695. OrgName: org_name,
  696. Doctor: doctor,
  697. RequestUrl: url,
  698. AccessKey: ak,
  699. Cainfo: cainfo,
  700. }
  701. businessParams := models.BusinessParams{
  702. PsnNo: psnNo,
  703. MdtrtId: mdtrtId,
  704. SetlId: setlId,
  705. }
  706. result, request_log := service.Jsyb5203(baseParams, businessParams)
  707. saveJsLog(result, request_log, "5203", "结算单", org_name)
  708. var dat map[string]interface{}
  709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  710. fmt.Println(dat)
  711. } else {
  712. fmt.Println(err)
  713. }
  714. var dat2 map[string]interface{}
  715. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  716. fmt.Println(dat2)
  717. } else {
  718. fmt.Println(err)
  719. }
  720. c.ServeSuccessJSON(map[string]interface{}{
  721. "pre": dat,
  722. "request_log": dat2,
  723. })
  724. }
  725. func (c *JSybController) Get2503() {
  726. psnNo := c.GetString("psn_no")
  727. insutype := c.GetString("insutype")
  728. sick_code := c.GetString("sick_code")
  729. sick_name := c.GetString("sick_name")
  730. insuplc_admdvs := c.GetString("insuplc_admdvs")
  731. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  732. secret_key := c.GetString("secret_key")
  733. access_key := c.GetString("access_key")
  734. fixmedins_code := c.GetString("fixmedins_code")
  735. org_name := c.GetString("org_name")
  736. check_time := c.GetString("check_time")
  737. doctor_id := c.GetString("doctor_id")
  738. doctor := c.GetString("doctor")
  739. start_time := c.GetString("start_time")
  740. end_time := c.GetString("end_time")
  741. url := c.GetString("url")
  742. cainfo := c.GetString("cainfo")
  743. 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)
  744. }
  745. func (c *JSybController) Get3201() {
  746. insutype := c.GetString("insutype")
  747. clrType := c.GetString("clr_type")
  748. setlOptins := c.GetString("setl_optins")
  749. stmtBegndate := c.GetString("stmt_begndate")
  750. stmtEnddate := c.GetString("stm_enddate")
  751. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  752. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  753. acctPay, _ := c.GetFloat("acct_pay", 0)
  754. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  755. fixmedins_code := c.GetString("fixmedins_code")
  756. insuplc_admdvs := c.GetString("insuplc_admdvs")
  757. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  758. secret_key := c.GetString("secret_key")
  759. org_name := c.GetString("org_name")
  760. doctor := c.GetString("doctor")
  761. url := c.GetString("url")
  762. ak := c.GetString("ak")
  763. cainfo := c.GetString("cainfo")
  764. 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)
  765. saveJsLog(result, request_log, "3201", "对总账", org_name)
  766. var dat map[string]interface{}
  767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  768. fmt.Println(dat)
  769. } else {
  770. fmt.Println(err)
  771. }
  772. var dat2 map[string]interface{}
  773. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  774. fmt.Println(dat2)
  775. } else {
  776. fmt.Println(err)
  777. }
  778. c.ServeSuccessJSON(map[string]interface{}{
  779. "pre": dat,
  780. "request_log": dat2,
  781. })
  782. }
  783. type ELeData struct {
  784. Data struct {
  785. SiNo string `json:"si_no"`
  786. SiCardNo string `json:"si_card_no"`
  787. SiCardIssueArea string `json:"si_card_issue_area"`
  788. Name string `json:"name"`
  789. Gender string `json:"gender"`
  790. IdType string `json:"id_type"`
  791. IdNo string `json:"id_no"`
  792. EcCardToken string `json:"ecCardToken"`
  793. } `json:"data"`
  794. Code int `json:"code"`
  795. Message string `json:"message"`
  796. }
  797. type ELeCertData struct {
  798. Data struct {
  799. Extra string `json:"extra"`
  800. IDNo string `json:"idNo"`
  801. IDType string `json:"idType"`
  802. EcToken string `json:"ecToken"`
  803. InsuOrg string `json:"insuOrg"`
  804. UserName string `json:"userName"`
  805. EcIndexNo string `json:"ecIndexNo"`
  806. Gender string `json:"gender"`
  807. Birthday string `json:"birthday"`
  808. Nationality string `json:"nationality"`
  809. Email string `json:"email"`
  810. } `json:"data"`
  811. Code int `json:"code"`
  812. Message string `json:"message"`
  813. }
  814. func (c *JSybController) ReadCard() {
  815. fixmedins_code := c.GetString("fixmedins_code")
  816. secret_key := c.GetString("secret_key")
  817. ak := c.GetString("ak")
  818. org_name := c.GetString("org_name")
  819. doctor := c.GetString("doctor")
  820. insuplc_admdvs := c.GetString("insuplc_admdvs")
  821. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  822. url := c.GetString("url")
  823. cainfo := c.GetString("cainfo")
  824. id_card_type := c.GetString("id_card_type")
  825. operator_id := c.GetString("operator_id")
  826. operator := c.GetString("operator")
  827. //result, request := service.Jsyb9001(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, url, cainfo, ak)
  828. //fmt.Println(request)
  829. //fmt.Println(result)
  830. c.TestGetBasBaseInit(fixmedins_code, secret_key, ak)
  831. switch id_card_type {
  832. case "1":
  833. pCardInfo, pBusiCardInfo := c.GetBasBaseInfo()
  834. pBusiCardInfo = Remove0000(pBusiCardInfo)
  835. pCardInfo = Remove0000(pCardInfo)
  836. fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8"))
  837. fmt.Println(pBusiCardInfo)
  838. fmt.Println(pCardInfo)
  839. bas := strings.Split(pCardInfo, "|")
  840. basNumber := bas[2]
  841. id_card_no := bas[1]
  842. card_sn := bas[3]
  843. id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64)
  844. if len(pCardInfo) > 0 && len(pBusiCardInfo) > 0 {
  845. 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)
  846. var dat map[string]interface{}
  847. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  848. fmt.Println(dat)
  849. } else {
  850. fmt.Println(err)
  851. }
  852. c.ServeSuccessJSON(map[string]interface{}{
  853. "status": "0",
  854. "card_info": pCardInfo,
  855. "busi_card_info": pBusiCardInfo,
  856. "result": dat,
  857. "type": "1",
  858. })
  859. } else {
  860. c.ServeSuccessJSON(map[string]interface{}{
  861. "status": "-1",
  862. })
  863. }
  864. break
  865. case "3": //电子社保卡
  866. _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  867. //fmt.Println(pCardInfo)
  868. fmt.Println(pBusiCardInfo)
  869. pBusiCardInfo = Remove0000(pBusiCardInfo)
  870. //pCardInfo = Remove0000(pCardInfo)
  871. var ele ELeData
  872. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  873. if err != nil {
  874. utils.ErrorLog("解析失败:%v", err)
  875. }
  876. token := ele.Data.EcCardToken
  877. if len(token) > 0 {
  878. result, _ := service.Jsyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IdNo)
  879. var dat map[string]interface{}
  880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  881. fmt.Println(dat)
  882. } else {
  883. fmt.Println(err)
  884. }
  885. c.ServeSuccessJSON(map[string]interface{}{
  886. "status": "0",
  887. //"card_info": pCardInfo,
  888. "busi_card_info": pBusiCardInfo,
  889. "token": token,
  890. "result": dat,
  891. "type": "2",
  892. })
  893. } else {
  894. c.ServeSuccessJSON(map[string]interface{}{
  895. "status": "-1",
  896. })
  897. }
  898. break
  899. case "4": //电子凭证
  900. fmt.Println(operator_id)
  901. fmt.Println(operator)
  902. pCardInfo, pBusiCardInfo := c.GetELeCertInfo(fixmedins_code, operator_id, operator)
  903. fmt.Println(pCardInfo)
  904. fmt.Println(pBusiCardInfo)
  905. pBusiCardInfo = Remove0000(pBusiCardInfo)
  906. pCardInfo = Remove0000(pCardInfo)
  907. var ele ELeCertData
  908. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  909. if err != nil {
  910. utils.ErrorLog("解析失败:%v", err)
  911. }
  912. token := ele.Data.EcToken
  913. fmt.Println(token)
  914. if len(token) > 0 {
  915. userName := ele.Data.UserName
  916. fmt.Println(userName)
  917. userName = Remove0000(userName)
  918. userName = DeleteExtraSpace(userName)
  919. fmt.Println(userName)
  920. enc := mahonia.NewEncoder("gbk")
  921. fmt.Println(enc.ConvertString(userName))
  922. result, _ := service.Jsyb1101ForEleCert(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  923. var dat map[string]interface{}
  924. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  925. fmt.Println(dat)
  926. } else {
  927. fmt.Println(err)
  928. }
  929. c.ServeSuccessJSON(map[string]interface{}{
  930. "status": "0",
  931. "card_info": pCardInfo,
  932. "busi_card_info": pBusiCardInfo,
  933. "token": token,
  934. "result": dat,
  935. })
  936. } else {
  937. c.ServeSuccessJSON(map[string]interface{}{
  938. "status": "-1",
  939. })
  940. }
  941. break
  942. }
  943. }
  944. func (c *JSybController) TestGetBasBaseInit(code string, secret_key string, ak string) {
  945. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  946. Iinit := DllDef.MustFindProc("Init")
  947. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  948. str := make([]byte, 2048)
  949. inputData := make(map[string]interface{})
  950. inputData["IP"] = "10.72.3.87"
  951. inputData["PORT"] = "8086"
  952. inputData["TIMEOUT"] = "180"
  953. inputData["LOG_PATH"] = "C:\\log\\"
  954. //inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  955. inputData["EC_URL"] = "http://10.72.3.127:10086/localcfc/api/hsecfc/localQrCodeQuery"
  956. inputData["CARD_PASSTYPE"] = "1"
  957. inputData["API_NAME"] = "hssServives"
  958. inputData["API_VERSION"] = "1.0.0"
  959. inputData["ACCESS_KEY"] = ak
  960. inputData["SECRETKEY"] = secret_key
  961. inputData["ORG_ID"] = code
  962. inputData["EXT"] = ""
  963. bytesData, _ := json.Marshal(inputData)
  964. fmt.Println(inputData)
  965. fmt.Println(bytesData)
  966. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  967. if ret != 0 {
  968. fmt.Println("SSCard的报错原因:", err)
  969. fmt.Println("SSCard的运算结果为:", ret)
  970. fmt.Println("SSCard的返回结果为:", string(str))
  971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  972. return
  973. }
  974. fmt.Println("SSCard的返回结果为:", string(str))
  975. result := int(ret)
  976. fmt.Println("SSCard的运算结果为1:", result)
  977. //initFlag = 1
  978. return
  979. }
  980. func (c *JSybController) GetBasBaseInfo() (string, string) {
  981. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  982. readCard := DllDef.MustFindProc("ReadCardBas")
  983. fmt.Println(readCard)
  984. fmt.Println("!!!!!")
  985. pCardInfo := make([]byte, 2048)
  986. pBusiCardInfo := make([]byte, 8192)
  987. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  988. fmt.Println(ret2)
  989. fmt.Println(DeleteExtraSpace(string(pCardInfo)))
  990. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  991. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
  992. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  993. if ret2 != 0 {
  994. return "", ""
  995. }
  996. return DeleteExtraSpace(string(pCardInfo)), DeleteExtraSpace(string(pBusiCardInfo))
  997. }
  998. func (c *JSybController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  999. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1000. readCard := DllDef.MustFindProc("EcCardQuery")
  1001. fmt.Println(readCard)
  1002. fmt.Println("!!!!!")
  1003. //pCardInfo := make([]byte, 8192)
  1004. pBusiCardInfo := make([]byte, 8192)
  1005. //data := make(map[string]interface{})
  1006. //pData := make(map[string]interface{})
  1007. //inputData := make(map[string]interface{})
  1008. //inputData["orgId"] = code
  1009. //inputData["businessType"] = "01101"
  1010. //inputData["operatorId"] = operator_id
  1011. //inputData["operatorName"] = operator_name
  1012. //inputData["officeId"] = "001"
  1013. //inputData["officeName"] = "血透室"
  1014. //data["data"] = inputData
  1015. //data["transType"] = "ec.query"
  1016. //data["orgId"] = code
  1017. //bytesData, _ := json.Marshal(data)
  1018. //pCardInfo = bytesData
  1019. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1020. fmt.Println(ret2)
  1021. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  1022. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1023. //fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1024. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1025. if ret2 != 0 {
  1026. return "", ""
  1027. }
  1028. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1029. }
  1030. func (c *JSybController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  1031. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1032. readCard := DllDef.MustFindProc("GetPersonInfo")
  1033. pCardInfo := make([]byte, 8192)
  1034. pBusiCardInfo := make([]byte, 8192)
  1035. data := make(map[string]interface{})
  1036. inputData := make(map[string]interface{})
  1037. inputData["orgId"] = code
  1038. inputData["businessType"] = "01101"
  1039. inputData["operatorId"] = "1"
  1040. inputData["operatorName"] = "admin"
  1041. inputData["officeId"] = "001"
  1042. inputData["officeName"] = "admin"
  1043. data["data"] = inputData
  1044. data["transType"] = "ec.query"
  1045. data["orgId"] = code
  1046. bytesData, _ := json.Marshal(data)
  1047. pCardInfo = bytesData
  1048. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1049. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1050. fmt.Println(ret2)
  1051. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1052. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1053. if ret2 != 0 {
  1054. return "", ""
  1055. }
  1056. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1057. }
  1058. func GetELeCertInfoSettle(code string, operator_id string, operator_name string) (string, string) {
  1059. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1060. readCard := DllDef.MustFindProc("GetPersonInfo")
  1061. pCardInfo := make([]byte, 8192)
  1062. pBusiCardInfo := make([]byte, 8192)
  1063. data := make(map[string]interface{})
  1064. inputData := make(map[string]interface{})
  1065. inputData["orgId"] = code
  1066. inputData["businessType"] = "01301"
  1067. inputData["operatorId"] = "1"
  1068. inputData["operatorName"] = "admin"
  1069. inputData["officeId"] = "001"
  1070. inputData["officeName"] = "admin"
  1071. data["data"] = inputData
  1072. data["transType"] = "ec.query"
  1073. data["orgId"] = code
  1074. bytesData, _ := json.Marshal(data)
  1075. pCardInfo = bytesData
  1076. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1077. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1078. fmt.Println(ret2)
  1079. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1080. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1081. if ret2 != 0 {
  1082. return "", ""
  1083. }
  1084. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1085. }
  1086. func IntPtr(n int) uintptr {
  1087. return uintptr(n)
  1088. }
  1089. func StrPtr(s string) uintptr {
  1090. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1091. }
  1092. type Charset string
  1093. const (
  1094. UTF8 = Charset("UTF-8")
  1095. GB18030 = Charset("GB18030")
  1096. )
  1097. func ConvertToString(src string, srcCode string, tagCode string) string {
  1098. srcCoder := mahonia.NewDecoder(srcCode)
  1099. srcResult := srcCoder.ConvertString(src)
  1100. tagCoder := mahonia.NewDecoder(tagCode)
  1101. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1102. result := string(cdata)
  1103. return result
  1104. }
  1105. func DeleteExtraSpace(s string) string {
  1106. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1107. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1108. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1109. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1110. s2 := make([]byte, len(s1)) //定义字符数组切片
  1111. copy(s2, s1) //将字符串复制到切片
  1112. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1113. for len(spc_index) > 0 { //找到适配项
  1114. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1115. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1116. }
  1117. return string(s2)
  1118. }
  1119. func Remove0000(s string) string {
  1120. str := make([]rune, 0, len(s))
  1121. for _, v := range []rune(s) {
  1122. if v == 0 {
  1123. continue
  1124. }
  1125. str = append(str, v)
  1126. }
  1127. return string(str)
  1128. }
  1129. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1130. //org_id, _ := beego.AppConfig.Int64("org_id")
  1131. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1132. dir := org_name + "日志"
  1133. utils.Mkdir(dir)
  1134. month := time.Unix(1557042972, 0).Format("1")
  1135. year := time.Now().Format("2006")
  1136. month = time.Now().Format("01")
  1137. day := time.Now().Format("02")
  1138. hour := time.Now().Format("15")
  1139. min := time.Now().Format("04")
  1140. sec := time.Now().Format("05")
  1141. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1142. file := org_name + "_" + year + month + day + "_log"
  1143. file_name := file + ".txt"
  1144. file_path := org_name + "日志" + "/" + file_name
  1145. exist, _ := utils.PathExists(file_path)
  1146. if exist { //存在
  1147. fmt.Println("存在")
  1148. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1149. if err != nil {
  1150. fmt.Println("read fail")
  1151. }
  1152. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1153. n, _ := f.Seek(0, 2)
  1154. _, err = f.WriteAt([]byte(content), n)
  1155. } else { //不存在
  1156. fmt.Println("文件不存在,创建文件")
  1157. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1158. defer f.Close()
  1159. if err != nil {
  1160. } else {
  1161. _, err = f.Write([]byte("记录日志"))
  1162. }
  1163. }
  1164. }
  1165. func (c *JSybController) Get3101() {
  1166. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1167. var respJSON map[string]interface{}
  1168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1170. return
  1171. }
  1172. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  1173. var pd models.PatientDtos
  1174. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  1175. utils.ErrorLog("解析失败:%v", err)
  1176. return
  1177. }
  1178. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  1179. var fed models.FsiEncounterDtos
  1180. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  1181. utils.ErrorLog("解析失败:%v", err)
  1182. return
  1183. }
  1184. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  1185. var fdd []*models.FsiDiagnoseDtos
  1186. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  1187. utils.ErrorLog("解析失败:%v", err)
  1188. return
  1189. }
  1190. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  1191. var fod []*models.FsiOrderDtos
  1192. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1193. utils.ErrorLog("解析失败:%v", err)
  1194. return
  1195. }
  1196. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1197. var fopd []*models.FsiOperationDtosData
  1198. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1199. utils.ErrorLog("解析失败:%v", err)
  1200. return
  1201. }
  1202. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1203. var pp models.PublicParams
  1204. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1205. utils.ErrorLog("解析失败:%v", err)
  1206. return
  1207. }
  1208. request, result := service.Jsyb3101(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1209. var dat map[string]interface{}
  1210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1211. fmt.Println(dat)
  1212. } else {
  1213. fmt.Println(err)
  1214. }
  1215. var dat2 map[string]interface{}
  1216. if err := json.Unmarshal([]byte(request), &dat2); err == nil {
  1217. fmt.Println(dat2)
  1218. } else {
  1219. fmt.Println(err)
  1220. }
  1221. saveJsLog(result, request, "3101", "事前", pp.FixmedinsName)
  1222. c.ServeSuccessJSON(map[string]interface{}{
  1223. "pre": dat,
  1224. "request_log": dat2,
  1225. })
  1226. }
  1227. func (c *JSybController) Get3102() {
  1228. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1229. var respJSON map[string]interface{}
  1230. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1232. return
  1233. }
  1234. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  1235. var pd models.PatientDtos
  1236. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  1237. utils.ErrorLog("解析失败:%v", err)
  1238. return
  1239. }
  1240. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  1241. var fed models.FsiEncounterDtos
  1242. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  1243. utils.ErrorLog("解析失败:%v", err)
  1244. return
  1245. }
  1246. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  1247. var fdd []*models.FsiDiagnoseDtos
  1248. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  1249. utils.ErrorLog("解析失败:%v", err)
  1250. return
  1251. }
  1252. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  1253. var fod []*models.FsiOrderDtos
  1254. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1255. utils.ErrorLog("解析失败:%v", err)
  1256. return
  1257. }
  1258. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1259. var fopd []*models.FsiOperationDtosData
  1260. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1261. utils.ErrorLog("解析失败:%v", err)
  1262. return
  1263. }
  1264. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1265. var pp models.PublicParams
  1266. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1267. utils.ErrorLog("解析失败:%v", err)
  1268. return
  1269. }
  1270. request, result := service.Jsyb3102(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1271. var dat map[string]interface{}
  1272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1273. fmt.Println(dat)
  1274. } else {
  1275. fmt.Println(err)
  1276. }
  1277. var dat2 map[string]interface{}
  1278. if err := json.Unmarshal([]byte(request), &dat2); err == nil {
  1279. fmt.Println(dat2)
  1280. } else {
  1281. fmt.Println(err)
  1282. }
  1283. saveJsLog(result, request, "3102", "事后", pp.FixmedinsName)
  1284. c.ServeSuccessJSON(map[string]interface{}{
  1285. "pre": dat,
  1286. "request_log": dat2,
  1287. })
  1288. }
  1289. func (c *JSybController) Get4101() {
  1290. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1291. var respJSON map[string]interface{}
  1292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1294. return
  1295. }
  1296. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  1297. var struct4101 service.Struct4101
  1298. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  1299. utils.ErrorLog("解析失败:%v", err)
  1300. return
  1301. }
  1302. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1303. var pp models.PublicParams
  1304. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1305. utils.ErrorLog("解析失败:%v", err)
  1306. return
  1307. }
  1308. request, result := service.Jsyb4101(struct4101, pp)
  1309. var dat map[string]interface{}
  1310. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1311. fmt.Println(dat)
  1312. } else {
  1313. fmt.Println(err)
  1314. }
  1315. var dat2 map[string]interface{}
  1316. if err := json.Unmarshal([]byte(request), &dat2); err == nil {
  1317. fmt.Println(dat2)
  1318. } else {
  1319. fmt.Println(err)
  1320. }
  1321. saveJsLog(result, request, "4101", "上传明细清单", pp.FixmedinsName)
  1322. c.ServeSuccessJSON(map[string]interface{}{
  1323. "pre": dat,
  1324. "request_log": dat2,
  1325. })
  1326. }
  1327. func ConvertByte2String(byte []byte, charset Charset) string {
  1328. var str string
  1329. switch charset {
  1330. case GB18030:
  1331. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1332. str = string(decodeBytes)
  1333. case UTF8:
  1334. fallthrough
  1335. default:
  1336. str = string(byte)
  1337. }
  1338. return str
  1339. }