nm_controller.go 41KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304
  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. "golang.org/x/text/encoding/simplifiedchinese"
  14. "io/ioutil"
  15. "net/http"
  16. "os"
  17. "os/exec"
  18. "regexp"
  19. "strconv"
  20. "strings"
  21. "syscall"
  22. "time"
  23. "unsafe"
  24. )
  25. type NmController struct {
  26. controllers.BaseAuthAPIController
  27. }
  28. func NmybRegistRouters() {
  29. beego.Router("/nmyb/1101", &NmController{}, "get:Post1101")
  30. beego.Router("/nmyb/2401", &NmController{}, "post:Post2401")
  31. beego.Router("/nmyb/2402", &NmController{}, "post:Post2402")
  32. beego.Router("/nmyb/2404", &NmController{}, "get:Post2404")
  33. beego.Router("/nmyb/2405", &NmController{}, "get:Post2405")
  34. beego.Router("/nmyb/2301", &NmController{}, "post:Post2301")
  35. beego.Router("/nmyb/2302", &NmController{}, "get:Post2302")
  36. beego.Router("/nmyb/2303", &NmController{}, "get:Post2303")
  37. beego.Router("/nmyb/2304", &NmController{}, "get:Post2304")
  38. beego.Router("/nmyb/2305", &NmController{}, "get:Post2305")
  39. beego.Router("/nmyb/5203", &NmController{}, "get:Post5203")
  40. beego.Router("/nmyb/readcard", &NmController{}, "get:ReadCard")
  41. beego.Router("/nmyb/3201", &NmController{}, "get:Get3201")
  42. beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
  43. beego.Router("/nmyb/4101", &NmController{}, "post:Post4101")
  44. beego.Router("/nmyb/2601", &NmController{}, "get:Get2601")
  45. beego.Router("/api/token", &NmController{}, "get:GetToken")
  46. beego.Router("/api/eleinfo", &NmController{}, "get:GetNewELeInfo")
  47. beego.Router("/nmyb/4102", &NmController{}, "get:Post4102")
  48. beego.Router("/nmyb/4103", &NmController{}, "get:Post4103")
  49. }
  50. func (c *NmController) GetNewELeInfo() {
  51. token := c.GetString("token")
  52. user_name := c.GetString("user_name")
  53. id_card_no := c.GetString("id_card_no")
  54. result, _ := service.Gdyb1101ForEleCert("赤峰费森血液透析中心", "关学丽", "H15049901371", "150499", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", token, user_name, id_card_no)
  55. var dat map[string]interface{}
  56. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  57. fmt.Println(dat)
  58. } else {
  59. fmt.Println(err)
  60. }
  61. userJSONBytes, _ := json.Marshal(dat)
  62. var res ResultTwo
  63. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  64. utils.ErrorLog("解析失败:%v", err)
  65. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  66. return
  67. }
  68. infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  69. if infocode == 0 {
  70. data := make(map[string]interface{})
  71. data["token"] = token
  72. data["result"] = dat
  73. var req *http.Request
  74. bytesData, _ := json.Marshal(data)
  75. req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/ele/info", bytes.NewReader(bytesData))
  76. client := &http.Client{}
  77. resp, _ := client.Do(req)
  78. defer resp.Body.Close()
  79. body, ioErr := ioutil.ReadAll(resp.Body)
  80. if ioErr != nil {
  81. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  82. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  83. return
  84. }
  85. var respJSON map[string]interface{}
  86. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  87. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  88. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  89. return
  90. }
  91. c.ServeSuccessJSON(map[string]interface{}{
  92. "msg": "成功",
  93. })
  94. }
  95. }
  96. func (c *NmController) GetToken() {
  97. token := c.GetString("token")
  98. results := strings.Split(token, "-")
  99. fmt.Println(token)
  100. result_code := results[0]
  101. result_info := results[1]
  102. if result_code == "0000" {
  103. var ele2 ELeData2
  104. err := json.Unmarshal([]byte(result_info), &ele2)
  105. if err != nil {
  106. utils.ErrorLog("解析失败:%v", err)
  107. }
  108. if ele2.Code != -2 {
  109. var ele ELeData
  110. err := json.Unmarshal([]byte(result_info), &ele)
  111. if err != nil {
  112. utils.ErrorLog("解析失败:%v", err)
  113. }
  114. token := ele.Data.EcToken
  115. if len(token) > 0 {
  116. data := make(map[string]interface{})
  117. data["token"] = token
  118. data["id_card_no"] = ele.Data.IdNo
  119. fmt.Println(data)
  120. var req *http.Request
  121. fmt.Println(req)
  122. bytesData, _ := json.Marshal(data)
  123. fmt.Println(bytesData)
  124. req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/token/get", bytes.NewReader(bytesData))
  125. fmt.Println(req)
  126. client := &http.Client{}
  127. resp, _ := client.Do(req)
  128. fmt.Println(resp)
  129. defer resp.Body.Close()
  130. body, ioErr := ioutil.ReadAll(resp.Body)
  131. fmt.Println(resp.Body)
  132. fmt.Println(body)
  133. fmt.Println(ioErr)
  134. if ioErr != nil {
  135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  137. return
  138. }
  139. var respJSON map[string]interface{}
  140. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  143. return
  144. }
  145. } else {
  146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  147. return
  148. }
  149. }
  150. } else {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  152. return
  153. }
  154. }
  155. type ReadCardResult struct {
  156. Output struct {
  157. CardInfo string `json:"cardInfo"`
  158. RegionCode string `json:"regionCode"`
  159. } `json:"output"`
  160. Code string `json:"CODE"`
  161. ErrMsg string `json:"ERRMSG"`
  162. }
  163. type ELeData2 struct {
  164. Code int `json:"code"`
  165. Message string `json:"message"`
  166. }
  167. type ELeData struct {
  168. Data struct {
  169. IdNo string `json:"idNo"`
  170. IdType string `json:"idType"`
  171. UserName string `json:"userName"`
  172. EcToken string `json:"ecToken"`
  173. InsuOrg string `json:"insuOrg"`
  174. Gender string `json:"gender"`
  175. Birthday string `json:"birthday"`
  176. Nationality string `json:"nationality"`
  177. Email string `json:"email"`
  178. Extra string `json:"extra"`
  179. } `json:"data"`
  180. Code int `json:"code"`
  181. Message string `json:"message"`
  182. }
  183. type ResultTwo struct {
  184. ErrMsg string `json:"err_msg"`
  185. InfRefmsgid string `json:"inf_refmsgid"`
  186. Infcode string `json:"infcode"`
  187. Output struct {
  188. Baseinfo struct {
  189. Age float64 `json:"age"`
  190. Brdy string `json:"brdy"`
  191. Certno string `json:"certno"`
  192. Gend string `json:"gend"`
  193. Naty string `json:"naty"`
  194. PsnCertType string `json:"psn_cert_type"`
  195. PsnName string `json:"psn_name"`
  196. PsnNo string `json:"psn_no"`
  197. } `json:"baseinfo"`
  198. Idetinfo []interface{} `json:"idetinfo"`
  199. Iinfo []struct {
  200. Balc float64 `json:"balc"`
  201. CvlservFlag string `json:"cvlserv_flag"`
  202. EmpName string `json:"emp_name"`
  203. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  204. Insutype string `json:"insutype"`
  205. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  206. PausInsuDate string `json:"paus_insu_date"`
  207. PsnInsuDate string `json:"psn_insu_date"`
  208. PsnInsuStas string `json:"psn_insu_stas"`
  209. PsnType string `json:"psn_type"`
  210. } `json:"insuinfo"`
  211. } `json:"output"`
  212. RefmsgTime string `json:"refmsg_time"`
  213. RespondTime string `json:"respond_time"`
  214. Signtype interface{} `json:"signtype"`
  215. WarnInfo interface{} `json:"warn_info"`
  216. }
  217. type ResultTwo10265 struct {
  218. ErrMsg string `json:"err_msg"`
  219. InfRefmsgid string `json:"inf_refmsgid"`
  220. Infcode string `json:"infcode"`
  221. Output struct {
  222. Baseinfo struct {
  223. Age float64 `json:"age"`
  224. Brdy string `json:"brdy"`
  225. Certno string `json:"certno"`
  226. Gend string `json:"gend"`
  227. Naty string `json:"naty"`
  228. PsnCertType string `json:"psn_cert_type"`
  229. PsnName string `json:"psn_name"`
  230. PsnNo string `json:"psn_no"`
  231. } `json:"baseinfo"`
  232. Idetinfo []interface{} `json:"idetinfo"`
  233. Iinfo []struct {
  234. Balc float64 `json:"balc"`
  235. CvlservFlag string `json:"cvlserv_flag"`
  236. EmpName string `json:"emp_name"`
  237. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  238. Insutype string `json:"insutype"`
  239. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  240. PausInsuDate string `json:"paus_insu_date"`
  241. PsnInsuDate string `json:"psn_insu_date"`
  242. PsnInsuStas string `json:"psn_insu_stas"`
  243. PsnType string `json:"psn_type"`
  244. } `json:"insuinfo"`
  245. } `json:"output"`
  246. RefmsgTime string `json:"refmsg_time"`
  247. RespondTime string `json:"respond_time"`
  248. Signtype interface{} `json:"signtype"`
  249. WarnInfo interface{} `json:"warn_info"`
  250. }
  251. func (c *NmController) Post4101() {
  252. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  253. var respJSON map[string]interface{}
  254. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  255. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  256. return
  257. }
  258. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  259. var struct4101 service.Struct4101
  260. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  261. utils.ErrorLog("解析失败:%v", err)
  262. return
  263. }
  264. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  265. var pp models.PublicParams
  266. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  267. utils.ErrorLog("解析失败:%v", err)
  268. return
  269. }
  270. result := service.Gdyb4101(struct4101, pp.SecretKey, pp.FixmedinsName, pp.OpterName, pp.FixmedinsCode, pp.InsuplcAdmdvs, pp.MdtrtareaAdmvs, 0)
  271. var dat map[string]interface{}
  272. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  273. fmt.Println(dat)
  274. } else {
  275. fmt.Println(err)
  276. }
  277. saveJsLog(result, "", "4101", "上传明细清单", pp.FixmedinsName)
  278. c.ServeSuccessJSON(map[string]interface{}{
  279. "pre": dat,
  280. })
  281. }
  282. func (c *NmController) Post2202() {
  283. result, requestLog := service.Gdyb2202("150000CFSJM100000100005413", "20211227145332876188", "2021122714565410808111489", "赤峰费森血液透析中心", "李彩星", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", "H15049901371")
  284. var dat map[string]interface{}
  285. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  286. } else {
  287. }
  288. c.ServeSuccessJSON(map[string]interface{}{
  289. "pre": dat,
  290. "request_log": requestLog,
  291. })
  292. }
  293. func (c *NmController) Post5203() {
  294. fmt.Println("------")
  295. org_name := c.GetString("org_name")
  296. doctor := c.GetString("doctor")
  297. fixmedins_code := c.GetString("fixmedins_code")
  298. insuplc_admdvs := c.GetString("insuplc_admdvs")
  299. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  300. secret_key := c.GetString("secret_key")
  301. psn_no := c.GetString("psn_no")
  302. mdtrt_id := c.GetString("mdtrt_id")
  303. setl_id := c.GetString("setl_id")
  304. fmt.Println("------")
  305. bp := models.BaseParams{
  306. SecretKey: secret_key,
  307. FixmedinsCode: fixmedins_code,
  308. InsuplcAdmdvs: insuplc_admdvs,
  309. MdtrtareaAdmvs: mdtrtarea_admvs,
  310. OrgName: org_name,
  311. Doctor: doctor,
  312. }
  313. bps := models.BusinessParams{
  314. PsnNo: psn_no,
  315. MdtrtId: mdtrt_id,
  316. SetlId: setl_id,
  317. }
  318. result := service.ZHyb5203(bp, bps)
  319. saveJsLog(result, "", "5203", "结算单", org_name)
  320. var dat map[string]interface{}
  321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  322. } else {
  323. }
  324. c.ServeSuccessJSON(map[string]interface{}{
  325. "pre": dat,
  326. })
  327. }
  328. func (c *NmController) Post4102() {
  329. org_name := c.GetString("org_name")
  330. doctor := c.GetString("doctor")
  331. fixmedins_code := c.GetString("fixmedins_code")
  332. insuplc_admdvs := c.GetString("insuplc_admdvs")
  333. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  334. secret_key := c.GetString("secret_key")
  335. psn_no := c.GetString("psn_no")
  336. mdtrt_id := c.GetString("mdtrt_id")
  337. setl_id := c.GetString("setl_id")
  338. stas_type := c.GetString("stas_type")
  339. bp := models.BaseParams{
  340. SecretKey: secret_key,
  341. FixmedinsCode: fixmedins_code,
  342. InsuplcAdmdvs: insuplc_admdvs,
  343. MdtrtareaAdmvs: mdtrtarea_admvs,
  344. OrgName: org_name,
  345. Doctor: doctor,
  346. }
  347. bps := models.BusinessParams{
  348. PsnNo: psn_no,
  349. MdtrtId: mdtrt_id,
  350. SetlId: setl_id,
  351. StasType: stas_type,
  352. }
  353. result := service.ZHyb4102(bp, bps)
  354. saveJsLog(result, "", "4102", "确认结算清单", org_name)
  355. var dat map[string]interface{}
  356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  357. } else {
  358. }
  359. c.ServeSuccessJSON(map[string]interface{}{
  360. "pre": dat,
  361. })
  362. }
  363. func (c *NmController) Post4103() {
  364. org_name := c.GetString("org_name")
  365. doctor := c.GetString("doctor")
  366. fixmedins_code := c.GetString("fixmedins_code")
  367. insuplc_admdvs := c.GetString("insuplc_admdvs")
  368. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  369. secret_key := c.GetString("secret_key")
  370. psn_no := c.GetString("psn_no")
  371. mdtrt_id := c.GetString("mdtrt_id")
  372. setl_id := c.GetString("setl_id")
  373. bp := models.BaseParams{
  374. SecretKey: secret_key,
  375. FixmedinsCode: fixmedins_code,
  376. InsuplcAdmdvs: insuplc_admdvs,
  377. MdtrtareaAdmvs: mdtrtarea_admvs,
  378. OrgName: org_name,
  379. Doctor: doctor,
  380. }
  381. bps := models.BusinessParams{
  382. PsnNo: psn_no,
  383. MdtrtId: mdtrt_id,
  384. SetlId: setl_id,
  385. }
  386. result := service.ZHyb4103(bp, bps)
  387. saveJsLog(result, "", "4103", "查询结算清单", org_name)
  388. var dat map[string]interface{}
  389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  390. } else {
  391. }
  392. c.ServeSuccessJSON(map[string]interface{}{
  393. "pre": dat,
  394. })
  395. }
  396. func (c *NmController) Post1101() {
  397. certNo := c.GetString("cert_no")
  398. org_name := c.GetString("org_name")
  399. doctor := c.GetString("doctor")
  400. fixmedins_code := c.GetString("fixmedins_code")
  401. insuplc_admdvs := c.GetString("insuplc_admdvs")
  402. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  403. secret_key := c.GetString("secret_key")
  404. id_card_type, _ := c.GetInt64("id_card_type")
  405. card_sn := c.GetString("card_sn")
  406. certificates := c.GetString("certificates")
  407. name := c.GetString("name")
  408. certificate, _ := strconv.ParseInt(certificates, 10, 64)
  409. 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)
  410. saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
  411. var dat map[string]interface{}
  412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  413. } else {
  414. }
  415. var dat2 map[string]interface{}
  416. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  417. } else {
  418. }
  419. c.ServeSuccessJSON(map[string]interface{}{
  420. "pre": dat,
  421. "log": dat2,
  422. })
  423. }
  424. func (c *NmController) Post2401() {
  425. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  426. var respJSON map[string]interface{}
  427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  429. return
  430. }
  431. userJSONBytes, _ := json.Marshal(respJSON["struct_2401"])
  432. var struct2401 service.Struct2401
  433. if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
  434. utils.ErrorLog("解析失败:%v", err)
  435. return
  436. }
  437. org_name := respJSON["org_name"].(string)
  438. fixmedins_code := respJSON["fixmedins_code"].(string)
  439. doctor := respJSON["doctor"].(string)
  440. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  441. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  442. secret_key := respJSON["secret_key"].(string)
  443. result, request_log := service.ZHGdyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  444. saveJsLog(result, request_log, "2401", "入院登记", org_name)
  445. var dat2 map[string]interface{}
  446. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  447. } else {
  448. }
  449. var dat map[string]interface{}
  450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  451. } else {
  452. }
  453. c.ServeSuccessJSON(map[string]interface{}{
  454. "pre": dat,
  455. "request_log": dat2,
  456. })
  457. }
  458. func (c *NmController) Post2404() {
  459. mdtrt_id := c.GetString("mdtrt_id")
  460. psn_no := c.GetString("psn_no")
  461. doctor := c.GetString("doctor")
  462. fixmedins_code := c.GetString("fixmedins_code")
  463. insuplc_admdvs := c.GetString("insuplc_admdvs")
  464. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  465. secret_key := c.GetString("secret_key")
  466. org_name := c.GetString("org_name")
  467. result, requestLog := service.ZHGdyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  468. saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
  469. var dat map[string]interface{}
  470. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  471. } else {
  472. }
  473. var dat2 map[string]interface{}
  474. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  475. } else {
  476. }
  477. c.ServeSuccessJSON(map[string]interface{}{
  478. "pre": dat,
  479. "log": dat2,
  480. })
  481. }
  482. func (c *NmController) Post2405() {
  483. mdtrt_id := c.GetString("mdtrt_id")
  484. psn_no := c.GetString("psn_no")
  485. doctor := c.GetString("doctor")
  486. fixmedins_code := c.GetString("fixmedins_code")
  487. insuplc_admdvs := c.GetString("insuplc_admdvs")
  488. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  489. secret_key := c.GetString("secret_key")
  490. org_name := c.GetString("org_name")
  491. result, requestLog := service.ZHGdyb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  492. saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
  493. var dat map[string]interface{}
  494. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  495. } else {
  496. }
  497. var dat2 map[string]interface{}
  498. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  499. } else {
  500. }
  501. c.ServeSuccessJSON(map[string]interface{}{
  502. "pre": dat,
  503. "log": dat2,
  504. })
  505. }
  506. func (c *NmController) Post2402() {
  507. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  508. var respJSON map[string]interface{}
  509. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  510. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  511. return
  512. }
  513. userJSONBytes, _ := json.Marshal(respJSON["struct_2402"])
  514. var struct2402 service.Struct2402
  515. if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
  516. utils.ErrorLog("解析失败:%v", err)
  517. return
  518. }
  519. org_name := respJSON["org_name"].(string)
  520. fixmedins_code := respJSON["fixmedins_code"].(string)
  521. doctor := respJSON["doctor"].(string)
  522. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  523. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  524. secret_key := respJSON["secret_key"].(string)
  525. result, request_log := service.ZHGdyb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  526. saveJsLog(result, request_log, "2402", "出院", org_name)
  527. var dat2 map[string]interface{}
  528. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  529. } else {
  530. }
  531. var dat map[string]interface{}
  532. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  533. } else {
  534. }
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "pre": dat,
  537. "request_log": dat2,
  538. })
  539. }
  540. func (c *NmController) Post2301() {
  541. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  542. var respJSON map[string]interface{}
  543. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  545. return
  546. }
  547. userJSONBytes, _ := json.Marshal(respJSON["customs"])
  548. var customs []*models.NewCustom
  549. if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
  550. utils.ErrorLog("解析失败:%v", err)
  551. return
  552. }
  553. number := respJSON["number"].(string)
  554. chrg_bchno := respJSON["chrg_bchno"].(string)
  555. dept := respJSON["dept"].(string)
  556. dept_code := respJSON["dept_code"].(string)
  557. doctor_code := respJSON["doctor_code"].(string)
  558. doctor_name := respJSON["doctor_name"].(string)
  559. opertor := respJSON["opertor"].(string)
  560. org_name := respJSON["org_name"].(string)
  561. fixmedins_code := respJSON["fixmedins_code"].(string)
  562. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  563. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  564. secret_key := respJSON["secret_key"].(string)
  565. med_type := respJSON["med_type"].(string)
  566. //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
  567. psn_no := respJSON["psn_no"].(string)
  568. 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)
  569. saveJsLog(result, requestLog, "2301", "上传明细", org_name)
  570. var dat2 map[string]interface{}
  571. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  572. } else {
  573. }
  574. var dat map[string]interface{}
  575. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  576. } else {
  577. }
  578. c.ServeSuccessJSON(map[string]interface{}{
  579. "pre": dat,
  580. "request_log": dat2,
  581. })
  582. }
  583. func (c *NmController) Post2302() {
  584. mdtrt_id := c.GetString("mdtrtId")
  585. psn_no := c.GetString("psn_no")
  586. number := c.GetString("feedetl_sn")
  587. doctor := c.GetString("doctor")
  588. fixmedins_code := c.GetString("fixmedins_code")
  589. insuplc_admdvs := c.GetString("insuplc_admdvs")
  590. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  591. secret_key := c.GetString("secret_key")
  592. org_name := c.GetString("org_name")
  593. refund_type, _ := c.GetInt64("refund_type")
  594. result, requestLog := service.Gdyb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
  595. saveJsLog(result, requestLog, "2302", "退明细", org_name)
  596. var dat2 map[string]interface{}
  597. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  598. } else {
  599. }
  600. var dat map[string]interface{}
  601. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  602. } else {
  603. }
  604. c.ServeSuccessJSON(map[string]interface{}{
  605. "pre": dat,
  606. "request_log": dat2,
  607. })
  608. }
  609. func (c *NmController) Post2303() {
  610. mdtrt_id := c.GetString("mdtrt_id")
  611. psn_no := c.GetString("psn_no")
  612. chrg_bchno := c.GetString("chrg_bchno")
  613. cert_no := c.GetString("cert_no")
  614. insutype_type := c.GetString("insutype_type")
  615. allTotal := c.GetString("total")
  616. id_card_type, _ := c.GetInt64("id_card_type")
  617. doctor := c.GetString("doctor")
  618. certificates, _ := c.GetInt64("certificates")
  619. fixmedins_code := c.GetString("fixmedins_code")
  620. insuplc_admdvs := c.GetString("insuplc_admdvs")
  621. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  622. secret_key := c.GetString("secret_key")
  623. org_name := c.GetString("org_name")
  624. 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)
  625. saveJsLog(result, src_resquest, "2303", "预结算", org_name)
  626. var dat2 map[string]interface{}
  627. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  628. } else {
  629. }
  630. var dat map[string]interface{}
  631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  632. } else {
  633. }
  634. c.ServeSuccessJSON(map[string]interface{}{
  635. "pre": dat,
  636. "request_log": dat2,
  637. })
  638. }
  639. func (c *NmController) Post2304() {
  640. mdtrt_id := c.GetString("mdtrt_id")
  641. psn_no := c.GetString("psn_no")
  642. chrg_bchno := c.GetString("chrg_bchno")
  643. cert_no := c.GetString("cert_no")
  644. insutype_type := c.GetString("insutype_type")
  645. allTotal := c.GetString("total")
  646. id_card_type, _ := c.GetInt64("id_card_type")
  647. doctor := c.GetString("doctor")
  648. certificates, _ := c.GetInt64("certificates")
  649. fixmedins_code := c.GetString("fixmedins_code")
  650. insuplc_admdvs := c.GetString("insuplc_admdvs")
  651. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  652. secret_key := c.GetString("secret_key")
  653. org_name := c.GetString("org_name")
  654. fapiao_number := c.GetString("fapiao_number")
  655. acct_used_flag := c.GetString("acct_used_flag")
  656. 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)
  657. saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
  658. var dat2 map[string]interface{}
  659. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  660. } else {
  661. }
  662. var dat map[string]interface{}
  663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  664. } else {
  665. }
  666. c.ServeSuccessJSON(map[string]interface{}{
  667. "pre": dat,
  668. "request_log": dat2,
  669. })
  670. }
  671. func (c *NmController) Post2305() {
  672. mdtrt_id := c.GetString("mdtrt_id")
  673. psn_no := c.GetString("psn_no")
  674. doctor := c.GetString("doctor")
  675. setl_id := c.GetString("setl_id")
  676. fixmedins_code := c.GetString("fixmedins_code")
  677. insuplc_admdvs := c.GetString("insuplc_admdvs")
  678. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  679. secret_key := c.GetString("secret_key")
  680. org_name := c.GetString("org_name")
  681. result, requestLog := service.Gdyb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  682. saveJsLog(result, requestLog, "2305", "退费", org_name)
  683. var dat2 map[string]interface{}
  684. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  685. } else {
  686. }
  687. var dat map[string]interface{}
  688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  689. } else {
  690. }
  691. c.ServeSuccessJSON(map[string]interface{}{
  692. "pre": dat,
  693. "request_log": dat2,
  694. })
  695. }
  696. func (c *NmController) Get2503() {
  697. }
  698. func (c *NmController) ReadCard() {
  699. fixmedins_code := c.GetString("fixmedins_code")
  700. secret_key := c.GetString("secret_key")
  701. org_name := c.GetString("org_name")
  702. insuplc_admdvs := c.GetString("insuplc_admdvs")
  703. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  704. id_card_type := c.GetString("id_card_type")
  705. operator_id := c.GetString("operator_id")
  706. operator := c.GetString("operator")
  707. switch id_card_type {
  708. case "1":
  709. if initFlag == 0 {
  710. c.TestGetBasBaseInit()
  711. }
  712. pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
  713. basStr := Remove0000(pBusiCardInfo)
  714. if len(basStr) == 0 {
  715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  716. return
  717. }
  718. var dat2 map[string]interface{}
  719. if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
  720. fmt.Println(dat2)
  721. } else {
  722. fmt.Println(err)
  723. }
  724. userJSONBytes, _ := json.Marshal(dat2)
  725. var res ReadCardResult
  726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  727. utils.ErrorLog("解析失败:%v", err)
  728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  729. return
  730. }
  731. fmt.Println(basStr)
  732. bas := strings.Split(res.Output.CardInfo, "|")
  733. basNumber := bas[1]
  734. fmt.Println(basNumber)
  735. card_sn := bas[3]
  736. fmt.Println(card_sn)
  737. cardNumber := bas[2]
  738. name := bas[4]
  739. result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
  740. var dat map[string]interface{}
  741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  742. fmt.Println(dat)
  743. } else {
  744. fmt.Println(err)
  745. }
  746. userJSONBytes2, _ := json.Marshal(dat)
  747. var res2 ResultTwo
  748. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  749. utils.ErrorLog("解析失败:%v", err)
  750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  751. return
  752. }
  753. infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
  754. if infocode == 0 {
  755. c.ServeSuccessJSON(map[string]interface{}{
  756. "status": "0",
  757. "card_info": res.Output.CardInfo,
  758. "busi_card_info": pBusiCardInfo,
  759. "result": res2,
  760. "type": "1",
  761. })
  762. } else {
  763. c.ServeSuccessJSON(map[string]interface{}{
  764. "status": "-1",
  765. })
  766. }
  767. break
  768. case "4": //电子凭证
  769. c.GetELeInfo()
  770. //if result_code == "0000" {
  771. // var ele ELeData
  772. // err := json.Unmarshal([]byte(result_info), &ele)
  773. // if err != nil {
  774. // utils.ErrorLog("解析失败:%v", err)
  775. // }
  776. // token := ele.Data.EcToken
  777. // fmt.Println(token)
  778. // if len(token) > 0 {
  779. // result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.UserName, ele.Data.IdNo)
  780. // var dat map[string]interface{}
  781. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  782. // fmt.Println(dat)
  783. // } else {
  784. // fmt.Println(err)
  785. // }
  786. // userJSONBytes, _ := json.Marshal(dat)
  787. // var res ResultTwo
  788. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  789. // utils.ErrorLog("解析失败:%v", err)
  790. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  791. // return
  792. // }
  793. //
  794. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  795. //
  796. // if infocode == 0 {
  797. //
  798. // c.ServeSuccessJSON(map[string]interface{}{
  799. // "status": "0",
  800. // "card_info": result_info,
  801. // "busi_card_info": result_info,
  802. // "token": token,
  803. // "result": dat,
  804. // })
  805. //
  806. // } else {
  807. // c.ServeSuccessJSON(map[string]interface{}{
  808. // "status": "-1",
  809. // })
  810. //
  811. // }
  812. // } else {
  813. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  814. // return
  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() (string, string) {
  999. fmt.Println("执行java")
  1000. var json string
  1001. cmd := exec.Command("java", "-jar", "NM_DZPZ.jar", json)
  1002. //fmt.Println(cmd)
  1003. //fmt.Println(cmd.Output())
  1004. out, err := cmd.Output()
  1005. if err != nil {
  1006. fmt.Println("error:", err.Error())
  1007. }
  1008. fmt.Println(err)
  1009. fmt.Println(string(out))
  1010. fmt.Println("json:")
  1011. fmt.Println(cmd.Args[0])
  1012. fmt.Println(json)
  1013. fmt.Println(string(json))
  1014. fmt.Println("json:")
  1015. results := strings.Split(string(out), "-")
  1016. return results[0], results[1]
  1017. }
  1018. func IntPtr(n int) uintptr {
  1019. return uintptr(n)
  1020. }
  1021. func StrPtr(s string) uintptr {
  1022. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1023. }
  1024. type Charset string
  1025. const (
  1026. UTF8 = Charset("UTF-8")
  1027. GB18030 = Charset("GB18030")
  1028. )
  1029. func ConvertToString(src string, srcCode string, tagCode string) string {
  1030. srcCoder := mahonia.NewDecoder(srcCode)
  1031. srcResult := srcCoder.ConvertString(src)
  1032. tagCoder := mahonia.NewDecoder(tagCode)
  1033. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1034. result := string(cdata)
  1035. return result
  1036. }
  1037. func DeleteExtraSpace(s string) string {
  1038. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1039. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1040. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1041. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1042. s2 := make([]byte, len(s1)) //定义字符数组切片
  1043. copy(s2, s1) //将字符串复制到切片
  1044. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1045. for len(spc_index) > 0 { //找到适配项
  1046. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1047. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1048. }
  1049. return string(s2)
  1050. }
  1051. func Remove0000(s string) string {
  1052. str := make([]rune, 0, len(s))
  1053. for _, v := range []rune(s) {
  1054. if v == 0 {
  1055. continue
  1056. }
  1057. str = append(str, v)
  1058. }
  1059. return string(str)
  1060. }
  1061. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1062. //org_id, _ := beego.AppConfig.Int64("org_id")
  1063. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1064. dir := org_name + "日志"
  1065. utils.Mkdir(dir)
  1066. month := time.Unix(1557042972, 0).Format("1")
  1067. year := time.Now().Format("2006")
  1068. month = time.Now().Format("01")
  1069. day := time.Now().Format("02")
  1070. hour := time.Now().Format("15")
  1071. min := time.Now().Format("04")
  1072. sec := time.Now().Format("05")
  1073. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1074. file := org_name + "_" + year + month + day + "_log"
  1075. file_name := file + ".txt"
  1076. file_path := org_name + "日志" + "/" + file_name
  1077. exist, _ := utils.PathExists(file_path)
  1078. if exist { //存在
  1079. fmt.Println("存在")
  1080. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1081. if err != nil {
  1082. fmt.Println("read fail")
  1083. }
  1084. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1085. n, _ := f.Seek(0, 2)
  1086. _, err = f.WriteAt([]byte(content), n)
  1087. } else { //不存在
  1088. fmt.Println("文件不存在,创建文件")
  1089. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1090. defer f.Close()
  1091. if err != nil {
  1092. } else {
  1093. _, err = f.Write([]byte("记录日志"))
  1094. }
  1095. }
  1096. }
  1097. func (c *NmController) Get3201() {
  1098. insutype := c.GetString("insutype")
  1099. clrType := c.GetString("clr_type")
  1100. setlOptins := c.GetString("setl_optins")
  1101. stmtBegndate := c.GetString("stmt_begndate")
  1102. stmtEnddate := c.GetString("stm_enddate")
  1103. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  1104. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  1105. acctPay, _ := c.GetFloat("acct_pay", 0)
  1106. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  1107. fixmedins_code := c.GetString("fixmedins_code")
  1108. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1109. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1110. secret_key := c.GetString("secret_key")
  1111. org_name := c.GetString("org_name")
  1112. doctor := c.GetString("doctor")
  1113. baseParams := models.BaseParams{
  1114. SecretKey: secret_key,
  1115. FixmedinsCode: fixmedins_code,
  1116. InsuplcAdmdvs: insuplc_admdvs,
  1117. MdtrtareaAdmvs: mdtrtarea_admvs,
  1118. OrgName: org_name,
  1119. Doctor: doctor,
  1120. }
  1121. businessParams := models.BusinessParams{
  1122. Insutype: insutype,
  1123. ClrType: clrType,
  1124. SetlOptins: setlOptins,
  1125. StmtBegndate: stmtBegndate,
  1126. StmtEnddate: stmtEnddate,
  1127. MedfeeSumamt: medfeeSumamt,
  1128. FundPaySumamt: fundPaySumamt,
  1129. AcctPay: acctPay,
  1130. FixmedinsSetlCnt: fixmedinsSetlCnt,
  1131. }
  1132. result := service.Gdyb3201(baseParams, businessParams)
  1133. saveJsLog(result, "", "3201", "对总账", org_name)
  1134. var dat map[string]interface{}
  1135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1136. fmt.Println(dat)
  1137. } else {
  1138. fmt.Println(err)
  1139. }
  1140. c.ServeSuccessJSON(map[string]interface{}{
  1141. "pre": dat,
  1142. })
  1143. }
  1144. func (c *NmController) Get2601() {
  1145. result := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202210111721190000", "2305", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1146. var dat map[string]interface{}
  1147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1148. fmt.Println(dat)
  1149. } else {
  1150. fmt.Println(err)
  1151. }
  1152. result2 := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202209281143070000", "2304", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1153. var dat2 map[string]interface{}
  1154. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  1155. fmt.Println(dat2)
  1156. } else {
  1157. fmt.Println(err)
  1158. }
  1159. c.ServeSuccessJSON(map[string]interface{}{
  1160. "pre": dat,
  1161. })
  1162. }
  1163. func ConvertByte2String(byte []byte, charset Charset) string {
  1164. var str string
  1165. switch charset {
  1166. case GB18030:
  1167. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1168. str = string(decodeBytes)
  1169. case UTF8:
  1170. fallthrough
  1171. default:
  1172. str = string(byte)
  1173. }
  1174. return str
  1175. }