jsyb_controller.go 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951
  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. "io/ioutil"
  13. "os"
  14. "regexp"
  15. "strconv"
  16. "strings"
  17. "syscall"
  18. "time"
  19. "unsafe"
  20. )
  21. type JSybController struct {
  22. controllers.BaseAuthAPIController
  23. }
  24. func JSybRegistRouters() {
  25. beego.Router("/jsyb/1101", &JSybController{}, "get:PostOne")
  26. beego.Router("/jsyb/1101D", &JSybController{}, "get:PostOneD")
  27. beego.Router("/jsyb/1101c", &JSybController{}, "get:PostOnec")
  28. beego.Router("/jsyb/2201c", &JSybController{}, "get:Posttwoc")
  29. beego.Router("/jsyb/2201", &JSybController{}, "get:PostTwo")
  30. beego.Router("/jsyb/2202", &JSybController{}, "get:PostThree")
  31. beego.Router("/jsyb/2203", &JSybController{}, "post:PostFour")
  32. beego.Router("/jsyb/2204", &JSybController{}, "post:PostFive")
  33. beego.Router("/jsyb/2205", &JSybController{}, "get:PostSix")
  34. beego.Router("/jsyb/2206", &JSybController{}, "get:PostSeven")
  35. beego.Router("/jsyb/2207", &JSybController{}, "get:PostEight")
  36. beego.Router("/jsyb/2208", &JSybController{}, "get:PostNine")
  37. beego.Router("/jsyb/5203", &JSybController{}, "get:PostTen")
  38. beego.Router("/jsyb/5301", &JSybController{}, "get:Get5301")
  39. beego.Router("/jsyb/3201", &JSybController{}, "get:Get3201")
  40. beego.Router("/jsyb/9001", &JSybController{}, "get:Get9001")
  41. //beego.Router("/jsyb/2503", &JSybController{}, "get:Get2503")
  42. beego.Router("/jsyb/readcard", &JSybController{}, "get:ReadCard")
  43. }
  44. func (c *JSybController) Get9001() {
  45. }
  46. func (c *JSybController) PostOnec() {
  47. result, inputLog := service.Jsyb1101F()
  48. fmt.Println(result)
  49. fmt.Println(inputLog)
  50. }
  51. func (c *JSybController) Posttwoc() {
  52. result, request_log := service.Jsyb2201F()
  53. saveJsLog(result, request_log, "2201", "挂号", "盐城响水悦达血液透析中心有限公司")
  54. }
  55. func (c *JSybController) Get5301() {
  56. psn_no := c.GetString("psn_no")
  57. org_name := c.GetString("org_name")
  58. doctor := c.GetString("doctor")
  59. fixmedins_code := c.GetString("fixmedins_code")
  60. insuplc_admdvs := c.GetString("insuplc_admdvs")
  61. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  62. secret_key := c.GetString("secret_key")
  63. url := c.GetString("url")
  64. ak := c.GetString("ak")
  65. cainfo := c.GetString("cainfo")
  66. result, inputLog := service.Jsyb5301(psn_no, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, cainfo)
  67. //saveJsLog()
  68. saveJsLog(result, inputLog, "5301", "查询备案", org_name)
  69. var dat map[string]interface{}
  70. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  71. } else {
  72. }
  73. var dat2 map[string]interface{}
  74. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  75. } else {
  76. }
  77. c.ServeSuccessJSON(map[string]interface{}{
  78. "pre": dat,
  79. "log": dat2,
  80. })
  81. }
  82. func (c *JSybController) PostOne() {
  83. certNo := c.GetString("cert_no")
  84. org_name := c.GetString("org_name")
  85. doctor := c.GetString("doctor")
  86. fixmedins_code := c.GetString("fixmedins_code")
  87. insuplc_admdvs := c.GetString("insuplc_admdvs")
  88. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  89. secret_key := c.GetString("secret_key")
  90. id_card_type, _ := c.GetInt64("id_card_type")
  91. card_sn := c.GetString("card_sn")
  92. certificates := c.GetString("certificates")
  93. url := c.GetString("url")
  94. ak := c.GetString("ak")
  95. cainfo := c.GetString("cainfo")
  96. 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)
  97. fmt.Println(result)
  98. fmt.Println(inputLog)
  99. saveJsLog(result, inputLog, "1101", "查询个人信息", org_name)
  100. var dat map[string]interface{}
  101. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  102. } else {
  103. }
  104. var dat2 map[string]interface{}
  105. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  106. } else {
  107. }
  108. c.ServeSuccessJSON(map[string]interface{}{
  109. "pre": dat,
  110. "log": dat2,
  111. })
  112. }
  113. func (c *JSybController) PostOneD() {
  114. result, inputLog := service.Jsyb1101F()
  115. fmt.Println(result)
  116. fmt.Println(inputLog)
  117. saveJsLog(result, inputLog, "1101", "查询个人信息", "盐城响水悦达血液透析中心有限公司")
  118. var dat map[string]interface{}
  119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  120. } else {
  121. }
  122. var dat2 map[string]interface{}
  123. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  124. } else {
  125. }
  126. c.ServeSuccessJSON(map[string]interface{}{
  127. "pre": dat,
  128. "log": dat2,
  129. })
  130. }
  131. func (c *JSybController) PostTwo() {
  132. psnNo := c.GetString("psn_no")
  133. insutype := c.GetString("insutype")
  134. certNo := c.GetString("cert_no")
  135. org_name := c.GetString("org_name")
  136. doctor := c.GetString("doctor")
  137. ipt_otp_no := c.GetString("ipt_otp_no")
  138. dept := c.GetString("dept")
  139. verify_number := c.GetString("verify_number")
  140. fixmedins_code := c.GetString("fixmedins_code")
  141. dept_code := c.GetString("dept_code")
  142. doctor_id := c.GetString("doctor_id")
  143. insuplc_admdvs := c.GetString("insuplc_admdvs")
  144. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  145. secret_key := c.GetString("secret_key")
  146. id_card_type, _ := c.GetInt64("id_card_type")
  147. url := c.GetString("url")
  148. ak := c.GetString("ak")
  149. doctor_name := c.GetString("doctor_name")
  150. cainfo := c.GetString("cainfo")
  151. 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)
  152. saveJsLog(result, request_log, "2201", "挂号", org_name)
  153. var dat map[string]interface{}
  154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  155. } else {
  156. }
  157. var dat2 map[string]interface{}
  158. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  159. } else {
  160. }
  161. c.ServeSuccessJSON(map[string]interface{}{
  162. "pre": dat,
  163. "request_log": dat2,
  164. })
  165. }
  166. func (c *JSybController) PostThree() {
  167. psnNo := c.GetString("psn_no")
  168. mdtrtId := c.GetString("mdtrt_id")
  169. iptOtpNo := c.GetString("ipt_otp_no")
  170. org_name := c.GetString("org_name")
  171. doctor := c.GetString("doctor")
  172. insuplc_admdvs := c.GetString("insuplc_admdvs")
  173. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  174. secret_key := c.GetString("secret_key")
  175. fixmedins_code := c.GetString("fixmedins_code")
  176. url := c.GetString("url")
  177. ak := c.GetString("ak")
  178. cainfo := c.GetString("cainfo")
  179. result, request_log := service.Jsyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  180. saveJsLog(result, request_log, "2202", "退号", org_name)
  181. var dat map[string]interface{}
  182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  183. } else {
  184. }
  185. var dat2 map[string]interface{}
  186. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  187. } else {
  188. }
  189. c.ServeSuccessJSON(map[string]interface{}{
  190. "pre": dat,
  191. "request_log": dat2,
  192. })
  193. }
  194. func (c *JSybController) PostFour() {
  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 config []*models.HisXtDiagnoseConfig
  203. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  204. utils.ErrorLog("解析失败:%v", err)
  205. return
  206. }
  207. fmt.Println(respJSON["psn_no"].(string))
  208. fmt.Println(respJSON["mdtrt_id"].(string))
  209. psnNo := respJSON["psn_no"].(string)
  210. mdtrtId := respJSON["mdtrt_id"].(string)
  211. doctor := respJSON["doctor"].(string)
  212. department := respJSON["department"].(string)
  213. org_name := respJSON["org_name"].(string)
  214. med_type := respJSON["med_type"].(string)
  215. doctor_id := respJSON["doctor_id"].(string)
  216. fixmedins_code := respJSON["fixmedins_code"].(string)
  217. sick_code := respJSON["sick_code"].(string)
  218. sick_name := respJSON["sick_name"].(string)
  219. dept := respJSON["dept"].(string)
  220. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  221. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  222. secret_key := respJSON["secret_key"].(string)
  223. url := respJSON["url"].(string)
  224. ak := respJSON["ak"].(string)
  225. begin_time := respJSON["begin_time"].(string)
  226. cainfo := respJSON["cainfo"].(string)
  227. //cainfo := c.GetString("cainfo")
  228. 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)
  229. saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
  230. var dat2 map[string]interface{}
  231. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  232. } else {
  233. }
  234. var dat map[string]interface{}
  235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  236. } else {
  237. }
  238. var dat3 int64
  239. if err := json.Unmarshal([]byte(strconv.FormatInt(timeStamp, 10)), &dat3); err == nil {
  240. } else {
  241. }
  242. c.ServeSuccessJSON(map[string]interface{}{
  243. "pre": dat,
  244. "request_log": dat2,
  245. "time_stamp": dat3,
  246. })
  247. }
  248. type All struct {
  249. HisPrescription HisPrescription
  250. mdtrt_id string
  251. psn_no string
  252. }
  253. type HisPrescription struct {
  254. ID int64 `gorm:"column:id" json:"id" form:"id"`
  255. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  256. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  257. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  258. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  259. Status int64 `gorm:"column:status" json:"status" form:"status"`
  260. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  261. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  262. Number string `gorm:"column:number" json:"number" form:"number"`
  263. Type int64 `gorm:"column:type" json:"type" form:"type"`
  264. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  265. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  266. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  267. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  268. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  269. }
  270. func (c *JSybController) PostFive() {
  271. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  272. var respJSON map[string]interface{}
  273. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  275. return
  276. }
  277. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  278. var hp []*models.HisPrescription
  279. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  280. utils.ErrorLog("解析失败:%v", err)
  281. return
  282. }
  283. //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
  284. result, request_log := service.Jsyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  285. 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))
  286. saveJsLog(result, request_log, "2204", "上传明细", respJSON["org_name"].(string))
  287. var dat map[string]interface{}
  288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  289. fmt.Println(dat)
  290. } else {
  291. fmt.Println(err)
  292. }
  293. var dat2 map[string]interface{}
  294. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  295. fmt.Println(dat2)
  296. } else {
  297. fmt.Println(err)
  298. }
  299. c.ServeSuccessJSON(map[string]interface{}{
  300. "pre": dat,
  301. "request_log": dat2,
  302. })
  303. }
  304. func (c *JSybController) PostSix() {
  305. psnNo := c.GetString("psn_no")
  306. mdtrtId := c.GetString("mdtrt_id")
  307. chrgBchno := c.GetString("chrg_bchno")
  308. org_name := c.GetString("org_name")
  309. doctor := c.GetString("doctor")
  310. insuplc_admdvs := c.GetString("insuplc_admdvs")
  311. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  312. secret_key := c.GetString("secret_key")
  313. fixmedins_code := c.GetString("fixmedins_code")
  314. url := c.GetString("url")
  315. ak := c.GetString("ak")
  316. cainfo := c.GetString("cainfo")
  317. result, request_log := service.Jsyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  318. fmt.Println(request_log)
  319. saveJsLog(result, request_log, "2205", "撤销明细", org_name)
  320. var dat map[string]interface{}
  321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  322. fmt.Println(dat)
  323. } else {
  324. fmt.Println(err)
  325. }
  326. var dat2 map[string]interface{}
  327. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  328. fmt.Println(dat2)
  329. } else {
  330. fmt.Println(err)
  331. }
  332. c.ServeSuccessJSON(map[string]interface{}{
  333. "pre": dat,
  334. "request_log": dat2,
  335. })
  336. }
  337. func (c *JSybController) PostSeven() {
  338. psnNo := c.GetString("psn_no")
  339. mdtrtId := c.GetString("mdtrt_id")
  340. chrgBchno := c.GetString("chrg_bchno")
  341. certNo := c.GetString("cert_no")
  342. insutype := c.GetString("insutype")
  343. total := c.GetString("total")
  344. org_name := c.GetString("org_name")
  345. doctor := c.GetString("doctor")
  346. fixmedins_code := c.GetString("fixmedins_code")
  347. insuplc_admdvs := c.GetString("insuplc_admdvs")
  348. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  349. secret_key := c.GetString("secret_key")
  350. med_type := c.GetString("med_type")
  351. id_card_type, _ := c.GetInt64("id_card_type")
  352. certificates, _ := c.GetInt64("certificates")
  353. verify_number := c.GetString("verify_number")
  354. cainfo := c.GetString("cainfo")
  355. url := c.GetString("url")
  356. ak := c.GetString("ak")
  357. 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)
  358. saveJsLog(result, request_log, "2206", "预结算", org_name)
  359. var dat map[string]interface{}
  360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  361. fmt.Println(dat)
  362. } else {
  363. fmt.Println(err)
  364. }
  365. var dat2 map[string]interface{}
  366. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  367. fmt.Println(dat2)
  368. } else {
  369. fmt.Println(err)
  370. }
  371. c.ServeSuccessJSON(map[string]interface{}{
  372. "pre": dat,
  373. "request_log": dat2,
  374. })
  375. }
  376. func (c *JSybController) PostEight() {
  377. psnNo := c.GetString("psn_no")
  378. mdtrtId := c.GetString("mdtrt_id")
  379. chrgBchno := c.GetString("chrg_bchno")
  380. certNo := c.GetString("cert_no")
  381. insutype := c.GetString("insutype")
  382. total := c.GetString("total")
  383. org_name := c.GetString("org_name")
  384. doctor := c.GetString("doctor")
  385. fixmedins_code := c.GetString("fixmedins_code")
  386. insuplc_admdvs := c.GetString("insuplc_admdvs")
  387. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  388. secret_key := c.GetString("secret_key")
  389. med_type := c.GetString("med_type")
  390. id_card_type, _ := c.GetInt64("id_card_type")
  391. certificates, _ := c.GetInt64("certificates")
  392. fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
  393. overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
  394. preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
  395. inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
  396. acct_used_flag := c.GetString("acct_used_flag")
  397. url := c.GetString("url")
  398. ak := c.GetString("ak")
  399. verify_number := c.GetString("verify_number")
  400. cainfo := c.GetString("cainfo")
  401. 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)
  402. saveJsLog(result, request_log, "2207", "结算", org_name)
  403. var dat map[string]interface{}
  404. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  405. fmt.Println(dat)
  406. } else {
  407. fmt.Println(err)
  408. }
  409. var dat2 map[string]interface{}
  410. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  411. fmt.Println(dat2)
  412. } else {
  413. fmt.Println(err)
  414. }
  415. c.ServeSuccessJSON(map[string]interface{}{
  416. "pre": dat,
  417. "request_log": dat2,
  418. })
  419. }
  420. func (c *JSybController) PostNine() {
  421. psnNo := c.GetString("psn_no")
  422. mdtrtId := c.GetString("mdtrt_id")
  423. setlId := c.GetString("setl_id")
  424. org_name := c.GetString("org_name")
  425. doctor := c.GetString("doctor")
  426. secret_key := c.GetString("secret_key")
  427. fixmedins_code := c.GetString("fixmedins_code")
  428. insuplc_admdvs := c.GetString("insuplc_admdvs")
  429. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  430. url := c.GetString("url")
  431. ak := c.GetString("ak")
  432. cainfo := c.GetString("cainfo")
  433. result, request_log := service.Jsyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  434. saveJsLog(result, request_log, "2208", "退费", org_name)
  435. fmt.Println(request_log)
  436. var dat map[string]interface{}
  437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  438. fmt.Println(dat)
  439. } else {
  440. fmt.Println(err)
  441. }
  442. var dat2 map[string]interface{}
  443. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  444. fmt.Println(dat2)
  445. } else {
  446. fmt.Println(err)
  447. }
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "pre": dat,
  450. "request_log": dat2,
  451. })
  452. }
  453. func (c *JSybController) PostTen() {
  454. psnNo := c.GetString("psn_no")
  455. mdtrtId := c.GetString("mdtrt_id")
  456. setlId := c.GetString("setl_id")
  457. org_name := c.GetString("org_name")
  458. doctor := c.GetString("doctor")
  459. secret_key := c.GetString("secret_key")
  460. fixmedins_code := c.GetString("fixmedins_code")
  461. insuplc_admdvs := c.GetString("insuplc_admdvs")
  462. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  463. url := c.GetString("url")
  464. ak := c.GetString("ak")
  465. cainfo := c.GetString("cainfo")
  466. baseParams := models.BaseParams{
  467. SecretKey: secret_key,
  468. FixmedinsCode: fixmedins_code,
  469. InsuplcAdmdvs: insuplc_admdvs,
  470. MdtrtareaAdmvs: mdtrtarea_admvs,
  471. OrgName: org_name,
  472. Doctor: doctor,
  473. RequestUrl: url,
  474. AccessKey: ak,
  475. Cainfo: cainfo,
  476. }
  477. businessParams := models.BusinessParams{
  478. PsnNo: psnNo,
  479. MdtrtId: mdtrtId,
  480. SetlId: setlId,
  481. }
  482. result, request_log := service.Jsyb5203(baseParams, businessParams)
  483. saveJsLog(result, request_log, "5203", "结算单", org_name)
  484. var dat map[string]interface{}
  485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  486. fmt.Println(dat)
  487. } else {
  488. fmt.Println(err)
  489. }
  490. var dat2 map[string]interface{}
  491. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  492. fmt.Println(dat2)
  493. } else {
  494. fmt.Println(err)
  495. }
  496. c.ServeSuccessJSON(map[string]interface{}{
  497. "pre": dat,
  498. "request_log": dat2,
  499. })
  500. }
  501. func (c *JSybController) Get2503() {
  502. psnNo := c.GetString("psn_no")
  503. insutype := c.GetString("insutype")
  504. sick_code := c.GetString("sick_code")
  505. sick_name := c.GetString("sick_name")
  506. insuplc_admdvs := c.GetString("insuplc_admdvs")
  507. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  508. secret_key := c.GetString("secret_key")
  509. access_key := c.GetString("access_key")
  510. fixmedins_code := c.GetString("fixmedins_code")
  511. org_name := c.GetString("org_name")
  512. check_time := c.GetString("check_time")
  513. doctor_id := c.GetString("doctor_id")
  514. doctor := c.GetString("doctor")
  515. start_time := c.GetString("start_time")
  516. end_time := c.GetString("end_time")
  517. url := c.GetString("url")
  518. cainfo := c.GetString("cainfo")
  519. 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)
  520. }
  521. func (c *JSybController) Get3201() {
  522. insutype := c.GetString("insutype")
  523. clrType := c.GetString("clr_type")
  524. setlOptins := c.GetString("setl_optins")
  525. stmtBegndate := c.GetString("stmt_begndate")
  526. stmtEnddate := c.GetString("stm_enddate")
  527. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  528. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  529. acctPay, _ := c.GetFloat("acct_pay", 0)
  530. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  531. fixmedins_code := c.GetString("fixmedins_code")
  532. insuplc_admdvs := c.GetString("insuplc_admdvs")
  533. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  534. secret_key := c.GetString("secret_key")
  535. org_name := c.GetString("org_name")
  536. doctor := c.GetString("doctor")
  537. url := c.GetString("url")
  538. ak := c.GetString("ak")
  539. cainfo := c.GetString("cainfo")
  540. 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)
  541. saveJsLog(result, request_log, "3201", "对总账", org_name)
  542. var dat map[string]interface{}
  543. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  544. fmt.Println(dat)
  545. } else {
  546. fmt.Println(err)
  547. }
  548. var dat2 map[string]interface{}
  549. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  550. fmt.Println(dat2)
  551. } else {
  552. fmt.Println(err)
  553. }
  554. c.ServeSuccessJSON(map[string]interface{}{
  555. "pre": dat,
  556. "request_log": dat2,
  557. })
  558. }
  559. type ELeData struct {
  560. Data struct {
  561. SiNo string `json:"si_no"`
  562. SiCardNo string `json:"si_card_no"`
  563. SiCardIssueArea string `json:"si_card_issue_area"`
  564. Name string `json:"name"`
  565. Gender string `json:"gender"`
  566. IdType string `json:"id_type"`
  567. IdNo string `json:"id_no"`
  568. EcCardToken string `json:"ecCardToken"`
  569. } `json:"data"`
  570. Code int `json:"code"`
  571. Message string `json:"message"`
  572. }
  573. func (c *JSybController) ReadCard() {
  574. fixmedins_code := c.GetString("fixmedins_code")
  575. secret_key := c.GetString("secret_key")
  576. ak := c.GetString("ak")
  577. org_name := c.GetString("org_name")
  578. doctor := c.GetString("doctor")
  579. insuplc_admdvs := c.GetString("insuplc_admdvs")
  580. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  581. url := c.GetString("url")
  582. cainfo := c.GetString("cainfo")
  583. id_card_type := c.GetString("id_card_type")
  584. operator_id := c.GetString("operator_id")
  585. operator := c.GetString("operator")
  586. //result, request := service.Jsyb9001(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, url, cainfo, ak)
  587. //fmt.Println(request)
  588. //fmt.Println(result)
  589. c.TestGetBasBaseInit(fixmedins_code, secret_key, ak)
  590. fmt.Println(id_card_type)
  591. switch id_card_type {
  592. case "1":
  593. pCardInfo, pBusiCardInfo := c.GetBasBaseInfo()
  594. pBusiCardInfo = Remove0000(pBusiCardInfo)
  595. pCardInfo = Remove0000(pCardInfo)
  596. fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8"))
  597. fmt.Println(pBusiCardInfo)
  598. fmt.Println(pCardInfo)
  599. bas := strings.Split(pCardInfo, "|")
  600. basNumber := bas[2]
  601. id_card_no := bas[1]
  602. card_sn := bas[3]
  603. id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64)
  604. if len(pCardInfo) > 0 && len(pBusiCardInfo) > 0 {
  605. 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)
  606. var dat map[string]interface{}
  607. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  608. fmt.Println(dat)
  609. } else {
  610. fmt.Println(err)
  611. }
  612. c.ServeSuccessJSON(map[string]interface{}{
  613. "status": "0",
  614. "card_info": pCardInfo,
  615. "busi_card_info": pBusiCardInfo,
  616. "result": dat,
  617. "type": "1",
  618. })
  619. } else {
  620. c.ServeSuccessJSON(map[string]interface{}{
  621. "status": "-1",
  622. })
  623. }
  624. break
  625. case "3": //电子凭证
  626. pCardInfo, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  627. fmt.Println(pCardInfo)
  628. fmt.Println(pBusiCardInfo)
  629. pBusiCardInfo = Remove0000(pBusiCardInfo)
  630. pCardInfo = Remove0000(pCardInfo)
  631. var ele ELeData
  632. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  633. if err != nil {
  634. utils.ErrorLog("解析失败:%v", err)
  635. }
  636. token := ele.Data.EcCardToken
  637. if len(token) > 0 {
  638. result, _ := service.Jsyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo)
  639. var dat map[string]interface{}
  640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  641. fmt.Println(dat)
  642. } else {
  643. fmt.Println(err)
  644. }
  645. c.ServeSuccessJSON(map[string]interface{}{
  646. "status": "0",
  647. "card_info": pCardInfo,
  648. "busi_card_info": pBusiCardInfo,
  649. "token": token,
  650. "result": dat,
  651. "type": "2",
  652. })
  653. } else {
  654. c.ServeSuccessJSON(map[string]interface{}{
  655. "status": "-1",
  656. })
  657. }
  658. break
  659. }
  660. }
  661. func (c *JSybController) TestGetBasBaseInit(code string, secret_key string, ak string) {
  662. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  663. Iinit := DllDef.MustFindProc("Init")
  664. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  665. str := make([]byte, 2048)
  666. inputData := make(map[string]interface{})
  667. inputData["IP"] = "10.72.3.87"
  668. inputData["PORT"] = "8086"
  669. inputData["TIMEOUT"] = "180"
  670. inputData["LOG_PATH"] = "C:\\log\\"
  671. //
  672. inputData["EC_URL"] = "http://10.72.3.127:10086/localcfc/api/hsecfc/localQrCodeQuery"
  673. inputData["CARD_PASSTYPE"] = "1"
  674. inputData["API_NAME"] = "hssServives"
  675. inputData["API_VERSION"] = "1.0.0"
  676. inputData["ACCESS_KEY"] = ak
  677. inputData["SECRETKEY"] = secret_key
  678. inputData["ORG_ID"] = code
  679. inputData["EXT"] = ""
  680. bytesData, _ := json.Marshal(inputData)
  681. fmt.Println(inputData)
  682. fmt.Println(bytesData)
  683. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  684. if ret != 0 {
  685. fmt.Println("SSCard的报错原因:", err)
  686. fmt.Println("SSCard的运算结果为:", ret)
  687. fmt.Println("SSCard的返回结果为:", string(str))
  688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  689. return
  690. }
  691. fmt.Println("SSCard的返回结果为:", string(str))
  692. result := int(ret)
  693. fmt.Println("SSCard的运算结果为1:", result)
  694. //initFlag = 1
  695. return
  696. }
  697. func (c *JSybController) GetBasBaseInfo() (string, string) {
  698. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  699. readCard := DllDef.MustFindProc("ReadCardBas")
  700. fmt.Println(readCard)
  701. fmt.Println("!!!!!")
  702. pCardInfo := make([]byte, 2048)
  703. pBusiCardInfo := make([]byte, 8192)
  704. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  705. fmt.Println(ret2)
  706. fmt.Println(DeleteExtraSpace(string(pCardInfo)))
  707. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  708. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
  709. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  710. if ret2 != 0 {
  711. return "", ""
  712. }
  713. return DeleteExtraSpace(string(pCardInfo)), DeleteExtraSpace(string(pBusiCardInfo))
  714. }
  715. func (c *JSybController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  716. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  717. readCard := DllDef.MustFindProc("EcCardQuery")
  718. fmt.Println(readCard)
  719. fmt.Println("!!!!!")
  720. //pCardInfo := make([]byte, 8192)
  721. pBusiCardInfo := make([]byte, 8192)
  722. data := make(map[string]interface{})
  723. //pData := make(map[string]interface{})
  724. inputData := make(map[string]interface{})
  725. inputData["orgId"] = code
  726. inputData["businessType"] = "01101"
  727. inputData["operatorId"] = operator_id
  728. inputData["operatorName"] = operator_name
  729. inputData["officeId"] = "001"
  730. inputData["officeName"] = "血透室"
  731. data["data"] = inputData
  732. data["transType"] = "ec.query"
  733. data["orgId"] = code
  734. bytesData, _ := json.Marshal(data)
  735. //pCardInfo = bytesData
  736. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  737. fmt.Println(ret2)
  738. fmt.Println(DeleteExtraSpace(string(bytesData)))
  739. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  740. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  741. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  742. if ret2 != 0 {
  743. return "", ""
  744. }
  745. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  746. }
  747. func IntPtr(n int) uintptr {
  748. return uintptr(n)
  749. }
  750. func StrPtr(s string) uintptr {
  751. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  752. }
  753. type Charset string
  754. const (
  755. UTF8 = Charset("UTF-8")
  756. GB18030 = Charset("GB18030")
  757. )
  758. func ConvertToString(src string, srcCode string, tagCode string) string {
  759. srcCoder := mahonia.NewDecoder(srcCode)
  760. srcResult := srcCoder.ConvertString(src)
  761. tagCoder := mahonia.NewDecoder(tagCode)
  762. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  763. result := string(cdata)
  764. return result
  765. }
  766. func DeleteExtraSpace(s string) string {
  767. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  768. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  769. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  770. reg, _ := regexp.Compile(regstr) //编译正则表达式
  771. s2 := make([]byte, len(s1)) //定义字符数组切片
  772. copy(s2, s1) //将字符串复制到切片
  773. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  774. for len(spc_index) > 0 { //找到适配项
  775. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  776. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  777. }
  778. return string(s2)
  779. }
  780. func Remove0000(s string) string {
  781. str := make([]rune, 0, len(s))
  782. for _, v := range []rune(s) {
  783. if v == 0 {
  784. continue
  785. }
  786. str = append(str, v)
  787. }
  788. return string(str)
  789. }
  790. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  791. //org_id, _ := beego.AppConfig.Int64("org_id")
  792. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  793. dir := org_name + "日志"
  794. utils.Mkdir(dir)
  795. month := time.Unix(1557042972, 0).Format("1")
  796. year := time.Now().Format("2006")
  797. month = time.Now().Format("01")
  798. day := time.Now().Format("02")
  799. hour := time.Now().Format("15")
  800. min := time.Now().Format("04")
  801. sec := time.Now().Format("05")
  802. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  803. file := org_name + "_" + year + month + day + "_log"
  804. file_name := file + ".txt"
  805. file_path := org_name + "日志" + "/" + file_name
  806. exist, _ := utils.PathExists(file_path)
  807. if exist { //存在
  808. fmt.Println("存在")
  809. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  810. if err != nil {
  811. fmt.Println("read fail")
  812. }
  813. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  814. n, _ := f.Seek(0, 2)
  815. _, err = f.WriteAt([]byte(content), n)
  816. } else { //不存在
  817. fmt.Println("文件不存在,创建文件")
  818. f, err := os.Create(org_name + "日志" + "/" + file_name)
  819. defer f.Close()
  820. if err != nil {
  821. } else {
  822. _, err = f.Write([]byte("记录日志"))
  823. }
  824. }
  825. }