gdyb_controller.go 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. package controllers
  2. import (
  3. "XT_New/models"
  4. "XT_New/service"
  5. "XT_New/utils"
  6. "encoding/json"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "io/ioutil"
  10. )
  11. type GdybController struct {
  12. BaseAuthAPIController
  13. }
  14. func GdybRegistRouters() {
  15. beego.Router("/gdyb/one", &GdybController{}, "get:PostOne")
  16. beego.Router("/gdyb/two", &GdybController{}, "get:PostTwo")
  17. beego.Router("/gdyb/three", &GdybController{}, "get:PostThree")
  18. beego.Router("/gdyb/four", &GdybController{}, "get:PostFour")
  19. beego.Router("/gdyb/five", &GdybController{}, "post:PostFive")
  20. beego.Router("/gdyb/six", &GdybController{}, "get:PostSix")
  21. beego.Router("/gdyb/seven", &GdybController{}, "get:PostSeven")
  22. beego.Router("/gdyb/eight", &GdybController{}, "get:PostEight")
  23. beego.Router("/gdyb/nine", &GdybController{}, "get:PostNine")
  24. beego.Router("/gdyb/ten", &GdybController{}, "get:PostTen")
  25. beego.Router("/gdyb/eleven", &GdybController{}, "get:PostEleven")
  26. beego.Router("/gdyb/twelve", &GdybController{}, "get:PostTwelve")
  27. }
  28. type Result struct {
  29. ErrMsg interface{} `json:"err_msg"`
  30. InfRefmsgid string `json:"inf_refmsgid"`
  31. Infcode int64 `json:"infcode"`
  32. Output struct {
  33. Baseinfo struct {
  34. Age float64 `json:"age"`
  35. Brdy string `json:"brdy"`
  36. Certno string `json:"certno"`
  37. Gend string `json:"gend"`
  38. Naty string `json:"naty"`
  39. PsnCertType string `json:"psn_cert_type"`
  40. PsnName string `json:"psn_name"`
  41. PsnNo string `json:"psn_no"`
  42. } `json:"baseinfo"`
  43. Idetinfo []interface{} `json:"idetinfo"`
  44. Iinfo []struct {
  45. Balc int64 `json:"balc"`
  46. CvlservFlag string `json:"cvlserv_flag"`
  47. EmpName string `json:"emp_name"`
  48. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  49. Insutype string `json:"insutype"`
  50. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  51. PausInsuDate interface{} `json:"paus_insu_date"`
  52. PsnInsuDate string `json:"psn_insu_date"`
  53. PsnInsuStas string `json:"psn_insu_stas"`
  54. PsnType string `json:"psn_type"`
  55. } `json:"iinfo"`
  56. } `json:"output"`
  57. RefmsgTime string `json:"refmsg_time"`
  58. RespondTime string `json:"respond_time"`
  59. Signtype interface{} `json:"signtype"`
  60. WarnInfo interface{} `json:"warn_info"`
  61. }
  62. func (c *GdybController) PostOne() {
  63. certNo := c.GetString("cert_no")
  64. org_name := c.GetString("org_name")
  65. doctor := c.GetString("doctor")
  66. fixmedins_code := c.GetString("fixmedins_code")
  67. insuplc_admdvs := c.GetString("insuplc_admdvs")
  68. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  69. secret_key := c.GetString("secret_key")
  70. result := service.Gdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
  71. var dat map[string]interface{}
  72. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  73. } else {
  74. }
  75. c.ServeSuccessJSON(map[string]interface{}{
  76. "pre": dat,
  77. })
  78. }
  79. func (c *GdybController) PostTwo() {
  80. psnNo := c.GetString("psn_no")
  81. insutype := c.GetString("insutype")
  82. certNo := c.GetString("cert_no")
  83. org_name := c.GetString("org_name")
  84. doctor := c.GetString("doctor")
  85. ipt_otp_no := c.GetString("ipt_otp_no")
  86. dept := c.GetString("dept")
  87. fixmedins_code := c.GetString("fixmedins_code")
  88. dept_code := c.GetString("dept_code")
  89. doctor_id := c.GetString("doctor_id")
  90. insuplc_admdvs := c.GetString("insuplc_admdvs")
  91. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  92. secret_key := c.GetString("secret_key")
  93. result := service.Gdyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key)
  94. var dat map[string]interface{}
  95. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  96. //fmt.Println(dat["status"])
  97. } else {
  98. }
  99. c.ServeSuccessJSON(map[string]interface{}{
  100. "pre": dat,
  101. })
  102. }
  103. func (c *GdybController) PostThree() {
  104. psnNo := c.GetString("psn_no")
  105. mdtrtId := c.GetString("mdtrt_id")
  106. iptOtpNo := c.GetString("ipt_otp_no")
  107. org_name := c.GetString("org_name")
  108. doctor := c.GetString("doctor")
  109. insuplc_admdvs := c.GetString("insuplc_admdvs")
  110. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  111. secret_key := c.GetString("secret_key")
  112. result := service.Gdyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key)
  113. c.ServeSuccessJSON(map[string]interface{}{
  114. "pre": result,
  115. })
  116. }
  117. func (c *GdybController) PostFour() {
  118. psnNo := c.GetString("psn_no")
  119. mdtrtId := c.GetString("mdtrt_id")
  120. doctor := c.GetString("doctor")
  121. department := c.GetString("department")
  122. diag := c.GetString("diag")
  123. org_name := c.GetString("org_name")
  124. med_type := c.GetString("med_type")
  125. doctor_id, _ := c.GetInt64("doctor_id", 0)
  126. fixmedins_code := c.GetString("fixmedins_code")
  127. diag_code := c.GetString("diag_code")
  128. insuplc_admdvs := c.GetString("insuplc_admdvs")
  129. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  130. secret_key := c.GetString("secret_key")
  131. result := service.Gdyb2203(psnNo, mdtrtId, doctor, department, diag, org_name, med_type, doctor_id, fixmedins_code, diag_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
  132. var dat map[string]interface{}
  133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  134. } else {
  135. }
  136. c.ServeSuccessJSON(map[string]interface{}{
  137. "pre": dat,
  138. })
  139. }
  140. type All struct {
  141. HisPrescription HisPrescription
  142. mdtrt_id string
  143. psn_no string
  144. }
  145. type HisPrescription struct {
  146. ID int64 `gorm:"column:id" json:"id" form:"id"`
  147. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  148. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  149. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  150. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  151. Status int64 `gorm:"column:status" json:"status" form:"status"`
  152. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  153. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  154. Number string `gorm:"column:number" json:"number" form:"number"`
  155. Type int64 `gorm:"column:type" json:"type" form:"type"`
  156. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  157. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  158. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  159. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  160. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  161. }
  162. func (c *GdybController) PostFive() {
  163. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  164. var respJSON map[string]interface{}
  165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  167. return
  168. }
  169. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  170. var hp []*models.HisPrescription
  171. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  172. utils.ErrorLog("解析失败:%v", err)
  173. return
  174. }
  175. fmt.Println(respJSON["psn_no"].(string))
  176. fmt.Println(respJSON["mdtrt_id"].(string))
  177. fmt.Println(respJSON["chrg_bchno"].(string))
  178. fmt.Println(respJSON["org_name"].(string))
  179. fmt.Println(respJSON["doctor"].(string))
  180. fmt.Println(respJSON["dept"].(string))
  181. fmt.Println(respJSON["fixmedins_code"].(string))
  182. fmt.Println(respJSON["dept_code"].(string))
  183. fmt.Println(respJSON["doctor_id"].(string))
  184. fmt.Println(respJSON["insuplc_admdvs"].(string))
  185. fmt.Println(respJSON["mdtrtarea_admvs"].(string))
  186. fmt.Println(respJSON["secret_key"].(string))
  187. result := service.Gdyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  188. 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))
  189. var dat map[string]interface{}
  190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  191. fmt.Println(dat)
  192. } else {
  193. fmt.Println(err)
  194. }
  195. c.ServeSuccessJSON(map[string]interface{}{
  196. "pre": dat,
  197. })
  198. }
  199. func (c *GdybController) PostSix() {
  200. psnNo := c.GetString("psn_no")
  201. mdtrtId := c.GetString("mdtrt_id")
  202. chrgBchno := c.GetString("chrg_bchno")
  203. org_name := c.GetString("org_name")
  204. doctor := c.GetString("doctor")
  205. insuplc_admdvs := c.GetString("insuplc_admdvs")
  206. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  207. secret_key := c.GetString("secret_key")
  208. fixmedins_code := c.GetString("fixmedins_code")
  209. result := service.Gdyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  210. var dat map[string]interface{}
  211. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  212. fmt.Println(dat)
  213. } else {
  214. fmt.Println(err)
  215. }
  216. c.ServeSuccessJSON(map[string]interface{}{
  217. "pre": result,
  218. })
  219. }
  220. func (c *GdybController) PostSeven() {
  221. psnNo := c.GetString("psn_no")
  222. mdtrtId := c.GetString("mdtrt_id")
  223. chrgBchno := c.GetString("chrg_bchno")
  224. certNo := c.GetString("cert_no")
  225. insutype := c.GetString("insutype")
  226. total := c.GetString("total")
  227. org_name := c.GetString("org_name")
  228. doctor := c.GetString("doctor")
  229. secret_key := c.GetString("secret_key")
  230. result := service.Gdyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, secret_key)
  231. var dat map[string]interface{}
  232. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  233. fmt.Println(dat)
  234. } else {
  235. fmt.Println(err)
  236. }
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "pre": dat,
  239. })
  240. }
  241. func (c *GdybController) PostEight() {
  242. psnNo := c.GetString("psn_no")
  243. mdtrtId := c.GetString("mdtrt_id")
  244. chrgBchno := c.GetString("chrg_bchno")
  245. certNo := c.GetString("cert_no")
  246. insutype := c.GetString("insutype")
  247. total := c.GetString("total")
  248. org_name := c.GetString("org_name")
  249. doctor := c.GetString("doctor")
  250. fixmedins_code := c.GetString("fixmedins_code")
  251. insuplc_admdvs := c.GetString("insuplc_admdvs")
  252. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  253. secret_key := c.GetString("secret_key")
  254. result := service.Gdyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key)
  255. var dat map[string]interface{}
  256. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  257. fmt.Println(dat)
  258. } else {
  259. fmt.Println(err)
  260. }
  261. c.ServeSuccessJSON(map[string]interface{}{
  262. "pre": dat,
  263. })
  264. }
  265. func (c *GdybController) PostNine() {
  266. psnNo := c.GetString("psn_no")
  267. mdtrtId := c.GetString("mdtrt_id")
  268. setlId := c.GetString("setl_id")
  269. org_name := c.GetString("org_name")
  270. doctor := c.GetString("doctor")
  271. secret_key := c.GetString("secret_key")
  272. fixmedins_code := c.GetString("fixmedins_code")
  273. insuplc_admdvs := c.GetString("insuplc_admdvs")
  274. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  275. result := service.Gdyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  276. var dat map[string]interface{}
  277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  278. fmt.Println(dat)
  279. } else {
  280. fmt.Println(err)
  281. }
  282. c.ServeSuccessJSON(map[string]interface{}{
  283. "pre": dat,
  284. })
  285. }
  286. func (c *GdybController) PostTen() {
  287. fmt.Println("11222333-----")
  288. insutype := c.GetString("insutype")
  289. clrType := c.GetString("clr_type")
  290. setlOptins := c.GetString("setl_optins")
  291. stmtBegndate := c.GetString("stmt_begndate")
  292. stmtEnddate := c.GetString("stm_enddate")
  293. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  294. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  295. acctPay, _ := c.GetFloat("acct_pay", 0)
  296. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  297. fixmedins_code := c.GetString("fixmedins_code")
  298. insuplc_admdvs := c.GetString("insuplc_admdvs")
  299. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  300. secret_key := c.GetString("secret_key")
  301. org_name := c.GetString("org_name")
  302. doctor := c.GetString("doctor")
  303. fmt.Println(insutype)
  304. fmt.Println(clrType)
  305. fmt.Println(setlOptins)
  306. fmt.Println(stmtBegndate)
  307. fmt.Println(stmtEnddate)
  308. fmt.Println(medfeeSumamt)
  309. baseParams := models.BaseParams{
  310. SecretKey: secret_key,
  311. FixmedinsCode: fixmedins_code,
  312. InsuplcAdmdvs: insuplc_admdvs,
  313. MdtrtareaAdmvs: mdtrtarea_admvs,
  314. OrgName: org_name,
  315. Doctor: doctor,
  316. }
  317. businessParams := models.BusinessParams{
  318. Insutype: insutype,
  319. ClrType: clrType,
  320. SetlOptins: setlOptins,
  321. StmtBegndate: stmtBegndate,
  322. StmtEnddate: stmtEnddate,
  323. MedfeeSumamt: medfeeSumamt,
  324. FundPaySumamt: fundPaySumamt,
  325. AcctPay: acctPay,
  326. FixmedinsSetlCnt: fixmedinsSetlCnt,
  327. }
  328. fmt.Println(baseParams)
  329. fmt.Println(businessParams)
  330. fmt.Println("11222333--33333---")
  331. result := service.Gdyb3201(baseParams, businessParams)
  332. fmt.Println("11222333--33333---555555")
  333. var dat map[string]interface{}
  334. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  335. fmt.Println(dat)
  336. } else {
  337. fmt.Println(err)
  338. }
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "pre": dat,
  341. })
  342. }
  343. func (c *GdybController) PostEleven() {
  344. //fmt.Println("777777666666-----")
  345. //
  346. //file_byte := c.GetString("file_byte")
  347. //file_name := c.GetString("file_name")
  348. //fixmedins_code := c.GetString("fixmedins_code")
  349. //insuplc_admdvs := c.GetString("insuplc_admdvs")
  350. //mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  351. //secret_key := c.GetString("secret_key")
  352. //org_name := c.GetString("org_name")
  353. //doctor := c.GetString("doctor")
  354. //
  355. //baseParams := models.BaseParams{
  356. // SecretKey: secret_key,
  357. // FixmedinsCode: fixmedins_code,
  358. // InsuplcAdmdvs: insuplc_admdvs,
  359. // MdtrtareaAdmvs: mdtrtarea_admvs,
  360. // OrgName: org_name,
  361. // Doctor: doctor,
  362. //}
  363. //x := (*[2]uintptr)(unsafe.Pointer(&file_byte))
  364. //h := [3]uintptr{x[0], x[1], x[1]}
  365. //bytes := *(*[]byte)(unsafe.Pointer(&h))
  366. //result := service.Gdyb9101(baseParams, file_name, []byte(file_byte))
  367. //var dat map[string]interface{}
  368. //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  369. // fmt.Println(dat)
  370. //} else {
  371. // fmt.Println(err)
  372. //}
  373. //c.ServeSuccessJSON(map[string]interface{}{
  374. // "pre": dat,
  375. //})
  376. }
  377. func (c *GdybController) PostTwelve() {
  378. fileQuryNo := c.GetString("file_qury_no")
  379. setlOptins := c.GetString("setl_optins")
  380. stmtBegndate := c.GetString("stmt_begndate")
  381. stmtEnddate := c.GetString("stm_enddate")
  382. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  383. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  384. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  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. org_name := c.GetString("org_name")
  390. doctor := c.GetString("doctor")
  391. cashPayamt, _ := c.GetFloat("cash_payamt", 0)
  392. baseParams := models.BaseParams{
  393. SecretKey: secret_key,
  394. FixmedinsCode: fixmedins_code,
  395. InsuplcAdmdvs: insuplc_admdvs,
  396. MdtrtareaAdmvs: mdtrtarea_admvs,
  397. OrgName: org_name,
  398. Doctor: doctor,
  399. }
  400. businessParams := models.BusinessParams{
  401. FileQuryNo: fileQuryNo,
  402. SetlOptins: setlOptins,
  403. StmtBegndate: stmtBegndate,
  404. StmtEnddate: stmtEnddate,
  405. MedfeeSumamt: medfeeSumamt,
  406. FundPaySumamt: fundPaySumamt,
  407. FixmedinsSetlCnt: fixmedinsSetlCnt,
  408. CashPayamt: cashPayamt,
  409. }
  410. result := service.Gdyb3202(baseParams, businessParams)
  411. var dat map[string]interface{}
  412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  413. fmt.Println(dat)
  414. } else {
  415. fmt.Println(err)
  416. }
  417. c.ServeSuccessJSON(map[string]interface{}{
  418. "pre": dat,
  419. })
  420. }