jsyb_controller.go 40KB

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