nm_controller.go 54KB

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