nm_controller.go 33KB

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