nm_controller.go 37KB

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