ahyb_controller.go 64KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138
  1. package ah
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "github.com/axgle/mahonia"
  12. "github.com/gorilla/websocket"
  13. "golang.org/x/text/encoding/simplifiedchinese"
  14. "io/ioutil"
  15. "log"
  16. "net/url"
  17. "os"
  18. "regexp"
  19. "strconv"
  20. "strings"
  21. "syscall"
  22. "time"
  23. "unsafe"
  24. )
  25. type AHybController struct {
  26. controllers.BaseAuthAPIController
  27. }
  28. type Body struct {
  29. ErrMsg string `json:"err_msg"`
  30. InfRefMsgID string `json:"inf_refmsgid"`
  31. InfCode int `json:"infcode"`
  32. Output map[string]interface{} `json:"output"`
  33. }
  34. type Response struct {
  35. Body Body `json:"body"`
  36. Code int `json:"code"`
  37. CSBCode int `json:"csbCode"`
  38. Message string `json:"message"`
  39. RequestID string `json:"requestId"`
  40. State struct{} `json:"state"`
  41. }
  42. func AHybRegistRouters() {
  43. beego.Router("/ahyb/1101", &AHybController{}, "get:PostOne")
  44. beego.Router("/ahyb/2201", &AHybController{}, "get:PostTwo")
  45. beego.Router("/ahyb/2202", &AHybController{}, "get:PostThree")
  46. beego.Router("/ahyb/2203", &AHybController{}, "post:PostFour")
  47. beego.Router("/ahyb/2204", &AHybController{}, "post:PostFive")
  48. beego.Router("/ahyb/2205", &AHybController{}, "get:PostSix")
  49. beego.Router("/ahyb/2206", &AHybController{}, "get:PostSeven")
  50. beego.Router("/ahyb/2207", &AHybController{}, "get:PostEight")
  51. beego.Router("/ahyb/2208", &AHybController{}, "get:PostNine")
  52. beego.Router("/ahyb/5203", &AHybController{}, "get:PostTen")
  53. beego.Router("/ahyb/5301", &AHybController{}, "get:Get5301")
  54. beego.Router("/ahyb/3201", &AHybController{}, "get:Get3201")
  55. beego.Router("/ahyb/9001", &AHybController{}, "get:Get9001")
  56. beego.Router("/ahyb/4101", &AHybController{}, "post:Get4101")
  57. beego.Router("/ahyb/readcard", &AHybController{}, "get:ReadCard")
  58. beego.Router("/ahyb/2503", &AHybController{}, "get:Get2503")
  59. beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406")
  60. beego.Router("/ahyb/readcardcharge", &AHybController{}, "get:Readcardcharge")
  61. beego.Router("/ahyb/3501", &AHybController{}, "post:Get3501")
  62. beego.Router("/ahyb/3502", &AHybController{}, "post:Get3502")
  63. beego.Router("/ahyb/3503", &AHybController{}, "post:Get3503")
  64. beego.Router("/ahyb/3504", &AHybController{}, "post:Get3504")
  65. beego.Router("/ahyb/3505", &AHybController{}, "post:Get3505")
  66. beego.Router("/ahyb/3506", &AHybController{}, "post:Get3506")
  67. beego.Router("/ahyb/3507", &AHybController{}, "post:Get3507")
  68. beego.Router("/ahyb/3508", &AHybController{}, "post:Get3508")
  69. beego.Router("/ahyb/3509", &AHybController{}, "post:Get3509")
  70. beego.Router("/ahyb/3510", &AHybController{}, "post:Get3510")
  71. beego.Router("/ahyb/3511", &AHybController{}, "post:Get3511")
  72. beego.Router("/ahyb/3512", &AHybController{}, "post:Get3512")
  73. beego.Router("/ahyb/3513", &AHybController{}, "post:Get3513")
  74. beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406")
  75. beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406")
  76. }
  77. func (c *AHybController) Get3501() {
  78. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  79. var respJSON map[string]interface{}
  80. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  81. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  82. return
  83. }
  84. userJSONBytes, _ := json.Marshal(respJSON["struct_3501s"])
  85. var struct3501 models.Struct3501
  86. if err := json.Unmarshal(userJSONBytes, &struct3501); err != nil {
  87. utils.ErrorLog("解析失败:%v", err)
  88. return
  89. }
  90. result, request_log := service.Jsyb3501(struct3501)
  91. saveJsLog(result, request_log, "3501", "库存盘点", struct3501.OrgName)
  92. var dat2 map[string]interface{}
  93. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  94. } else {
  95. }
  96. var dat map[string]interface{}
  97. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  98. } else {
  99. }
  100. c.ServeSuccessJSON(map[string]interface{}{
  101. "pre": dat,
  102. "request_log": dat2,
  103. })
  104. }
  105. func (c *AHybController) Get3502() {
  106. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  107. var respJSON map[string]interface{}
  108. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  110. return
  111. }
  112. userJSONBytes, _ := json.Marshal(respJSON["struct_3502s"])
  113. var struct3502s models.Struct3502
  114. if err := json.Unmarshal(userJSONBytes, &struct3502s); err != nil {
  115. utils.ErrorLog("解析失败:%v", err)
  116. return
  117. }
  118. result, request_log := service.Jsyb3502(struct3502s)
  119. saveJsLog(result, request_log, "3502", "库存变更", struct3502s.OrgName)
  120. var dat2 map[string]interface{}
  121. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  122. } else {
  123. }
  124. var dat map[string]interface{}
  125. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  126. } else {
  127. }
  128. c.ServeSuccessJSON(map[string]interface{}{
  129. "pre": dat,
  130. "request_log": dat2,
  131. })
  132. }
  133. func (c *AHybController) Get3503() {
  134. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  135. var respJSON map[string]interface{}
  136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  138. return
  139. }
  140. userJSONBytes, _ := json.Marshal(respJSON["struct_3503s"])
  141. var struct3503 models.Struct3503
  142. if err := json.Unmarshal(userJSONBytes, &struct3503); err != nil {
  143. utils.ErrorLog("解析失败:%v", err)
  144. return
  145. }
  146. fmt.Println(struct3503)
  147. result, request_log := service.Jsyb3503(struct3503)
  148. saveJsLog(result, request_log, "3503", "库存采购", struct3503.OrgName)
  149. var dat2 map[string]interface{}
  150. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  151. } else {
  152. }
  153. var dat map[string]interface{}
  154. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  155. } else {
  156. }
  157. c.ServeSuccessJSON(map[string]interface{}{
  158. "pre": dat,
  159. "request_log": dat2,
  160. })
  161. }
  162. func (c *AHybController) Get3504() {
  163. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  164. var respJSON map[string]interface{}
  165. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  167. return
  168. }
  169. userJSONBytes, _ := json.Marshal(respJSON["struct_3504s"])
  170. var struct3504 []models.Struct3504
  171. if err := json.Unmarshal(userJSONBytes, &struct3504); err != nil {
  172. utils.ErrorLog("解析失败:%v", err)
  173. return
  174. }
  175. result, request_log := service.Jsyb3504(struct3504[0])
  176. saveJsLog(result, request_log, "3504", "库存盘点", struct3504[0].OrgName)
  177. var dat2 map[string]interface{}
  178. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  179. } else {
  180. }
  181. var dat map[string]interface{}
  182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  183. } else {
  184. }
  185. c.ServeSuccessJSON(map[string]interface{}{
  186. "pre": dat,
  187. "request_log": dat2,
  188. })
  189. }
  190. func (c *AHybController) Get3505() {
  191. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  192. var respJSON map[string]interface{}
  193. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  195. return
  196. }
  197. userJSONBytes, _ := json.Marshal(respJSON["struct_3505s"])
  198. var struct3505 models.Struct3505
  199. if err := json.Unmarshal(userJSONBytes, &struct3505); err != nil {
  200. utils.ErrorLog("解析失败:%v", err)
  201. return
  202. }
  203. result, inputLog := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl)
  204. saveJsLog(result, inputLog, "3505", "销售上传", struct3505.OrgName)
  205. var response Response
  206. if err := json.Unmarshal([]byte(result), &response); err != nil {
  207. fmt.Println("Error decoding JSON:", err)
  208. return
  209. }
  210. if response.Code == 200 {
  211. var dat2 map[string]interface{}
  212. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  213. } else {
  214. }
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "pre": response.Body,
  217. "log": dat2,
  218. "status": "1",
  219. "msg": "",
  220. })
  221. } else {
  222. c.ServeSuccessJSON(map[string]interface{}{
  223. "status": "0",
  224. "msg": response.Message,
  225. })
  226. }
  227. }
  228. func (c *AHybController) Get3506() {
  229. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  230. var respJSON map[string]interface{}
  231. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  233. return
  234. }
  235. userJSONBytes, _ := json.Marshal(respJSON["struct_3506s"])
  236. var struct3506 models.Struct3506
  237. if err := json.Unmarshal(userJSONBytes, &struct3506); err != nil {
  238. utils.ErrorLog("解析失败:%v", err)
  239. return
  240. }
  241. result, request_log := service.Jsyb3506(struct3506)
  242. saveJsLog(result, request_log, "3506", "销售退库", struct3506.OrgName)
  243. var dat2 map[string]interface{}
  244. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  245. } else {
  246. }
  247. var dat map[string]interface{}
  248. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  249. } else {
  250. }
  251. c.ServeSuccessJSON(map[string]interface{}{
  252. "pre": dat,
  253. "request_log": dat2,
  254. })
  255. }
  256. func (c *AHybController) Get3507() {
  257. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  258. var respJSON map[string]interface{}
  259. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  260. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  261. return
  262. }
  263. userJSONBytes, _ := json.Marshal(respJSON["struct_3507s"])
  264. var struct3507 models.Struct3507
  265. if err := json.Unmarshal(userJSONBytes, &struct3507); err != nil {
  266. utils.ErrorLog("解析失败:%v", err)
  267. return
  268. }
  269. result, request_log := service.Jsyb3507(struct3507)
  270. saveJsLog(result, request_log, "3507", "库存盘点", struct3507.OrgName)
  271. var dat2 map[string]interface{}
  272. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  273. } else {
  274. }
  275. var dat map[string]interface{}
  276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  277. } else {
  278. }
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "pre": dat,
  281. "request_log": dat2,
  282. })
  283. }
  284. func (c *AHybController) Get3508() {
  285. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  286. var respJSON map[string]interface{}
  287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  289. return
  290. }
  291. userJSONBytes, _ := json.Marshal(respJSON["struct_3508s"])
  292. var struct3508 models.Struct3508
  293. if err := json.Unmarshal(userJSONBytes, &struct3508); err != nil {
  294. utils.ErrorLog("解析失败:%v", err)
  295. return
  296. }
  297. result, request_log := service.Jsyb3508(struct3508)
  298. saveJsLog(result, request_log, "3508", "库存查询", struct3508.OrgName)
  299. var dat2 map[string]interface{}
  300. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  301. } else {
  302. }
  303. var dat map[string]interface{}
  304. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  305. } else {
  306. }
  307. c.ServeSuccessJSON(map[string]interface{}{
  308. "pre": dat,
  309. "request_log": dat2,
  310. })
  311. }
  312. func (c *AHybController) Get3509() {
  313. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  314. var respJSON map[string]interface{}
  315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  317. return
  318. }
  319. userJSONBytes, _ := json.Marshal(respJSON["struct_3509s"])
  320. var struct3509 models.Struct3509
  321. if err := json.Unmarshal(userJSONBytes, &struct3509); err != nil {
  322. utils.ErrorLog("解析失败:%v", err)
  323. return
  324. }
  325. result, request_log := service.Jsyb3509(struct3509)
  326. saveJsLog(result, request_log, "3509", "库存查询", struct3509.OrgName)
  327. var dat2 map[string]interface{}
  328. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  329. } else {
  330. }
  331. var dat map[string]interface{}
  332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  333. } else {
  334. }
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "pre": dat,
  337. "request_log": dat2,
  338. })
  339. }
  340. func (c *AHybController) Get3510() {
  341. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  342. var respJSON map[string]interface{}
  343. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  345. return
  346. }
  347. userJSONBytes, _ := json.Marshal(respJSON["struct_3510s"])
  348. var struct3510 models.Struct3510
  349. if err := json.Unmarshal(userJSONBytes, &struct3510); err != nil {
  350. utils.ErrorLog("解析失败:%v", err)
  351. return
  352. }
  353. result, request_log := service.Jsyb3510(struct3510)
  354. saveJsLog(result, request_log, "3510", "库存盘点", struct3510.OrgName)
  355. var dat2 map[string]interface{}
  356. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  357. } else {
  358. }
  359. var dat map[string]interface{}
  360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  361. } else {
  362. }
  363. c.ServeSuccessJSON(map[string]interface{}{
  364. "pre": dat,
  365. "request_log": dat2,
  366. })
  367. }
  368. func (c *AHybController) Get3511() {
  369. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  370. var respJSON map[string]interface{}
  371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  373. return
  374. }
  375. userJSONBytes, _ := json.Marshal(respJSON["struct_3511s"])
  376. var struct3511 models.Struct3511
  377. if err := json.Unmarshal(userJSONBytes, &struct3511); err != nil {
  378. utils.ErrorLog("解析失败:%v", err)
  379. return
  380. }
  381. result, request_log := service.Jsyb3511(struct3511)
  382. saveJsLog(result, request_log, "3511", "库存查询", struct3511.OrgName)
  383. var dat2 map[string]interface{}
  384. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  385. } else {
  386. }
  387. var dat map[string]interface{}
  388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  389. } else {
  390. }
  391. c.ServeSuccessJSON(map[string]interface{}{
  392. "pre": dat,
  393. "request_log": dat2,
  394. })
  395. }
  396. func (c *AHybController) Get3512() {
  397. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  398. var respJSON map[string]interface{}
  399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  401. return
  402. }
  403. userJSONBytes, _ := json.Marshal(respJSON["struct_3512s"])
  404. var struct3512 models.Struct3512
  405. if err := json.Unmarshal(userJSONBytes, &struct3512); err != nil {
  406. utils.ErrorLog("解析失败:%v", err)
  407. return
  408. }
  409. result, request_log := service.Jsyb3512(struct3512)
  410. saveJsLog(result, request_log, "3512", "3512查询", struct3512.OrgName)
  411. var dat2 map[string]interface{}
  412. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  413. } else {
  414. }
  415. var dat map[string]interface{}
  416. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  417. } else {
  418. }
  419. c.ServeSuccessJSON(map[string]interface{}{
  420. "pre": dat,
  421. "request_log": dat2,
  422. })
  423. }
  424. func (c *AHybController) Get3513() {
  425. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  426. var respJSON map[string]interface{}
  427. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  429. return
  430. }
  431. userJSONBytes, _ := json.Marshal(respJSON["struct_3513s"])
  432. var struct3513 models.Struct3513
  433. if err := json.Unmarshal(userJSONBytes, &struct3513); err != nil {
  434. utils.ErrorLog("解析失败:%v", err)
  435. return
  436. }
  437. result, request_log := service.Jsyb3513(struct3513)
  438. saveJsLog(result, request_log, "3513", "库存盘点", struct3513.OrgName)
  439. var dat2 map[string]interface{}
  440. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  441. } else {
  442. }
  443. var dat map[string]interface{}
  444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  445. } else {
  446. }
  447. c.ServeSuccessJSON(map[string]interface{}{
  448. "pre": dat,
  449. "request_log": dat2,
  450. })
  451. }
  452. func (c *AHybController) Readcardcharge() {
  453. fixmedins_code := c.GetString("fixmedins_code")
  454. secret_key := c.GetString("secret_key")
  455. ak := c.GetString("ak")
  456. org_name := c.GetString("org_name")
  457. doctor := c.GetString("doctor")
  458. //insuplc_admdvs := c.GetString("insuplc_admdvs")
  459. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  460. url := c.GetString("url")
  461. cainfo := c.GetString("cainfo")
  462. operator_id := c.GetString("operator_id")
  463. operator := c.GetString("operator")
  464. _, pBusiCardInfo := c.GetELeCertInfoThree(fixmedins_code, operator_id, operator)
  465. fmt.Println(pBusiCardInfo)
  466. pBusiCardInfo = Remove0000(pBusiCardInfo)
  467. var ele ELeCertData
  468. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  469. if err != nil {
  470. utils.ErrorLog("解析失败:%v", err)
  471. }
  472. token := ele.Data.EcToken
  473. fmt.Println(token)
  474. if len(token) > 0 {
  475. userName := ele.Data.UserName
  476. fmt.Println(userName)
  477. userName = Remove0000(userName)
  478. userName = DeleteExtraSpace(userName)
  479. fmt.Println(userName)
  480. enc := mahonia.NewEncoder("gbk")
  481. fmt.Println(enc.ConvertString(userName))
  482. result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  483. var response Response
  484. if err := json.Unmarshal([]byte(result), &response); err != nil {
  485. fmt.Println("Error decoding JSON:", err)
  486. return
  487. }
  488. if response.Code == 200 {
  489. c.ServeSuccessJSON(map[string]interface{}{
  490. "status": "1",
  491. "card_info": "",
  492. "busi_card_info": pBusiCardInfo,
  493. "token": token,
  494. "result": response.Body,
  495. })
  496. } else {
  497. c.ServeSuccessJSON(map[string]interface{}{
  498. "status": "0",
  499. "msg": response.Message,
  500. })
  501. }
  502. } else {
  503. c.ServeSuccessJSON(map[string]interface{}{
  504. "status": "-1",
  505. })
  506. }
  507. }
  508. func (c *AHybController) Get9001() {
  509. url := c.GetString("url")
  510. org_name := c.GetString("org_name")
  511. opera_name := c.GetString("opera_name")
  512. opera_id := c.GetString("opera_id")
  513. fixmedins_code := c.GetString("fixmedins_code")
  514. insuplc_admdvs := c.GetString("insuplc_admdvs")
  515. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  516. secret_key := c.GetString("secret_key")
  517. cainfo := c.GetString("cainfo")
  518. result, inputLog := service.AHyb9001(org_name, opera_name, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, opera_id, url, cainfo, "")
  519. fmt.Println(result)
  520. fmt.Println(inputLog)
  521. saveJsLog(result, inputLog, "9001", "签到", org_name)
  522. var response Response
  523. if err := json.Unmarshal([]byte(result), &response); err != nil {
  524. fmt.Println("Error decoding JSON:", err)
  525. return
  526. }
  527. if response.Code == 200 {
  528. var dat2 map[string]interface{}
  529. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  530. } else {
  531. }
  532. c.ServeSuccessJSON(map[string]interface{}{
  533. "pre": response.Body,
  534. "log": dat2,
  535. "status": "1",
  536. "msg": "",
  537. })
  538. } else {
  539. c.ServeSuccessJSON(map[string]interface{}{
  540. "status": "0",
  541. "msg": response.Message,
  542. })
  543. }
  544. }
  545. func (c *AHybController) Get5301() {
  546. psn_no := c.GetString("psn_no")
  547. org_name := c.GetString("org_name")
  548. doctor := c.GetString("doctor")
  549. fixmedins_code := c.GetString("fixmedins_code")
  550. insuplc_admdvs := c.GetString("insuplc_admdvs")
  551. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  552. secret_key := c.GetString("secret_key")
  553. url := c.GetString("url")
  554. ak := c.GetString("ak")
  555. cainfo := c.GetString("cainfo")
  556. result, inputLog := service.AHyb5301(psn_no, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, cainfo)
  557. //saveJsLog()
  558. saveJsLog(result, inputLog, "5301", "查询备案", org_name)
  559. var response Response
  560. if err := json.Unmarshal([]byte(result), &response); err != nil {
  561. fmt.Println("Error decoding JSON:", err)
  562. return
  563. }
  564. if response.Code == 200 {
  565. var dat2 map[string]interface{}
  566. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  567. } else {
  568. }
  569. c.ServeSuccessJSON(map[string]interface{}{
  570. "pre": response.Body,
  571. "log": dat2,
  572. "status": "1",
  573. "msg": "",
  574. })
  575. } else {
  576. c.ServeSuccessJSON(map[string]interface{}{
  577. "status": "0",
  578. "msg": response.Message,
  579. })
  580. }
  581. }
  582. func (c *AHybController) PostOne() {
  583. certNo := c.GetString("cert_no")
  584. org_name := c.GetString("org_name")
  585. doctor := c.GetString("doctor")
  586. fixmedins_code := c.GetString("fixmedins_code")
  587. insuplc_admdvs := c.GetString("insuplc_admdvs")
  588. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  589. id_card_type, _ := c.GetInt64("id_card_type")
  590. card_sn := c.GetString("card_sn")
  591. certificates := c.GetString("certificates")
  592. url := c.GetString("url")
  593. token := c.GetString("token")
  594. name := c.GetString("name")
  595. result, inputLog := service.AHyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, id_card_type, card_sn, certificates, url, name, token)
  596. fmt.Println(result)
  597. fmt.Println(inputLog)
  598. saveJsLog(result, inputLog, "1101", "查询个人信息", org_name)
  599. var response Response
  600. if err := json.Unmarshal([]byte(result), &response); err != nil {
  601. fmt.Println("Error decoding JSON:", err)
  602. return
  603. }
  604. if response.Code == 200 {
  605. var dat2 map[string]interface{}
  606. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  607. } else {
  608. }
  609. c.ServeSuccessJSON(map[string]interface{}{
  610. "pre": response.Body,
  611. "log": dat2,
  612. "status": "1",
  613. "msg": "",
  614. })
  615. } else {
  616. c.ServeSuccessJSON(map[string]interface{}{
  617. "status": "0",
  618. "msg": response.Message,
  619. })
  620. }
  621. }
  622. func (c *AHybController) PostTwo() {
  623. psnNo := c.GetString("psn_no")
  624. insutype := c.GetString("insutype")
  625. certNo := c.GetString("cert_no")
  626. org_name := c.GetString("org_name")
  627. opera := c.GetString("opera")
  628. ipt_otp_no := c.GetString("ipt_otp_no")
  629. dept := c.GetString("dept")
  630. verify_number := c.GetString("verify_number")
  631. fixmedins_code := c.GetString("fixmedins_code")
  632. dept_code := c.GetString("dept_code")
  633. doctor_id := c.GetString("doctor_id")
  634. insuplc_admdvs := c.GetString("insuplc_admdvs")
  635. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  636. secret_key := c.GetString("secret_key")
  637. id_card_type, _ := c.GetInt64("id_card_type")
  638. url := c.GetString("url")
  639. ak := c.GetString("ak")
  640. doctor_name := c.GetString("doctor_name")
  641. cainfo := c.GetString("cainfo")
  642. card_sn := c.GetString("card_sn")
  643. result, inputLog := service.AHyb2201(psnNo, insutype, certNo, org_name, opera, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, ak, verify_number, cainfo, card_sn)
  644. var response Response
  645. if err := json.Unmarshal([]byte(result), &response); err != nil {
  646. fmt.Println("Error decoding JSON:", err)
  647. return
  648. }
  649. if response.Code == 200 {
  650. var dat2 map[string]interface{}
  651. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  652. } else {
  653. }
  654. c.ServeSuccessJSON(map[string]interface{}{
  655. "pre": response.Body,
  656. "log": dat2,
  657. "status": "1",
  658. "msg": "",
  659. })
  660. } else {
  661. c.ServeSuccessJSON(map[string]interface{}{
  662. "status": "0",
  663. "msg": response.Message,
  664. })
  665. }
  666. }
  667. func (c *AHybController) PostThree() {
  668. psnNo := c.GetString("psn_no")
  669. mdtrtId := c.GetString("mdtrt_id")
  670. iptOtpNo := c.GetString("ipt_otp_no")
  671. org_name := c.GetString("org_name")
  672. doctor := c.GetString("doctor")
  673. insuplc_admdvs := c.GetString("insuplc_admdvs")
  674. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  675. secret_key := c.GetString("secret_key")
  676. fixmedins_code := c.GetString("fixmedins_code")
  677. url := c.GetString("url")
  678. ak := c.GetString("ak")
  679. cainfo := c.GetString("cainfo")
  680. result, inputLog := service.AHyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  681. saveJsLog(result, inputLog, "2202", "退号", org_name)
  682. var response Response
  683. if err := json.Unmarshal([]byte(result), &response); err != nil {
  684. fmt.Println("Error decoding JSON:", err)
  685. return
  686. }
  687. if response.Code == 200 {
  688. var dat2 map[string]interface{}
  689. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  690. } else {
  691. }
  692. c.ServeSuccessJSON(map[string]interface{}{
  693. "pre": response.Body,
  694. "log": dat2,
  695. "status": "1",
  696. "msg": "",
  697. })
  698. } else {
  699. c.ServeSuccessJSON(map[string]interface{}{
  700. "status": "0",
  701. "msg": response.Message,
  702. })
  703. }
  704. }
  705. func (c *AHybController) PostFour() {
  706. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  707. var respJSON map[string]interface{}
  708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  710. return
  711. }
  712. userJSONBytes, _ := json.Marshal(respJSON["config"])
  713. var config []*models.HisXtDiagnoseConfig
  714. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  715. utils.ErrorLog("解析失败:%v", err)
  716. return
  717. }
  718. fmt.Println(respJSON["psn_no"].(string))
  719. fmt.Println(respJSON["mdtrt_id"].(string))
  720. psnNo := respJSON["psn_no"].(string)
  721. mdtrtId := respJSON["mdtrt_id"].(string)
  722. operator := respJSON["operator"].(string)
  723. department := respJSON["department"].(string)
  724. org_name := respJSON["org_name"].(string)
  725. med_type := respJSON["med_type"].(string)
  726. fixmedins_code := respJSON["fixmedins_code"].(string)
  727. sick_code := respJSON["sick_code"].(string)
  728. sick_name := respJSON["sick_name"].(string)
  729. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  730. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  731. url := respJSON["url"].(string)
  732. begin_time := respJSON["begin_time"].(string)
  733. cainfo := respJSON["cainfo"].(string)
  734. doctor_name := respJSON["doctor_name"].(string)
  735. doctor_number := respJSON["doctor_number"].(string)
  736. //cainfo := c.GetString("cainfo")
  737. result, inputLog := service.AHyb2203(psnNo, mdtrtId, operator, department, org_name, med_type, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sick_code, sick_name, config, url, begin_time, cainfo, doctor_name, doctor_number)
  738. saveJsLog(result, inputLog, "2203", "上传就诊信息", org_name)
  739. var response Response
  740. if err := json.Unmarshal([]byte(result), &response); err != nil {
  741. fmt.Println("Error decoding JSON:", err)
  742. return
  743. }
  744. if response.Code == 200 {
  745. var dat2 map[string]interface{}
  746. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  747. } else {
  748. }
  749. c.ServeSuccessJSON(map[string]interface{}{
  750. "pre": response.Body,
  751. "log": dat2,
  752. "status": "1",
  753. "msg": "",
  754. })
  755. } else {
  756. c.ServeSuccessJSON(map[string]interface{}{
  757. "status": "0",
  758. "msg": response.Message,
  759. })
  760. }
  761. }
  762. func (c *AHybController) Get2406() {
  763. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  764. var respJSON map[string]interface{}
  765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  767. return
  768. }
  769. psnNo := respJSON["psn_no"].(string)
  770. mdtrtId := respJSON["mdtrt_id"].(string)
  771. operator := respJSON["operator"].(string)
  772. cert_no := respJSON["cert_no"].(string)
  773. org_name := respJSON["org_name"].(string)
  774. psn_name := respJSON["psn_name"].(string)
  775. ipt_otp_no := respJSON["ipt_otp_no"].(string)
  776. ipt_psn_sp_flag_type := respJSON["ipt_psn_sp_flag_type"].(string)
  777. ipt_psn_sp_flag := respJSON["ipt_psn_sp_flag"].(string)
  778. fixmedins_code := respJSON["fixmedins_code"].(string)
  779. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  780. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  781. url := respJSON["url"].(string)
  782. result, inputLog := service.AHyb2406(psnNo, mdtrtId, cert_no, psn_name, operator, ipt_otp_no, ipt_psn_sp_flag_type, ipt_psn_sp_flag, org_name, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url)
  783. saveJsLog(result, inputLog, "2406", "上传2406信息", org_name)
  784. var response Response
  785. if err := json.Unmarshal([]byte(result), &response); err != nil {
  786. fmt.Println("Error decoding JSON:", err)
  787. return
  788. }
  789. if response.Code == 200 {
  790. var dat2 map[string]interface{}
  791. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  792. } else {
  793. }
  794. c.ServeSuccessJSON(map[string]interface{}{
  795. "pre": response.Body,
  796. "log": dat2,
  797. "status": "1",
  798. "msg": "",
  799. })
  800. } else {
  801. c.ServeSuccessJSON(map[string]interface{}{
  802. "status": "0",
  803. "msg": response.Message,
  804. })
  805. }
  806. }
  807. type All struct {
  808. HisPrescription HisPrescription
  809. mdtrt_id string
  810. psn_no string
  811. }
  812. type HisPrescription struct {
  813. ID int64 `gorm:"column:id" json:"id" form:"id"`
  814. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  815. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  816. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  817. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  818. Status int64 `gorm:"column:status" json:"status" form:"status"`
  819. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  820. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  821. Number string `gorm:"column:number" json:"number" form:"number"`
  822. Type int64 `gorm:"column:type" json:"type" form:"type"`
  823. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  824. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  825. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  826. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  827. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  828. }
  829. func (c *AHybController) PostFive() {
  830. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  831. var respJSON map[string]interface{}
  832. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  834. return
  835. }
  836. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  837. var hp []*models.HisPrescription
  838. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  839. utils.ErrorLog("解析失败:%v", err)
  840. return
  841. }
  842. //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
  843. result, inputLog := service.AHyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  844. 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), respJSON["opter"].(string))
  845. saveJsLog(result, inputLog, "2204", "上传明细", respJSON["org_name"].(string))
  846. var response Response
  847. if err := json.Unmarshal([]byte(result), &response); err != nil {
  848. fmt.Println("Error decoding JSON:", err)
  849. return
  850. }
  851. if response.Code == 200 {
  852. var dat2 map[string]interface{}
  853. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  854. } else {
  855. }
  856. c.ServeSuccessJSON(map[string]interface{}{
  857. "pre": response.Body,
  858. "log": dat2,
  859. "status": "1",
  860. "msg": "",
  861. })
  862. } else {
  863. c.ServeSuccessJSON(map[string]interface{}{
  864. "status": "0",
  865. "msg": response.Message,
  866. })
  867. }
  868. }
  869. func (c *AHybController) PostSix() {
  870. psnNo := c.GetString("psn_no")
  871. mdtrtId := c.GetString("mdtrt_id")
  872. chrgBchno := c.GetString("chrg_bchno")
  873. org_name := c.GetString("org_name")
  874. doctor := c.GetString("doctor")
  875. insuplc_admdvs := c.GetString("insuplc_admdvs")
  876. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  877. secret_key := c.GetString("secret_key")
  878. fixmedins_code := c.GetString("fixmedins_code")
  879. url := c.GetString("url")
  880. ak := c.GetString("ak")
  881. cainfo := c.GetString("cainfo")
  882. result, inputLog := service.AHyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  883. fmt.Println(inputLog)
  884. saveJsLog(result, inputLog, "2205", "撤销明细", org_name)
  885. var response Response
  886. if err := json.Unmarshal([]byte(result), &response); err != nil {
  887. fmt.Println("Error decoding JSON:", err)
  888. return
  889. }
  890. if response.Code == 200 {
  891. var dat2 map[string]interface{}
  892. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  893. } else {
  894. }
  895. c.ServeSuccessJSON(map[string]interface{}{
  896. "pre": response.Body,
  897. "log": dat2,
  898. "status": "1",
  899. "msg": "",
  900. })
  901. } else {
  902. c.ServeSuccessJSON(map[string]interface{}{
  903. "status": "0",
  904. "msg": response.Message,
  905. })
  906. }
  907. }
  908. func (c *AHybController) PostSeven() {
  909. psnNo := c.GetString("psn_no")
  910. mdtrtId := c.GetString("mdtrt_id")
  911. chrgBchno := c.GetString("chrg_bchno")
  912. certNo := c.GetString("cert_no")
  913. insutype := c.GetString("insutype")
  914. total := c.GetString("total")
  915. org_name := c.GetString("org_name")
  916. doctor := c.GetString("doctor")
  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. med_type := c.GetString("med_type")
  922. id_card_type, _ := c.GetInt64("id_card_type")
  923. certificates, _ := c.GetInt64("certificates")
  924. verify_number := c.GetString("verify_number")
  925. cainfo := c.GetString("cainfo")
  926. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  927. url := c.GetString("url")
  928. ak := c.GetString("ak")
  929. var result string
  930. var inputLog string
  931. result, inputLog = service.AHyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, certificates, url, ak, verify_number, cainfo, mdtrt_grp_type)
  932. saveJsLog(result, inputLog, "2206", "预结算", org_name)
  933. var response Response
  934. if err := json.Unmarshal([]byte(result), &response); err != nil {
  935. fmt.Println("Error decoding JSON:", err)
  936. return
  937. }
  938. if response.Code == 200 {
  939. var dat2 map[string]interface{}
  940. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  941. } else {
  942. }
  943. c.ServeSuccessJSON(map[string]interface{}{
  944. "pre": response.Body,
  945. "log": dat2,
  946. "status": "1",
  947. "msg": "",
  948. })
  949. } else {
  950. c.ServeSuccessJSON(map[string]interface{}{
  951. "status": "0",
  952. "msg": response.Message,
  953. })
  954. }
  955. }
  956. func (c *AHybController) PostEight() {
  957. psnNo := c.GetString("psn_no")
  958. mdtrtId := c.GetString("mdtrt_id")
  959. chrgBchno := c.GetString("chrg_bchno")
  960. certNo := c.GetString("cert_no")
  961. insutype := c.GetString("insutype")
  962. total := c.GetString("total")
  963. org_name := c.GetString("org_name")
  964. doctor := c.GetString("doctor")
  965. fixmedins_code := c.GetString("fixmedins_code")
  966. insuplc_admdvs := c.GetString("insuplc_admdvs")
  967. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  968. secret_key := c.GetString("secret_key")
  969. med_type := c.GetString("med_type")
  970. id_card_type, _ := c.GetInt64("id_card_type")
  971. acct_used_flag := c.GetString("acct_used_flag")
  972. url := c.GetString("url")
  973. ak := c.GetString("ak")
  974. verify_number := c.GetString("verify_number")
  975. cainfo := c.GetString("cainfo")
  976. mdtrt_grp_type := c.GetString("mdtrt_grp_type")
  977. var result string
  978. var inputLog string
  979. result, inputLog = service.AHyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, acct_used_flag, url, ak, verify_number, cainfo, mdtrt_grp_type)
  980. saveJsLog(result, inputLog, "2207", "结算", org_name)
  981. var response Response
  982. if err := json.Unmarshal([]byte(result), &response); err != nil {
  983. fmt.Println("Error decoding JSON:", err)
  984. return
  985. }
  986. if response.Code == 200 {
  987. var dat2 map[string]interface{}
  988. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  989. } else {
  990. }
  991. c.ServeSuccessJSON(map[string]interface{}{
  992. "pre": response.Body,
  993. "log": dat2,
  994. "status": "1",
  995. "msg": "",
  996. })
  997. } else {
  998. c.ServeSuccessJSON(map[string]interface{}{
  999. "status": "0",
  1000. "msg": response.Message,
  1001. })
  1002. }
  1003. }
  1004. func (c *AHybController) PostNine() {
  1005. psnNo := c.GetString("psn_no")
  1006. mdtrtId := c.GetString("mdtrt_id")
  1007. setlId := c.GetString("setl_id")
  1008. org_name := c.GetString("org_name")
  1009. doctor := c.GetString("doctor")
  1010. secret_key := c.GetString("secret_key")
  1011. fixmedins_code := c.GetString("fixmedins_code")
  1012. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1013. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1014. url := c.GetString("url")
  1015. ak := c.GetString("ak")
  1016. cainfo := c.GetString("cainfo")
  1017. result, inputLog := service.AHyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  1018. saveJsLog(result, inputLog, "2208", "退费", org_name)
  1019. var response Response
  1020. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1021. fmt.Println("Error decoding JSON:", err)
  1022. return
  1023. }
  1024. if response.Code == 200 {
  1025. var dat2 map[string]interface{}
  1026. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1027. } else {
  1028. }
  1029. c.ServeSuccessJSON(map[string]interface{}{
  1030. "pre": response.Body,
  1031. "log": dat2,
  1032. "status": "1",
  1033. "msg": "",
  1034. })
  1035. } else {
  1036. c.ServeSuccessJSON(map[string]interface{}{
  1037. "status": "0",
  1038. "msg": response.Message,
  1039. })
  1040. }
  1041. }
  1042. func (c *AHybController) PostTen() {
  1043. psnNo := c.GetString("psn_no")
  1044. mdtrtId := c.GetString("mdtrt_id")
  1045. setlId := c.GetString("setl_id")
  1046. org_name := c.GetString("org_name")
  1047. doctor := c.GetString("doctor")
  1048. secret_key := c.GetString("secret_key")
  1049. fixmedins_code := c.GetString("fixmedins_code")
  1050. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1051. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1052. url := c.GetString("url")
  1053. ak := c.GetString("ak")
  1054. cainfo := c.GetString("cainfo")
  1055. baseParams := models.BaseParams{
  1056. SecretKey: secret_key,
  1057. FixmedinsCode: fixmedins_code,
  1058. InsuplcAdmdvs: insuplc_admdvs,
  1059. MdtrtareaAdmvs: mdtrtarea_admvs,
  1060. OrgName: org_name,
  1061. Doctor: doctor,
  1062. RequestUrl: url,
  1063. AccessKey: ak,
  1064. Cainfo: cainfo,
  1065. }
  1066. businessParams := models.BusinessParams{
  1067. PsnNo: psnNo,
  1068. MdtrtId: mdtrtId,
  1069. SetlId: setlId,
  1070. }
  1071. result, inputLog := service.AHyb5203(baseParams, businessParams)
  1072. saveJsLog(result, inputLog, "5203", "结算单", org_name)
  1073. var response Response
  1074. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1075. fmt.Println("Error decoding JSON:", err)
  1076. return
  1077. }
  1078. if response.Code == 200 {
  1079. var dat2 map[string]interface{}
  1080. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1081. } else {
  1082. }
  1083. c.ServeSuccessJSON(map[string]interface{}{
  1084. "pre": response.Body,
  1085. "log": dat2,
  1086. "status": "1",
  1087. "msg": "",
  1088. })
  1089. } else {
  1090. c.ServeSuccessJSON(map[string]interface{}{
  1091. "status": "0",
  1092. "msg": response.Message,
  1093. })
  1094. }
  1095. }
  1096. func (c *AHybController) Get2503() {
  1097. psnNo := c.GetString("psn_no")
  1098. insutype := c.GetString("insutype")
  1099. sick_code := c.GetString("sick_code")
  1100. sick_name := c.GetString("sick_name")
  1101. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1102. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1103. secret_key := c.GetString("secret_key")
  1104. access_key := c.GetString("access_key")
  1105. fixmedins_code := c.GetString("fixmedins_code")
  1106. org_name := c.GetString("org_name")
  1107. check_time := c.GetString("check_time")
  1108. doctor_id := c.GetString("doctor_id")
  1109. doctor := c.GetString("doctor")
  1110. start_time := c.GetString("start_time")
  1111. end_time := c.GetString("end_time")
  1112. url := c.GetString("url")
  1113. cainfo := c.GetString("cainfo")
  1114. service.AHyb2503(psnNo, insutype, org_name, doctor, fixmedins_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_name, sick_code, start_time, end_time, check_time, url, access_key, cainfo)
  1115. }
  1116. func (c *AHybController) Get3201() {
  1117. insutype := c.GetString("insutype")
  1118. clrType := c.GetString("clr_type")
  1119. setlOptins := c.GetString("setl_optins")
  1120. stmtBegndate := c.GetString("stmt_begndate")
  1121. stmtEnddate := c.GetString("stm_enddate")
  1122. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  1123. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  1124. acctPay, _ := c.GetFloat("acct_pay", 0)
  1125. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  1126. fixmedins_code := c.GetString("fixmedins_code")
  1127. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1128. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1129. secret_key := c.GetString("secret_key")
  1130. org_name := c.GetString("org_name")
  1131. doctor := c.GetString("doctor")
  1132. url := c.GetString("url")
  1133. ak := c.GetString("ak")
  1134. cainfo := c.GetString("cainfo")
  1135. result, inputLog := service.AHyb3201(fixmedinsSetlCnt, acctPay, fundPaySumamt, medfeeSumamt, stmtBegndate, stmtEnddate, setlOptins, clrType, insutype, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, secret_key, cainfo)
  1136. saveJsLog(result, inputLog, "3201", "对总账", org_name)
  1137. var response Response
  1138. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1139. fmt.Println("Error decoding JSON:", err)
  1140. return
  1141. }
  1142. if response.Code == 200 {
  1143. var dat2 map[string]interface{}
  1144. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1145. } else {
  1146. }
  1147. c.ServeSuccessJSON(map[string]interface{}{
  1148. "pre": response.Body,
  1149. "log": dat2,
  1150. "status": "1",
  1151. "msg": "",
  1152. })
  1153. } else {
  1154. c.ServeSuccessJSON(map[string]interface{}{
  1155. "status": "0",
  1156. "msg": response.Message,
  1157. })
  1158. }
  1159. }
  1160. type ELeData struct {
  1161. Data struct {
  1162. SiNo string `json:"si_no"`
  1163. SiCardNo string `json:"si_card_no"`
  1164. SiCardIssueArea string `json:"si_card_issue_area"`
  1165. Name string `json:"name"`
  1166. Gender string `json:"gender"`
  1167. IdType string `json:"id_type"`
  1168. IdNo string `json:"id_no"`
  1169. EcCardToken string `json:"ecCardToken"`
  1170. } `json:"data"`
  1171. Code int `json:"code"`
  1172. Message string `json:"message"`
  1173. }
  1174. type ELeCertData struct {
  1175. Data struct {
  1176. Extra string `json:"extra"`
  1177. IDNo string `json:"idNo"`
  1178. IDType string `json:"idType"`
  1179. EcToken string `json:"ecToken"`
  1180. InsuOrg string `json:"insuOrg"`
  1181. UserName string `json:"userName"`
  1182. EcIndexNo string `json:"ecIndexNo"`
  1183. Gender string `json:"gender"`
  1184. Birthday string `json:"birthday"`
  1185. Nationality string `json:"nationality"`
  1186. Email string `json:"email"`
  1187. } `json:"data"`
  1188. Code int `json:"code"`
  1189. Message string `json:"message"`
  1190. }
  1191. func (c *AHybController) ReadCard() {
  1192. fixmedins_code := c.GetString("fixmedins_code")
  1193. secret_key := c.GetString("secret_key")
  1194. ak := c.GetString("ak")
  1195. org_name := c.GetString("org_name")
  1196. doctor := c.GetString("doctor")
  1197. insuplc_admdvs := c.GetString("insuplc_admdvs")
  1198. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  1199. url := c.GetString("url")
  1200. cainfo := c.GetString("cainfo")
  1201. id_card_type := c.GetString("id_card_type")
  1202. operator_id := c.GetString("operator_id")
  1203. operator := c.GetString("operator")
  1204. //result, request := service.AHyb9001(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, url, cainfo, ak)
  1205. //fmt.Println(request)
  1206. //fmt.Println(result)
  1207. //c.TestGetBasBaseInit(fixmedins_code, secret_key, ak)
  1208. switch id_card_type {
  1209. case "1":
  1210. pCardInfo := c.GetBasBaseInfo()
  1211. pCardInfo = Remove0000(pCardInfo)
  1212. fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8"))
  1213. fmt.Println(pCardInfo)
  1214. bas := strings.Split(pCardInfo, "|")
  1215. basNumber := bas[2]
  1216. id_card_no := bas[1]
  1217. card_sn := bas[3]
  1218. id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64)
  1219. if len(pCardInfo) > 0 {
  1220. result, _ := service.AHyb1101A(basNumber, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type_int, card_sn, "1", url, ak, id_card_no, cainfo)
  1221. var response Response
  1222. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1223. fmt.Println("Error decoding JSON:", err)
  1224. return
  1225. }
  1226. if response.Code == 200 {
  1227. c.ServeSuccessJSON(map[string]interface{}{
  1228. "status": "0",
  1229. "card_info": pCardInfo,
  1230. "result": response.Body,
  1231. "type": "1",
  1232. })
  1233. } else {
  1234. c.ServeSuccessJSON(map[string]interface{}{
  1235. "status": "0",
  1236. "msg": response.Message,
  1237. })
  1238. }
  1239. } else {
  1240. c.ServeSuccessJSON(map[string]interface{}{
  1241. "status": "-1",
  1242. })
  1243. }
  1244. break
  1245. case "3": //电子社保卡
  1246. _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  1247. //fmt.Println(pCardInfo)
  1248. fmt.Println(pBusiCardInfo)
  1249. pBusiCardInfo = Remove0000(pBusiCardInfo)
  1250. //pCardInfo = Remove0000(pCardInfo)
  1251. var ele ELeData
  1252. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  1253. if err != nil {
  1254. utils.ErrorLog("解析失败:%v", err)
  1255. }
  1256. token := ele.Data.EcCardToken
  1257. if len(token) > 0 {
  1258. result, _ := service.AHyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IdNo)
  1259. var dat map[string]interface{}
  1260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1261. fmt.Println(dat)
  1262. } else {
  1263. fmt.Println(err)
  1264. }
  1265. c.ServeSuccessJSON(map[string]interface{}{
  1266. "status": "0",
  1267. //"card_info": pCardInfo,
  1268. "busi_card_info": pBusiCardInfo,
  1269. "token": token,
  1270. "result": dat,
  1271. "type": "2",
  1272. })
  1273. } else {
  1274. c.ServeSuccessJSON(map[string]interface{}{
  1275. "status": "-1",
  1276. })
  1277. }
  1278. break
  1279. case "4": //电子凭证
  1280. fmt.Println(operator_id)
  1281. fmt.Println(operator)
  1282. _, pBusiCardInfo := c.GetELeCertInfoTwo(fixmedins_code, operator_id, operator)
  1283. fmt.Println(pBusiCardInfo)
  1284. pBusiCardInfo = Remove0000(pBusiCardInfo)
  1285. var ele ELeCertData
  1286. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  1287. if err != nil {
  1288. utils.ErrorLog("解析失败:%v", err)
  1289. }
  1290. token := ele.Data.EcToken
  1291. fmt.Println(token)
  1292. if len(token) > 0 {
  1293. userName := ele.Data.UserName
  1294. fmt.Println(userName)
  1295. userName = Remove0000(userName)
  1296. userName = DeleteExtraSpace(userName)
  1297. fmt.Println(userName)
  1298. enc := mahonia.NewEncoder("gbk")
  1299. fmt.Println(enc.ConvertString(userName))
  1300. result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  1301. var response Response
  1302. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1303. fmt.Println("Error decoding JSON:", err)
  1304. return
  1305. }
  1306. if response.Code == 200 {
  1307. c.ServeSuccessJSON(map[string]interface{}{
  1308. "status": "1",
  1309. "card_info": "",
  1310. "busi_card_info": pBusiCardInfo,
  1311. "token": token,
  1312. "result": response.Body,
  1313. })
  1314. } else {
  1315. c.ServeSuccessJSON(map[string]interface{}{
  1316. "status": "0",
  1317. "msg": response.Message,
  1318. })
  1319. }
  1320. } else {
  1321. c.ServeSuccessJSON(map[string]interface{}{
  1322. "status": "-1",
  1323. })
  1324. }
  1325. break
  1326. }
  1327. }
  1328. func (c *AHybController) TestGetBasBaseInit(code string, secret_key string, ak string) {
  1329. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1330. Iinit := DllDef.MustFindProc("Init")
  1331. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1332. str := make([]byte, 2048)
  1333. inputData := make(map[string]interface{})
  1334. inputData["IP"] = "10.58.65.240"
  1335. inputData["PORT"] = "8086"
  1336. inputData["TIMEOUT"] = "180"
  1337. inputData["LOG_PATH"] = "C:\\log\\"
  1338. //inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  1339. inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  1340. inputData["CARD_PASSTYPE"] = "1"
  1341. inputData["API_NAME"] = "hssServives"
  1342. inputData["API_VERSION"] = "1.0.0"
  1343. inputData["ACCESS_KEY"] = ak
  1344. inputData["SECRETKEY"] = secret_key
  1345. inputData["ORG_ID"] = code
  1346. inputData["EXT"] = ""
  1347. bytesData, _ := json.Marshal(inputData)
  1348. fmt.Println(inputData)
  1349. fmt.Println(bytesData)
  1350. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  1351. if ret != 0 {
  1352. fmt.Println("SSCard的报错原因:", err)
  1353. fmt.Println("SSCard的运算结果为:", ret)
  1354. fmt.Println("SSCard的返回结果为:", string(str))
  1355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1356. return
  1357. }
  1358. fmt.Println("SSCard的返回结果为:", string(str))
  1359. result := int(ret)
  1360. fmt.Println("SSCard的运算结果为1:", result)
  1361. //initFlag = 1
  1362. return
  1363. }
  1364. func (c *AHybController) GetBasBaseInfo() string {
  1365. DllDef := syscall.MustLoadDLL("SSCardDriver.dll")
  1366. readCard := DllDef.MustFindProc("iReadCardBas")
  1367. fmt.Println(readCard)
  1368. fmt.Println("!!!!!")
  1369. pCardInfo := make([]byte, 2048)
  1370. ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&pCardInfo[0])))
  1371. fmt.Println(ret2)
  1372. fmt.Println(DeleteExtraSpace(string(pCardInfo)))
  1373. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
  1374. if ret2 != 0 {
  1375. return ""
  1376. }
  1377. return DeleteExtraSpace(string(pCardInfo))
  1378. }
  1379. func (c *AHybController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  1380. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1381. readCard := DllDef.MustFindProc("EcCardQuery")
  1382. fmt.Println(readCard)
  1383. fmt.Println("!!!!!")
  1384. //pCardInfo := make([]byte, 8192)
  1385. pBusiCardInfo := make([]byte, 8192)
  1386. //data := make(map[string]interface{})
  1387. //pData := make(map[string]interface{})
  1388. //inputData := make(map[string]interface{})
  1389. //inputData["orgId"] = code
  1390. //inputData["businessType"] = "01101"
  1391. //inputData["operatorId"] = operator_id
  1392. //inputData["operatorName"] = operator_name
  1393. //inputData["officeId"] = "001"
  1394. //inputData["officeName"] = "血透室"
  1395. //data["data"] = inputData
  1396. //data["transType"] = "ec.query"
  1397. //data["orgId"] = code
  1398. //bytesData, _ := json.Marshal(data)
  1399. //pCardInfo = bytesData
  1400. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1401. fmt.Println(ret2)
  1402. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  1403. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  1404. //fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1405. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1406. if ret2 != 0 {
  1407. return "", ""
  1408. }
  1409. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  1410. }
  1411. func (c *AHybController) GetELeCertInfoFour1(code string, operator_id string, operator_name string) (string, string) {
  1412. DllDef := syscall.MustLoadDLL("NationEcCode.dll")
  1413. readCard := DllDef.MustFindProc("EcQuery")
  1414. pCardInfo := make([]byte, 8192)
  1415. pBusiCardInfo := make([]byte, 8192)
  1416. data := make(map[string]interface{})
  1417. inputData := make(map[string]interface{})
  1418. inputData["orgId"] = code
  1419. inputData["businessType"] = "01301"
  1420. inputData["operatorId"] = operator_id
  1421. inputData["operatorName"] = operator_name
  1422. inputData["officeId"] = "001"
  1423. inputData["officeName"] = "xuetou"
  1424. data["data"] = inputData
  1425. data["transType"] = "ec.query"
  1426. data["orgId"] = code
  1427. bytesData, _ := json.Marshal(data)
  1428. pCardInfo = bytesData
  1429. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1430. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1431. fmt.Println(ret2)
  1432. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1433. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1434. if ret2 != 0 {
  1435. return "", ""
  1436. }
  1437. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1438. }
  1439. func (c *AHybController) GetELeCertInfoFour(code string, operator_id string, operator_name string) (string, string) {
  1440. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1441. readCard := DllDef.MustFindProc("GetPersonInfo")
  1442. pCardInfo := make([]byte, 8192)
  1443. pBusiCardInfo := make([]byte, 8192)
  1444. data := make(map[string]interface{})
  1445. inputData := make(map[string]interface{})
  1446. inputData["orgId"] = code
  1447. inputData["businessType"] = "01301"
  1448. inputData["operatorId"] = operator_id
  1449. inputData["operatorName"] = operator_name
  1450. inputData["officeId"] = "001"
  1451. inputData["officeName"] = "xuetou"
  1452. data["data"] = inputData
  1453. data["transType"] = "ec.query"
  1454. data["orgId"] = code
  1455. bytesData, _ := json.Marshal(data)
  1456. pCardInfo = bytesData
  1457. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1458. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1459. fmt.Println(ret2)
  1460. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1461. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1462. if ret2 != 0 {
  1463. return "", ""
  1464. }
  1465. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1466. }
  1467. func (c *AHybController) GetELeCertInfoFour2223(code string, operator_id string, operator_name string) (string, string) {
  1468. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  1469. readCard := DllDef.MustFindProc("GetPersonInfo")
  1470. pCardInfo := make([]byte, 8192)
  1471. pBusiCardInfo := make([]byte, 8192)
  1472. data := make(map[string]interface{})
  1473. inputData := make(map[string]interface{})
  1474. inputData["orgId"] = code
  1475. inputData["businessType"] = "01101"
  1476. inputData["operatorId"] = operator_id
  1477. inputData["operatorName"] = operator_name
  1478. inputData["officeId"] = "001"
  1479. inputData["officeName"] = "xuetou"
  1480. data["data"] = inputData
  1481. data["transType"] = "ec.query"
  1482. data["orgId"] = code
  1483. bytesData, _ := json.Marshal(data)
  1484. pCardInfo = bytesData
  1485. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  1486. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  1487. fmt.Println(ret2)
  1488. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  1489. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  1490. if ret2 != 0 {
  1491. return "", ""
  1492. }
  1493. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  1494. }
  1495. func (c *AHybController) GetELeCertInfoTwo(code string, operator_id string, operator_name string) (string, string) {
  1496. // WebSocket服务器地址
  1497. serverURL := "ws://127.0.0.1:8899"
  1498. // 解析WebSocket服务器地址
  1499. u, err := url.Parse(serverURL)
  1500. if err != nil {
  1501. log.Fatal(err)
  1502. }
  1503. // 建立WebSocket连接
  1504. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1505. if err != nil {
  1506. log.Fatal(err)
  1507. }
  1508. defer conn.Close()
  1509. input2 := make(map[string]interface{})
  1510. input := make(map[string]interface{})
  1511. inputData := make(map[string]interface{})
  1512. inputData["orgId"] = code
  1513. inputData["businessType"] = "01101"
  1514. inputData["operatorId"] = operator_id
  1515. inputData["operatorName"] = operator_name
  1516. inputData["officeId"] = "001"
  1517. inputData["officeName"] = "血透室"
  1518. inputData["deviceType"] = ""
  1519. input["data"] = inputData
  1520. input["orgId"] = code
  1521. input["transType"] = "ec.query"
  1522. input2["url"] = "http://10.66.159.55:8080/localcfc/api/hsecfc/localQrCodeQuery"
  1523. input2["indata"] = input
  1524. bytesData, _ := json.Marshal(input2)
  1525. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1526. if err != nil {
  1527. fmt.Println(err)
  1528. }
  1529. // 接收消息
  1530. _, receivedMessage, err := conn.ReadMessage()
  1531. if err != nil {
  1532. fmt.Println(err)
  1533. }
  1534. return "", string(receivedMessage)
  1535. }
  1536. func (c *AHybController) GetELeCertInfoThree(code string, operator_id string, operator_name string) (string, string) {
  1537. // WebSocket服务器地址
  1538. serverURL := "ws://127.0.0.1:8899"
  1539. // 解析WebSocket服务器地址
  1540. u, err := url.Parse(serverURL)
  1541. if err != nil {
  1542. log.Fatal(err)
  1543. }
  1544. // 建立WebSocket连接
  1545. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  1546. if err != nil {
  1547. log.Fatal(err)
  1548. }
  1549. defer conn.Close()
  1550. input2 := make(map[string]interface{})
  1551. input := make(map[string]interface{})
  1552. inputData := make(map[string]interface{})
  1553. inputData["orgId"] = code
  1554. inputData["businessType"] = "01301"
  1555. inputData["operatorId"] = operator_id
  1556. inputData["operatorName"] = operator_name
  1557. inputData["officeId"] = "001"
  1558. inputData["officeName"] = "血透室"
  1559. inputData["deviceType"] = ""
  1560. input["data"] = inputData
  1561. input["orgId"] = code
  1562. input["transType"] = "ec.query"
  1563. input2["url"] = "http://10.66.159.55:8080/localcfc/api/hsecfc/localQrCodeQuery"
  1564. input2["indata"] = input
  1565. bytesData, _ := json.Marshal(input2)
  1566. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  1567. if err != nil {
  1568. fmt.Println(err)
  1569. }
  1570. // 接收消息
  1571. _, receivedMessage, err := conn.ReadMessage()
  1572. if err != nil {
  1573. fmt.Println(err)
  1574. }
  1575. return "", string(receivedMessage)
  1576. }
  1577. func IntPtr(n int) uintptr {
  1578. return uintptr(n)
  1579. }
  1580. func StrPtr(s string) uintptr {
  1581. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  1582. }
  1583. type Charset string
  1584. const (
  1585. UTF8 = Charset("UTF-8")
  1586. GB18030 = Charset("GB18030")
  1587. )
  1588. func ConvertToString(src string, srcCode string, tagCode string) string {
  1589. srcCoder := mahonia.NewDecoder(srcCode)
  1590. srcResult := srcCoder.ConvertString(src)
  1591. tagCoder := mahonia.NewDecoder(tagCode)
  1592. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  1593. result := string(cdata)
  1594. return result
  1595. }
  1596. func DeleteExtraSpace(s string) string {
  1597. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  1598. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  1599. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  1600. reg, _ := regexp.Compile(regstr) //编译正则表达式
  1601. s2 := make([]byte, len(s1)) //定义字符数组切片
  1602. copy(s2, s1) //将字符串复制到切片
  1603. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  1604. for len(spc_index) > 0 { //找到适配项
  1605. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  1606. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  1607. }
  1608. return string(s2)
  1609. }
  1610. func Remove0000(s string) string {
  1611. str := make([]rune, 0, len(s))
  1612. for _, v := range []rune(s) {
  1613. if v == 0 {
  1614. continue
  1615. }
  1616. str = append(str, v)
  1617. }
  1618. return string(str)
  1619. }
  1620. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  1621. //org_id, _ := beego.AppConfig.Int64("org_id")
  1622. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  1623. dir := org_name + "日志"
  1624. utils.Mkdir(dir)
  1625. month := time.Unix(1557042972, 0).Format("1")
  1626. year := time.Now().Format("2006")
  1627. month = time.Now().Format("01")
  1628. day := time.Now().Format("02")
  1629. hour := time.Now().Format("15")
  1630. min := time.Now().Format("04")
  1631. sec := time.Now().Format("05")
  1632. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  1633. file := org_name + "_" + year + month + day + "_log"
  1634. file_name := file + ".txt"
  1635. file_path := org_name + "日志" + "/" + file_name
  1636. exist, _ := utils.PathExists(file_path)
  1637. if exist { //存在
  1638. fmt.Println("存在")
  1639. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  1640. if err != nil {
  1641. fmt.Println("read fail")
  1642. }
  1643. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  1644. n, _ := f.Seek(0, 2)
  1645. _, err = f.WriteAt([]byte(content), n)
  1646. } else { //不存在
  1647. fmt.Println("文件不存在,创建文件")
  1648. f, err := os.Create(org_name + "日志" + "/" + file_name)
  1649. defer f.Close()
  1650. if err != nil {
  1651. } else {
  1652. _, err = f.Write([]byte("记录日志"))
  1653. }
  1654. }
  1655. }
  1656. func (c *AHybController) Get3101() {
  1657. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1658. var respJSON map[string]interface{}
  1659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1661. return
  1662. }
  1663. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  1664. var pd models.PatientDtos
  1665. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  1666. utils.ErrorLog("解析失败:%v", err)
  1667. return
  1668. }
  1669. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  1670. var fed models.FsiEncounterDtos
  1671. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  1672. utils.ErrorLog("解析失败:%v", err)
  1673. return
  1674. }
  1675. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  1676. var fdd []*models.FsiDiagnoseDtos
  1677. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  1678. utils.ErrorLog("解析失败:%v", err)
  1679. return
  1680. }
  1681. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  1682. var fod []*models.FsiOrderDtos
  1683. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1684. utils.ErrorLog("解析失败:%v", err)
  1685. return
  1686. }
  1687. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1688. var fopd []*models.FsiOperationDtosData
  1689. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1690. utils.ErrorLog("解析失败:%v", err)
  1691. return
  1692. }
  1693. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1694. var pp models.PublicParams
  1695. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1696. utils.ErrorLog("解析失败:%v", err)
  1697. return
  1698. }
  1699. inputLog, result := service.AHyb3101(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1700. var response Response
  1701. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1702. fmt.Println("Error decoding JSON:", err)
  1703. return
  1704. }
  1705. if response.Code == 200 {
  1706. var dat2 map[string]interface{}
  1707. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1708. } else {
  1709. }
  1710. c.ServeSuccessJSON(map[string]interface{}{
  1711. "pre": response.Body,
  1712. "log": dat2,
  1713. "status": 1,
  1714. "msg": "",
  1715. })
  1716. } else {
  1717. c.ServeSuccessJSON(map[string]interface{}{
  1718. "status": 0,
  1719. "msg": response.Message,
  1720. })
  1721. }
  1722. }
  1723. func (c *AHybController) Get3102() {
  1724. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1725. var respJSON map[string]interface{}
  1726. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1728. return
  1729. }
  1730. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  1731. var pd models.PatientDtos
  1732. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  1733. utils.ErrorLog("解析失败:%v", err)
  1734. return
  1735. }
  1736. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  1737. var fed models.FsiEncounterDtos
  1738. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  1739. utils.ErrorLog("解析失败:%v", err)
  1740. return
  1741. }
  1742. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  1743. var fdd []*models.FsiDiagnoseDtos
  1744. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  1745. utils.ErrorLog("解析失败:%v", err)
  1746. return
  1747. }
  1748. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  1749. var fod []*models.FsiOrderDtos
  1750. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1751. utils.ErrorLog("解析失败:%v", err)
  1752. return
  1753. }
  1754. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1755. var fopd []*models.FsiOperationDtosData
  1756. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1757. utils.ErrorLog("解析失败:%v", err)
  1758. return
  1759. }
  1760. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1761. var pp models.PublicParams
  1762. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1763. utils.ErrorLog("解析失败:%v", err)
  1764. return
  1765. }
  1766. _, result := service.AHyb3102(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1767. var response Response
  1768. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1769. fmt.Println("Error decoding JSON:", err)
  1770. return
  1771. }
  1772. if response.Code == 200 {
  1773. c.ServeSuccessJSON(map[string]interface{}{
  1774. "pre": response.Body,
  1775. "status": 1,
  1776. "msg": "",
  1777. })
  1778. } else {
  1779. c.ServeSuccessJSON(map[string]interface{}{
  1780. "status": 0,
  1781. "msg": response.Message,
  1782. })
  1783. }
  1784. }
  1785. func (c *AHybController) Get4101() {
  1786. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1787. var respJSON map[string]interface{}
  1788. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1790. return
  1791. }
  1792. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  1793. var struct4101 service.Struct4101
  1794. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  1795. utils.ErrorLog("解析失败:%v", err)
  1796. return
  1797. }
  1798. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1799. var pp models.PublicParams
  1800. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1801. utils.ErrorLog("解析失败:%v", err)
  1802. return
  1803. }
  1804. inputLog, result := service.AHyb4101(struct4101, pp)
  1805. saveJsLog(result, inputLog, "4101", "上传明细清单", pp.FixmedinsName)
  1806. var response Response
  1807. if err := json.Unmarshal([]byte(result), &response); err != nil {
  1808. fmt.Println("Error decoding JSON:", err)
  1809. return
  1810. }
  1811. if response.Code == 200 {
  1812. var dat2 map[string]interface{}
  1813. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  1814. } else {
  1815. }
  1816. c.ServeSuccessJSON(map[string]interface{}{
  1817. "pre": response.Body,
  1818. "log": dat2,
  1819. "status": 1,
  1820. "msg": "",
  1821. })
  1822. } else {
  1823. c.ServeSuccessJSON(map[string]interface{}{
  1824. "status": 0,
  1825. "msg": response.Message,
  1826. })
  1827. }
  1828. }
  1829. func ConvertByte2String(byte []byte, charset Charset) string {
  1830. var str string
  1831. switch charset {
  1832. case GB18030:
  1833. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1834. str = string(decodeBytes)
  1835. case UTF8:
  1836. fallthrough
  1837. default:
  1838. str = string(byte)
  1839. }
  1840. return str
  1841. }