nm_controller.go 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. package nm
  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 NmController struct {
  22. controllers.BaseAuthAPIController
  23. }
  24. func NmybRegistRouters() {
  25. beego.Router("/nmyb/1101", &NmController{}, "get:Post1101")
  26. beego.Router("/nmyb/2401", &NmController{}, "post:Post2401")
  27. beego.Router("/nmyb/2402", &NmController{}, "post:Post2402")
  28. beego.Router("/nmyb/2404", &NmController{}, "get:Post2404")
  29. beego.Router("/nmyb/2405", &NmController{}, "get:Post2405")
  30. beego.Router("/nmyb/2301", &NmController{}, "post:Post2301")
  31. beego.Router("/nmyb/2302", &NmController{}, "get:Post2302")
  32. beego.Router("/nmyb/2303", &NmController{}, "get:Post2303")
  33. beego.Router("/nmyb/2304", &NmController{}, "get:Post2304")
  34. beego.Router("/nmyb/2305", &NmController{}, "get:Post2305")
  35. beego.Router("/nmyb/5203", &NmController{}, "get:Post5203")
  36. //beego.Router("/nmyb/readcard", &NmController{}, "get:ReadCard")
  37. beego.Router("/nmyb/3201", &NmController{}, "get:Get3201")
  38. beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
  39. beego.Router("/nmyb/4101", &NmController{}, "post:Post4101")
  40. }
  41. type ReadCardResult struct {
  42. Output struct {
  43. CardInfo string `json:"cardInfo"`
  44. RegionCode string `json:"regionCode"`
  45. } `json:"output"`
  46. Code string `json:"CODE"`
  47. ErrMsg string `json:"ERRMSG"`
  48. }
  49. type ELeData struct {
  50. Data struct {
  51. IdNo string `json:"idNo"`
  52. IdType string `json:"idType"`
  53. UserName string `json:"userName"`
  54. EcToken string `json:"ecToken"`
  55. InsuOrg string `json:"insuOrg"`
  56. Gender string `json:"gender"`
  57. Birthday string `json:"birthday"`
  58. Nationality string `json:"nationality"`
  59. Email string `json:"email"`
  60. Extra string `json:"extra"`
  61. } `json:"data"`
  62. Code int `json:"code"`
  63. Message string `json:"message"`
  64. }
  65. type ResultTwo struct {
  66. ErrMsg string `json:"err_msg"`
  67. InfRefmsgid string `json:"inf_refmsgid"`
  68. Infcode string `json:"infcode"`
  69. Output struct {
  70. Baseinfo struct {
  71. Age float64 `json:"age"`
  72. Brdy string `json:"brdy"`
  73. Certno string `json:"certno"`
  74. Gend string `json:"gend"`
  75. Naty string `json:"naty"`
  76. PsnCertType string `json:"psn_cert_type"`
  77. PsnName string `json:"psn_name"`
  78. PsnNo string `json:"psn_no"`
  79. } `json:"baseinfo"`
  80. Idetinfo []interface{} `json:"idetinfo"`
  81. Iinfo []struct {
  82. Balc float64 `json:"balc"`
  83. CvlservFlag string `json:"cvlserv_flag"`
  84. EmpName string `json:"emp_name"`
  85. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  86. Insutype string `json:"insutype"`
  87. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  88. PausInsuDate string `json:"paus_insu_date"`
  89. PsnInsuDate string `json:"psn_insu_date"`
  90. PsnInsuStas string `json:"psn_insu_stas"`
  91. PsnType string `json:"psn_type"`
  92. } `json:"insuinfo"`
  93. } `json:"output"`
  94. RefmsgTime string `json:"refmsg_time"`
  95. RespondTime string `json:"respond_time"`
  96. Signtype interface{} `json:"signtype"`
  97. WarnInfo interface{} `json:"warn_info"`
  98. }
  99. type ResultTwo10265 struct {
  100. ErrMsg string `json:"err_msg"`
  101. InfRefmsgid string `json:"inf_refmsgid"`
  102. Infcode string `json:"infcode"`
  103. Output struct {
  104. Baseinfo struct {
  105. Age float64 `json:"age"`
  106. Brdy string `json:"brdy"`
  107. Certno string `json:"certno"`
  108. Gend string `json:"gend"`
  109. Naty string `json:"naty"`
  110. PsnCertType string `json:"psn_cert_type"`
  111. PsnName string `json:"psn_name"`
  112. PsnNo string `json:"psn_no"`
  113. } `json:"baseinfo"`
  114. Idetinfo []interface{} `json:"idetinfo"`
  115. Iinfo []struct {
  116. Balc float64 `json:"balc"`
  117. CvlservFlag string `json:"cvlserv_flag"`
  118. EmpName string `json:"emp_name"`
  119. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  120. Insutype string `json:"insutype"`
  121. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  122. PausInsuDate string `json:"paus_insu_date"`
  123. PsnInsuDate string `json:"psn_insu_date"`
  124. PsnInsuStas string `json:"psn_insu_stas"`
  125. PsnType string `json:"psn_type"`
  126. } `json:"insuinfo"`
  127. } `json:"output"`
  128. RefmsgTime string `json:"refmsg_time"`
  129. RespondTime string `json:"respond_time"`
  130. Signtype interface{} `json:"signtype"`
  131. WarnInfo interface{} `json:"warn_info"`
  132. }
  133. func (c *NmController) Post4101() {
  134. }
  135. func (c *NmController) Post2202() {
  136. result, requestLog := service.Gdyb2202("150000CFSJM100000100005413", "20211227145332876188", "2021122714565410808111489", "赤峰费森血液透析中心", "李彩星", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", "H15049901371")
  137. var dat map[string]interface{}
  138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  139. } else {
  140. }
  141. c.ServeSuccessJSON(map[string]interface{}{
  142. "pre": dat,
  143. "request_log": requestLog,
  144. })
  145. }
  146. func (c *NmController) Post5203() {
  147. fmt.Println("------")
  148. org_name := c.GetString("org_name")
  149. doctor := c.GetString("doctor")
  150. fixmedins_code := c.GetString("fixmedins_code")
  151. insuplc_admdvs := c.GetString("insuplc_admdvs")
  152. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  153. secret_key := c.GetString("secret_key")
  154. psn_no := c.GetString("psn_no")
  155. mdtrt_id := c.GetString("mdtrt_id")
  156. setl_id := c.GetString("setl_id")
  157. fmt.Println("------")
  158. bp := models.BaseParams{
  159. SecretKey: secret_key,
  160. FixmedinsCode: fixmedins_code,
  161. InsuplcAdmdvs: insuplc_admdvs,
  162. MdtrtareaAdmvs: mdtrtarea_admvs,
  163. OrgName: org_name,
  164. Doctor: doctor,
  165. }
  166. bps := models.BusinessParams{
  167. PsnNo: psn_no,
  168. MdtrtId: mdtrt_id,
  169. SetlId: setl_id,
  170. }
  171. result := service.ZHyb5203(bp, bps)
  172. saveJsLog(result, "", "5203", "结算单", org_name)
  173. var dat map[string]interface{}
  174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  175. } else {
  176. }
  177. c.ServeSuccessJSON(map[string]interface{}{
  178. "pre": dat,
  179. })
  180. }
  181. func (c *NmController) Post1101() {
  182. certNo := c.GetString("cert_no")
  183. org_name := c.GetString("org_name")
  184. doctor := c.GetString("doctor")
  185. fixmedins_code := c.GetString("fixmedins_code")
  186. insuplc_admdvs := c.GetString("insuplc_admdvs")
  187. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  188. secret_key := c.GetString("secret_key")
  189. id_card_type, _ := c.GetInt64("id_card_type")
  190. card_sn := c.GetString("card_sn")
  191. certificates := c.GetString("certificates")
  192. name := c.GetString("name")
  193. certificate, _ := strconv.ParseInt(certificates, 10, 64)
  194. result, request_log, result_log := service.ZHGdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificate, name)
  195. saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
  196. var dat map[string]interface{}
  197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  198. } else {
  199. }
  200. var dat2 map[string]interface{}
  201. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  202. } else {
  203. }
  204. c.ServeSuccessJSON(map[string]interface{}{
  205. "pre": dat,
  206. "log": dat2,
  207. })
  208. }
  209. func (c *NmController) Post2401() {
  210. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  211. var respJSON map[string]interface{}
  212. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  214. return
  215. }
  216. userJSONBytes, _ := json.Marshal(respJSON["struct_2401"])
  217. var struct2401 service.Struct2401
  218. if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
  219. utils.ErrorLog("解析失败:%v", err)
  220. return
  221. }
  222. org_name := respJSON["org_name"].(string)
  223. fixmedins_code := respJSON["fixmedins_code"].(string)
  224. doctor := respJSON["doctor"].(string)
  225. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  226. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  227. secret_key := respJSON["secret_key"].(string)
  228. result, request_log := service.ZHGdyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  229. saveJsLog(result, request_log, "2401", "入院登记", 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. c.ServeSuccessJSON(map[string]interface{}{
  239. "pre": dat,
  240. "request_log": dat2,
  241. })
  242. }
  243. func (c *NmController) Post2404() {
  244. mdtrt_id := c.GetString("mdtrt_id")
  245. psn_no := c.GetString("psn_no")
  246. doctor := c.GetString("doctor")
  247. fixmedins_code := c.GetString("fixmedins_code")
  248. insuplc_admdvs := c.GetString("insuplc_admdvs")
  249. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  250. secret_key := c.GetString("secret_key")
  251. org_name := c.GetString("org_name")
  252. result, requestLog := service.ZHGdyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  253. saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
  254. var dat map[string]interface{}
  255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  256. } else {
  257. }
  258. var dat2 map[string]interface{}
  259. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  260. } else {
  261. }
  262. c.ServeSuccessJSON(map[string]interface{}{
  263. "pre": dat,
  264. "log": dat2,
  265. })
  266. }
  267. func (c *NmController) Post2405() {
  268. mdtrt_id := c.GetString("mdtrt_id")
  269. psn_no := c.GetString("psn_no")
  270. doctor := c.GetString("doctor")
  271. fixmedins_code := c.GetString("fixmedins_code")
  272. insuplc_admdvs := c.GetString("insuplc_admdvs")
  273. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  274. secret_key := c.GetString("secret_key")
  275. org_name := c.GetString("org_name")
  276. result, requestLog := service.ZHGdyb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  277. saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
  278. var dat map[string]interface{}
  279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  280. } else {
  281. }
  282. var dat2 map[string]interface{}
  283. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  284. } else {
  285. }
  286. c.ServeSuccessJSON(map[string]interface{}{
  287. "pre": dat,
  288. "log": dat2,
  289. })
  290. }
  291. func (c *NmController) Post2402() {
  292. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  293. var respJSON map[string]interface{}
  294. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  295. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  296. return
  297. }
  298. userJSONBytes, _ := json.Marshal(respJSON["struct_2402"])
  299. var struct2402 service.Struct2402
  300. if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
  301. utils.ErrorLog("解析失败:%v", err)
  302. return
  303. }
  304. org_name := respJSON["org_name"].(string)
  305. fixmedins_code := respJSON["fixmedins_code"].(string)
  306. doctor := respJSON["doctor"].(string)
  307. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  308. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  309. secret_key := respJSON["secret_key"].(string)
  310. result, request_log := service.ZHGdyb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  311. saveJsLog(result, request_log, "2402", "出院", org_name)
  312. var dat2 map[string]interface{}
  313. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  314. } else {
  315. }
  316. var dat map[string]interface{}
  317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  318. } else {
  319. }
  320. c.ServeSuccessJSON(map[string]interface{}{
  321. "pre": dat,
  322. "request_log": dat2,
  323. })
  324. }
  325. func (c *NmController) Post2301() {
  326. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  327. var respJSON map[string]interface{}
  328. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  330. return
  331. }
  332. userJSONBytes, _ := json.Marshal(respJSON["customs"])
  333. var customs []*models.NewCustom
  334. if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
  335. utils.ErrorLog("解析失败:%v", err)
  336. return
  337. }
  338. number := respJSON["number"].(string)
  339. chrg_bchno := respJSON["chrg_bchno"].(string)
  340. dept := respJSON["dept"].(string)
  341. dept_code := respJSON["dept_code"].(string)
  342. doctor_code := respJSON["doctor_code"].(string)
  343. doctor_name := respJSON["doctor_name"].(string)
  344. opertor := respJSON["opertor"].(string)
  345. org_name := respJSON["org_name"].(string)
  346. fixmedins_code := respJSON["fixmedins_code"].(string)
  347. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  348. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  349. secret_key := respJSON["secret_key"].(string)
  350. med_type := respJSON["med_type"].(string)
  351. //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
  352. psn_no := respJSON["psn_no"].(string)
  353. result, requestLog := service.ZHGdyb2301A(psn_no, number, customs, chrg_bchno, org_name, doctor_name, dept, fixmedins_code, dept_code, doctor_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, opertor)
  354. saveJsLog(result, requestLog, "2301", "上传明细", org_name)
  355. var dat2 map[string]interface{}
  356. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  357. } else {
  358. }
  359. var dat map[string]interface{}
  360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  361. } else {
  362. }
  363. c.ServeSuccessJSON(map[string]interface{}{
  364. "pre": dat,
  365. "request_log": dat2,
  366. })
  367. }
  368. func (c *NmController) Post2302() {
  369. mdtrt_id := c.GetString("mdtrtId")
  370. psn_no := c.GetString("psn_no")
  371. number := c.GetString("feedetl_sn")
  372. doctor := c.GetString("doctor")
  373. fixmedins_code := c.GetString("fixmedins_code")
  374. insuplc_admdvs := c.GetString("insuplc_admdvs")
  375. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  376. secret_key := c.GetString("secret_key")
  377. org_name := c.GetString("org_name")
  378. refund_type, _ := c.GetInt64("refund_type")
  379. result, requestLog := service.Gdyb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
  380. saveJsLog(result, requestLog, "2302", "退明细", org_name)
  381. var dat2 map[string]interface{}
  382. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  383. } else {
  384. }
  385. var dat map[string]interface{}
  386. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  387. } else {
  388. }
  389. c.ServeSuccessJSON(map[string]interface{}{
  390. "pre": dat,
  391. "request_log": dat2,
  392. })
  393. }
  394. func (c *NmController) Post2303() {
  395. mdtrt_id := c.GetString("mdtrt_id")
  396. psn_no := c.GetString("psn_no")
  397. chrg_bchno := c.GetString("chrg_bchno")
  398. cert_no := c.GetString("cert_no")
  399. insutype_type := c.GetString("insutype_type")
  400. allTotal := c.GetString("total")
  401. id_card_type, _ := c.GetInt64("id_card_type")
  402. doctor := c.GetString("doctor")
  403. certificates, _ := c.GetInt64("certificates")
  404. fixmedins_code := c.GetString("fixmedins_code")
  405. insuplc_admdvs := c.GetString("insuplc_admdvs")
  406. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  407. secret_key := c.GetString("secret_key")
  408. org_name := c.GetString("org_name")
  409. result, src_resquest := service.ZHGdyb2303(psn_no, mdtrt_id, chrg_bchno, cert_no, insutype_type, allTotal, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, "0", id_card_type, 0, 0, 0, 0, certificates)
  410. saveJsLog(result, src_resquest, "2303", "预结算", org_name)
  411. var dat2 map[string]interface{}
  412. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  413. } else {
  414. }
  415. var dat map[string]interface{}
  416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  417. } else {
  418. }
  419. c.ServeSuccessJSON(map[string]interface{}{
  420. "pre": dat,
  421. "request_log": dat2,
  422. })
  423. }
  424. func (c *NmController) Post2304() {
  425. mdtrt_id := c.GetString("mdtrt_id")
  426. psn_no := c.GetString("psn_no")
  427. chrg_bchno := c.GetString("chrg_bchno")
  428. cert_no := c.GetString("cert_no")
  429. insutype_type := c.GetString("insutype_type")
  430. allTotal := c.GetString("total")
  431. id_card_type, _ := c.GetInt64("id_card_type")
  432. doctor := c.GetString("doctor")
  433. certificates, _ := c.GetInt64("certificates")
  434. fixmedins_code := c.GetString("fixmedins_code")
  435. insuplc_admdvs := c.GetString("insuplc_admdvs")
  436. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  437. secret_key := c.GetString("secret_key")
  438. org_name := c.GetString("org_name")
  439. fapiao_number := c.GetString("fapiao_number")
  440. acct_used_flag := c.GetString("acct_used_flag")
  441. result, src_resquest := service.ZHGdyb2304(psn_no, mdtrt_id, chrg_bchno, cert_no, insutype_type, allTotal, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, "0", id_card_type, 0, 0, 0, 0, certificates, fapiao_number, acct_used_flag)
  442. saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
  443. var dat2 map[string]interface{}
  444. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  445. } else {
  446. }
  447. var dat map[string]interface{}
  448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  449. } else {
  450. }
  451. c.ServeSuccessJSON(map[string]interface{}{
  452. "pre": dat,
  453. "request_log": dat2,
  454. })
  455. }
  456. func (c *NmController) Post2305() {
  457. mdtrt_id := c.GetString("mdtrt_id")
  458. psn_no := c.GetString("psn_no")
  459. doctor := c.GetString("doctor")
  460. setl_id := c.GetString("setl_id")
  461. fixmedins_code := c.GetString("fixmedins_code")
  462. insuplc_admdvs := c.GetString("insuplc_admdvs")
  463. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  464. secret_key := c.GetString("secret_key")
  465. org_name := c.GetString("org_name")
  466. result, requestLog := service.Gdyb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  467. saveJsLog(result, requestLog, "2305", "退费", org_name)
  468. var dat2 map[string]interface{}
  469. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  470. } else {
  471. }
  472. var dat map[string]interface{}
  473. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  474. } else {
  475. }
  476. c.ServeSuccessJSON(map[string]interface{}{
  477. "pre": dat,
  478. "request_log": dat2,
  479. })
  480. }
  481. func (c *NmController) Get2503() {
  482. }
  483. //func (c *NmController) ReadCard() {
  484. // fixmedins_code := c.GetString("fixmedins_code")
  485. // secret_key := c.GetString("secret_key")
  486. // org_name := c.GetString("org_name")
  487. // insuplc_admdvs := c.GetString("insuplc_admdvs")
  488. // mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  489. // id_card_type := c.GetString("id_card_type")
  490. // operator_id := c.GetString("operator_id")
  491. // operator := c.GetString("operator")
  492. //
  493. // if initFlag == 0 {
  494. // c.TestGetBasBaseInit()
  495. // }
  496. // switch id_card_type {
  497. // case "1":
  498. // pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
  499. // basStr := Remove0000(pBusiCardInfo)
  500. //
  501. // if len(basStr) == 0 {
  502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  503. // return
  504. // }
  505. //
  506. // var dat2 map[string]interface{}
  507. // if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
  508. // fmt.Println(dat2)
  509. // } else {
  510. // fmt.Println(err)
  511. // }
  512. //
  513. // userJSONBytes, _ := json.Marshal(dat2)
  514. // var res ReadCardResult
  515. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  516. // utils.ErrorLog("解析失败:%v", err)
  517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  518. // return
  519. // }
  520. //
  521. // fmt.Println(basStr)
  522. // bas := strings.Split(res.Output.CardInfo, "|")
  523. // basNumber := bas[1]
  524. // fmt.Println(basNumber)
  525. // card_sn := bas[3]
  526. // fmt.Println(card_sn)
  527. // cardNumber := bas[2]
  528. // name := bas[4]
  529. //
  530. // result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
  531. // var dat map[string]interface{}
  532. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  533. // fmt.Println(dat)
  534. // } else {
  535. // fmt.Println(err)
  536. // }
  537. //
  538. // userJSONBytes2, _ := json.Marshal(dat)
  539. // var res2 ResultTwo
  540. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  541. // utils.ErrorLog("解析失败:%v", err)
  542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  543. // return
  544. // }
  545. // infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
  546. //
  547. // if infocode == 0 {
  548. // c.ServeSuccessJSON(map[string]interface{}{
  549. // "status": "0",
  550. // "card_info": res.Output.CardInfo,
  551. // "busi_card_info": pBusiCardInfo,
  552. // "result": res2,
  553. // "type": "1",
  554. // })
  555. //
  556. // } else {
  557. // c.ServeSuccessJSON(map[string]interface{}{
  558. // "status": "-1",
  559. // })
  560. // }
  561. //
  562. // break
  563. // case "4": //电子凭证
  564. // _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  565. //
  566. // var ele ELeData
  567. // err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  568. // if err != nil {
  569. // utils.ErrorLog("解析失败:%v", err)
  570. // }
  571. // token := ele.Data.EcToken
  572. // fmt.Println(token)
  573. // if len(token) > 0 {
  574. // result := service.Gdyb1101ForEleCert("", org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, "")
  575. // var dat map[string]interface{}
  576. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  577. // fmt.Println(dat)
  578. // } else {
  579. // fmt.Println(err)
  580. // }
  581. // userJSONBytes, _ := json.Marshal(dat)
  582. // var res ResultTwo
  583. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  584. // utils.ErrorLog("解析失败:%v", err)
  585. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  586. // return
  587. // }
  588. //
  589. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  590. //
  591. // if infocode == 0 {
  592. //
  593. // c.ServeSuccessJSON(map[string]interface{}{
  594. // "status": "0",
  595. // "card_info": pBusiCardInfo,
  596. // "busi_card_info": pBusiCardInfo,
  597. // "token": token,
  598. // "result": dat,
  599. // })
  600. //
  601. // } else {
  602. // c.ServeSuccessJSON(map[string]interface{}{
  603. // "status": "-1",
  604. // })
  605. //
  606. // }
  607. // } else {
  608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  609. // return
  610. // }
  611. // break
  612. //
  613. // }
  614. //
  615. //}
  616. var initFlag int64 = 0
  617. func (c *NmController) TestGetBasBaseInit() {
  618. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  619. Iinit := DllDef.MustFindProc("Init")
  620. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  621. str := make([]byte, 2048)
  622. inputData := make(map[string]interface{})
  623. inputData["IP"] = "tyjk.nm.hsip.gov.cn"
  624. inputData["PORT"] = 8090
  625. inputData["TIMEOUT"] = 180
  626. inputData["LOG_PATH"] = "C:\\log\\"
  627. //inputData["SFZ_DRIVER_TYPE"] = 0
  628. inputData["URL"] = "/uif-hsaf-med-api/api/medical/service"
  629. bytesData, _ := json.Marshal(inputData)
  630. fmt.Println(inputData)
  631. fmt.Println(bytesData)
  632. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  633. if ret != 0 {
  634. fmt.Println("SSCard的报错原因:", err)
  635. fmt.Println("SSCard的运算结果为:", ret)
  636. fmt.Println("SSCard的返回结果为:", string(str))
  637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  638. return
  639. }
  640. fmt.Println("SSCard的返回结果为:", string(str))
  641. result := int(ret)
  642. fmt.Println("SSCard的运算结果为1:", result)
  643. //initFlag = 1
  644. return
  645. }
  646. func (c *NmController) GetSFZBaseInfo() string {
  647. DllDef := syscall.MustLoadDLL("SSCard.dll")
  648. readCard := DllDef.MustFindProc("ReadSFZ")
  649. if readCard == nil {
  650. fmt.Println("readcard is nil")
  651. readCard = DllDef.MustFindProc("ReadSFZ")
  652. }
  653. str := make([]byte, 256)
  654. str1 := make([]byte, 256)
  655. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  656. fmt.Println(r)
  657. return string(str)
  658. }
  659. func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  660. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  661. readCard := DllDef.MustFindProc("ReadCardBas")
  662. fmt.Println(readCard)
  663. fmt.Println("!!!!!")
  664. month := time.Unix(1557042972, 0).Format("1")
  665. year := time.Now().Format("2006")
  666. month = time.Now().Format("01")
  667. day := time.Now().Format("02")
  668. hour := time.Now().Format("15")
  669. min := time.Now().Format("04")
  670. sec := time.Now().Format("05")
  671. msec := time.Now().Format("000")
  672. timestamp := time.Now().Unix()
  673. tempTime := time.Unix(timestamp, 0)
  674. //timeFormat := tempTime.Format("20060102150405")
  675. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  676. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  677. inputData := make(map[string]interface{})
  678. inputData["infno"] = "1199"
  679. //inputData["msgid"] = "7021"
  680. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  681. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  682. inputData["insuplc_admdvs"] = "" // 发送方报文 ID
  683. // 发送方报文 ID
  684. inputData["recer_sys_code"] = "01"
  685. inputData["dev_no"] = ""
  686. inputData["dev_safe_info"] = ""
  687. inputData["cainfo"] = ""
  688. inputData["signtype"] = "SM3"
  689. inputData["infver"] = "V1.0"
  690. inputData["opter_type"] = "1"
  691. inputData["opter"] = opter_id
  692. inputData["opter_name"] = opter_name
  693. inputData["inf_time"] = timeFormatOne
  694. inputData["fixmedins_code"] = fixmedins_code
  695. inputData["fixmedins_name"] = fixmedins_name
  696. inputData["sign_no"] = ""
  697. bytesData, _ := json.Marshal(inputData)
  698. fmt.Println(string(bytesData))
  699. pBusiCardInfo := make([]byte, 8192)
  700. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  701. fmt.Println(ret2)
  702. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  703. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  704. if ret2 != 0 {
  705. return ""
  706. }
  707. return DeleteExtraSpace(string(pBusiCardInfo))
  708. }
  709. func (c *NmController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  710. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  711. readCard := DllDef.MustFindProc("NationEcTrans")
  712. fmt.Println(readCard)
  713. fmt.Println("!!!!!")
  714. pBusiCardInfo := make([]byte, 2048)
  715. input := make(map[string]interface{})
  716. inputData := make(map[string]interface{})
  717. inputData["orgId"] = code
  718. inputData["businessType"] = "01101"
  719. inputData["operatorId"] = operator_id
  720. inputData["operatorName"] = operator_name
  721. inputData["officeId"] = "001"
  722. inputData["officeName"] = "血透室"
  723. inputData["deviceType"] = ""
  724. input["data"] = inputData
  725. input["orgId"] = code
  726. input["transType"] = "ec.query"
  727. bytesData, _ := json.Marshal(input)
  728. //gdyb_url := beego.AppConfig.String("gdyb_url")
  729. fmt.Println(string(bytesData))
  730. url := "http://10.38.22.15:8081" + "/localcfc/api/hsecfc/localQrCodeQuery"
  731. ret2, aa, bb := readCard.Call(StrPtr(url), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  732. fmt.Println(aa)
  733. fmt.Println(bb)
  734. fmt.Println(ret2)
  735. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  736. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  737. if ret2 != 0 {
  738. return "", ""
  739. }
  740. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  741. }
  742. func IntPtr(n int) uintptr {
  743. return uintptr(n)
  744. }
  745. func StrPtr(s string) uintptr {
  746. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  747. }
  748. type Charset string
  749. const (
  750. UTF8 = Charset("UTF-8")
  751. GB18030 = Charset("GB18030")
  752. )
  753. func ConvertToString(src string, srcCode string, tagCode string) string {
  754. srcCoder := mahonia.NewDecoder(srcCode)
  755. srcResult := srcCoder.ConvertString(src)
  756. tagCoder := mahonia.NewDecoder(tagCode)
  757. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  758. result := string(cdata)
  759. return result
  760. }
  761. func DeleteExtraSpace(s string) string {
  762. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  763. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  764. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  765. reg, _ := regexp.Compile(regstr) //编译正则表达式
  766. s2 := make([]byte, len(s1)) //定义字符数组切片
  767. copy(s2, s1) //将字符串复制到切片
  768. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  769. for len(spc_index) > 0 { //找到适配项
  770. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  771. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  772. }
  773. return string(s2)
  774. }
  775. func Remove0000(s string) string {
  776. str := make([]rune, 0, len(s))
  777. for _, v := range []rune(s) {
  778. if v == 0 {
  779. continue
  780. }
  781. str = append(str, v)
  782. }
  783. return string(str)
  784. }
  785. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  786. //org_id, _ := beego.AppConfig.Int64("org_id")
  787. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  788. dir := org_name + "日志"
  789. utils.Mkdir(dir)
  790. month := time.Unix(1557042972, 0).Format("1")
  791. year := time.Now().Format("2006")
  792. month = time.Now().Format("01")
  793. day := time.Now().Format("02")
  794. hour := time.Now().Format("15")
  795. min := time.Now().Format("04")
  796. sec := time.Now().Format("05")
  797. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  798. file := org_name + "_" + year + month + day + "_log"
  799. file_name := file + ".txt"
  800. file_path := org_name + "日志" + "/" + file_name
  801. exist, _ := utils.PathExists(file_path)
  802. if exist { //存在
  803. fmt.Println("存在")
  804. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  805. if err != nil {
  806. fmt.Println("read fail")
  807. }
  808. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  809. n, _ := f.Seek(0, 2)
  810. _, err = f.WriteAt([]byte(content), n)
  811. } else { //不存在
  812. fmt.Println("文件不存在,创建文件")
  813. f, err := os.Create(org_name + "日志" + "/" + file_name)
  814. defer f.Close()
  815. if err != nil {
  816. } else {
  817. _, err = f.Write([]byte("记录日志"))
  818. }
  819. }
  820. }
  821. func (c *NmController) Get3201() {
  822. insutype := c.GetString("insutype")
  823. clrType := c.GetString("clr_type")
  824. setlOptins := c.GetString("setl_optins")
  825. stmtBegndate := c.GetString("stmt_begndate")
  826. stmtEnddate := c.GetString("stm_enddate")
  827. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  828. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  829. acctPay, _ := c.GetFloat("acct_pay", 0)
  830. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  831. fixmedins_code := c.GetString("fixmedins_code")
  832. insuplc_admdvs := c.GetString("insuplc_admdvs")
  833. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  834. secret_key := c.GetString("secret_key")
  835. org_name := c.GetString("org_name")
  836. doctor := c.GetString("doctor")
  837. baseParams := models.BaseParams{
  838. SecretKey: secret_key,
  839. FixmedinsCode: fixmedins_code,
  840. InsuplcAdmdvs: insuplc_admdvs,
  841. MdtrtareaAdmvs: mdtrtarea_admvs,
  842. OrgName: org_name,
  843. Doctor: doctor,
  844. }
  845. businessParams := models.BusinessParams{
  846. Insutype: insutype,
  847. ClrType: clrType,
  848. SetlOptins: setlOptins,
  849. StmtBegndate: stmtBegndate,
  850. StmtEnddate: stmtEnddate,
  851. MedfeeSumamt: medfeeSumamt,
  852. FundPaySumamt: fundPaySumamt,
  853. AcctPay: acctPay,
  854. FixmedinsSetlCnt: fixmedinsSetlCnt,
  855. }
  856. result := service.Gdyb3201(baseParams, businessParams)
  857. saveJsLog(result, "", "3201", "对总账", org_name)
  858. var dat map[string]interface{}
  859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  860. fmt.Println(dat)
  861. } else {
  862. fmt.Println(err)
  863. }
  864. c.ServeSuccessJSON(map[string]interface{}{
  865. "pre": dat,
  866. })
  867. }