jsyb_controller.go 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230
  1. package js
  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. "golang.org/x/text/encoding/simplifiedchinese"
  13. "io/ioutil"
  14. "os"
  15. "regexp"
  16. "strconv"
  17. "strings"
  18. "syscall"
  19. "time"
  20. "unsafe"
  21. )
  22. type JSybController struct {
  23. controllers.BaseAuthAPIController
  24. }
  25. func JSybRegistRouters() {
  26. beego.Router("/jsyb/1101", &JSybController{}, "get:PostOne")
  27. beego.Router("/jsyb/1101D", &JSybController{}, "get:PostOneD")
  28. beego.Router("/jsyb/1101c", &JSybController{}, "get:PostOnec")
  29. beego.Router("/jsyb/2201c", &JSybController{}, "get:Posttwoc")
  30. beego.Router("/jsyb/2201", &JSybController{}, "get:PostTwo")
  31. beego.Router("/jsyb/2202", &JSybController{}, "get:PostThree")
  32. beego.Router("/jsyb/2203", &JSybController{}, "post:PostFour")
  33. beego.Router("/jsyb/2204", &JSybController{}, "post:PostFive")
  34. beego.Router("/jsyb/2205", &JSybController{}, "get:PostSix")
  35. beego.Router("/jsyb/2206", &JSybController{}, "get:PostSeven")
  36. beego.Router("/jsyb/2207", &JSybController{}, "get:PostEight")
  37. beego.Router("/jsyb/2208", &JSybController{}, "get:PostNine")
  38. beego.Router("/jsyb/5203", &JSybController{}, "get:PostTen")
  39. beego.Router("/jsyb/5301", &JSybController{}, "get:Get5301")
  40. beego.Router("/jsyb/3201", &JSybController{}, "get:Get3201")
  41. beego.Router("/jsyb/9001", &JSybController{}, "get:Get9001")
  42. beego.Router("/jsyb/3101", &JSybController{}, "post:Get3101")
  43. beego.Router("/jsyb/3102", &JSybController{}, "post:Get3102")
  44. beego.Router("/jsyb/4101", &JSybController{}, "post:Get4101")
  45. beego.Router("/jsyb/readcard", &JSybController{}, "get:ReadCard")
  46. }
  47. func (c *JSybController) Get9001() {
  48. }
  49. func (c *JSybController) PostOnec() {
  50. result, inputLog := service.Jsyb1101F()
  51. fmt.Println(result)
  52. fmt.Println(inputLog)
  53. }
  54. func (c *JSybController) Posttwoc() {
  55. result, request_log := service.Jsyb2201F()
  56. saveJsLog(result, request_log, "2201", "挂号", "盐城响水悦达血液透析中心有限公司")
  57. }
  58. func (c *JSybController) Get5301() {
  59. psn_no := c.GetString("psn_no")
  60. org_name := c.GetString("org_name")
  61. doctor := c.GetString("doctor")
  62. fixmedins_code := c.GetString("fixmedins_code")
  63. insuplc_admdvs := c.GetString("insuplc_admdvs")
  64. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  65. secret_key := c.GetString("secret_key")
  66. url := c.GetString("url")
  67. ak := c.GetString("ak")
  68. cainfo := c.GetString("cainfo")
  69. result, inputLog := service.Jsyb5301(psn_no, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, cainfo)
  70. //saveJsLog()
  71. saveJsLog(result, inputLog, "5301", "查询备案", org_name)
  72. var dat map[string]interface{}
  73. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  74. } else {
  75. }
  76. var dat2 map[string]interface{}
  77. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  78. } else {
  79. }
  80. c.ServeSuccessJSON(map[string]interface{}{
  81. "pre": dat,
  82. "log": dat2,
  83. })
  84. }
  85. func (c *JSybController) PostOne() {
  86. certNo := c.GetString("cert_no")
  87. org_name := c.GetString("org_name")
  88. doctor := c.GetString("doctor")
  89. fixmedins_code := c.GetString("fixmedins_code")
  90. insuplc_admdvs := c.GetString("insuplc_admdvs")
  91. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  92. secret_key := c.GetString("secret_key")
  93. id_card_type, _ := c.GetInt64("id_card_type")
  94. card_sn := c.GetString("card_sn")
  95. certificates := c.GetString("certificates")
  96. url := c.GetString("url")
  97. ak := c.GetString("ak")
  98. cainfo := c.GetString("cainfo")
  99. result, inputLog := service.Jsyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificates, url, ak, cainfo)
  100. fmt.Println(result)
  101. fmt.Println(inputLog)
  102. saveJsLog(result, inputLog, "1101", "查询个人信息", org_name)
  103. var dat map[string]interface{}
  104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  105. } else {
  106. }
  107. var dat2 map[string]interface{}
  108. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  109. } else {
  110. }
  111. c.ServeSuccessJSON(map[string]interface{}{
  112. "pre": dat,
  113. "log": dat2,
  114. })
  115. }
  116. func (c *JSybController) PostOneD() {
  117. result, inputLog := service.Jsyb1101F()
  118. fmt.Println(result)
  119. fmt.Println(inputLog)
  120. saveJsLog(result, inputLog, "1101", "查询个人信息", "盐城响水悦达血液透析中心有限公司")
  121. var dat map[string]interface{}
  122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  123. } else {
  124. }
  125. var dat2 map[string]interface{}
  126. if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil {
  127. } else {
  128. }
  129. c.ServeSuccessJSON(map[string]interface{}{
  130. "pre": dat,
  131. "log": dat2,
  132. })
  133. }
  134. func (c *JSybController) PostTwo() {
  135. psnNo := c.GetString("psn_no")
  136. insutype := c.GetString("insutype")
  137. certNo := c.GetString("cert_no")
  138. org_name := c.GetString("org_name")
  139. doctor := c.GetString("doctor")
  140. ipt_otp_no := c.GetString("ipt_otp_no")
  141. dept := c.GetString("dept")
  142. verify_number := c.GetString("verify_number")
  143. fixmedins_code := c.GetString("fixmedins_code")
  144. dept_code := c.GetString("dept_code")
  145. doctor_id := c.GetString("doctor_id")
  146. insuplc_admdvs := c.GetString("insuplc_admdvs")
  147. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  148. secret_key := c.GetString("secret_key")
  149. id_card_type, _ := c.GetInt64("id_card_type")
  150. url := c.GetString("url")
  151. ak := c.GetString("ak")
  152. doctor_name := c.GetString("doctor_name")
  153. cainfo := c.GetString("cainfo")
  154. result, request_log := service.Jsyb2201(psnNo, insutype, certNo, org_name, doctor, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, ak, verify_number, cainfo)
  155. saveJsLog(result, request_log, "2201", "挂号", org_name)
  156. var dat map[string]interface{}
  157. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  158. } else {
  159. }
  160. var dat2 map[string]interface{}
  161. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  162. } else {
  163. }
  164. c.ServeSuccessJSON(map[string]interface{}{
  165. "pre": dat,
  166. "request_log": dat2,
  167. })
  168. }
  169. func (c *JSybController) PostThree() {
  170. psnNo := c.GetString("psn_no")
  171. mdtrtId := c.GetString("mdtrt_id")
  172. iptOtpNo := c.GetString("ipt_otp_no")
  173. org_name := c.GetString("org_name")
  174. doctor := c.GetString("doctor")
  175. insuplc_admdvs := c.GetString("insuplc_admdvs")
  176. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  177. secret_key := c.GetString("secret_key")
  178. fixmedins_code := c.GetString("fixmedins_code")
  179. url := c.GetString("url")
  180. ak := c.GetString("ak")
  181. cainfo := c.GetString("cainfo")
  182. result, request_log := service.Jsyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  183. saveJsLog(result, request_log, "2202", "退号", org_name)
  184. var dat map[string]interface{}
  185. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  186. } else {
  187. }
  188. var dat2 map[string]interface{}
  189. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  190. } else {
  191. }
  192. c.ServeSuccessJSON(map[string]interface{}{
  193. "pre": dat,
  194. "request_log": dat2,
  195. })
  196. }
  197. func (c *JSybController) PostFour() {
  198. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  199. var respJSON map[string]interface{}
  200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  202. return
  203. }
  204. userJSONBytes, _ := json.Marshal(respJSON["config"])
  205. var config []*models.HisXtDiagnoseConfig
  206. if err := json.Unmarshal(userJSONBytes, &config); err != nil {
  207. utils.ErrorLog("解析失败:%v", err)
  208. return
  209. }
  210. fmt.Println(respJSON["psn_no"].(string))
  211. fmt.Println(respJSON["mdtrt_id"].(string))
  212. psnNo := respJSON["psn_no"].(string)
  213. mdtrtId := respJSON["mdtrt_id"].(string)
  214. doctor := respJSON["doctor"].(string)
  215. department := respJSON["department"].(string)
  216. org_name := respJSON["org_name"].(string)
  217. med_type := respJSON["med_type"].(string)
  218. doctor_id := respJSON["doctor_id"].(string)
  219. fixmedins_code := respJSON["fixmedins_code"].(string)
  220. sick_code := respJSON["sick_code"].(string)
  221. sick_name := respJSON["sick_name"].(string)
  222. dept := respJSON["dept"].(string)
  223. insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
  224. mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
  225. secret_key := respJSON["secret_key"].(string)
  226. url := respJSON["url"].(string)
  227. ak := respJSON["ak"].(string)
  228. begin_time := respJSON["begin_time"].(string)
  229. cainfo := respJSON["cainfo"].(string)
  230. //cainfo := c.GetString("cainfo")
  231. result, request_log, timeStamp := service.Jsyb2203(psnNo, mdtrtId, doctor, department, org_name, med_type, doctor_id, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_code, sick_name, dept, config, url, ak, begin_time, cainfo)
  232. saveJsLog(result, request_log, "2203", "上传就诊信息", org_name)
  233. var dat2 map[string]interface{}
  234. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  235. } else {
  236. }
  237. var dat map[string]interface{}
  238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  239. } else {
  240. }
  241. var dat3 int64
  242. if err := json.Unmarshal([]byte(strconv.FormatInt(timeStamp, 10)), &dat3); err == nil {
  243. } else {
  244. }
  245. c.ServeSuccessJSON(map[string]interface{}{
  246. "pre": dat,
  247. "request_log": dat2,
  248. "time_stamp": dat3,
  249. })
  250. }
  251. type All struct {
  252. HisPrescription HisPrescription
  253. mdtrt_id string
  254. psn_no string
  255. }
  256. type HisPrescription struct {
  257. ID int64 `gorm:"column:id" json:"id" form:"id"`
  258. UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
  259. RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
  260. PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
  261. HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
  262. Status int64 `gorm:"column:status" json:"status" form:"status"`
  263. Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
  264. Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
  265. Number string `gorm:"column:number" json:"number" form:"number"`
  266. Type int64 `gorm:"column:type" json:"type" form:"type"`
  267. Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"`
  268. Creator int64 `gorm:"column:creator" json:"creator" form:"creator"`
  269. Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"`
  270. HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
  271. HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
  272. }
  273. func (c *JSybController) PostFive() {
  274. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  275. var respJSON map[string]interface{}
  276. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  278. return
  279. }
  280. userJSONBytes, _ := json.Marshal(respJSON["pre"])
  281. var hp []*models.HisPrescription
  282. if err := json.Unmarshal(userJSONBytes, &hp); err != nil {
  283. utils.ErrorLog("解析失败:%v", err)
  284. return
  285. }
  286. //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string))
  287. result, request_log := service.Jsyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string),
  288. 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))
  289. saveJsLog(result, request_log, "2204", "上传明细", respJSON["org_name"].(string))
  290. var dat map[string]interface{}
  291. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  292. fmt.Println(dat)
  293. } else {
  294. fmt.Println(err)
  295. }
  296. var dat2 map[string]interface{}
  297. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  298. fmt.Println(dat2)
  299. } else {
  300. fmt.Println(err)
  301. }
  302. c.ServeSuccessJSON(map[string]interface{}{
  303. "pre": dat,
  304. "request_log": dat2,
  305. })
  306. }
  307. func (c *JSybController) PostSix() {
  308. psnNo := c.GetString("psn_no")
  309. mdtrtId := c.GetString("mdtrt_id")
  310. chrgBchno := c.GetString("chrg_bchno")
  311. org_name := c.GetString("org_name")
  312. doctor := c.GetString("doctor")
  313. insuplc_admdvs := c.GetString("insuplc_admdvs")
  314. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  315. secret_key := c.GetString("secret_key")
  316. fixmedins_code := c.GetString("fixmedins_code")
  317. url := c.GetString("url")
  318. ak := c.GetString("ak")
  319. cainfo := c.GetString("cainfo")
  320. result, request_log := service.Jsyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo)
  321. fmt.Println(request_log)
  322. saveJsLog(result, request_log, "2205", "撤销明细", org_name)
  323. var dat map[string]interface{}
  324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  325. fmt.Println(dat)
  326. } else {
  327. fmt.Println(err)
  328. }
  329. var dat2 map[string]interface{}
  330. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  331. fmt.Println(dat2)
  332. } else {
  333. fmt.Println(err)
  334. }
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "pre": dat,
  337. "request_log": dat2,
  338. })
  339. }
  340. func (c *JSybController) PostSeven() {
  341. psnNo := c.GetString("psn_no")
  342. mdtrtId := c.GetString("mdtrt_id")
  343. chrgBchno := c.GetString("chrg_bchno")
  344. certNo := c.GetString("cert_no")
  345. insutype := c.GetString("insutype")
  346. total := c.GetString("total")
  347. org_name := c.GetString("org_name")
  348. doctor := c.GetString("doctor")
  349. fixmedins_code := c.GetString("fixmedins_code")
  350. insuplc_admdvs := c.GetString("insuplc_admdvs")
  351. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  352. secret_key := c.GetString("secret_key")
  353. med_type := c.GetString("med_type")
  354. id_card_type, _ := c.GetInt64("id_card_type")
  355. certificates, _ := c.GetInt64("certificates")
  356. verify_number := c.GetString("verify_number")
  357. cainfo := c.GetString("cainfo")
  358. url := c.GetString("url")
  359. ak := c.GetString("ak")
  360. result, request_log := service.Jsyb2206(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)
  361. saveJsLog(result, request_log, "2206", "预结算", org_name)
  362. var dat map[string]interface{}
  363. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  364. fmt.Println(dat)
  365. } else {
  366. fmt.Println(err)
  367. }
  368. var dat2 map[string]interface{}
  369. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  370. fmt.Println(dat2)
  371. } else {
  372. fmt.Println(err)
  373. }
  374. c.ServeSuccessJSON(map[string]interface{}{
  375. "pre": dat,
  376. "request_log": dat2,
  377. })
  378. }
  379. func (c *JSybController) PostEight() {
  380. psnNo := c.GetString("psn_no")
  381. mdtrtId := c.GetString("mdtrt_id")
  382. chrgBchno := c.GetString("chrg_bchno")
  383. certNo := c.GetString("cert_no")
  384. insutype := c.GetString("insutype")
  385. total := c.GetString("total")
  386. org_name := c.GetString("org_name")
  387. doctor := c.GetString("doctor")
  388. fixmedins_code := c.GetString("fixmedins_code")
  389. insuplc_admdvs := c.GetString("insuplc_admdvs")
  390. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  391. secret_key := c.GetString("secret_key")
  392. med_type := c.GetString("med_type")
  393. id_card_type, _ := c.GetInt64("id_card_type")
  394. certificates, _ := c.GetInt64("certificates")
  395. fulamt_ownpay_amt, _ := c.GetFloat("fulamt_ownpay_amt")
  396. overlmt_selfpay, _ := c.GetFloat("overlmt_selfpay")
  397. preselfpay_amt, _ := c.GetFloat("preselfpay_amt")
  398. inscp_scp_amt, _ := c.GetFloat("inscp_scp_amt")
  399. acct_used_flag := c.GetString("acct_used_flag")
  400. url := c.GetString("url")
  401. ak := c.GetString("ak")
  402. verify_number := c.GetString("verify_number")
  403. cainfo := c.GetString("cainfo")
  404. result, request_log := service.Jsyb2207(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)
  405. saveJsLog(result, request_log, "2207", "结算", org_name)
  406. var dat map[string]interface{}
  407. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  408. fmt.Println(dat)
  409. } else {
  410. fmt.Println(err)
  411. }
  412. var dat2 map[string]interface{}
  413. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  414. fmt.Println(dat2)
  415. } else {
  416. fmt.Println(err)
  417. }
  418. c.ServeSuccessJSON(map[string]interface{}{
  419. "pre": dat,
  420. "request_log": dat2,
  421. })
  422. }
  423. func (c *JSybController) PostNine() {
  424. psnNo := c.GetString("psn_no")
  425. mdtrtId := c.GetString("mdtrt_id")
  426. setlId := c.GetString("setl_id")
  427. org_name := c.GetString("org_name")
  428. doctor := c.GetString("doctor")
  429. secret_key := c.GetString("secret_key")
  430. fixmedins_code := c.GetString("fixmedins_code")
  431. insuplc_admdvs := c.GetString("insuplc_admdvs")
  432. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  433. url := c.GetString("url")
  434. ak := c.GetString("ak")
  435. cainfo := c.GetString("cainfo")
  436. result, request_log := service.Jsyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo)
  437. saveJsLog(result, request_log, "2208", "退费", org_name)
  438. fmt.Println(request_log)
  439. var dat map[string]interface{}
  440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  441. fmt.Println(dat)
  442. } else {
  443. fmt.Println(err)
  444. }
  445. var dat2 map[string]interface{}
  446. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  447. fmt.Println(dat2)
  448. } else {
  449. fmt.Println(err)
  450. }
  451. c.ServeSuccessJSON(map[string]interface{}{
  452. "pre": dat,
  453. "request_log": dat2,
  454. })
  455. }
  456. func (c *JSybController) PostTen() {
  457. psnNo := c.GetString("psn_no")
  458. mdtrtId := c.GetString("mdtrt_id")
  459. setlId := c.GetString("setl_id")
  460. org_name := c.GetString("org_name")
  461. doctor := c.GetString("doctor")
  462. secret_key := c.GetString("secret_key")
  463. fixmedins_code := c.GetString("fixmedins_code")
  464. insuplc_admdvs := c.GetString("insuplc_admdvs")
  465. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  466. url := c.GetString("url")
  467. ak := c.GetString("ak")
  468. cainfo := c.GetString("cainfo")
  469. baseParams := models.BaseParams{
  470. SecretKey: secret_key,
  471. FixmedinsCode: fixmedins_code,
  472. InsuplcAdmdvs: insuplc_admdvs,
  473. MdtrtareaAdmvs: mdtrtarea_admvs,
  474. OrgName: org_name,
  475. Doctor: doctor,
  476. RequestUrl: url,
  477. AccessKey: ak,
  478. Cainfo: cainfo,
  479. }
  480. businessParams := models.BusinessParams{
  481. PsnNo: psnNo,
  482. MdtrtId: mdtrtId,
  483. SetlId: setlId,
  484. }
  485. result, request_log := service.Jsyb5203(baseParams, businessParams)
  486. saveJsLog(result, request_log, "5203", "结算单", org_name)
  487. var dat map[string]interface{}
  488. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  489. fmt.Println(dat)
  490. } else {
  491. fmt.Println(err)
  492. }
  493. var dat2 map[string]interface{}
  494. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  495. fmt.Println(dat2)
  496. } else {
  497. fmt.Println(err)
  498. }
  499. c.ServeSuccessJSON(map[string]interface{}{
  500. "pre": dat,
  501. "request_log": dat2,
  502. })
  503. }
  504. func (c *JSybController) Get2503() {
  505. psnNo := c.GetString("psn_no")
  506. insutype := c.GetString("insutype")
  507. sick_code := c.GetString("sick_code")
  508. sick_name := c.GetString("sick_name")
  509. insuplc_admdvs := c.GetString("insuplc_admdvs")
  510. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  511. secret_key := c.GetString("secret_key")
  512. access_key := c.GetString("access_key")
  513. fixmedins_code := c.GetString("fixmedins_code")
  514. org_name := c.GetString("org_name")
  515. check_time := c.GetString("check_time")
  516. doctor_id := c.GetString("doctor_id")
  517. doctor := c.GetString("doctor")
  518. start_time := c.GetString("start_time")
  519. end_time := c.GetString("end_time")
  520. url := c.GetString("url")
  521. cainfo := c.GetString("cainfo")
  522. service.Jsyb2503(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)
  523. }
  524. func (c *JSybController) Get3201() {
  525. insutype := c.GetString("insutype")
  526. clrType := c.GetString("clr_type")
  527. setlOptins := c.GetString("setl_optins")
  528. stmtBegndate := c.GetString("stmt_begndate")
  529. stmtEnddate := c.GetString("stm_enddate")
  530. medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0)
  531. fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0)
  532. acctPay, _ := c.GetFloat("acct_pay", 0)
  533. fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0)
  534. fixmedins_code := c.GetString("fixmedins_code")
  535. insuplc_admdvs := c.GetString("insuplc_admdvs")
  536. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  537. secret_key := c.GetString("secret_key")
  538. org_name := c.GetString("org_name")
  539. doctor := c.GetString("doctor")
  540. url := c.GetString("url")
  541. ak := c.GetString("ak")
  542. cainfo := c.GetString("cainfo")
  543. result, request_log := service.Jsyb3201(fixmedinsSetlCnt, acctPay, fundPaySumamt, medfeeSumamt, stmtBegndate, stmtEnddate, setlOptins, clrType, insutype, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, secret_key, cainfo)
  544. saveJsLog(result, request_log, "3201", "对总账", org_name)
  545. var dat map[string]interface{}
  546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  547. fmt.Println(dat)
  548. } else {
  549. fmt.Println(err)
  550. }
  551. var dat2 map[string]interface{}
  552. if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
  553. fmt.Println(dat2)
  554. } else {
  555. fmt.Println(err)
  556. }
  557. c.ServeSuccessJSON(map[string]interface{}{
  558. "pre": dat,
  559. "request_log": dat2,
  560. })
  561. }
  562. type ELeData struct {
  563. Data struct {
  564. SiNo string `json:"si_no"`
  565. SiCardNo string `json:"si_card_no"`
  566. SiCardIssueArea string `json:"si_card_issue_area"`
  567. Name string `json:"name"`
  568. Gender string `json:"gender"`
  569. IdType string `json:"id_type"`
  570. IdNo string `json:"id_no"`
  571. EcCardToken string `json:"ecCardToken"`
  572. } `json:"data"`
  573. Code int `json:"code"`
  574. Message string `json:"message"`
  575. }
  576. type ELeCertData struct {
  577. Data struct {
  578. Extra string `json:"extra"`
  579. IDNo string `json:"idNo"`
  580. IDType string `json:"idType"`
  581. EcToken string `json:"ecToken"`
  582. InsuOrg string `json:"insuOrg"`
  583. UserName string `json:"userName"`
  584. EcIndexNo string `json:"ecIndexNo"`
  585. Gender string `json:"gender"`
  586. Birthday string `json:"birthday"`
  587. Nationality string `json:"nationality"`
  588. Email string `json:"email"`
  589. } `json:"data"`
  590. Code int `json:"code"`
  591. Message string `json:"message"`
  592. }
  593. func (c *JSybController) ReadCard() {
  594. fixmedins_code := c.GetString("fixmedins_code")
  595. secret_key := c.GetString("secret_key")
  596. ak := c.GetString("ak")
  597. org_name := c.GetString("org_name")
  598. doctor := c.GetString("doctor")
  599. insuplc_admdvs := c.GetString("insuplc_admdvs")
  600. mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
  601. url := c.GetString("url")
  602. cainfo := c.GetString("cainfo")
  603. id_card_type := c.GetString("id_card_type")
  604. operator_id := c.GetString("operator_id")
  605. operator := c.GetString("operator")
  606. //result, request := service.Jsyb9001(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, url, cainfo, ak)
  607. //fmt.Println(request)
  608. //fmt.Println(result)
  609. c.TestGetBasBaseInit(fixmedins_code, secret_key, ak)
  610. switch id_card_type {
  611. case "1":
  612. pCardInfo, pBusiCardInfo := c.GetBasBaseInfo()
  613. pBusiCardInfo = Remove0000(pBusiCardInfo)
  614. pCardInfo = Remove0000(pCardInfo)
  615. fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8"))
  616. fmt.Println(pBusiCardInfo)
  617. fmt.Println(pCardInfo)
  618. bas := strings.Split(pCardInfo, "|")
  619. basNumber := bas[2]
  620. id_card_no := bas[1]
  621. card_sn := bas[3]
  622. id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64)
  623. if len(pCardInfo) > 0 && len(pBusiCardInfo) > 0 {
  624. result, _ := service.Jsyb1101A(basNumber, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type_int, card_sn, "1", url, ak, pBusiCardInfo, id_card_no, cainfo)
  625. var dat map[string]interface{}
  626. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  627. fmt.Println(dat)
  628. } else {
  629. fmt.Println(err)
  630. }
  631. c.ServeSuccessJSON(map[string]interface{}{
  632. "status": "0",
  633. "card_info": pCardInfo,
  634. "busi_card_info": pBusiCardInfo,
  635. "result": dat,
  636. "type": "1",
  637. })
  638. } else {
  639. c.ServeSuccessJSON(map[string]interface{}{
  640. "status": "-1",
  641. })
  642. }
  643. break
  644. case "3": //电子社保卡
  645. _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator)
  646. //fmt.Println(pCardInfo)
  647. fmt.Println(pBusiCardInfo)
  648. pBusiCardInfo = Remove0000(pBusiCardInfo)
  649. //pCardInfo = Remove0000(pCardInfo)
  650. var ele ELeData
  651. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  652. if err != nil {
  653. utils.ErrorLog("解析失败:%v", err)
  654. }
  655. token := ele.Data.EcCardToken
  656. if len(token) > 0 {
  657. result, _ := service.Jsyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IdNo)
  658. var dat map[string]interface{}
  659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  660. fmt.Println(dat)
  661. } else {
  662. fmt.Println(err)
  663. }
  664. c.ServeSuccessJSON(map[string]interface{}{
  665. "status": "0",
  666. //"card_info": pCardInfo,
  667. "busi_card_info": pBusiCardInfo,
  668. "token": token,
  669. "result": dat,
  670. "type": "2",
  671. })
  672. } else {
  673. c.ServeSuccessJSON(map[string]interface{}{
  674. "status": "-1",
  675. })
  676. }
  677. break
  678. case "4": //电子凭证
  679. fmt.Println(operator_id)
  680. fmt.Println(operator)
  681. pCardInfo, pBusiCardInfo := c.GetELeCertInfo(fixmedins_code, operator_id, operator)
  682. fmt.Println(pCardInfo)
  683. fmt.Println(pBusiCardInfo)
  684. pBusiCardInfo = Remove0000(pBusiCardInfo)
  685. pCardInfo = Remove0000(pCardInfo)
  686. var ele ELeCertData
  687. err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
  688. if err != nil {
  689. utils.ErrorLog("解析失败:%v", err)
  690. }
  691. token := ele.Data.EcToken
  692. fmt.Println(token)
  693. if len(token) > 0 {
  694. userName := ConvertByte2String([]byte(ele.Data.UserName), GB18030)
  695. userName = Remove0000(userName)
  696. result, _ := service.Jsyb1101ForEleCert(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName)
  697. var dat map[string]interface{}
  698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  699. fmt.Println(dat)
  700. } else {
  701. fmt.Println(err)
  702. }
  703. c.ServeSuccessJSON(map[string]interface{}{
  704. "status": "0",
  705. "card_info": pCardInfo,
  706. "busi_card_info": pBusiCardInfo,
  707. "token": token,
  708. "result": dat,
  709. })
  710. } else {
  711. c.ServeSuccessJSON(map[string]interface{}{
  712. "status": "-1",
  713. })
  714. }
  715. break
  716. }
  717. }
  718. func (c *JSybController) TestGetBasBaseInit(code string, secret_key string, ak string) {
  719. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  720. Iinit := DllDef.MustFindProc("Init")
  721. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  722. str := make([]byte, 2048)
  723. inputData := make(map[string]interface{})
  724. inputData["IP"] = "10.72.3.87"
  725. inputData["PORT"] = "8086"
  726. inputData["TIMEOUT"] = "180"
  727. inputData["LOG_PATH"] = "C:\\log\\"
  728. //inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery"
  729. inputData["EC_URL"] = "http://10.72.3.127:10086/localcfc/api/hsecfc/localQrCodeQuery"
  730. inputData["CARD_PASSTYPE"] = "1"
  731. inputData["API_NAME"] = "hssServives"
  732. inputData["API_VERSION"] = "1.0.0"
  733. inputData["ACCESS_KEY"] = ak
  734. inputData["SECRETKEY"] = secret_key
  735. inputData["ORG_ID"] = code
  736. inputData["EXT"] = ""
  737. bytesData, _ := json.Marshal(inputData)
  738. fmt.Println(inputData)
  739. fmt.Println(bytesData)
  740. ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0])))
  741. if ret != 0 {
  742. fmt.Println("SSCard的报错原因:", err)
  743. fmt.Println("SSCard的运算结果为:", ret)
  744. fmt.Println("SSCard的返回结果为:", string(str))
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  746. return
  747. }
  748. fmt.Println("SSCard的返回结果为:", string(str))
  749. result := int(ret)
  750. fmt.Println("SSCard的运算结果为1:", result)
  751. //initFlag = 1
  752. return
  753. }
  754. func (c *JSybController) GetBasBaseInfo() (string, string) {
  755. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  756. readCard := DllDef.MustFindProc("ReadCardBas")
  757. fmt.Println(readCard)
  758. fmt.Println("!!!!!")
  759. pCardInfo := make([]byte, 2048)
  760. pBusiCardInfo := make([]byte, 8192)
  761. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  762. fmt.Println(ret2)
  763. fmt.Println(DeleteExtraSpace(string(pCardInfo)))
  764. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  765. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8"))
  766. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  767. if ret2 != 0 {
  768. return "", ""
  769. }
  770. return DeleteExtraSpace(string(pCardInfo)), DeleteExtraSpace(string(pBusiCardInfo))
  771. }
  772. func (c *JSybController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  773. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  774. readCard := DllDef.MustFindProc("EcCardQuery")
  775. fmt.Println(readCard)
  776. fmt.Println("!!!!!")
  777. //pCardInfo := make([]byte, 8192)
  778. pBusiCardInfo := make([]byte, 8192)
  779. //data := make(map[string]interface{})
  780. //pData := make(map[string]interface{})
  781. //inputData := make(map[string]interface{})
  782. //inputData["orgId"] = code
  783. //inputData["businessType"] = "01101"
  784. //inputData["operatorId"] = operator_id
  785. //inputData["operatorName"] = operator_name
  786. //inputData["officeId"] = "001"
  787. //inputData["officeName"] = "血透室"
  788. //data["data"] = inputData
  789. //data["transType"] = "ec.query"
  790. //data["orgId"] = code
  791. //bytesData, _ := json.Marshal(data)
  792. //pCardInfo = bytesData
  793. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  794. fmt.Println(ret2)
  795. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  796. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  797. //fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  798. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  799. if ret2 != 0 {
  800. return "", ""
  801. }
  802. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  803. }
  804. func (c *JSybController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  805. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  806. readCard := DllDef.MustFindProc("GetPersonInfo")
  807. pCardInfo := make([]byte, 8192)
  808. pBusiCardInfo := make([]byte, 8192)
  809. data := make(map[string]interface{})
  810. inputData := make(map[string]interface{})
  811. inputData["orgId"] = code
  812. inputData["businessType"] = "01101"
  813. inputData["operatorId"] = "1"
  814. inputData["operatorName"] = "admin"
  815. inputData["officeId"] = "001"
  816. inputData["officeName"] = "admin"
  817. data["data"] = inputData
  818. data["transType"] = "ec.query"
  819. data["orgId"] = code
  820. bytesData, _ := json.Marshal(data)
  821. pCardInfo = bytesData
  822. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  823. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  824. fmt.Println(ret2)
  825. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  826. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  827. if ret2 != 0 {
  828. return "", ""
  829. }
  830. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030)
  831. }
  832. func IntPtr(n int) uintptr {
  833. return uintptr(n)
  834. }
  835. func StrPtr(s string) uintptr {
  836. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  837. }
  838. type Charset string
  839. const (
  840. UTF8 = Charset("UTF-8")
  841. GB18030 = Charset("GB18030")
  842. )
  843. func ConvertToString(src string, srcCode string, tagCode string) string {
  844. srcCoder := mahonia.NewDecoder(srcCode)
  845. srcResult := srcCoder.ConvertString(src)
  846. tagCoder := mahonia.NewDecoder(tagCode)
  847. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  848. result := string(cdata)
  849. return result
  850. }
  851. func DeleteExtraSpace(s string) string {
  852. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  853. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  854. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  855. reg, _ := regexp.Compile(regstr) //编译正则表达式
  856. s2 := make([]byte, len(s1)) //定义字符数组切片
  857. copy(s2, s1) //将字符串复制到切片
  858. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  859. for len(spc_index) > 0 { //找到适配项
  860. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  861. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  862. }
  863. return string(s2)
  864. }
  865. func Remove0000(s string) string {
  866. str := make([]rune, 0, len(s))
  867. for _, v := range []rune(s) {
  868. if v == 0 {
  869. continue
  870. }
  871. str = append(str, v)
  872. }
  873. return string(str)
  874. }
  875. func saveJsLog(result string, request string, infno string, desc string, org_name string) {
  876. //org_id, _ := beego.AppConfig.Int64("org_id")
  877. //miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  878. dir := org_name + "日志"
  879. utils.Mkdir(dir)
  880. month := time.Unix(1557042972, 0).Format("1")
  881. year := time.Now().Format("2006")
  882. month = time.Now().Format("01")
  883. day := time.Now().Format("02")
  884. hour := time.Now().Format("15")
  885. min := time.Now().Format("04")
  886. sec := time.Now().Format("05")
  887. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  888. file := org_name + "_" + year + month + day + "_log"
  889. file_name := file + ".txt"
  890. file_path := org_name + "日志" + "/" + file_name
  891. exist, _ := utils.PathExists(file_path)
  892. if exist { //存在
  893. fmt.Println("存在")
  894. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  895. if err != nil {
  896. fmt.Println("read fail")
  897. }
  898. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  899. n, _ := f.Seek(0, 2)
  900. _, err = f.WriteAt([]byte(content), n)
  901. } else { //不存在
  902. fmt.Println("文件不存在,创建文件")
  903. f, err := os.Create(org_name + "日志" + "/" + file_name)
  904. defer f.Close()
  905. if err != nil {
  906. } else {
  907. _, err = f.Write([]byte("记录日志"))
  908. }
  909. }
  910. }
  911. func (c *JSybController) Get3101() {
  912. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  913. var respJSON map[string]interface{}
  914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  916. return
  917. }
  918. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  919. var pd models.PatientDtos
  920. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  921. utils.ErrorLog("解析失败:%v", err)
  922. return
  923. }
  924. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  925. var fed models.FsiEncounterDtos
  926. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  927. utils.ErrorLog("解析失败:%v", err)
  928. return
  929. }
  930. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  931. var fdd []*models.FsiDiagnoseDtos
  932. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  933. utils.ErrorLog("解析失败:%v", err)
  934. return
  935. }
  936. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  937. var fod []*models.FsiOrderDtos
  938. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  939. utils.ErrorLog("解析失败:%v", err)
  940. return
  941. }
  942. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  943. var fopd []*models.FsiOperationDtosData
  944. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  945. utils.ErrorLog("解析失败:%v", err)
  946. return
  947. }
  948. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  949. var pp models.PublicParams
  950. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  951. utils.ErrorLog("解析失败:%v", err)
  952. return
  953. }
  954. request, result := service.Jsyb3101(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  955. var dat map[string]interface{}
  956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  957. fmt.Println(dat)
  958. } else {
  959. fmt.Println(err)
  960. }
  961. var dat2 map[string]interface{}
  962. if err := json.Unmarshal([]byte(request), &dat2); err == nil {
  963. fmt.Println(dat2)
  964. } else {
  965. fmt.Println(err)
  966. }
  967. saveJsLog(result, request, "3101", "事前", pp.FixmedinsName)
  968. c.ServeSuccessJSON(map[string]interface{}{
  969. "pre": dat,
  970. "request_log": dat2,
  971. })
  972. }
  973. func (c *JSybController) Get3102() {
  974. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  975. var respJSON map[string]interface{}
  976. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  978. return
  979. }
  980. pdUserJSONBytes, _ := json.Marshal(respJSON["pd"])
  981. var pd models.PatientDtos
  982. if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil {
  983. utils.ErrorLog("解析失败:%v", err)
  984. return
  985. }
  986. fedUserJSONBytes, _ := json.Marshal(respJSON["fed"])
  987. var fed models.FsiEncounterDtos
  988. if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil {
  989. utils.ErrorLog("解析失败:%v", err)
  990. return
  991. }
  992. fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"])
  993. var fdd []*models.FsiDiagnoseDtos
  994. if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil {
  995. utils.ErrorLog("解析失败:%v", err)
  996. return
  997. }
  998. fodUserJSONBytes, _ := json.Marshal(respJSON["fod"])
  999. var fod []*models.FsiOrderDtos
  1000. if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil {
  1001. utils.ErrorLog("解析失败:%v", err)
  1002. return
  1003. }
  1004. fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"])
  1005. var fopd []*models.FsiOperationDtosData
  1006. if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil {
  1007. utils.ErrorLog("解析失败:%v", err)
  1008. return
  1009. }
  1010. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1011. var pp models.PublicParams
  1012. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1013. utils.ErrorLog("解析失败:%v", err)
  1014. return
  1015. }
  1016. request, result := service.Jsyb3102(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string))
  1017. var dat map[string]interface{}
  1018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1019. fmt.Println(dat)
  1020. } else {
  1021. fmt.Println(err)
  1022. }
  1023. var dat2 map[string]interface{}
  1024. if err := json.Unmarshal([]byte(request), &dat2); err == nil {
  1025. fmt.Println(dat2)
  1026. } else {
  1027. fmt.Println(err)
  1028. }
  1029. saveJsLog(result, request, "3102", "事后", pp.FixmedinsName)
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "pre": dat,
  1032. "request_log": dat2,
  1033. })
  1034. }
  1035. func (c *JSybController) Get4101() {
  1036. body, _ := ioutil.ReadAll(c.Ctx.Request.Body)
  1037. var respJSON map[string]interface{}
  1038. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1040. return
  1041. }
  1042. struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"])
  1043. var struct4101 service.Struct4101
  1044. if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. return
  1047. }
  1048. ppUserJSONBytes, _ := json.Marshal(respJSON["pp"])
  1049. var pp models.PublicParams
  1050. if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil {
  1051. utils.ErrorLog("解析失败:%v", err)
  1052. return
  1053. }
  1054. request, result := service.Jsyb4101(struct4101, pp)
  1055. var dat map[string]interface{}
  1056. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1057. fmt.Println(dat)
  1058. } else {
  1059. fmt.Println(err)
  1060. }
  1061. var dat2 map[string]interface{}
  1062. if err := json.Unmarshal([]byte(request), &dat2); err == nil {
  1063. fmt.Println(dat2)
  1064. } else {
  1065. fmt.Println(err)
  1066. }
  1067. saveJsLog(result, request, "4101", "上传明细清单", pp.FixmedinsName)
  1068. c.ServeSuccessJSON(map[string]interface{}{
  1069. "pre": dat,
  1070. "request_log": dat2,
  1071. })
  1072. }
  1073. func ConvertByte2String(byte []byte, charset Charset) string {
  1074. var str string
  1075. switch charset {
  1076. case GB18030:
  1077. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  1078. str = string(decodeBytes)
  1079. case UTF8:
  1080. fallthrough
  1081. default:
  1082. str = string(byte)
  1083. }
  1084. return str
  1085. }