package ah import ( "encoding/json" "fmt" "gdyb/controllers" "gdyb/enums" "gdyb/models" "gdyb/service" "gdyb/utils" "github.com/astaxie/beego" "github.com/axgle/mahonia" "github.com/gorilla/websocket" "golang.org/x/text/encoding/simplifiedchinese" "io/ioutil" "log" "net/url" "os" "regexp" "strconv" "strings" "syscall" "time" "unsafe" ) type AHybController struct { controllers.BaseAuthAPIController } type Body struct { ErrMsg string `json:"err_msg"` InfRefMsgID string `json:"inf_refmsgid"` InfCode int `json:"infcode"` Output map[string]interface{} `json:"output"` } type Response struct { Body Body `json:"body"` Code int `json:"code"` CSBCode int `json:"csbCode"` Message string `json:"message"` RequestID string `json:"requestId"` State struct{} `json:"state"` } func AHybRegistRouters() { beego.Router("/ahyb/1101", &AHybController{}, "get:PostOne") beego.Router("/ahyb/2201", &AHybController{}, "get:PostTwo") beego.Router("/ahyb/2202", &AHybController{}, "get:PostThree") beego.Router("/ahyb/2203", &AHybController{}, "post:PostFour") beego.Router("/ahyb/2204", &AHybController{}, "post:PostFive") beego.Router("/ahyb/2205", &AHybController{}, "get:PostSix") beego.Router("/ahyb/2206", &AHybController{}, "get:PostSeven") beego.Router("/ahyb/2207", &AHybController{}, "get:PostEight") beego.Router("/ahyb/2208", &AHybController{}, "get:PostNine") beego.Router("/ahyb/5203", &AHybController{}, "get:PostTen") beego.Router("/ahyb/5301", &AHybController{}, "get:Get5301") beego.Router("/ahyb/3201", &AHybController{}, "get:Get3201") beego.Router("/ahyb/9001", &AHybController{}, "get:Get9001") beego.Router("/ahyb/4101", &AHybController{}, "post:Get4101") beego.Router("/ahyb/readcard", &AHybController{}, "get:ReadCard") beego.Router("/ahyb/2503", &AHybController{}, "get:Get2503") beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406") beego.Router("/ahyb/readcardcharge", &AHybController{}, "get:Readcardcharge") beego.Router("/ahyb/3501", &AHybController{}, "post:Get3501") beego.Router("/ahyb/3502", &AHybController{}, "post:Get3502") beego.Router("/ahyb/3503", &AHybController{}, "post:Get3503") beego.Router("/ahyb/3504", &AHybController{}, "post:Get3504") beego.Router("/ahyb/3505", &AHybController{}, "post:Get3505") beego.Router("/ahyb/3506", &AHybController{}, "post:Get3506") beego.Router("/ahyb/3507", &AHybController{}, "post:Get3507") beego.Router("/ahyb/3508", &AHybController{}, "post:Get3508") beego.Router("/ahyb/3509", &AHybController{}, "post:Get3509") beego.Router("/ahyb/3510", &AHybController{}, "post:Get3510") beego.Router("/ahyb/3511", &AHybController{}, "post:Get3511") beego.Router("/ahyb/3512", &AHybController{}, "post:Get3512") beego.Router("/ahyb/3513", &AHybController{}, "post:Get3513") beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406") beego.Router("/ahyb/2406", &AHybController{}, "post:Get2406") } func (c *AHybController) Get3501() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3501s"]) var struct3501 models.Struct3501 if err := json.Unmarshal(userJSONBytes, &struct3501); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3501(struct3501) saveJsLog(result, request_log, "3501", "库存盘点", struct3501.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3502() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3502s"]) var struct3502s models.Struct3502 if err := json.Unmarshal(userJSONBytes, &struct3502s); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3502(struct3502s) saveJsLog(result, request_log, "3502", "库存变更", struct3502s.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3503() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3503s"]) var struct3503 models.Struct3503 if err := json.Unmarshal(userJSONBytes, &struct3503); err != nil { utils.ErrorLog("解析失败:%v", err) return } fmt.Println(struct3503) result, request_log := service.Jsyb3503(struct3503) saveJsLog(result, request_log, "3503", "库存采购", struct3503.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3504() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3504s"]) var struct3504 []models.Struct3504 if err := json.Unmarshal(userJSONBytes, &struct3504); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3504(struct3504[0]) saveJsLog(result, request_log, "3504", "库存盘点", struct3504[0].OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3505() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3505s"]) var struct3505 models.Struct3505 if err := json.Unmarshal(userJSONBytes, &struct3505); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, inputLog := service.AHyb3505(struct3505, struct3505.SecretKey, struct3505.RequestUrl) saveJsLog(result, inputLog, "3505", "销售上传", struct3505.OrgName) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) Get3506() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3506s"]) var struct3506 models.Struct3506 if err := json.Unmarshal(userJSONBytes, &struct3506); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3506(struct3506) saveJsLog(result, request_log, "3506", "销售退库", struct3506.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3507() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3507s"]) var struct3507 models.Struct3507 if err := json.Unmarshal(userJSONBytes, &struct3507); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3507(struct3507) saveJsLog(result, request_log, "3507", "库存盘点", struct3507.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3508() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3508s"]) var struct3508 models.Struct3508 if err := json.Unmarshal(userJSONBytes, &struct3508); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3508(struct3508) saveJsLog(result, request_log, "3508", "库存查询", struct3508.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3509() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3509s"]) var struct3509 models.Struct3509 if err := json.Unmarshal(userJSONBytes, &struct3509); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3509(struct3509) saveJsLog(result, request_log, "3509", "库存查询", struct3509.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3510() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3510s"]) var struct3510 models.Struct3510 if err := json.Unmarshal(userJSONBytes, &struct3510); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3510(struct3510) saveJsLog(result, request_log, "3510", "库存盘点", struct3510.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3511() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3511s"]) var struct3511 models.Struct3511 if err := json.Unmarshal(userJSONBytes, &struct3511); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3511(struct3511) saveJsLog(result, request_log, "3511", "库存查询", struct3511.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3512() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3512s"]) var struct3512 models.Struct3512 if err := json.Unmarshal(userJSONBytes, &struct3512); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3512(struct3512) saveJsLog(result, request_log, "3512", "3512查询", struct3512.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Get3513() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["struct_3513s"]) var struct3513 models.Struct3513 if err := json.Unmarshal(userJSONBytes, &struct3513); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request_log := service.Jsyb3513(struct3513) saveJsLog(result, request_log, "3513", "库存盘点", struct3513.OrgName) var dat2 map[string]interface{} if err := json.Unmarshal([]byte(request_log), &dat2); err == nil { } else { } var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": dat, "request_log": dat2, }) } func (c *AHybController) Readcardcharge() { fixmedins_code := c.GetString("fixmedins_code") secret_key := c.GetString("secret_key") ak := c.GetString("ak") org_name := c.GetString("org_name") doctor := c.GetString("doctor") //insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") url := c.GetString("url") cainfo := c.GetString("cainfo") operator_id := c.GetString("operator_id") operator := c.GetString("operator") _, pBusiCardInfo := c.GetELeCertInfoThree(fixmedins_code, operator_id, operator) fmt.Println(pBusiCardInfo) pBusiCardInfo = Remove0000(pBusiCardInfo) var ele ELeCertData err := json.Unmarshal([]byte(pBusiCardInfo), &ele) if err != nil { utils.ErrorLog("解析失败:%v", err) } token := ele.Data.EcToken fmt.Println(token) if len(token) > 0 { userName := ele.Data.UserName fmt.Println(userName) userName = Remove0000(userName) userName = DeleteExtraSpace(userName) fmt.Println(userName) enc := mahonia.NewEncoder("gbk") fmt.Println(enc.ConvertString(userName)) result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { c.ServeSuccessJSON(map[string]interface{}{ "status": "1", "card_info": "", "busi_card_info": pBusiCardInfo, "token": token, "result": response.Body, }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "-1", }) } } func (c *AHybController) Get9001() { url := c.GetString("url") org_name := c.GetString("org_name") opera_name := c.GetString("opera_name") opera_id := c.GetString("opera_id") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") cainfo := c.GetString("cainfo") result, inputLog := service.AHyb9001(org_name, opera_name, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, opera_id, url, cainfo, "") fmt.Println(result) fmt.Println(inputLog) saveJsLog(result, inputLog, "9001", "签到", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) Get5301() { psn_no := c.GetString("psn_no") org_name := c.GetString("org_name") doctor := c.GetString("doctor") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") url := c.GetString("url") ak := c.GetString("ak") cainfo := c.GetString("cainfo") result, inputLog := service.AHyb5301(psn_no, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, cainfo) //saveJsLog() saveJsLog(result, inputLog, "5301", "查询备案", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostOne() { certNo := c.GetString("cert_no") org_name := c.GetString("org_name") doctor := c.GetString("doctor") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") id_card_type, _ := c.GetInt64("id_card_type") card_sn := c.GetString("card_sn") certificates := c.GetString("certificates") url := c.GetString("url") token := c.GetString("token") name := c.GetString("name") result, inputLog := service.AHyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, id_card_type, card_sn, certificates, url, name, token) fmt.Println(result) fmt.Println(inputLog) saveJsLog(result, inputLog, "1101", "查询个人信息", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostTwo() { psnNo := c.GetString("psn_no") insutype := c.GetString("insutype") certNo := c.GetString("cert_no") org_name := c.GetString("org_name") opera := c.GetString("opera") ipt_otp_no := c.GetString("ipt_otp_no") dept := c.GetString("dept") verify_number := c.GetString("verify_number") fixmedins_code := c.GetString("fixmedins_code") dept_code := c.GetString("dept_code") doctor_id := c.GetString("doctor_id") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") id_card_type, _ := c.GetInt64("id_card_type") url := c.GetString("url") ak := c.GetString("ak") doctor_name := c.GetString("doctor_name") cainfo := c.GetString("cainfo") card_sn := c.GetString("card_sn") result, inputLog := service.AHyb2201(psnNo, insutype, certNo, org_name, opera, ipt_otp_no, dept, fixmedins_code, dept_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, doctor_name, url, ak, verify_number, cainfo, card_sn) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostThree() { psnNo := c.GetString("psn_no") mdtrtId := c.GetString("mdtrt_id") iptOtpNo := c.GetString("ipt_otp_no") org_name := c.GetString("org_name") doctor := c.GetString("doctor") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") fixmedins_code := c.GetString("fixmedins_code") url := c.GetString("url") ak := c.GetString("ak") cainfo := c.GetString("cainfo") result, inputLog := service.AHyb2202(psnNo, mdtrtId, iptOtpNo, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo) saveJsLog(result, inputLog, "2202", "退号", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostFour() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["config"]) var config []*models.HisXtDiagnoseConfig if err := json.Unmarshal(userJSONBytes, &config); err != nil { utils.ErrorLog("解析失败:%v", err) return } fmt.Println(respJSON["psn_no"].(string)) fmt.Println(respJSON["mdtrt_id"].(string)) psnNo := respJSON["psn_no"].(string) mdtrtId := respJSON["mdtrt_id"].(string) operator := respJSON["operator"].(string) department := respJSON["department"].(string) org_name := respJSON["org_name"].(string) med_type := respJSON["med_type"].(string) fixmedins_code := respJSON["fixmedins_code"].(string) sick_code := respJSON["sick_code"].(string) sick_name := respJSON["sick_name"].(string) insuplc_admdvs := respJSON["insuplc_admdvs"].(string) mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string) url := respJSON["url"].(string) begin_time := respJSON["begin_time"].(string) cainfo := respJSON["cainfo"].(string) doctor_name := respJSON["doctor_name"].(string) doctor_number := respJSON["doctor_number"].(string) //cainfo := c.GetString("cainfo") result, inputLog := service.AHyb2203(psnNo, mdtrtId, operator, department, org_name, med_type, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sick_code, sick_name, config, url, begin_time, cainfo, doctor_name, doctor_number) saveJsLog(result, inputLog, "2203", "上传就诊信息", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) Get2406() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } psnNo := respJSON["psn_no"].(string) mdtrtId := respJSON["mdtrt_id"].(string) operator := respJSON["operator"].(string) cert_no := respJSON["cert_no"].(string) org_name := respJSON["org_name"].(string) psn_name := respJSON["psn_name"].(string) ipt_otp_no := respJSON["ipt_otp_no"].(string) ipt_psn_sp_flag_type := respJSON["ipt_psn_sp_flag_type"].(string) ipt_psn_sp_flag := respJSON["ipt_psn_sp_flag"].(string) fixmedins_code := respJSON["fixmedins_code"].(string) insuplc_admdvs := respJSON["insuplc_admdvs"].(string) mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string) url := respJSON["url"].(string) result, inputLog := service.AHyb2406(psnNo, mdtrtId, cert_no, psn_name, operator, ipt_otp_no, ipt_psn_sp_flag_type, ipt_psn_sp_flag, org_name, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url) saveJsLog(result, inputLog, "2406", "上传2406信息", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } type All struct { HisPrescription HisPrescription mdtrt_id string psn_no string } type HisPrescription struct { ID int64 `gorm:"column:id" json:"id" form:"id"` UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"` RecordDate int64 `gorm:"column:record_date" json:"record_date" form:"record_date"` PatientId int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"` HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"` Status int64 `gorm:"column:status" json:"status" form:"status"` Ctime int64 `gorm:"column:ctime" json:"ctime" form:"ctime"` Mtime int64 `gorm:"column:mtime" json:"mtime" form:"mtime"` Number string `gorm:"column:number" json:"number" form:"number"` Type int64 `gorm:"column:type" json:"type" form:"type"` Doctor int64 `gorm:"column:doctor" json:"doctor" form:"doctor"` Creator int64 `gorm:"column:creator" json:"creator" form:"creator"` Modifier int64 `gorm:"column:modifier" json:"modifier" form:"modifier"` HisDoctorAdviceInfo []*models.HisDoctorAdviceInfo `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"` HisPrescriptionProject []*models.HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"` } func (c *AHybController) PostFive() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } userJSONBytes, _ := json.Marshal(respJSON["pre"]) var hp []*models.HisPrescription if err := json.Unmarshal(userJSONBytes, &hp); err != nil { utils.ErrorLog("解析失败:%v", err) return } //fmt.Println("2203A的time_stamp=" + respJSON["time_stamp"].(string)) result, inputLog := service.AHyb2204(respJSON["psn_no"].(string), respJSON["mdtrt_id"].(string), hp, respJSON["chrg_bchno"].(string), respJSON["org_name"].(string), respJSON["doctor"].(string), respJSON["dept"].(string), respJSON["fixmedins_code"].(string), respJSON["dept_code"].(string), respJSON["doctor_id"].(string), respJSON["insuplc_admdvs"].(string), respJSON["mdtrtarea_admvs"].(string), respJSON["secret_key"].(string), respJSON["balance_accounts_type"].(string), respJSON["diag_code"].(string), respJSON["url"].(string), respJSON["ak"].(string), respJSON["new_doctor_name"].(string), "", respJSON["cainfo"].(string), respJSON["opter"].(string)) saveJsLog(result, inputLog, "2204", "上传明细", respJSON["org_name"].(string)) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostSix() { psnNo := c.GetString("psn_no") mdtrtId := c.GetString("mdtrt_id") chrgBchno := c.GetString("chrg_bchno") org_name := c.GetString("org_name") doctor := c.GetString("doctor") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") fixmedins_code := c.GetString("fixmedins_code") url := c.GetString("url") ak := c.GetString("ak") cainfo := c.GetString("cainfo") result, inputLog := service.AHyb2205(psnNo, mdtrtId, chrgBchno, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, url, ak, cainfo) fmt.Println(inputLog) saveJsLog(result, inputLog, "2205", "撤销明细", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostSeven() { psnNo := c.GetString("psn_no") mdtrtId := c.GetString("mdtrt_id") chrgBchno := c.GetString("chrg_bchno") certNo := c.GetString("cert_no") insutype := c.GetString("insutype") total := c.GetString("total") org_name := c.GetString("org_name") doctor := c.GetString("doctor") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") med_type := c.GetString("med_type") id_card_type, _ := c.GetInt64("id_card_type") certificates, _ := c.GetInt64("certificates") verify_number := c.GetString("verify_number") cainfo := c.GetString("cainfo") mdtrt_grp_type := c.GetString("mdtrt_grp_type") url := c.GetString("url") ak := c.GetString("ak") var result string var inputLog string result, inputLog = service.AHyb2206(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, certificates, url, ak, verify_number, cainfo, mdtrt_grp_type) saveJsLog(result, inputLog, "2206", "预结算", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostEight() { psnNo := c.GetString("psn_no") mdtrtId := c.GetString("mdtrt_id") chrgBchno := c.GetString("chrg_bchno") certNo := c.GetString("cert_no") insutype := c.GetString("insutype") total := c.GetString("total") org_name := c.GetString("org_name") doctor := c.GetString("doctor") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") med_type := c.GetString("med_type") id_card_type, _ := c.GetInt64("id_card_type") acct_used_flag := c.GetString("acct_used_flag") url := c.GetString("url") ak := c.GetString("ak") verify_number := c.GetString("verify_number") cainfo := c.GetString("cainfo") mdtrt_grp_type := c.GetString("mdtrt_grp_type") var result string var inputLog string result, inputLog = service.AHyb2207(psnNo, mdtrtId, chrgBchno, certNo, insutype, total, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, id_card_type, acct_used_flag, url, ak, verify_number, cainfo, mdtrt_grp_type) saveJsLog(result, inputLog, "2207", "结算", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostNine() { psnNo := c.GetString("psn_no") mdtrtId := c.GetString("mdtrt_id") setlId := c.GetString("setl_id") org_name := c.GetString("org_name") doctor := c.GetString("doctor") secret_key := c.GetString("secret_key") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") url := c.GetString("url") ak := c.GetString("ak") cainfo := c.GetString("cainfo") result, inputLog := service.AHyb2208(psnNo, mdtrtId, setlId, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, cainfo) saveJsLog(result, inputLog, "2208", "退费", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) PostTen() { psnNo := c.GetString("psn_no") mdtrtId := c.GetString("mdtrt_id") setlId := c.GetString("setl_id") org_name := c.GetString("org_name") doctor := c.GetString("doctor") secret_key := c.GetString("secret_key") fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") url := c.GetString("url") ak := c.GetString("ak") cainfo := c.GetString("cainfo") baseParams := models.BaseParams{ SecretKey: secret_key, FixmedinsCode: fixmedins_code, InsuplcAdmdvs: insuplc_admdvs, MdtrtareaAdmvs: mdtrtarea_admvs, OrgName: org_name, Doctor: doctor, RequestUrl: url, AccessKey: ak, Cainfo: cainfo, } businessParams := models.BusinessParams{ PsnNo: psnNo, MdtrtId: mdtrtId, SetlId: setlId, } result, inputLog := service.AHyb5203(baseParams, businessParams) saveJsLog(result, inputLog, "5203", "结算单", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } func (c *AHybController) Get2503() { psnNo := c.GetString("psn_no") insutype := c.GetString("insutype") sick_code := c.GetString("sick_code") sick_name := c.GetString("sick_name") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") access_key := c.GetString("access_key") fixmedins_code := c.GetString("fixmedins_code") org_name := c.GetString("org_name") check_time := c.GetString("check_time") doctor_id := c.GetString("doctor_id") doctor := c.GetString("doctor") start_time := c.GetString("start_time") end_time := c.GetString("end_time") url := c.GetString("url") cainfo := c.GetString("cainfo") service.AHyb2503(psnNo, insutype, org_name, doctor, fixmedins_code, doctor_id, insuplc_admdvs, mdtrtarea_admvs, secret_key, sick_name, sick_code, start_time, end_time, check_time, url, access_key, cainfo) } func (c *AHybController) Get3201() { insutype := c.GetString("insutype") clrType := c.GetString("clr_type") setlOptins := c.GetString("setl_optins") stmtBegndate := c.GetString("stmt_begndate") stmtEnddate := c.GetString("stm_enddate") medfeeSumamt, _ := c.GetFloat("medfee_sumamt", 0) fundPaySumamt, _ := c.GetFloat("fund_pay_sumamt", 0) acctPay, _ := c.GetFloat("acct_pay", 0) fixmedinsSetlCnt, _ := c.GetInt64("fixmedins_setl_cnt", 0) fixmedins_code := c.GetString("fixmedins_code") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") secret_key := c.GetString("secret_key") org_name := c.GetString("org_name") doctor := c.GetString("doctor") url := c.GetString("url") ak := c.GetString("ak") cainfo := c.GetString("cainfo") result, inputLog := service.AHyb3201(fixmedinsSetlCnt, acctPay, fundPaySumamt, medfeeSumamt, stmtBegndate, stmtEnddate, setlOptins, clrType, insutype, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, ak, secret_key, cainfo) saveJsLog(result, inputLog, "3201", "对总账", org_name) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": "1", "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } type ELeData struct { Data struct { SiNo string `json:"si_no"` SiCardNo string `json:"si_card_no"` SiCardIssueArea string `json:"si_card_issue_area"` Name string `json:"name"` Gender string `json:"gender"` IdType string `json:"id_type"` IdNo string `json:"id_no"` EcCardToken string `json:"ecCardToken"` } `json:"data"` Code int `json:"code"` Message string `json:"message"` } type ELeCertData struct { Data struct { Extra string `json:"extra"` IDNo string `json:"idNo"` IDType string `json:"idType"` EcToken string `json:"ecToken"` InsuOrg string `json:"insuOrg"` UserName string `json:"userName"` EcIndexNo string `json:"ecIndexNo"` Gender string `json:"gender"` Birthday string `json:"birthday"` Nationality string `json:"nationality"` Email string `json:"email"` } `json:"data"` Code int `json:"code"` Message string `json:"message"` } func (c *AHybController) ReadCard() { fixmedins_code := c.GetString("fixmedins_code") secret_key := c.GetString("secret_key") ak := c.GetString("ak") org_name := c.GetString("org_name") doctor := c.GetString("doctor") insuplc_admdvs := c.GetString("insuplc_admdvs") mdtrtarea_admvs := c.GetString("mdtrtarea_admvs") url := c.GetString("url") cainfo := c.GetString("cainfo") id_card_type := c.GetString("id_card_type") operator_id := c.GetString("operator_id") operator := c.GetString("operator") //result, request := service.AHyb9001(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, url, cainfo, ak) //fmt.Println(request) //fmt.Println(result) //c.TestGetBasBaseInit(fixmedins_code, secret_key, ak) switch id_card_type { case "1": pCardInfo := c.GetBasBaseInfo() pCardInfo = Remove0000(pCardInfo) fmt.Println(":", ConvertToString(pCardInfo, "gbk", "utf-8")) fmt.Println(pCardInfo) bas := strings.Split(pCardInfo, "|") basNumber := bas[2] id_card_no := bas[1] card_sn := bas[3] id_card_type_int, _ := strconv.ParseInt(id_card_type, 10, 64) if len(pCardInfo) > 0 { result, _ := service.AHyb1101A(basNumber, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type_int, card_sn, "1", url, ak, id_card_no, cainfo) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "card_info": pCardInfo, "result": response.Body, "type": "1", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "-1", }) } break case "3": //电子社保卡 _, pBusiCardInfo := c.GetELeInfo(fixmedins_code, operator_id, operator) //fmt.Println(pCardInfo) fmt.Println(pBusiCardInfo) pBusiCardInfo = Remove0000(pBusiCardInfo) //pCardInfo = Remove0000(pCardInfo) var ele ELeData err := json.Unmarshal([]byte(pBusiCardInfo), &ele) if err != nil { utils.ErrorLog("解析失败:%v", err) } token := ele.Data.EcCardToken if len(token) > 0 { result, _ := service.AHyb1101B(org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IdNo) var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { fmt.Println(dat) } else { fmt.Println(err) } c.ServeSuccessJSON(map[string]interface{}{ "status": "0", //"card_info": pCardInfo, "busi_card_info": pBusiCardInfo, "token": token, "result": dat, "type": "2", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "-1", }) } break case "4": //电子凭证 fmt.Println(operator_id) fmt.Println(operator) _, pBusiCardInfo := c.GetELeCertInfoTwo(fixmedins_code, operator_id, operator) fmt.Println(pBusiCardInfo) pBusiCardInfo = Remove0000(pBusiCardInfo) var ele ELeCertData err := json.Unmarshal([]byte(pBusiCardInfo), &ele) if err != nil { utils.ErrorLog("解析失败:%v", err) } token := ele.Data.EcToken fmt.Println(token) if len(token) > 0 { userName := ele.Data.UserName fmt.Println(userName) userName = Remove0000(userName) userName = DeleteExtraSpace(userName) fmt.Println(userName) enc := mahonia.NewEncoder("gbk") fmt.Println(enc.ConvertString(userName)) result, _ := service.AHyb1101ForEleCert(org_name, doctor, fixmedins_code, ele.Data.InsuOrg, mdtrtarea_admvs, secret_key, url, ak, token, cainfo, ele.Data.IDNo, userName) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { c.ServeSuccessJSON(map[string]interface{}{ "status": "1", "card_info": "", "busi_card_info": pBusiCardInfo, "token": token, "result": response.Body, }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "0", "msg": response.Message, }) } } else { c.ServeSuccessJSON(map[string]interface{}{ "status": "-1", }) } break } } func (c *AHybController) TestGetBasBaseInit(code string, secret_key string, ak string) { DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll") Iinit := DllDef.MustFindProc("Init") //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId) str := make([]byte, 2048) inputData := make(map[string]interface{}) inputData["IP"] = "10.58.65.240" inputData["PORT"] = "8086" inputData["TIMEOUT"] = "180" inputData["LOG_PATH"] = "C:\\log\\" //inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery" inputData["EC_URL"] = "http://10.58.33.207:10086/localcfc/api/hsecfc/localQrCodeQuery" inputData["CARD_PASSTYPE"] = "1" inputData["API_NAME"] = "hssServives" inputData["API_VERSION"] = "1.0.0" inputData["ACCESS_KEY"] = ak inputData["SECRETKEY"] = secret_key inputData["ORG_ID"] = code inputData["EXT"] = "" bytesData, _ := json.Marshal(inputData) fmt.Println(inputData) fmt.Println(bytesData) ret, _, err := Iinit.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str[0]))) if ret != 0 { fmt.Println("SSCard的报错原因:", err) fmt.Println("SSCard的运算结果为:", ret) fmt.Println("SSCard的返回结果为:", string(str)) c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException) return } fmt.Println("SSCard的返回结果为:", string(str)) result := int(ret) fmt.Println("SSCard的运算结果为1:", result) //initFlag = 1 return } func (c *AHybController) GetBasBaseInfo() string { DllDef := syscall.MustLoadDLL("SSCardDriver.dll") readCard := DllDef.MustFindProc("iReadCardBas") fmt.Println(readCard) fmt.Println("!!!!!") pCardInfo := make([]byte, 2048) ret2, _, _ := readCard.Call(uintptr(3), (uintptr)(unsafe.Pointer(&pCardInfo[0]))) fmt.Println(ret2) fmt.Println(DeleteExtraSpace(string(pCardInfo))) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pCardInfo)), "gbk", "utf-8")) if ret2 != 0 { return "" } return DeleteExtraSpace(string(pCardInfo)) } func (c *AHybController) GetELeInfo(code string, operator_id string, operator_name string) (string, string) { DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll") readCard := DllDef.MustFindProc("EcCardQuery") fmt.Println(readCard) fmt.Println("!!!!!") //pCardInfo := make([]byte, 8192) pBusiCardInfo := make([]byte, 8192) //data := make(map[string]interface{}) //pData := make(map[string]interface{}) //inputData := make(map[string]interface{}) //inputData["orgId"] = code //inputData["businessType"] = "01101" //inputData["operatorId"] = operator_id //inputData["operatorName"] = operator_name //inputData["officeId"] = "001" //inputData["officeName"] = "血透室" //data["data"] = inputData //data["transType"] = "ec.query" //data["orgId"] = code //bytesData, _ := json.Marshal(data) //pCardInfo = bytesData ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pBusiCardInfo[0]))) fmt.Println(ret2) //fmt.Println(DeleteExtraSpace(string(bytesData))) fmt.Println(DeleteExtraSpace(string(pBusiCardInfo))) //fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8")) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")) if ret2 != 0 { return "", "" } return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo)) } func (c *AHybController) GetELeCertInfoFour1(code string, operator_id string, operator_name string) (string, string) { DllDef := syscall.MustLoadDLL("NationEcCode.dll") readCard := DllDef.MustFindProc("EcQuery") pCardInfo := make([]byte, 8192) pBusiCardInfo := make([]byte, 8192) data := make(map[string]interface{}) inputData := make(map[string]interface{}) inputData["orgId"] = code inputData["businessType"] = "01301" inputData["operatorId"] = operator_id inputData["operatorName"] = operator_name inputData["officeId"] = "001" inputData["officeName"] = "xuetou" data["data"] = inputData data["transType"] = "ec.query" data["orgId"] = code bytesData, _ := json.Marshal(data) pCardInfo = bytesData pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030)) ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0]))) fmt.Println(ret2) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8")) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")) if ret2 != 0 { return "", "" } return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030) } func (c *AHybController) GetELeCertInfoFour(code string, operator_id string, operator_name string) (string, string) { DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll") readCard := DllDef.MustFindProc("GetPersonInfo") pCardInfo := make([]byte, 8192) pBusiCardInfo := make([]byte, 8192) data := make(map[string]interface{}) inputData := make(map[string]interface{}) inputData["orgId"] = code inputData["businessType"] = "01301" inputData["operatorId"] = operator_id inputData["operatorName"] = operator_name inputData["officeId"] = "001" inputData["officeName"] = "xuetou" data["data"] = inputData data["transType"] = "ec.query" data["orgId"] = code bytesData, _ := json.Marshal(data) pCardInfo = bytesData pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030)) ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0]))) fmt.Println(ret2) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8")) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")) if ret2 != 0 { return "", "" } return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030) } func (c *AHybController) GetELeCertInfoFour2223(code string, operator_id string, operator_name string) (string, string) { DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll") readCard := DllDef.MustFindProc("GetPersonInfo") pCardInfo := make([]byte, 8192) pBusiCardInfo := make([]byte, 8192) data := make(map[string]interface{}) inputData := make(map[string]interface{}) inputData["orgId"] = code inputData["businessType"] = "01101" inputData["operatorId"] = operator_id inputData["operatorName"] = operator_name inputData["officeId"] = "001" inputData["officeName"] = "xuetou" data["data"] = inputData data["transType"] = "ec.query" data["orgId"] = code bytesData, _ := json.Marshal(data) pCardInfo = bytesData pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030)) ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0]))) fmt.Println(ret2) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8")) fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")) if ret2 != 0 { return "", "" } return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030) } func (c *AHybController) GetELeCertInfoTwo(code string, operator_id string, operator_name string) (string, string) { // WebSocket服务器地址 serverURL := "ws://127.0.0.1:8899" // 解析WebSocket服务器地址 u, err := url.Parse(serverURL) if err != nil { log.Fatal(err) } // 建立WebSocket连接 conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil) if err != nil { log.Fatal(err) } defer conn.Close() input2 := make(map[string]interface{}) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputData["orgId"] = code inputData["businessType"] = "01101" inputData["operatorId"] = operator_id inputData["operatorName"] = operator_name inputData["officeId"] = "001" inputData["officeName"] = "血透室" inputData["deviceType"] = "" input["data"] = inputData input["orgId"] = code input["transType"] = "ec.query" input2["url"] = "http://10.66.159.55:8080/localcfc/api/hsecfc/localQrCodeQuery" input2["indata"] = input bytesData, _ := json.Marshal(input2) err = conn.WriteMessage(websocket.TextMessage, bytesData) if err != nil { fmt.Println(err) } // 接收消息 _, receivedMessage, err := conn.ReadMessage() if err != nil { fmt.Println(err) } return "", string(receivedMessage) } func (c *AHybController) GetELeCertInfoThree(code string, operator_id string, operator_name string) (string, string) { // WebSocket服务器地址 serverURL := "ws://127.0.0.1:8899" // 解析WebSocket服务器地址 u, err := url.Parse(serverURL) if err != nil { log.Fatal(err) } // 建立WebSocket连接 conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil) if err != nil { log.Fatal(err) } defer conn.Close() input2 := make(map[string]interface{}) input := make(map[string]interface{}) inputData := make(map[string]interface{}) inputData["orgId"] = code inputData["businessType"] = "01301" inputData["operatorId"] = operator_id inputData["operatorName"] = operator_name inputData["officeId"] = "001" inputData["officeName"] = "血透室" inputData["deviceType"] = "" input["data"] = inputData input["orgId"] = code input["transType"] = "ec.query" input2["url"] = "http://10.66.159.55:8080/localcfc/api/hsecfc/localQrCodeQuery" input2["indata"] = input bytesData, _ := json.Marshal(input2) err = conn.WriteMessage(websocket.TextMessage, bytesData) if err != nil { fmt.Println(err) } // 接收消息 _, receivedMessage, err := conn.ReadMessage() if err != nil { fmt.Println(err) } return "", string(receivedMessage) } func IntPtr(n int) uintptr { return uintptr(n) } func StrPtr(s string) uintptr { return uintptr(unsafe.Pointer(syscall.StringBytePtr(s))) } type Charset string const ( UTF8 = Charset("UTF-8") GB18030 = Charset("GB18030") ) func ConvertToString(src string, srcCode string, tagCode string) string { srcCoder := mahonia.NewDecoder(srcCode) srcResult := srcCoder.ConvertString(src) tagCoder := mahonia.NewDecoder(tagCode) _, cdata, _ := tagCoder.Translate([]byte(srcResult), true) result := string(cdata) return result } func DeleteExtraSpace(s string) string { //删除字符串中的多余空格,有多个空格时,仅保留一个空格 s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格 regstr := "\\s{2,}" //两个及两个以上空格的正则表达式 reg, _ := regexp.Compile(regstr) //编译正则表达式 s2 := make([]byte, len(s1)) //定义字符数组切片 copy(s2, s1) //将字符串复制到切片 spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索 for len(spc_index) > 0 { //找到适配项 s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格 spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索 } return string(s2) } func Remove0000(s string) string { str := make([]rune, 0, len(s)) for _, v := range []rune(s) { if v == 0 { continue } str = append(str, v) } return string(str) } func saveJsLog(result string, request string, infno string, desc string, org_name string) { //org_id, _ := beego.AppConfig.Int64("org_id") //miConfig, _ := service.FindMedicalInsuranceInfo(org_id) dir := org_name + "日志" utils.Mkdir(dir) month := time.Unix(1557042972, 0).Format("1") year := time.Now().Format("2006") month = time.Now().Format("01") day := time.Now().Format("02") hour := time.Now().Format("15") min := time.Now().Format("04") sec := time.Now().Format("05") result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec file := org_name + "_" + year + month + day + "_log" file_name := file + ".txt" file_path := org_name + "日志" + "/" + file_name exist, _ := utils.PathExists(file_path) if exist { //存在 fmt.Println("存在") f, err := os.OpenFile(file_path, os.O_WRONLY, 0644) if err != nil { fmt.Println("read fail") } content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result n, _ := f.Seek(0, 2) _, err = f.WriteAt([]byte(content), n) } else { //不存在 fmt.Println("文件不存在,创建文件") f, err := os.Create(org_name + "日志" + "/" + file_name) defer f.Close() if err != nil { } else { _, err = f.Write([]byte("记录日志")) } } } func (c *AHybController) Get3101() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } pdUserJSONBytes, _ := json.Marshal(respJSON["pd"]) var pd models.PatientDtos if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil { utils.ErrorLog("解析失败:%v", err) return } fedUserJSONBytes, _ := json.Marshal(respJSON["fed"]) var fed models.FsiEncounterDtos if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil { utils.ErrorLog("解析失败:%v", err) return } fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"]) var fdd []*models.FsiDiagnoseDtos if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil { utils.ErrorLog("解析失败:%v", err) return } fodUserJSONBytes, _ := json.Marshal(respJSON["fod"]) var fod []*models.FsiOrderDtos if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil { utils.ErrorLog("解析失败:%v", err) return } fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"]) var fopd []*models.FsiOperationDtosData if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil { utils.ErrorLog("解析失败:%v", err) return } ppUserJSONBytes, _ := json.Marshal(respJSON["pp"]) var pp models.PublicParams if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil { utils.ErrorLog("解析失败:%v", err) return } inputLog, result := service.AHyb3101(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string)) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": 1, "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": 0, "msg": response.Message, }) } } func (c *AHybController) Get3102() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } pdUserJSONBytes, _ := json.Marshal(respJSON["pd"]) var pd models.PatientDtos if err := json.Unmarshal(pdUserJSONBytes, &pd); err != nil { utils.ErrorLog("解析失败:%v", err) return } fedUserJSONBytes, _ := json.Marshal(respJSON["fed"]) var fed models.FsiEncounterDtos if err := json.Unmarshal(fedUserJSONBytes, &fed); err != nil { utils.ErrorLog("解析失败:%v", err) return } fddUserJSONBytes, _ := json.Marshal(respJSON["fdd"]) var fdd []*models.FsiDiagnoseDtos if err := json.Unmarshal(fddUserJSONBytes, &fdd); err != nil { utils.ErrorLog("解析失败:%v", err) return } fodUserJSONBytes, _ := json.Marshal(respJSON["fod"]) var fod []*models.FsiOrderDtos if err := json.Unmarshal(fodUserJSONBytes, &fod); err != nil { utils.ErrorLog("解析失败:%v", err) return } fopdUserJSONBytes, _ := json.Marshal(respJSON["fopd"]) var fopd []*models.FsiOperationDtosData if err := json.Unmarshal(fopdUserJSONBytes, &fopd); err != nil { utils.ErrorLog("解析失败:%v", err) return } ppUserJSONBytes, _ := json.Marshal(respJSON["pp"]) var pp models.PublicParams if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil { utils.ErrorLog("解析失败:%v", err) return } _, result := service.AHyb3102(pd, fed, fdd, fod, fopd, pp, respJSON["trig_scen"].(string)) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "status": 1, "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": 0, "msg": response.Message, }) } } func (c *AHybController) Get4101() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) return } struct4101UserJSONBytes, _ := json.Marshal(respJSON["struct4101"]) var struct4101 service.Struct4101 if err := json.Unmarshal(struct4101UserJSONBytes, &struct4101); err != nil { utils.ErrorLog("解析失败:%v", err) return } ppUserJSONBytes, _ := json.Marshal(respJSON["pp"]) var pp models.PublicParams if err := json.Unmarshal(ppUserJSONBytes, &pp); err != nil { utils.ErrorLog("解析失败:%v", err) return } inputLog, result := service.AHyb4101(struct4101, pp) saveJsLog(result, inputLog, "4101", "上传明细清单", pp.FixmedinsName) var response Response if err := json.Unmarshal([]byte(result), &response); err != nil { fmt.Println("Error decoding JSON:", err) return } if response.Code == 200 { var dat2 map[string]interface{} if err := json.Unmarshal([]byte(inputLog), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ "pre": response.Body, "log": dat2, "status": 1, "msg": "", }) } else { c.ServeSuccessJSON(map[string]interface{}{ "status": 0, "msg": response.Message, }) } } func ConvertByte2String(byte []byte, charset Charset) string { var str string switch charset { case GB18030: decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte) str = string(decodeBytes) case UTF8: fallthrough default: str = string(byte) } return str }