nm_controller.go 43KB

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