1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165 |
- package nm
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "gdyb/controllers"
- "gdyb/enums"
- "gdyb/models"
- "gdyb/service"
- "gdyb/utils"
- "github.com/astaxie/beego"
- "github.com/axgle/mahonia"
- "io/ioutil"
- "net/http"
- "os"
- "os/exec"
- "regexp"
- "strconv"
- "strings"
- "syscall"
- "time"
- "unsafe"
- )
-
- type NmController struct {
- controllers.BaseAuthAPIController
- }
-
- func NmybRegistRouters() {
- beego.Router("/nmyb/1101", &NmController{}, "get:Post1101")
- beego.Router("/nmyb/2401", &NmController{}, "post:Post2401")
- beego.Router("/nmyb/2402", &NmController{}, "post:Post2402")
- beego.Router("/nmyb/2404", &NmController{}, "get:Post2404")
- beego.Router("/nmyb/2405", &NmController{}, "get:Post2405")
- beego.Router("/nmyb/2301", &NmController{}, "post:Post2301")
- beego.Router("/nmyb/2302", &NmController{}, "get:Post2302")
- beego.Router("/nmyb/2303", &NmController{}, "get:Post2303")
- beego.Router("/nmyb/2304", &NmController{}, "get:Post2304")
- beego.Router("/nmyb/2305", &NmController{}, "get:Post2305")
-
- beego.Router("/nmyb/5203", &NmController{}, "get:Post5203")
-
- beego.Router("/nmyb/readcard", &NmController{}, "get:ReadCard")
-
- beego.Router("/nmyb/3201", &NmController{}, "get:Get3201")
- beego.Router("/nmyb/2202", &NmController{}, "get:Post2202")
-
- beego.Router("/nmyb/4101", &NmController{}, "post:Post4101")
- beego.Router("/nmyb/2601", &NmController{}, "get:Get2601")
-
- beego.Router("/api/token", &NmController{}, "get:GetToken")
-
- }
- func (c *NmController) GetToken() {
- token := c.GetString("token")
- results := strings.Split(token, "-")
- fmt.Println(token)
- result_code := results[0]
- result_info := results[1]
- if result_code == "0000" {
- var ele2 ELeData2
- err := json.Unmarshal([]byte(result_info), &ele2)
- if err != nil {
- utils.ErrorLog("解析失败:%v", err)
- }
-
- if ele2.Code != -2 {
- var ele ELeData
- err := json.Unmarshal([]byte(result_info), &ele)
- if err != nil {
- utils.ErrorLog("解析失败:%v", err)
- }
- token := ele.Data.EcToken
- fmt.Println(token)
- if len(token) > 0 {
- result, _ := service.Gdyb1101ForEleCert("赤峰费森血液透析中心", "关学丽", "H15049901371", "150499", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", token, ele.Data.UserName, ele.Data.IdNo)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultTwo
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
- if infocode == 0 {
- data := make(map[string]interface{})
- data["token"] = token
- data["result"] = dat
- var req *http.Request
- bytesData, _ := json.Marshal(data)
- req, _ = http.NewRequest("POST", "http://172.16.23.189:9532/"+"api/token/get", bytes.NewReader(bytesData))
- client := &http.Client{}
- resp, _ := client.Do(req)
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- }
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- }
-
- type ReadCardResult struct {
- Output struct {
- CardInfo string `json:"cardInfo"`
- RegionCode string `json:"regionCode"`
- } `json:"output"`
- Code string `json:"CODE"`
- ErrMsg string `json:"ERRMSG"`
- }
-
- type ELeData2 struct {
- Code int `json:"code"`
- Message string `json:"message"`
- }
- type ELeData struct {
- Data struct {
- IdNo string `json:"idNo"`
- IdType string `json:"idType"`
- UserName string `json:"userName"`
- EcToken string `json:"ecToken"`
- InsuOrg string `json:"insuOrg"`
- Gender string `json:"gender"`
- Birthday string `json:"birthday"`
- Nationality string `json:"nationality"`
- Email string `json:"email"`
- Extra string `json:"extra"`
- } `json:"data"`
- Code int `json:"code"`
- Message string `json:"message"`
- }
-
- type ResultTwo struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PausInsuDate string `json:"paus_insu_date"`
- PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
- type ResultTwo10265 struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode string `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc float64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PausInsuDate string `json:"paus_insu_date"`
- PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
-
- func (c *NmController) Post4101() {
- 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
- }
- result := service.Gdyb4101(struct4101, pp.SecretKey, pp.FixmedinsName, pp.OpterName, pp.FixmedinsCode, pp.InsuplcAdmdvs, pp.MdtrtareaAdmvs, 0)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- saveJsLog(result, "", "4101", "上传明细清单", pp.FixmedinsName)
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- })
- }
-
- func (c *NmController) Post2202() {
-
- result, requestLog := service.Gdyb2202("150000CFSJM100000100005413", "20211227145332876188", "2021122714565410808111489", "赤峰费森血液透析中心", "李彩星", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57", "H15049901371")
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- } else {
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- "request_log": requestLog,
- })
-
- }
-
- func (c *NmController) Post5203() {
- fmt.Println("------")
- 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")
- psn_no := c.GetString("psn_no")
- mdtrt_id := c.GetString("mdtrt_id")
- setl_id := c.GetString("setl_id")
- fmt.Println("------")
- bp := models.BaseParams{
- SecretKey: secret_key,
- FixmedinsCode: fixmedins_code,
- InsuplcAdmdvs: insuplc_admdvs,
- MdtrtareaAdmvs: mdtrtarea_admvs,
- OrgName: org_name,
- Doctor: doctor,
- }
- bps := models.BusinessParams{
- PsnNo: psn_no,
- MdtrtId: mdtrt_id,
- SetlId: setl_id,
- }
- result := service.ZHyb5203(bp, bps)
- saveJsLog(result, "", "5203", "结算单", org_name)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
-
- } else {
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- })
- }
-
- func (c *NmController) Post1101() {
- 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")
- secret_key := c.GetString("secret_key")
- id_card_type, _ := c.GetInt64("id_card_type")
- card_sn := c.GetString("card_sn")
- certificates := c.GetString("certificates")
- name := c.GetString("name")
- certificate, _ := strconv.ParseInt(certificates, 10, 64)
- result, request_log, result_log := service.ZHGdyb1101(certNo, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, id_card_type, card_sn, certificate, name)
-
- saveJsLog(result_log, request_log, "1101", "查询个人信息", org_name)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
-
- } else {
-
- }
-
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(request_log), &dat2); err == nil {
-
- } else {
-
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- "log": dat2,
- })
-
- }
-
- func (c *NmController) Post2401() {
- 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_2401"])
- var struct2401 service.Struct2401
- if err := json.Unmarshal(userJSONBytes, &struct2401); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- return
- }
- org_name := respJSON["org_name"].(string)
- fixmedins_code := respJSON["fixmedins_code"].(string)
- doctor := respJSON["doctor"].(string)
- insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
- mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
- secret_key := respJSON["secret_key"].(string)
- result, request_log := service.ZHGdyb2401(struct2401, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
- saveJsLog(result, request_log, "2401", "入院登记", org_name)
- 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 *NmController) Post2404() {
- mdtrt_id := c.GetString("mdtrt_id")
- psn_no := c.GetString("psn_no")
- 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")
- org_name := c.GetString("org_name")
-
- result, requestLog := service.ZHGdyb2404(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
- saveJsLog(result, requestLog, "2404", "入院登记撤销", org_name)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- } else {
- }
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
- } else {
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- "log": dat2,
- })
-
- }
-
- func (c *NmController) Post2405() {
- mdtrt_id := c.GetString("mdtrt_id")
- psn_no := c.GetString("psn_no")
- 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")
- org_name := c.GetString("org_name")
-
- result, requestLog := service.ZHGdyb2405(mdtrt_id, psn_no, secret_key, org_name, fixmedins_code, doctor, insuplc_admdvs, mdtrtarea_admvs)
- saveJsLog(result, requestLog, "2405", "出院登记撤销", org_name)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- } else {
- }
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(requestLog), &dat2); err == nil {
- } else {
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- "log": dat2,
- })
-
- }
-
- func (c *NmController) Post2402() {
- 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_2402"])
- var struct2402 service.Struct2402
- if err := json.Unmarshal(userJSONBytes, &struct2402); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- return
- }
- org_name := respJSON["org_name"].(string)
- fixmedins_code := respJSON["fixmedins_code"].(string)
- doctor := respJSON["doctor"].(string)
- insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
- mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
- secret_key := respJSON["secret_key"].(string)
- result, request_log := service.ZHGdyb2402(struct2402, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code)
- saveJsLog(result, request_log, "2402", "出院", org_name)
- 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 *NmController) Post2301() {
-
- 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["customs"])
- var customs []*models.NewCustom
- if err := json.Unmarshal(userJSONBytes, &customs); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- return
- }
-
- number := respJSON["number"].(string)
-
- chrg_bchno := respJSON["chrg_bchno"].(string)
- dept := respJSON["dept"].(string)
- dept_code := respJSON["dept_code"].(string)
- doctor_code := respJSON["doctor_code"].(string)
-
- doctor_name := respJSON["doctor_name"].(string)
- opertor := respJSON["opertor"].(string)
-
- org_name := respJSON["org_name"].(string)
- fixmedins_code := respJSON["fixmedins_code"].(string)
- insuplc_admdvs := respJSON["insuplc_admdvs"].(string)
- mdtrtarea_admvs := respJSON["mdtrtarea_admvs"].(string)
- secret_key := respJSON["secret_key"].(string)
- med_type := respJSON["med_type"].(string)
- //med_type := strconv.FormatInt(int64(respJSON["med_type"].(float64)), 10)
- psn_no := respJSON["psn_no"].(string)
-
- result, requestLog := service.ZHGdyb2301A(psn_no, number, customs, chrg_bchno, org_name, doctor_name, dept, fixmedins_code, dept_code, doctor_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, med_type, opertor)
- saveJsLog(result, requestLog, "2301", "上传明细", org_name)
-
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(requestLog), &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 *NmController) Post2302() {
- mdtrt_id := c.GetString("mdtrtId")
- psn_no := c.GetString("psn_no")
- number := c.GetString("feedetl_sn")
- 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")
- org_name := c.GetString("org_name")
- refund_type, _ := c.GetInt64("refund_type")
-
- result, requestLog := service.Gdyb2302(psn_no, mdtrt_id, org_name, doctor, insuplc_admdvs, mdtrtarea_admvs, secret_key, fixmedins_code, number, refund_type)
- saveJsLog(result, requestLog, "2302", "退明细", org_name)
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(requestLog), &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 *NmController) Post2303() {
- mdtrt_id := c.GetString("mdtrt_id")
- psn_no := c.GetString("psn_no")
- chrg_bchno := c.GetString("chrg_bchno")
- cert_no := c.GetString("cert_no")
- insutype_type := c.GetString("insutype_type")
-
- allTotal := c.GetString("total")
- id_card_type, _ := c.GetInt64("id_card_type")
-
- doctor := c.GetString("doctor")
- certificates, _ := c.GetInt64("certificates")
-
- 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")
-
- result, src_resquest := service.ZHGdyb2303(psn_no, mdtrt_id, chrg_bchno, cert_no, insutype_type, allTotal, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, "0", id_card_type, 0, 0, 0, 0, certificates)
- saveJsLog(result, src_resquest, "2303", "预结算", org_name)
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(src_resquest), &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 *NmController) Post2304() {
- mdtrt_id := c.GetString("mdtrt_id")
- psn_no := c.GetString("psn_no")
- chrg_bchno := c.GetString("chrg_bchno")
- cert_no := c.GetString("cert_no")
- insutype_type := c.GetString("insutype_type")
-
- allTotal := c.GetString("total")
- id_card_type, _ := c.GetInt64("id_card_type")
-
- doctor := c.GetString("doctor")
- certificates, _ := c.GetInt64("certificates")
-
- 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")
- fapiao_number := c.GetString("fapiao_number")
- acct_used_flag := c.GetString("acct_used_flag")
-
- result, src_resquest := service.ZHGdyb2304(psn_no, mdtrt_id, chrg_bchno, cert_no, insutype_type, allTotal, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, "0", id_card_type, 0, 0, 0, 0, certificates, fapiao_number, acct_used_flag)
- saveJsLog(result, src_resquest, "2304", "住院结算", org_name)
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(src_resquest), &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 *NmController) Post2305() {
- mdtrt_id := c.GetString("mdtrt_id")
- psn_no := c.GetString("psn_no")
- doctor := c.GetString("doctor")
- setl_id := c.GetString("setl_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")
- org_name := c.GetString("org_name")
-
- result, requestLog := service.Gdyb2305(psn_no, mdtrt_id, setl_id, org_name, doctor, secret_key, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- saveJsLog(result, requestLog, "2305", "退费", org_name)
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(requestLog), &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 *NmController) Get2503() {
-
- }
-
- func (c *NmController) ReadCard() {
- fixmedins_code := c.GetString("fixmedins_code")
- secret_key := c.GetString("secret_key")
- org_name := c.GetString("org_name")
- insuplc_admdvs := c.GetString("insuplc_admdvs")
- mdtrtarea_admvs := c.GetString("mdtrtarea_admvs")
- id_card_type := c.GetString("id_card_type")
- operator_id := c.GetString("operator_id")
- operator := c.GetString("operator")
-
- switch id_card_type {
- case "1":
- if initFlag == 0 {
- c.TestGetBasBaseInit()
- }
- pBusiCardInfo := c.GetBasBaseInfo(fixmedins_code, mdtrtarea_admvs, operator, operator_id, org_name)
- basStr := Remove0000(pBusiCardInfo)
-
- if len(basStr) == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- return
- }
-
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(basStr), &dat2); err == nil {
- fmt.Println(dat2)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat2)
- var res ReadCardResult
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- fmt.Println(basStr)
- bas := strings.Split(res.Output.CardInfo, "|")
- basNumber := bas[1]
- fmt.Println(basNumber)
- card_sn := bas[3]
- fmt.Println(card_sn)
- cardNumber := bas[2]
- name := bas[4]
-
- result := service.Gdyb1101G(basNumber, org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, 1, card_sn, 1, name, cardNumber)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes2, _ := json.Marshal(dat)
- var res2 ResultTwo
- if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- infocode, _ := strconv.ParseInt(res2.Infcode, 10, 64)
-
- if infocode == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "0",
- "card_info": res.Output.CardInfo,
- "busi_card_info": pBusiCardInfo,
- "result": res2,
- "type": "1",
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "-1",
- })
- }
-
- break
- case "4": //电子凭证
- result_code, result_info := c.GetELeInfo()
- if result_code == "0000" {
- var ele ELeData
- err := json.Unmarshal([]byte(result_info), &ele)
- if err != nil {
- utils.ErrorLog("解析失败:%v", err)
- }
- token := ele.Data.EcToken
- fmt.Println(token)
- if len(token) > 0 {
- result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.UserName, ele.Data.IdNo)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultTwo
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
-
- if infocode == 0 {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "0",
- "card_info": result_info,
- "busi_card_info": result_info,
- "token": token,
- "result": dat,
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "-1",
- })
-
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
-
- break
- case "5": //电子凭证
- _, pBusiCardInfo := c.GetELeInfoTwo(fixmedins_code, operator_id, operator)
-
- var ele ELeData
- err := json.Unmarshal([]byte(pBusiCardInfo), &ele)
- if err != nil {
- utils.ErrorLog("解析失败:%v", err)
- }
- token := ele.Data.EcToken
- fmt.Println(token)
- if len(token) > 0 {
- result, _ := service.Gdyb1101ForEleCert(org_name, operator, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, secret_key, token, ele.Data.IdNo, ele.Data.UserName)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultTwo
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- infocode, _ := strconv.ParseInt(res.Infcode, 10, 64)
-
- if infocode == 0 {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "0",
- "card_info": pBusiCardInfo,
- "busi_card_info": pBusiCardInfo,
- "token": token,
- "result": dat,
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "-1",
- })
-
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- return
- }
- break
-
- }
-
- }
-
- var initFlag int64 = 0
-
- func (c *NmController) GetELeInfoTwo(code string, operator_id string, operator_name string) (string, string) {
- DllDef := syscall.MustLoadDLL("NationECCode.dll")
- readCard := DllDef.MustFindProc("NationEcTrans")
- fmt.Println(readCard)
- fmt.Println("!!!!!")
- pBusiCardInfo := make([]byte, 1024*10)
- 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"
-
- bytesData, _ := json.Marshal(input)
- //gdyb_url := beego.AppConfig.String("gdyb_url")
- fmt.Println(string(bytesData))
- url := "http://10.38.22.15:8081" + "/localcfc/api/hsecfc/localQrCodeQuery"
- ret2, aa, bb := readCard.Call(StrPtr(url), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
- fmt.Println(aa)
- fmt.Println(bb)
-
- fmt.Println(ret2)
- fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
- fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
- if ret2 != 0 {
- return "", ""
- }
- return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
- }
-
- func (c *NmController) TestGetBasBaseInit() {
- 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"] = "tyjk.nm.hsip.gov.cn"
- inputData["PORT"] = 8090
- inputData["TIMEOUT"] = 180
- inputData["LOG_PATH"] = "C:\\log\\"
- //inputData["SFZ_DRIVER_TYPE"] = 0
- inputData["URL"] = "/uif-hsaf-med-api/api/medical/service"
-
- 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 *NmController) GetSFZBaseInfo() string {
- DllDef := syscall.MustLoadDLL("SSCard.dll")
- readCard := DllDef.MustFindProc("ReadSFZ")
- if readCard == nil {
- fmt.Println("readcard is nil")
- readCard = DllDef.MustFindProc("ReadSFZ")
- }
-
- str := make([]byte, 256)
- str1 := make([]byte, 256)
- r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
-
- fmt.Println(r)
- return string(str)
- }
- func (c *NmController) GetBasBaseInfo(fixmedins_code string, mdtrtarea_admvs string, opter_name string, opter_id string, fixmedins_name string) string {
- DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
- readCard := DllDef.MustFindProc("ReadCardBas")
- fmt.Println(readCard)
- fmt.Println("!!!!!")
-
- 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")
-
- msec := time.Now().Format("000")
- timestamp := time.Now().Unix()
-
- tempTime := time.Unix(timestamp, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
-
- inputData := make(map[string]interface{})
- inputData["infno"] = "1199"
- //inputData["msgid"] = "7021"
- inputData["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
- inputData["mdtrtarea_admvs"] = mdtrtarea_admvs
- inputData["insuplc_admdvs"] = "" // 发送方报文 ID
- // 发送方报文 ID
- inputData["recer_sys_code"] = "01"
- inputData["dev_no"] = ""
- inputData["dev_safe_info"] = ""
- inputData["cainfo"] = ""
- inputData["signtype"] = "SM3"
- inputData["infver"] = "V1.0"
- inputData["opter_type"] = "1"
- inputData["opter"] = opter_id
- inputData["opter_name"] = opter_name
- inputData["inf_time"] = timeFormatOne
- inputData["fixmedins_code"] = fixmedins_code
- inputData["fixmedins_name"] = fixmedins_name
- inputData["sign_no"] = ""
-
- bytesData, _ := json.Marshal(inputData)
- fmt.Println(string(bytesData))
- pBusiCardInfo := make([]byte, 8192)
- ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
- fmt.Println(ret2)
- fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
- fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
- if ret2 != 0 {
- return ""
- }
- return DeleteExtraSpace(string(pBusiCardInfo))
- }
- func (c *NmController) GetELeInfo() (string, string) {
- fmt.Println("执行java")
- var json string
- cmd := exec.Command("java", "-jar", "NM_DZPZ.jar", json)
- //fmt.Println(cmd)
- //fmt.Println(cmd.Output())
-
- out, err := cmd.Output()
- if err != nil {
- fmt.Println("error:", err.Error())
- }
- fmt.Println(err)
- fmt.Println(string(out))
- fmt.Println("json:")
- fmt.Println(cmd.Args[0])
- fmt.Println(json)
- fmt.Println(string(json))
- fmt.Println("json:")
-
- results := strings.Split(string(out), "-")
- return results[0], results[1]
-
- }
- 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 *NmController) 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")
-
- baseParams := models.BaseParams{
- SecretKey: secret_key,
- FixmedinsCode: fixmedins_code,
- InsuplcAdmdvs: insuplc_admdvs,
- MdtrtareaAdmvs: mdtrtarea_admvs,
- OrgName: org_name,
- Doctor: doctor,
- }
- businessParams := models.BusinessParams{
- Insutype: insutype,
- ClrType: clrType,
- SetlOptins: setlOptins,
- StmtBegndate: stmtBegndate,
- StmtEnddate: stmtEnddate,
- MedfeeSumamt: medfeeSumamt,
- FundPaySumamt: fundPaySumamt,
- AcctPay: acctPay,
- FixmedinsSetlCnt: fixmedinsSetlCnt,
- }
- result := service.Gdyb3201(baseParams, businessParams)
- saveJsLog(result, "", "3201", "对总账", org_name)
- 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{}{
- "pre": dat,
- })
- }
- func (c *NmController) Get2601() {
- result := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202210111721190000", "2305", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- result2 := service.Gdyb26011("150000CFSJM100000100135084", "H15049901371202209281143070000", "2304", "赤峰费森血液透析中心", "李彩星", "H15049901371", "150402", "150499", "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57\n")
- var dat2 map[string]interface{}
- if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
- fmt.Println(dat2)
- } else {
- fmt.Println(err)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "pre": dat,
- })
- }
|