nm_controller.go 72KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271
  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{}, "post:Post2203")
  53. beego.Router("/nmyb/2203C", &NmController{}, "post:Post2203C")
  54. beego.Router("/nmyb/2204", &NmController{}, "post:Post2204")
  55. beego.Router("/nmyb/2205", &NmController{}, "get:Post2205")
  56. beego.Router("/nmyb/2206", &NmController{}, "get:Post2206")
  57. beego.Router("/nmyb/2207", &NmController{}, "get:Post2207")
  58. beego.Router("/nmyb/2208", &NmController{}, "get:Post2208")
  59. beego.Router("/nmyb/2503", &NmController{}, "get:Post2503")
  60. beego.Router("/nmyb/3501", &NmController{}, "get:Post3501")
  61. beego.Router("/nmyb/3502", &NmController{}, "get:Post3502")
  62. beego.Router("/nmyb/3503", &NmController{}, "get:Post3503")
  63. beego.Router("/nmyb/3504", &NmController{}, "get:Post3504")
  64. beego.Router("/nmyb/3505", &NmController{}, "post:Post3505")
  65. beego.Router("/nmyb/3506", &NmController{}, "get:Post3506")
  66. beego.Router("/nmyb/3507", &NmController{}, "get:Post3507")
  67. beego.Router("/nmyb/3508", &NmController{}, "get:Post3508")
  68. beego.Router("/nmyb/3509", &NmController{}, "get:Post3509")
  69. beego.Router("/nmyb/3510", &NmController{}, "get:Post3510")
  70. beego.Router("/nmyb/3511", &NmController{}, "get:Post3511")
  71. beego.Router("/nmyb/3512", &NmController{}, "get:Post3512")
  72. beego.Router("/nmyb/3513", &NmController{}, "get:Post3513")
  73. }
  74. func (c *NmController) Post3501() {
  75. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  76. var respJSON map[string]interface{}
  77. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  78. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  79. return
  80. }
  81. userJSONBytes, _ := json.Marshal(respJSON["struct_3501s"])
  82. var struct3501 models.Struct3501
  83. if err := json.Unmarshal(userJSONBytes, &struct3501); err != nil {
  84. utils.ErrorLog("解析失败:%v", err)
  85. return
  86. }
  87. result, request_log := service.NMyb3501(struct3501, struct3501.SecretKey)
  88. saveJsLog(result, request_log, "3501", "库存盘点", struct3501.OrgName)
  89. var dat2 map[string]interface{}
  90. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  91. } else {
  92. }
  93. var dat map[string]interface{}
  94. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  95. } else {
  96. }
  97. c.ServeSuccessJSON(map[string]interface{}{
  98. "pre": dat,
  99. "request_log": dat2,
  100. })
  101. }
  102. func (c *NmController) Post3502() {
  103. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  104. var respJSON map[string]interface{}
  105. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  107. return
  108. }
  109. userJSONBytes, _ := json.Marshal(respJSON["struct_3502s"])
  110. var struct3502s models.Struct3502
  111. if err := json.Unmarshal(userJSONBytes, &struct3502s); err != nil {
  112. utils.ErrorLog("解析失败:%v", err)
  113. return
  114. }
  115. result, request_log := service.NMyb3502(struct3502s, struct3502s.SecretKey)
  116. saveJsLog(result, request_log, "3502", "库存变更", struct3502s.OrgName)
  117. var dat2 map[string]interface{}
  118. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  119. } else {
  120. }
  121. var dat map[string]interface{}
  122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  123. } else {
  124. }
  125. c.ServeSuccessJSON(map[string]interface{}{
  126. "pre": dat,
  127. "request_log": dat2,
  128. })
  129. }
  130. func (c *NmController) Post3503() {
  131. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  132. var respJSON map[string]interface{}
  133. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  135. return
  136. }
  137. userJSONBytes, _ := json.Marshal(respJSON["struct_3503s"])
  138. var struct3503 models.Struct3503
  139. if err := json.Unmarshal(userJSONBytes, &struct3503); err != nil {
  140. utils.ErrorLog("解析失败:%v", err)
  141. return
  142. }
  143. fmt.Println(struct3503)
  144. result, request_log := service.NMyb3503(struct3503, struct3503.SecretKey)
  145. saveJsLog(result, request_log, "3503", "库存采购", struct3503.OrgName)
  146. var dat2 map[string]interface{}
  147. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  148. } else {
  149. }
  150. var dat map[string]interface{}
  151. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  152. } else {
  153. }
  154. c.ServeSuccessJSON(map[string]interface{}{
  155. "pre": dat,
  156. "request_log": dat2,
  157. })
  158. }
  159. func (c *NmController) Post3504() {
  160. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  161. var respJSON map[string]interface{}
  162. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  163. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  164. return
  165. }
  166. userJSONBytes, _ := json.Marshal(respJSON["struct_3504s"])
  167. var struct3504 []models.Struct3504
  168. if err := json.Unmarshal(userJSONBytes, &struct3504); err != nil {
  169. utils.ErrorLog("解析失败:%v", err)
  170. return
  171. }
  172. result, request_log := service.NMyb3504(struct3504[0], struct3504[0].SecretKey)
  173. saveJsLog(result, request_log, "3504", "库存盘点", struct3504[0].OrgName)
  174. var dat2 map[string]interface{}
  175. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  176. } else {
  177. }
  178. var dat map[string]interface{}
  179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  180. } else {
  181. }
  182. c.ServeSuccessJSON(map[string]interface{}{
  183. "pre": dat,
  184. "request_log": dat2,
  185. })
  186. }
  187. func (c *NmController) Post3505() {
  188. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  189. var respJSON map[string]interface{}
  190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  192. return
  193. }
  194. userJSONBytes, _ := json.Marshal(respJSON["struct_3505s"])
  195. var struct3505 models.Struct3505
  196. if err := json.Unmarshal(userJSONBytes, &struct3505); err != nil {
  197. utils.ErrorLog("解析失败:%v", err)
  198. return
  199. }
  200. result, request_log := service.NMyb3505(struct3505, struct3505.SecretKey)
  201. saveJsLog(result, request_log, "3505", "销售", struct3505.OrgName)
  202. var dat2 map[string]interface{}
  203. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  204. } else {
  205. }
  206. var dat map[string]interface{}
  207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  208. } else {
  209. }
  210. c.ServeSuccessJSON(map[string]interface{}{
  211. "pre": dat,
  212. "request_log": dat2,
  213. })
  214. }
  215. func (c *NmController) Post3506() {
  216. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  217. var respJSON map[string]interface{}
  218. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  220. return
  221. }
  222. userJSONBytes, _ := json.Marshal(respJSON["struct_3506s"])
  223. var struct3506 models.Struct3506
  224. if err := json.Unmarshal(userJSONBytes, &struct3506); err != nil {
  225. utils.ErrorLog("解析失败:%v", err)
  226. return
  227. }
  228. result, request_log := service.NMyb3506(struct3506, struct3506.SecretKey)
  229. saveJsLog(result, request_log, "3506", "销售退库", struct3506.OrgName)
  230. var dat2 map[string]interface{}
  231. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  232. } else {
  233. }
  234. var dat map[string]interface{}
  235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  236. } else {
  237. }
  238. c.ServeSuccessJSON(map[string]interface{}{
  239. "pre": dat,
  240. "request_log": dat2,
  241. })
  242. }
  243. func (c *NmController) Post3507() {
  244. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  245. var respJSON map[string]interface{}
  246. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  248. return
  249. }
  250. userJSONBytes, _ := json.Marshal(respJSON["struct_3507s"])
  251. var struct3507 models.Struct3507
  252. if err := json.Unmarshal(userJSONBytes, &struct3507); err != nil {
  253. utils.ErrorLog("解析失败:%v", err)
  254. return
  255. }
  256. result, request_log := service.NMyb3507(struct3507, struct3507.SecretKey)
  257. saveJsLog(result, request_log, "3507", "库存盘点", struct3507.OrgName)
  258. var dat2 map[string]interface{}
  259. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  260. } else {
  261. }
  262. var dat map[string]interface{}
  263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  264. } else {
  265. }
  266. c.ServeSuccessJSON(map[string]interface{}{
  267. "pre": dat,
  268. "request_log": dat2,
  269. })
  270. }
  271. func (c *NmController) Post3508() {
  272. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  273. var respJSON map[string]interface{}
  274. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  276. return
  277. }
  278. userJSONBytes, _ := json.Marshal(respJSON["struct_3508s"])
  279. var struct3508 models.Struct3508
  280. if err := json.Unmarshal(userJSONBytes, &struct3508); err != nil {
  281. utils.ErrorLog("解析失败:%v", err)
  282. return
  283. }
  284. result, request_log := service.NMyb3508(struct3508, struct3508.SecretKey)
  285. saveJsLog(result, request_log, "3508", "库存查询", struct3508.OrgName)
  286. var dat2 map[string]interface{}
  287. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  288. } else {
  289. }
  290. var dat map[string]interface{}
  291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  292. } else {
  293. }
  294. c.ServeSuccessJSON(map[string]interface{}{
  295. "pre": dat,
  296. "request_log": dat2,
  297. })
  298. }
  299. func (c *NmController) Post3509() {
  300. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  301. var respJSON map[string]interface{}
  302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  304. return
  305. }
  306. userJSONBytes, _ := json.Marshal(respJSON["struct_3509s"])
  307. var struct3509 models.Struct3509
  308. if err := json.Unmarshal(userJSONBytes, &struct3509); err != nil {
  309. utils.ErrorLog("解析失败:%v", err)
  310. return
  311. }
  312. result, request_log := service.NMyb3509(struct3509, struct3509.SecretKey)
  313. saveJsLog(result, request_log, "3509", "库存盘点", struct3509.OrgName)
  314. var dat2 map[string]interface{}
  315. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  316. } else {
  317. }
  318. var dat map[string]interface{}
  319. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  320. } else {
  321. }
  322. c.ServeSuccessJSON(map[string]interface{}{
  323. "pre": dat,
  324. "request_log": dat2,
  325. })
  326. }
  327. func (c *NmController) Post3510() {
  328. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  329. var respJSON map[string]interface{}
  330. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  332. return
  333. }
  334. userJSONBytes, _ := json.Marshal(respJSON["struct_3510s"])
  335. var struct3510 models.Struct3510
  336. if err := json.Unmarshal(userJSONBytes, &struct3510); err != nil {
  337. utils.ErrorLog("解析失败:%v", err)
  338. return
  339. }
  340. result, request_log := service.NMyb3510(struct3510, struct3510.SecretKey)
  341. saveJsLog(result, request_log, "3510", "库存盘点", struct3510.OrgName)
  342. var dat2 map[string]interface{}
  343. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  344. } else {
  345. }
  346. var dat map[string]interface{}
  347. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  348. } else {
  349. }
  350. c.ServeSuccessJSON(map[string]interface{}{
  351. "pre": dat,
  352. "request_log": dat2,
  353. })
  354. }
  355. func (c *NmController) Post3511() {
  356. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  357. var respJSON map[string]interface{}
  358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  360. return
  361. }
  362. userJSONBytes, _ := json.Marshal(respJSON["struct_3511s"])
  363. var struct3511 models.Struct3511
  364. if err := json.Unmarshal(userJSONBytes, &struct3511); err != nil {
  365. utils.ErrorLog("解析失败:%v", err)
  366. return
  367. }
  368. result, request_log := service.NMyb3511(struct3511, struct3511.SecretKey)
  369. saveJsLog(result, request_log, "3511", "库存查询", struct3511.OrgName)
  370. var dat2 map[string]interface{}
  371. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  372. } else {
  373. }
  374. var dat map[string]interface{}
  375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  376. } else {
  377. }
  378. c.ServeSuccessJSON(map[string]interface{}{
  379. "pre": dat,
  380. "request_log": dat2,
  381. })
  382. }
  383. func (c *NmController) Post3512() {
  384. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  385. var respJSON map[string]interface{}
  386. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  388. return
  389. }
  390. userJSONBytes, _ := json.Marshal(respJSON["struct_3512s"])
  391. var struct3512 models.Struct3512
  392. if err := json.Unmarshal(userJSONBytes, &struct3512); err != nil {
  393. utils.ErrorLog("解析失败:%v", err)
  394. return
  395. }
  396. result, request_log := service.NMyb3512(struct3512, struct3512.SecretKey)
  397. saveJsLog(result, request_log, "3512", "库存盘点", struct3512.OrgName)
  398. var dat2 map[string]interface{}
  399. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  400. } else {
  401. }
  402. var dat map[string]interface{}
  403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  404. } else {
  405. }
  406. c.ServeSuccessJSON(map[string]interface{}{
  407. "pre": dat,
  408. "request_log": dat2,
  409. })
  410. }
  411. func (c *NmController) Post3513() {
  412. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  413. var respJSON map[string]interface{}
  414. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  416. return
  417. }
  418. userJSONBytes, _ := json.Marshal(respJSON["struct_3513s"])
  419. var struct3513 models.Struct3513
  420. if err := json.Unmarshal(userJSONBytes, &struct3513); err != nil {
  421. utils.ErrorLog("解析失败:%v", err)
  422. return
  423. }
  424. result, request_log := service.NMyb3513(struct3513, struct3513.SecretKey)
  425. saveJsLog(result, request_log, "3513", "库存查询", struct3513.OrgName)
  426. var dat2 map[string]interface{}
  427. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  428. } else {
  429. }
  430. var dat map[string]interface{}
  431. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  432. } else {
  433. }
  434. c.ServeSuccessJSON(map[string]interface{}{
  435. "pre": dat,
  436. "request_log": dat2,
  437. })
  438. }
  439. func (c *NmController) Post2201() {
  440. psnNo := c.GetString("psn_no")
  441. insutype := c.GetString("insutype")
  442. certNo := c.GetString("cert_no")
  443. org_name := c.GetString("org_name")
  444. ipt_otp_no := c.GetString("ipt_otp_no")
  445. dept := c.GetString("dept")
  446. verify_number := c.GetString("verify_number")
  447. fixmedins_code := c.GetString("fixmedins_code")
  448. dept_code := c.GetString("dept_code")
  449. doctor_id := c.GetString("doctor_id")
  450. insuplc_admdvs := c.GetString("insuplc_admdvs")
  451. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  452. secret_key := c.GetString("secret_key")
  453. id_card_type, _ := c.GetInt64("id_card_type")
  454. doctor_name := c.GetString("doctor_name")
  455. cainfo := c.GetString("cainfo")
  456. opter := c.GetString("opter")
  457. result, request_log := service.Nmyb2201(psnNo, insutype, certNo, org_name, opter, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, verify_number, cainfo)
  458. saveJsLog(result, request_log, "2201", "挂号", org_name)
  459. var dat map[string]interface{}
  460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  461. } else {
  462. }
  463. var dat2 map[string]interface{}
  464. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  465. } else {
  466. }
  467. c.ServeSuccessJSON(map[string]interface{}{
  468. "pre": dat,
  469. "request_log": dat2,
  470. })
  471. }
  472. func (c *NmController) Post2202() {
  473. psnNo := c.GetString("psn_no")
  474. mdtrtId := c.GetString("mdtrt_id")
  475. iptOtpNo := c.GetString("ipt_otp_no")
  476. org_name := c.GetString("org_name")
  477. doctor := c.GetString("doctor")
  478. insuplc_admdvs := c.GetString("insuplc_admdvs")
  479. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  480. secret_key := c.GetString("secret_key")
  481. fixmedins_code := c.GetString("fixmedins_code")
  482. cainfo := c.GetString("cainfo")
  483. result, request_log := service.Nmyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, cainfo)
  484. saveJsLog(result, request_log, "2202", "退号", org_name)
  485. var dat map[string]interface{}
  486. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  487. } else {
  488. }
  489. var dat2 map[string]interface{}
  490. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  491. } else {
  492. }
  493. c.ServeSuccessJSON(map[string]interface{}{
  494. "pre": dat,
  495. "request_log": dat2,
  496. })
  497. }
  498. func (c *NmController) Post2203() {
  499. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  500. var respJSON map[string]interface{}
  501. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  503. return
  504. }
  505. userJSONBytes, _ := json.Marshal(respJSON["config"])
  506. var config []*models.HisXtDiagnoseConfig
  507. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  508. utils.ErrorLog("解析失败:%v", err)
  509. return
  510. }
  511. fmt.Println(respJSON["psn_no"].(string))
  512. fmt.Println(respJSON["mdtrt_id"].(string))
  513. psnNo := respJSON["psn_no"].(string)
  514. mdtrtId := respJSON["mdtrt_id"].(string)
  515. doctor := respJSON["doctor"].(string)
  516. department := respJSON["department"].(string)
  517. org_name := respJSON["org_name"].(string)
  518. med_type := respJSON["med_type"].(string)
  519. doctor_id := respJSON["doctor_id"].(string)
  520. fixmedins_code := respJSON["fixmedins_code"].(string)
  521. sick_code := respJSON["sick_code"].(string)
  522. sick_name := respJSON["sick_name"].(string)
  523. dept := respJSON["dept"].(string)
  524. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  525. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  526. secret_key := respJSON["secret_key"].(string)
  527. begin_time := respJSON["begin_time"].(string)
  528. cainfo := respJSON["cainfo"].(string)
  529. //cainfo := c.GetString("cainfo")
  530. 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)
  531. saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
  532. var dat2 map[string]interface{}
  533. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  534. } else {
  535. }
  536. var dat map[string]interface{}
  537. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  538. } else {
  539. }
  540. c.ServeSuccessJSON(map[string]interface{}{
  541. "pre": dat,
  542. "request_log": dat2,
  543. })
  544. }
  545. func (c *NmController) Post2203C() {
  546. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  547. var respJSON map[string]interface{}
  548. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  550. return
  551. }
  552. userJSONBytes, _ := json.Marshal(respJSON["config"])
  553. var config []*models.HisXtDiagnoseConfig
  554. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  555. utils.ErrorLog("解析失败:%v", err)
  556. return
  557. }
  558. fmt.Println(respJSON["psn_no"].(string))
  559. fmt.Println(respJSON["mdtrt_id"].(string))
  560. psnNo := respJSON["psn_no"].(string)
  561. mdtrtId := respJSON["mdtrt_id"].(string)
  562. doctor := respJSON["doctor"].(string)
  563. department := respJSON["department"].(string)
  564. org_name := respJSON["org_name"].(string)
  565. med_type := respJSON["med_type"].(string)
  566. doctor_id := respJSON["doctor_id"].(string)
  567. fixmedins_code := respJSON["fixmedins_code"].(string)
  568. sick_code := respJSON["sick_code"].(string)
  569. sick_name := respJSON["sick_name"].(string)
  570. dept := respJSON["dept"].(string)
  571. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  572. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  573. secret_key := respJSON["secret_key"].(string)
  574. begin_time := respJSON["begin_time"].(string)
  575. cainfo := respJSON["cainfo"].(string)
  576. //is_vaild := respJSON["is_vaild"].(string)
  577. //cainfo := c.GetString("cainfo")
  578. result, request_log := service.Nmyb2203C(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)
  579. saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
  580. var dat2 map[string]interface{}
  581. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  582. } else {
  583. }
  584. var dat map[string]interface{}
  585. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  586. } else {
  587. }
  588. c.ServeSuccessJSON(map[string]interface{}{
  589. "pre": dat,
  590. "request_log": dat2,
  591. })
  592. }
  593. func (c *NmController) Post2204() {
  594. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  595. var respJSON map[string]interface{}
  596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  598. return
  599. }
  600. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  601. var hp []*models.HisPrescription
  602. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  603. utils.ErrorLog("解析失败:%v", err)
  604. return
  605. }
  606. //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
  607. result, request_log := service.Nmyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  608. 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))
  609. saveJsLog(result, request_log, "2204", "上传明细", respJSON["org_name"].(string))
  610. var dat map[string]interface{}
  611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  612. fmt.Println(dat)
  613. } else {
  614. fmt.Println(err)
  615. }
  616. var dat2 map[string]interface{}
  617. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  618. fmt.Println(dat2)
  619. } else {
  620. fmt.Println(err)
  621. }
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "pre": dat,
  624. "request_log": dat2,
  625. })
  626. }
  627. func (c *NmController) Post2205() {
  628. psnNo := c.GetString("psn_no")
  629. mdtrtId := c.GetString("mdtrt_id")
  630. chrgBchno := c.GetString("chrg_bchno")
  631. org_name := c.GetString("org_name")
  632. doctor := c.GetString("doctor")
  633. insuplc_admdvs := c.GetString("insuplc_admdvs")
  634. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  635. secret_key := c.GetString("secret_key")
  636. fixmedins_code := c.GetString("fixmedins_code")
  637. url := c.GetString("url")
  638. ak := c.GetString("ak")
  639. cainfo := c.GetString("cainfo")
  640. result, request_log := service.Nmyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  641. fmt.Println(request_log)
  642. saveJsLog(result, request_log, "2205", "撤销明细", org_name)
  643. var dat map[string]interface{}
  644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  645. fmt.Println(dat)
  646. } else {
  647. fmt.Println(err)
  648. }
  649. var dat2 map[string]interface{}
  650. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  651. fmt.Println(dat2)
  652. } else {
  653. fmt.Println(err)
  654. }
  655. c.ServeSuccessJSON(map[string]interface{}{
  656. "pre": dat,
  657. "request_log": dat2,
  658. })
  659. }
  660. func (c *NmController) Post2206() {
  661. psnNo := c.GetString("psn_no")
  662. mdtrtId := c.GetString("mdtrt_id")
  663. chrgBchno := c.GetString("chrg_bchno")
  664. certNo := c.GetString("cert_no")
  665. insutype := c.GetString("insutype")
  666. total := c.GetString("total")
  667. org_name := c.GetString("org_name")
  668. doctor := c.GetString("doctor")
  669. fixmedins_code := c.GetString("fixmedins_code")
  670. insuplc_admdvs := c.GetString("insuplc_admdvs")
  671. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  672. secret_key := c.GetString("secret_key")
  673. med_type := c.GetString("med_type")
  674. id_card_type, _ := c.GetInt64("id_card_type")
  675. certificates, _ := c.GetInt64("certificates")
  676. verify_number := c.GetString("verify_number")
  677. cainfo := c.GetString("cainfo")
  678. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  679. url := c.GetString("url")
  680. ak := c.GetString("ak")
  681. var result string
  682. var request_log string
  683. 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)
  684. saveJsLog(result, request_log, "2206", "预结算", org_name)
  685. var dat map[string]interface{}
  686. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  687. fmt.Println(dat)
  688. } else {
  689. fmt.Println(err)
  690. }
  691. var dat2 map[string]interface{}
  692. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  693. fmt.Println(dat2)
  694. } else {
  695. fmt.Println(err)
  696. }
  697. c.ServeSuccessJSON(map[string]interface{}{
  698. "pre": dat,
  699. "request_log": dat2,
  700. })
  701. }
  702. func (c *NmController) Post2207() {
  703. psnNo := c.GetString("psn_no")
  704. mdtrtId := c.GetString("mdtrt_id")
  705. chrgBchno := c.GetString("chrg_bchno")
  706. certNo := c.GetString("cert_no")
  707. insutype := c.GetString("insutype")
  708. total := c.GetString("total")
  709. org_name := c.GetString("org_name")
  710. doctor := c.GetString("doctor")
  711. fixmedins_code := c.GetString("fixmedins_code")
  712. insuplc_admdvs := c.GetString("insuplc_admdvs")
  713. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  714. secret_key := c.GetString("secret_key")
  715. med_type := c.GetString("med_type")
  716. id_card_type, _ := c.GetInt64("id_card_type")
  717. certificates, _ := c.GetInt64("certificates")
  718. fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
  719. overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
  720. preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
  721. inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
  722. acct_used_flag := c.GetString("acct_used_flag")
  723. url := c.GetString("url")
  724. ak := c.GetString("ak")
  725. verify_number := c.GetString("verify_number")
  726. cainfo := c.GetString("cainfo")
  727. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  728. var result string
  729. var request_log string
  730. 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)
  731. saveJsLog(result, request_log, "2207", "结算", org_name)
  732. var dat map[string]interface{}
  733. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  734. fmt.Println(dat)
  735. } else {
  736. fmt.Println(err)
  737. }
  738. var dat2 map[string]interface{}
  739. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  740. fmt.Println(dat2)
  741. } else {
  742. fmt.Println(err)
  743. }
  744. c.ServeSuccessJSON(map[string]interface{}{
  745. "pre": dat,
  746. "request_log": dat2,
  747. })
  748. }
  749. func (c *NmController) Post2208() {
  750. psnNo := c.GetString("psn_no")
  751. mdtrtId := c.GetString("mdtrt_id")
  752. setlId := c.GetString("setl_id")
  753. org_name := c.GetString("org_name")
  754. doctor := c.GetString("doctor")
  755. secret_key := c.GetString("secret_key")
  756. fixmedins_code := c.GetString("fixmedins_code")
  757. insuplc_admdvs := c.GetString("insuplc_admdvs")
  758. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  759. url := c.GetString("url")
  760. ak := c.GetString("ak")
  761. cainfo := c.GetString("cainfo")
  762. result, request_log := service.Nmyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  763. saveJsLog(result, request_log, "2208", "退费", org_name)
  764. fmt.Println(request_log)
  765. var dat map[string]interface{}
  766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  767. fmt.Println(dat)
  768. } else {
  769. fmt.Println(err)
  770. }
  771. var dat2 map[string]interface{}
  772. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  773. fmt.Println(dat2)
  774. } else {
  775. fmt.Println(err)
  776. }
  777. c.ServeSuccessJSON(map[string]interface{}{
  778. "pre": dat,
  779. "request_log": dat2,
  780. })
  781. }
  782. func (c *NmController) Post2503() {
  783. psnNo := c.GetString("psn_no")
  784. insutype := c.GetString("insutype")
  785. opera := c.GetString("opera")
  786. org_name := c.GetString("org_name")
  787. doctor := c.GetString("doctor")
  788. doctor_id := c.GetString("doctor_id")
  789. secret_key := c.GetString("secret_key")
  790. fixmedins_code := c.GetString("fixmedins_code")
  791. insuplc_admdvs := c.GetString("insuplc_admdvs")
  792. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  793. sick_name := c.GetString("sick_name")
  794. sick_code := c.GetString("sick_code")
  795. start_time := c.GetString("start_time")
  796. end_time := c.GetString("end_time")
  797. check_time := c.GetString("check_time")
  798. hospital_name := c.GetString("hospital_name")
  799. hospital_code := c.GetString("hospital_code")
  800. result := service.Nmyb2503(psnNo, insutype, org_name, opera, doctor, fixmedins_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_name, sick_code, start_time, end_time, check_time, hospital_code, hospital_name)
  801. var dat map[string]interface{}
  802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  803. fmt.Println(dat)
  804. } else {
  805. fmt.Println(err)
  806. }
  807. c.ServeSuccessJSON(map[string]interface{}{
  808. "pre": dat,
  809. })
  810. }
  811. // func (c *NmController) GetNewELeInfo() {
  812. // token := c.GetString("token")
  813. // user_name := c.GetString("user_name")
  814. // id_card_no := c.GetString("id_card_no")
  815. //
  816. // result, _ := service.Gdyb1101ForEleCert("赤峰费森血液透析中心", "关学丽", "H15049901371", "150499", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", token, user_name, id_card_no)
  817. // var dat map[string]interface{}
  818. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  819. // fmt.Println(dat)
  820. // } else {
  821. // fmt.Println(err)
  822. // }
  823. // userJSONBytes, _ := json.Marshal(dat)
  824. // var res ResultTwo
  825. //
  826. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  827. // utils.ErrorLog("解析失败:%v", err)
  828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  829. // return
  830. // }
  831. //
  832. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  833. // if infocode == 0 {
  834. // data := make(map[string]interface{})
  835. // data["token"] = token
  836. // data["result"] = dat
  837. // var req *http.Request
  838. // bytesData, _ := json.Marshal(data)
  839. // req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/ele/info", bytes.NewReader(bytesData))
  840. // client := &http.Client{}
  841. // resp, _ := client.Do(req)
  842. // defer resp.Body.Close()
  843. // body, ioErr := ioutil.ReadAll(resp.Body)
  844. // if ioErr != nil {
  845. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  846. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  847. // return
  848. // }
  849. // var respJSON map[string]interface{}
  850. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  851. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  852. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  853. // return
  854. // }
  855. // c.ServeSuccessJSON(map[string]interface{}{
  856. // "msg": "成功",
  857. // })
  858. //
  859. // }
  860. // }
  861. func (c *NmController) GetToken() {
  862. token := c.GetString("token")
  863. results := strings.Split(token, "-")
  864. fmt.Println(token)
  865. result_code := results[0]
  866. result_info := results[1]
  867. if result_code == "0000" {
  868. var ele2 ELeData2
  869. err := json.Unmarshal([]byte(result_info), &ele2)
  870. if err != nil {
  871. utils.ErrorLog("解析失败:%v", err)
  872. }
  873. if ele2.Code != -2 {
  874. var ele ELeData
  875. err := json.Unmarshal([]byte(result_info), &ele)
  876. if err != nil {
  877. utils.ErrorLog("解析失败:%v", err)
  878. }
  879. token := ele.Data.EcToken
  880. if len(token) > 0 {
  881. data := make(map[string]interface{})
  882. data["token"] = token
  883. data["id_card_no"] = ele.Data.IdNo
  884. fmt.Println(data)
  885. var req *http.Request
  886. fmt.Println(req)
  887. bytesData, _ := json.Marshal(data)
  888. fmt.Println(bytesData)
  889. req, _ = http.NewRequest("POST", "http://172.16.13.253:9532/"+"api/token/get", bytes.NewReader(bytesData))
  890. fmt.Println(req)
  891. client := &http.Client{}
  892. resp, _ := client.Do(req)
  893. fmt.Println(resp)
  894. defer resp.Body.Close()
  895. body, ioErr := ioutil.ReadAll(resp.Body)
  896. fmt.Println(resp.Body)
  897. fmt.Println(body)
  898. fmt.Println(ioErr)
  899. if ioErr != nil {
  900. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  902. return
  903. }
  904. var respJSON map[string]interface{}
  905. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  908. return
  909. }
  910. } else {
  911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  912. return
  913. }
  914. }
  915. } else {
  916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  917. return
  918. }
  919. }
  920. type ReadCardResult struct {
  921. Output struct {
  922. CardInfo string `json:"cardInfo"`
  923. RegionCode string `json:"regionCode"`
  924. } `json:"output"`
  925. Code string `json:"CODE"`
  926. ErrMsg string `json:"ERRMSG"`
  927. }
  928. type ELeData2 struct {
  929. Code int `json:"code"`
  930. Message string `json:"message"`
  931. }
  932. type ELeData struct {
  933. Data struct {
  934. IdNo string `json:"idNo"`
  935. IdType string `json:"idType"`
  936. UserName string `json:"userName"`
  937. EcToken string `json:"ecToken"`
  938. InsuOrg string `json:"insuOrg"`
  939. Gender string `json:"gender"`
  940. Birthday string `json:"birthday"`
  941. Nationality string `json:"nationality"`
  942. Email string `json:"email"`
  943. Extra string `json:"extra"`
  944. } `json:"data"`
  945. Code int `json:"code"`
  946. Message string `json:"message"`
  947. }
  948. type ResultTwo struct {
  949. ErrMsg string `json:"err_msg"`
  950. InfRefmsgid string `json:"inf_refmsgid"`
  951. Infcode string `json:"infcode"`
  952. Output struct {
  953. Baseinfo struct {
  954. Age float64 `json:"age"`
  955. Brdy string `json:"brdy"`
  956. Certno string `json:"certno"`
  957. Gend string `json:"gend"`
  958. Naty string `json:"naty"`
  959. PsnCertType string `json:"psn_cert_type"`
  960. PsnName string `json:"psn_name"`
  961. PsnNo string `json:"psn_no"`
  962. } `json:"baseinfo"`
  963. Idetinfo []interface{} `json:"idetinfo"`
  964. Iinfo []struct {
  965. Balc float64 `json:"balc"`
  966. CvlservFlag string `json:"cvlserv_flag"`
  967. EmpName string `json:"emp_name"`
  968. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  969. Insutype string `json:"insutype"`
  970. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  971. PausInsuDate string `json:"paus_insu_date"`
  972. PsnInsuDate string `json:"psn_insu_date"`
  973. PsnInsuStas string `json:"psn_insu_stas"`
  974. PsnType string `json:"psn_type"`
  975. } `json:"insuinfo"`
  976. } `json:"output"`
  977. RefmsgTime string `json:"refmsg_time"`
  978. RespondTime string `json:"respond_time"`
  979. Signtype interface{} `json:"signtype"`
  980. WarnInfo interface{} `json:"warn_info"`
  981. }
  982. type ResultTwo10265 struct {
  983. ErrMsg string `json:"err_msg"`
  984. InfRefmsgid string `json:"inf_refmsgid"`
  985. Infcode string `json:"infcode"`
  986. Output struct {
  987. Baseinfo struct {
  988. Age float64 `json:"age"`
  989. Brdy string `json:"brdy"`
  990. Certno string `json:"certno"`
  991. Gend string `json:"gend"`
  992. Naty string `json:"naty"`
  993. PsnCertType string `json:"psn_cert_type"`
  994. PsnName string `json:"psn_name"`
  995. PsnNo string `json:"psn_no"`
  996. } `json:"baseinfo"`
  997. Idetinfo []interface{} `json:"idetinfo"`
  998. Iinfo []struct {
  999. Balc float64 `json:"balc"`
  1000. CvlservFlag string `json:"cvlserv_flag"`
  1001. EmpName string `json:"emp_name"`
  1002. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1003. Insutype string `json:"insutype"`
  1004. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1005. PausInsuDate string `json:"paus_insu_date"`
  1006. PsnInsuDate string `json:"psn_insu_date"`
  1007. PsnInsuStas string `json:"psn_insu_stas"`
  1008. PsnType string `json:"psn_type"`
  1009. } `json:"insuinfo"`
  1010. } `json:"output"`
  1011. RefmsgTime string `json:"refmsg_time"`
  1012. RespondTime string `json:"respond_time"`
  1013. Signtype interface{} `json:"signtype"`
  1014. WarnInfo interface{} `json:"warn_info"`
  1015. }
  1016. func (c *NmController) Post4101() {
  1017. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1018. var respJSON map[string]interface{}
  1019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1021. return
  1022. }
  1023. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  1024. var struct4101 service.Struct4101
  1025. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  1026. utils.ErrorLog("解析失败:%v", err)
  1027. return
  1028. }
  1029. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1030. var pp models.PublicParams
  1031. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1032. utils.ErrorLog("解析失败:%v", err)
  1033. return
  1034. }
  1035. result, _ := service.Gdyb4101fornm(struct4101, pp.SecretKey, pp.FixmedinsName, pp.OpterName, pp.FixmedinsCode, pp.InsuplcAdmdvs, pp.MdtrtareaAdmvs, 0, 0)
  1036. var dat map[string]interface{}
  1037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1038. fmt.Println(dat)
  1039. } else {
  1040. fmt.Println(err)
  1041. }
  1042. saveJsLog(result, "", "4101", "上传明细清单", pp.FixmedinsName)
  1043. c.ServeSuccessJSON(map[string]interface{}{
  1044. "pre": dat,
  1045. })
  1046. }
  1047. func (c *NmController) Post5203() {
  1048. fmt.Println("------")
  1049. org_name := c.GetString("org_name")
  1050. doctor := c.GetString("doctor")
  1051. fixmedins_code := c.GetString("fixmedins_code")
  1052. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1053. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1054. secret_key := c.GetString("secret_key")
  1055. psn_no := c.GetString("psn_no")
  1056. mdtrt_id := c.GetString("mdtrt_id")
  1057. setl_id := c.GetString("setl_id")
  1058. fmt.Println("------")
  1059. bp := models.BaseParams{
  1060. SecretKey: secret_key,
  1061. FixmedinsCode: fixmedins_code,
  1062. InsuplcAdmdvs: insuplc_admdvs,
  1063. MdtrtareaAdmvs: mdtrtarea_admvs,
  1064. OrgName: org_name,
  1065. Doctor: doctor,
  1066. }
  1067. bps := models.BusinessParams{
  1068. PsnNo: psn_no,
  1069. MdtrtId: mdtrt_id,
  1070. SetlId: setl_id,
  1071. }
  1072. result := service.ZHyb5203(bp, bps)
  1073. saveJsLog(result, "", "5203", "结算单", org_name)
  1074. var dat map[string]interface{}
  1075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1076. } else {
  1077. }
  1078. c.ServeSuccessJSON(map[string]interface{}{
  1079. "pre": dat,
  1080. })
  1081. }
  1082. func (c *NmController) Post4102() {
  1083. org_name := c.GetString("org_name")
  1084. doctor := c.GetString("doctor")
  1085. fixmedins_code := c.GetString("fixmedins_code")
  1086. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1087. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1088. secret_key := c.GetString("secret_key")
  1089. psn_no := c.GetString("psn_no")
  1090. mdtrt_id := c.GetString("mdtrt_id")
  1091. setl_id := c.GetString("setl_id")
  1092. stas_type := c.GetString("stas_type")
  1093. bp := models.BaseParams{
  1094. SecretKey: secret_key,
  1095. FixmedinsCode: fixmedins_code,
  1096. InsuplcAdmdvs: insuplc_admdvs,
  1097. MdtrtareaAdmvs: mdtrtarea_admvs,
  1098. OrgName: org_name,
  1099. Doctor: doctor,
  1100. }
  1101. bps := models.BusinessParams{
  1102. PsnNo: psn_no,
  1103. MdtrtId: mdtrt_id,
  1104. SetlId: setl_id,
  1105. StasType: stas_type,
  1106. }
  1107. result := service.ZHyb4102(bp, bps)
  1108. saveJsLog(result, "", "4102", "确认结算清单", org_name)
  1109. var dat map[string]interface{}
  1110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1111. } else {
  1112. }
  1113. c.ServeSuccessJSON(map[string]interface{}{
  1114. "pre": dat,
  1115. })
  1116. }
  1117. func (c *NmController) Post4103() {
  1118. org_name := c.GetString("org_name")
  1119. doctor := c.GetString("doctor")
  1120. fixmedins_code := c.GetString("fixmedins_code")
  1121. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1122. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1123. secret_key := c.GetString("secret_key")
  1124. psn_no := c.GetString("psn_no")
  1125. mdtrt_id := c.GetString("mdtrt_id")
  1126. setl_id := c.GetString("setl_id")
  1127. bp := models.BaseParams{
  1128. SecretKey: secret_key,
  1129. FixmedinsCode: fixmedins_code,
  1130. InsuplcAdmdvs: insuplc_admdvs,
  1131. MdtrtareaAdmvs: mdtrtarea_admvs,
  1132. OrgName: org_name,
  1133. Doctor: doctor,
  1134. }
  1135. bps := models.BusinessParams{
  1136. PsnNo: psn_no,
  1137. MdtrtId: mdtrt_id,
  1138. SetlId: setl_id,
  1139. }
  1140. result := service.ZHyb4103(bp, bps)
  1141. result2 := service.ZHyb4104(bp, bps)
  1142. saveJsLog(result, "", "4103", "查询结算清单", org_name)
  1143. saveJsLog(result2, "", "4104", "指控结算清单", org_name)
  1144. var dat map[string]interface{}
  1145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1146. } else {
  1147. }
  1148. c.ServeSuccessJSON(map[string]interface{}{
  1149. "pre": dat,
  1150. })
  1151. }
  1152. func (c *NmController) Post4104() {
  1153. org_name := c.GetString("org_name")
  1154. doctor := c.GetString("doctor")
  1155. fixmedins_code := c.GetString("fixmedins_code")
  1156. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1157. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1158. secret_key := c.GetString("secret_key")
  1159. psn_no := c.GetString("psn_no")
  1160. mdtrt_id := c.GetString("mdtrt_id")
  1161. setl_id := c.GetString("setl_id")
  1162. bp := models.BaseParams{
  1163. SecretKey: secret_key,
  1164. FixmedinsCode: fixmedins_code,
  1165. InsuplcAdmdvs: insuplc_admdvs,
  1166. MdtrtareaAdmvs: mdtrtarea_admvs,
  1167. OrgName: org_name,
  1168. Doctor: doctor,
  1169. }
  1170. bps := models.BusinessParams{
  1171. PsnNo: psn_no,
  1172. MdtrtId: mdtrt_id,
  1173. SetlId: setl_id,
  1174. }
  1175. result := service.ZHyb4104(bp, bps)
  1176. saveJsLog(result, "", "4104", "质控结算清单结果", org_name)
  1177. var dat map[string]interface{}
  1178. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1179. } else {
  1180. }
  1181. c.ServeSuccessJSON(map[string]interface{}{
  1182. "pre": dat,
  1183. })
  1184. }
  1185. func (c *NmController) Post1101() {
  1186. certNo := c.GetString("cert_no")
  1187. org_name := c.GetString("org_name")
  1188. doctor := c.GetString("doctor")
  1189. fixmedins_code := c.GetString("fixmedins_code")
  1190. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1191. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1192. secret_key := c.GetString("secret_key")
  1193. id_card_type, _ := c.GetInt64("id_card_type")
  1194. card_sn := c.GetString("card_sn")
  1195. certificates := c.GetString("certificates")
  1196. name := c.GetString("name")
  1197. certificate, _ := strconv.ParseInt(certificates, 10, 64)
  1198. 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, 0)
  1199. saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
  1200. var dat map[string]interface{}
  1201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1202. } else {
  1203. }
  1204. var dat2 map[string]interface{}
  1205. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  1206. } else {
  1207. }
  1208. c.ServeSuccessJSON(map[string]interface{}{
  1209. "pre": dat,
  1210. "log": dat2,
  1211. })
  1212. }
  1213. func (c *NmController) Post2401() {
  1214. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1215. var respJSON map[string]interface{}
  1216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1218. return
  1219. }
  1220. userJSONBytes, _ := json.Marshal(respJSON["struct_2401"])
  1221. var struct2401 service.Struct2401
  1222. if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
  1223. utils.ErrorLog("解析失败:%v", err)
  1224. return
  1225. }
  1226. org_name := respJSON["org_name"].(string)
  1227. fixmedins_code := respJSON["fixmedins_code"].(string)
  1228. doctor := respJSON["doctor"].(string)
  1229. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  1230. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  1231. secret_key := respJSON["secret_key"].(string)
  1232. result, request_log := service.Hbyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  1233. saveJsLog(result, request_log, "2401", "入院登记", org_name)
  1234. var dat2 map[string]interface{}
  1235. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  1236. } else {
  1237. }
  1238. var dat map[string]interface{}
  1239. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1240. } else {
  1241. }
  1242. c.ServeSuccessJSON(map[string]interface{}{
  1243. "pre": dat,
  1244. "request_log": dat2,
  1245. })
  1246. }
  1247. func (c *NmController) Post2404() {
  1248. mdtrt_id := c.GetString("mdtrt_id")
  1249. psn_no := c.GetString("psn_no")
  1250. doctor := c.GetString("doctor")
  1251. fixmedins_code := c.GetString("fixmedins_code")
  1252. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1253. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1254. secret_key := c.GetString("secret_key")
  1255. org_name := c.GetString("org_name")
  1256. result, requestLog := service.Hbyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  1257. saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
  1258. var dat map[string]interface{}
  1259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1260. } else {
  1261. }
  1262. var dat2 map[string]interface{}
  1263. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1264. } else {
  1265. }
  1266. c.ServeSuccessJSON(map[string]interface{}{
  1267. "pre": dat,
  1268. "log": dat2,
  1269. })
  1270. }
  1271. func (c *NmController) Post2405() {
  1272. mdtrt_id := c.GetString("mdtrt_id")
  1273. psn_no := c.GetString("psn_no")
  1274. doctor := c.GetString("doctor")
  1275. fixmedins_code := c.GetString("fixmedins_code")
  1276. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1277. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1278. secret_key := c.GetString("secret_key")
  1279. org_name := c.GetString("org_name")
  1280. result, requestLog := service.Hb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
  1281. saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
  1282. var dat map[string]interface{}
  1283. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1284. } else {
  1285. }
  1286. var dat2 map[string]interface{}
  1287. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1288. } else {
  1289. }
  1290. c.ServeSuccessJSON(map[string]interface{}{
  1291. "pre": dat,
  1292. "log": dat2,
  1293. })
  1294. }
  1295. func (c *NmController) Post2402() {
  1296. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1297. var respJSON map[string]interface{}
  1298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1300. return
  1301. }
  1302. userJSONBytes, _ := json.Marshal(respJSON["struct_2402"])
  1303. var struct2402 service.Struct2402
  1304. if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
  1305. utils.ErrorLog("解析失败:%v", err)
  1306. return
  1307. }
  1308. org_name := respJSON["org_name"].(string)
  1309. fixmedins_code := respJSON["fixmedins_code"].(string)
  1310. doctor := respJSON["doctor"].(string)
  1311. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  1312. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  1313. secret_key := respJSON["secret_key"].(string)
  1314. result, request_log := service.Hb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
  1315. saveJsLog(result, request_log, "2402", "出院", org_name)
  1316. var dat2 map[string]interface{}
  1317. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  1318. } else {
  1319. }
  1320. var dat map[string]interface{}
  1321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1322. } else {
  1323. }
  1324. c.ServeSuccessJSON(map[string]interface{}{
  1325. "pre": dat,
  1326. "request_log": dat2,
  1327. })
  1328. }
  1329. func (c *NmController) Post2301() {
  1330. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1331. var respJSON map[string]interface{}
  1332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1334. return
  1335. }
  1336. userJSONBytes, _ := json.Marshal(respJSON["customs"])
  1337. var customs []*models.NewCustom
  1338. if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
  1339. utils.ErrorLog("解析失败:%v", err)
  1340. return
  1341. }
  1342. number := respJSON["number"].(string)
  1343. chrg_bchno := respJSON["chrg_bchno"].(string)
  1344. dept := respJSON["dept"].(string)
  1345. dept_code := respJSON["dept_code"].(string)
  1346. doctor_code := respJSON["doctor_code"].(string)
  1347. doctor_name := respJSON["doctor_name"].(string)
  1348. opertor := respJSON["opertor"].(string)
  1349. org_name := respJSON["org_name"].(string)
  1350. fixmedins_code := respJSON["fixmedins_code"].(string)
  1351. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  1352. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  1353. secret_key := respJSON["secret_key"].(string)
  1354. med_type := respJSON["med_type"].(string)
  1355. //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
  1356. psn_no := respJSON["psn_no"].(string)
  1357. result, requestLog := service.Hb2301A(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)
  1358. saveJsLog(result, requestLog, "2301", "上传明细", org_name)
  1359. var dat2 map[string]interface{}
  1360. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1361. } else {
  1362. }
  1363. var dat map[string]interface{}
  1364. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1365. } else {
  1366. }
  1367. c.ServeSuccessJSON(map[string]interface{}{
  1368. "pre": dat,
  1369. "request_log": dat2,
  1370. })
  1371. }
  1372. func (c *NmController) Post2302() {
  1373. mdtrt_id := c.GetString("mdtrtId")
  1374. psn_no := c.GetString("psn_no")
  1375. number := c.GetString("feedetl_sn")
  1376. doctor := c.GetString("doctor")
  1377. fixmedins_code := c.GetString("fixmedins_code")
  1378. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1379. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1380. secret_key := c.GetString("secret_key")
  1381. org_name := c.GetString("org_name")
  1382. refund_type, _ := c.GetInt64("refund_type")
  1383. result, requestLog := service.Hb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
  1384. saveJsLog(result, requestLog, "2302", "退明细", org_name)
  1385. var dat2 map[string]interface{}
  1386. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1387. } else {
  1388. }
  1389. var dat map[string]interface{}
  1390. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1391. } else {
  1392. }
  1393. c.ServeSuccessJSON(map[string]interface{}{
  1394. "pre": dat,
  1395. "request_log": dat2,
  1396. })
  1397. }
  1398. func (c *NmController) Post2303() {
  1399. mdtrt_id := c.GetString("mdtrt_id")
  1400. psn_no := c.GetString("psn_no")
  1401. chrg_bchno := c.GetString("chrg_bchno")
  1402. cert_no := c.GetString("cert_no")
  1403. insutype_type := c.GetString("insutype_type")
  1404. allTotal := c.GetString("total")
  1405. id_card_type, _ := c.GetInt64("id_card_type")
  1406. doctor := c.GetString("doctor")
  1407. certificates, _ := c.GetInt64("certificates")
  1408. fixmedins_code := c.GetString("fixmedins_code")
  1409. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1410. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1411. secret_key := c.GetString("secret_key")
  1412. org_name := c.GetString("org_name")
  1413. result, src_resquest := service.Hb2303(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)
  1414. saveJsLog(result, src_resquest, "2303", "预结算", org_name)
  1415. var dat2 map[string]interface{}
  1416. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1417. } else {
  1418. }
  1419. var dat map[string]interface{}
  1420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1421. } else {
  1422. }
  1423. c.ServeSuccessJSON(map[string]interface{}{
  1424. "pre": dat,
  1425. "request_log": dat2,
  1426. })
  1427. }
  1428. func (c *NmController) Post2304() {
  1429. mdtrt_id := c.GetString("mdtrt_id")
  1430. psn_no := c.GetString("psn_no")
  1431. chrg_bchno := c.GetString("chrg_bchno")
  1432. cert_no := c.GetString("cert_no")
  1433. insutype_type := c.GetString("insutype_type")
  1434. allTotal := c.GetString("total")
  1435. id_card_type, _ := c.GetInt64("id_card_type")
  1436. doctor := c.GetString("doctor")
  1437. certificates, _ := c.GetInt64("certificates")
  1438. fixmedins_code := c.GetString("fixmedins_code")
  1439. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1440. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1441. secret_key := c.GetString("secret_key")
  1442. org_name := c.GetString("org_name")
  1443. fapiao_number := c.GetString("fapiao_number")
  1444. acct_used_flag := c.GetString("acct_used_flag")
  1445. result, src_resquest := service.Hb2304(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)
  1446. saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
  1447. var dat2 map[string]interface{}
  1448. if err := json.Unmarshal([]byte(src_resquest), &dat2); err == nil {
  1449. } else {
  1450. }
  1451. var dat map[string]interface{}
  1452. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1453. } else {
  1454. }
  1455. c.ServeSuccessJSON(map[string]interface{}{
  1456. "pre": dat,
  1457. "request_log": dat2,
  1458. })
  1459. }
  1460. func (c *NmController) Post2305() {
  1461. mdtrt_id := c.GetString("mdtrt_id")
  1462. psn_no := c.GetString("psn_no")
  1463. doctor := c.GetString("doctor")
  1464. setl_id := c.GetString("setl_id")
  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. result, requestLog := service.Hb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1471. saveJsLog(result, requestLog, "2305", "退费", org_name)
  1472. var dat2 map[string]interface{}
  1473. if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
  1474. } else {
  1475. }
  1476. var dat map[string]interface{}
  1477. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1478. } else {
  1479. }
  1480. c.ServeSuccessJSON(map[string]interface{}{
  1481. "pre": dat,
  1482. "request_log": dat2,
  1483. })
  1484. }
  1485. func (c *NmController) Get2503() {
  1486. }
  1487. func (c *NmController) ReadCard() {
  1488. fixmedins_code := c.GetString("fixmedins_code")
  1489. secret_key := c.GetString("secret_key")
  1490. org_name := c.GetString("org_name")
  1491. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1492. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1493. id_card_type := c.GetString("id_card_type")
  1494. operator_id := c.GetString("operator_id")
  1495. operator := c.GetString("operator")
  1496. is_settle := c.GetString("is_settle")
  1497. switch id_card_type {
  1498. case "1":
  1499. if initFlag == 0 {
  1500. c.TestGetBasBaseInit()
  1501. }
  1502. pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
  1503. basStr := Remove0000(pBusiCardInfo)
  1504. if len(basStr) == 0 {
  1505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1506. return
  1507. }
  1508. var dat2 map[string]interface{}
  1509. if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
  1510. fmt.Println(dat2)
  1511. } else {
  1512. fmt.Println(err)
  1513. }
  1514. userJSONBytes, _ := json.Marshal(dat2)
  1515. var res ReadCardResult
  1516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1517. utils.ErrorLog("解析失败:%v", err)
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1519. return
  1520. }
  1521. fmt.Println(basStr)
  1522. bas := strings.Split(res.Output.CardInfo, "|")
  1523. basNumber := bas[1]
  1524. fmt.Println(basNumber)
  1525. card_sn := bas[3]
  1526. fmt.Println(card_sn)
  1527. cardNumber := bas[2]
  1528. name := bas[4]
  1529. result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
  1530. var dat map[string]interface{}
  1531. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1532. fmt.Println(dat)
  1533. } else {
  1534. fmt.Println(err)
  1535. }
  1536. userJSONBytes2, _ := json.Marshal(dat)
  1537. var res2 ResultTwo
  1538. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1539. utils.ErrorLog("解析失败:%v", err)
  1540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1541. return
  1542. }
  1543. infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
  1544. if infocode == 0 {
  1545. c.ServeSuccessJSON(map[string]interface{}{
  1546. "status": "0",
  1547. "card_info": res.Output.CardInfo,
  1548. "busi_card_info": pBusiCardInfo,
  1549. "result": res2,
  1550. "type": "1",
  1551. })
  1552. } else {
  1553. c.ServeSuccessJSON(map[string]interface{}{
  1554. "status": "-1",
  1555. })
  1556. }
  1557. break
  1558. case "4": //电子凭证
  1559. //c.GetELeInfo()
  1560. var result_info string
  1561. if len(is_settle) > 0 {
  1562. _, result_info = c.GetELeInfo(fixmedins_code, operator_id, operator)
  1563. } else {
  1564. _, result_info = c.GetELeInfoThree(fixmedins_code, operator_id, operator)
  1565. }
  1566. //if result_code == "0000" {
  1567. var ele ELeData
  1568. err := json.Unmarshal([]byte(result_info), &ele)
  1569. if err != nil {
  1570. utils.ErrorLog("解析失败:%v", err)
  1571. }
  1572. token := ele.Data.EcToken
  1573. fmt.Println(token)
  1574. if len(token) > 0 {
  1575. result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.UserName, ele.Data.IdNo)
  1576. var dat map[string]interface{}
  1577. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1578. fmt.Println(dat)
  1579. } else {
  1580. fmt.Println(err)
  1581. }
  1582. userJSONBytes, _ := json.Marshal(dat)
  1583. var res ResultTwo
  1584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1585. utils.ErrorLog("解析失败:%v", err)
  1586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1587. return
  1588. }
  1589. infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1590. if infocode == 0 {
  1591. c.ServeSuccessJSON(map[string]interface{}{
  1592. "status": "0",
  1593. "card_info": result_info,
  1594. "busi_card_info": result_info,
  1595. "token": token,
  1596. "result": dat,
  1597. })
  1598. } else {
  1599. c.ServeSuccessJSON(map[string]interface{}{
  1600. "status": "-1",
  1601. })
  1602. }
  1603. } else {
  1604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1605. return
  1606. }
  1607. break
  1608. case "5": //电子凭证
  1609. //c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1610. //_, pBusiCardInfo := c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
  1611. //var ele ELeData
  1612. //err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  1613. //if err != nil {
  1614. // utils.ErrorLog("解析失败:%v", err)
  1615. //}
  1616. //token := ele.Data.EcToken
  1617. //fmt.Println(token)
  1618. //if len(token) > 0 {
  1619. // result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.IdNo, ele.Data.UserName)
  1620. // var dat map[string]interface{}
  1621. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1622. // fmt.Println(dat)
  1623. // } else {
  1624. // fmt.Println(err)
  1625. // }
  1626. // userJSONBytes, _ := json.Marshal(dat)
  1627. // var res ResultTwo
  1628. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1629. // utils.ErrorLog("解析失败:%v", err)
  1630. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. // return
  1632. // }
  1633. //
  1634. // infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
  1635. //
  1636. // if infocode == 0 {
  1637. //
  1638. // c.ServeSuccessJSON(map[string]interface{}{
  1639. // "status": "0",
  1640. // "card_info": pBusiCardInfo,
  1641. // "busi_card_info": pBusiCardInfo,
  1642. // "token": token,
  1643. // "result": dat,
  1644. // })
  1645. //
  1646. // } else {
  1647. // c.ServeSuccessJSON(map[string]interface{}{
  1648. // "status": "-1",
  1649. // })
  1650. //
  1651. // }
  1652. //} else {
  1653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1654. // return
  1655. //}
  1656. //break
  1657. }
  1658. }
  1659. var initFlag int64 = 0
  1660. func (c *NmController) GetELeInfoTwo(code string, operator_id string, operator_name string) (string, string) {
  1661. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  1662. readCard := DllDef.MustFindProc("NationEcTrans")
  1663. fmt.Println(readCard)
  1664. fmt.Println("!!!!!")
  1665. pBusiCardInfo := make([]byte, 1024*10)
  1666. input := make(map[string]interface{})
  1667. inputData := make(map[string]interface{})
  1668. inputData["orgId"] = code
  1669. inputData["businessType"] = "01101"
  1670. inputData["operatorId"] = operator_id
  1671. inputData["operatorName"] = operator_name
  1672. inputData["officeId"] = "001"
  1673. inputData["officeName"] = "血透室"
  1674. inputData["deviceType"] = ""
  1675. input["data"] = inputData
  1676. input["orgId"] = code
  1677. input["transType"] = "ec.query"
  1678. bytesData, _ := json.Marshal(input)
  1679. //gdyb_url := beego.AppConfig.String("gdyb_url")
  1680. fmt.Println(string(bytesData))
  1681. url := "http://10.38.22.15:8081" + "/localcfc/api/hsecfc/localQrCodeQuery"
  1682. ret2, aa, bb := readCard.Call(StrPtr(url), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1683. fmt.Println(aa)
  1684. fmt.Println(bb)
  1685. fmt.Println(ret2)
  1686. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1687. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1688. if ret2 != 0 {
  1689. return "", ""
  1690. }
  1691. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1692. }
  1693. func (c *NmController) TestGetBasBaseInit() {
  1694. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1695. Iinit := DllDef.MustFindProc("Init")
  1696. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1697. str := make([]byte, 2048)
  1698. inputData := make(map[string]interface{})
  1699. inputData["IP"] = "tyjk.nm.hsip.gov.cn"
  1700. inputData["PORT"] = 8090
  1701. inputData["TIMEOUT"] = 180
  1702. inputData["LOG_PATH"] = "C:\\log\\"
  1703. //inputData["SFZ_DRIVER_TYPE"] = 0
  1704. inputData["URL"] = "/uif-hsaf-med-api/api/medical/service"
  1705. bytesData, _ := json.Marshal(inputData)
  1706. fmt.Println(inputData)
  1707. fmt.Println(bytesData)
  1708. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  1709. if ret != 0 {
  1710. fmt.Println("SSCard的报错原因:", err)
  1711. fmt.Println("SSCard的运算结果为:", ret)
  1712. fmt.Println("SSCard的返回结果为:", string(str))
  1713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1714. return
  1715. }
  1716. fmt.Println("SSCard的返回结果为:", string(str))
  1717. result := int(ret)
  1718. fmt.Println("SSCard的运算结果为1:", result)
  1719. //initFlag = 1
  1720. return
  1721. }
  1722. func (c *NmController) GetSFZBaseInfo() string {
  1723. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1724. readCard := DllDef.MustFindProc("ReadSFZ")
  1725. if readCard == nil {
  1726. fmt.Println("readcard is nil")
  1727. readCard = DllDef.MustFindProc("ReadSFZ")
  1728. }
  1729. str := make([]byte, 256)
  1730. str1 := make([]byte, 256)
  1731. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1732. fmt.Println(r)
  1733. return string(str)
  1734. }
  1735. func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
  1736. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1737. readCard := DllDef.MustFindProc("ReadCardBas")
  1738. fmt.Println(readCard)
  1739. fmt.Println("!!!!!")
  1740. month := time.Unix(1557042972, 0).Format("1")
  1741. year := time.Now().Format("2006")
  1742. month = time.Now().Format("01")
  1743. day := time.Now().Format("02")
  1744. hour := time.Now().Format("15")
  1745. min := time.Now().Format("04")
  1746. sec := time.Now().Format("05")
  1747. msec := time.Now().Format("000")
  1748. timestamp := time.Now().Unix()
  1749. tempTime := time.Unix(timestamp, 0)
  1750. //timeFormat := tempTime.Format("20060102150405")
  1751. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1752. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  1753. inputData := make(map[string]interface{})
  1754. inputData["infno"] = "1199"
  1755. //inputData["msgid"] = "7021"
  1756. inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  1757. inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
  1758. inputData["insuplc_admdvs"] = "" // 发送方报文 ID
  1759. // 发送方报文 ID
  1760. inputData["recer_sys_code"] = "01"
  1761. inputData["dev_no"] = ""
  1762. inputData["dev_safe_info"] = ""
  1763. inputData["cainfo"] = ""
  1764. inputData["signtype"] = "SM3"
  1765. inputData["infver"] = "V1.0"
  1766. inputData["opter_type"] = "1"
  1767. inputData["opter"] = opter_id
  1768. inputData["opter_name"] = opter_name
  1769. inputData["inf_time"] = timeFormatOne
  1770. inputData["fixmedins_code"] = fixmedins_code
  1771. inputData["fixmedins_name"] = fixmedins_name
  1772. inputData["sign_no"] = ""
  1773. bytesData, _ := json.Marshal(inputData)
  1774. fmt.Println(string(bytesData))
  1775. pBusiCardInfo := make([]byte, 8192)
  1776. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1777. fmt.Println(ret2)
  1778. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1779. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1780. if ret2 != 0 {
  1781. return ""
  1782. }
  1783. return DeleteExtraSpace(string(pBusiCardInfo))
  1784. }
  1785. func (c *NmController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  1786. // WebSocket服务器地址
  1787. serverURL := "ws://127.0.0.1:8899"
  1788. // 解析WebSocket服务器地址
  1789. u, err := url.Parse(serverURL)
  1790. if err != nil {
  1791. log.Fatal(err)
  1792. }
  1793. // 建立WebSocket连接
  1794. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1795. if err != nil {
  1796. log.Fatal(err)
  1797. }
  1798. defer conn.Close()
  1799. input2 := make(map[string]interface{})
  1800. input := make(map[string]interface{})
  1801. inputData := make(map[string]interface{})
  1802. inputData["orgId"] = code
  1803. inputData["businessType"] = "01101"
  1804. inputData["operatorId"] = operator_id
  1805. inputData["operatorName"] = operator_name
  1806. inputData["officeId"] = "001"
  1807. inputData["officeName"] = "血透室"
  1808. inputData["deviceType"] = ""
  1809. input["data"] = inputData
  1810. input["orgId"] = code
  1811. input["transType"] = "ec.query"
  1812. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1813. input2["indata"] = input
  1814. bytesData, _ := json.Marshal(input2)
  1815. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1816. if err != nil {
  1817. fmt.Println(err)
  1818. }
  1819. // 接收消息
  1820. _, receivedMessage, err := conn.ReadMessage()
  1821. if err != nil {
  1822. fmt.Println(err)
  1823. }
  1824. return "", string(receivedMessage)
  1825. }
  1826. func (c *NmController) GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  1827. // WebSocket服务器地址
  1828. serverURL := "ws://127.0.0.1:8899"
  1829. // 解析WebSocket服务器地址
  1830. u, err := url.Parse(serverURL)
  1831. if err != nil {
  1832. log.Fatal(err)
  1833. }
  1834. // 建立WebSocket连接
  1835. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1836. if err != nil {
  1837. log.Fatal(err)
  1838. }
  1839. defer conn.Close()
  1840. input2 := make(map[string]interface{})
  1841. input := make(map[string]interface{})
  1842. inputData := make(map[string]interface{})
  1843. inputData["orgId"] = code
  1844. inputData["businessType"] = "01301"
  1845. inputData["operatorId"] = operator_id
  1846. inputData["operatorName"] = operator_name
  1847. inputData["officeId"] = "001"
  1848. inputData["officeName"] = "血透室"
  1849. inputData["deviceType"] = ""
  1850. input["data"] = inputData
  1851. input["orgId"] = code
  1852. input["transType"] = "ec.query"
  1853. input2["url"] = "http://10.38.22.15:8081/localcfc/api/hsecfc/localQrCodeQuery"
  1854. input2["indata"] = input
  1855. bytesData, _ := json.Marshal(input2)
  1856. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1857. if err != nil {
  1858. fmt.Println(err)
  1859. }
  1860. // 接收消息
  1861. _, receivedMessage, err := conn.ReadMessage()
  1862. if err != nil {
  1863. fmt.Println(err)
  1864. }
  1865. return "", string(receivedMessage)
  1866. }
  1867. func IntPtr(n int) uintptr {
  1868. return uintptr(n)
  1869. }
  1870. func StrPtr(s string) uintptr {
  1871. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1872. }
  1873. type Charset string
  1874. const (
  1875. UTF8 = Charset("UTF-8")
  1876. GB18030 = Charset("GB18030")
  1877. )
  1878. func ConvertToString(src string, srcCode string, tagCode string) string {
  1879. srcCoder := mahonia.NewDecoder(srcCode)
  1880. srcResult := srcCoder.ConvertString(src)
  1881. tagCoder := mahonia.NewDecoder(tagCode)
  1882. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1883. result := string(cdata)
  1884. return result
  1885. }
  1886. func DeleteExtraSpace(s string) string {
  1887. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1888. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1889. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1890. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1891. s2 := make([]byte, len(s1)) //定义字符数组切片
  1892. copy(s2, s1) //将字符串复制到切片
  1893. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1894. for len(spc_index) > 0 { //找到适配项
  1895. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1896. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1897. }
  1898. return string(s2)
  1899. }
  1900. func Remove0000(s string) string {
  1901. str := make([]rune, 0, len(s))
  1902. for _, v := range []rune(s) {
  1903. if v == 0 {
  1904. continue
  1905. }
  1906. str = append(str, v)
  1907. }
  1908. return string(str)
  1909. }
  1910. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1911. //org_id, _ := beego.AppConfig.Int64("org_id")
  1912. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1913. dir := org_name + "日志"
  1914. utils.Mkdir(dir)
  1915. month := time.Unix(1557042972, 0).Format("1")
  1916. year := time.Now().Format("2006")
  1917. month = time.Now().Format("01")
  1918. day := time.Now().Format("02")
  1919. hour := time.Now().Format("15")
  1920. min := time.Now().Format("04")
  1921. sec := time.Now().Format("05")
  1922. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1923. file := org_name + "_" + year + month + day + "_log"
  1924. file_name := file + ".txt"
  1925. file_path := org_name + "日志" + "/" + file_name
  1926. exist, _ := utils.PathExists(file_path)
  1927. if exist { //存在
  1928. fmt.Println("存在")
  1929. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1930. if err != nil {
  1931. fmt.Println("read fail")
  1932. }
  1933. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1934. n, _ := f.Seek(0, 2)
  1935. _, err = f.WriteAt([]byte(content), n)
  1936. } else { //不存在
  1937. fmt.Println("文件不存在,创建文件")
  1938. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1939. defer f.Close()
  1940. if err != nil {
  1941. } else {
  1942. _, err = f.Write([]byte("记录日志"))
  1943. }
  1944. }
  1945. }
  1946. func (c *NmController) Get3201() {
  1947. insutype := c.GetString("insutype")
  1948. clrType := c.GetString("clr_type")
  1949. setlOptins := c.GetString("setl_optins")
  1950. stmtBegndate := c.GetString("stmt_begndate")
  1951. stmtEnddate := c.GetString("stm_enddate")
  1952. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  1953. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  1954. acctPay, _ := c.GetFloat("acct_pay", 0)
  1955. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  1956. fixmedins_code := c.GetString("fixmedins_code")
  1957. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1958. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1959. secret_key := c.GetString("secret_key")
  1960. org_name := c.GetString("org_name")
  1961. doctor := c.GetString("doctor")
  1962. baseParams := models.BaseParams{
  1963. SecretKey: secret_key,
  1964. FixmedinsCode: fixmedins_code,
  1965. InsuplcAdmdvs: insuplc_admdvs,
  1966. MdtrtareaAdmvs: mdtrtarea_admvs,
  1967. OrgName: org_name,
  1968. Doctor: doctor,
  1969. }
  1970. businessParams := models.BusinessParams{
  1971. Insutype: insutype,
  1972. ClrType: clrType,
  1973. SetlOptins: setlOptins,
  1974. StmtBegndate: stmtBegndate,
  1975. StmtEnddate: stmtEnddate,
  1976. MedfeeSumamt: medfeeSumamt,
  1977. FundPaySumamt: fundPaySumamt,
  1978. AcctPay: acctPay,
  1979. FixmedinsSetlCnt: fixmedinsSetlCnt,
  1980. }
  1981. result := service.Gdyb3201(baseParams, businessParams, 0)
  1982. saveJsLog(result, "", "3201", "对总账", org_name)
  1983. var dat map[string]interface{}
  1984. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1985. fmt.Println(dat)
  1986. } else {
  1987. fmt.Println(err)
  1988. }
  1989. c.ServeSuccessJSON(map[string]interface{}{
  1990. "pre": dat,
  1991. })
  1992. }
  1993. func (c *NmController) Get2601() {
  1994. result := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202210111721190000", "2305", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  1995. var dat map[string]interface{}
  1996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1997. fmt.Println(dat)
  1998. } else {
  1999. fmt.Println(err)
  2000. }
  2001. result2 := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202209281143070000", "2304", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
  2002. var dat2 map[string]interface{}
  2003. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  2004. fmt.Println(dat2)
  2005. } else {
  2006. fmt.Println(err)
  2007. }
  2008. c.ServeSuccessJSON(map[string]interface{}{
  2009. "pre": dat,
  2010. })
  2011. }
  2012. func ConvertByte2String(byte []byte, charset Charset) string {
  2013. var str string
  2014. switch charset {
  2015. case GB18030:
  2016. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  2017. str = string(decodeBytes)
  2018. case UTF8:
  2019. fallthrough
  2020. default:
  2021. str = string(byte)
  2022. }
  2023. return str
  2024. }