jsyb_controller.go 49KB

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