package coordinate import ( "fmt" "gdyb/controllers" "gdyb/models" "gdyb/service" "gdyb/utils" "github.com/astaxie/beego" "io/ioutil" "encoding/xml" "os" "time" "encoding/json" ) type CoordinatenetController struct { controllers.BaseAuthAPIController } func CoordinatenetRcegistRouters() { ////内蒙古 //beego.Router("/nmg/coordinate/settleAccount", &CoordinatenetController{}, "get:NMGSettleAccount") //beego.Router("/nmg/coordinate/settleAccount/cancel", &CoordinatenetController{}, "get:NMGCancelSettleAccount") beego.Router("/nmg/coordinate/querystock", &CoordinatenetController{}, "get:QueryStock") beego.Router("/nmg/coordinate/patient", &CoordinatenetController{}, "get:NMGpatientinfo") beego.Router("/nmg/coordinate/patienttwo", &CoordinatenetController{}, "get:NMGpatientinfotwo") beego.Router("/nmg/coordinate/del", &CoordinatenetController{}, "post:NMGdelinfo") beego.Router("/nmg/coordinate/upload", &CoordinatenetController{}, "post:NMGuploadinfo") beego.Router("/nmg/coordinate/settle", &CoordinatenetController{}, "post:NMGsettle") } ////删医嘱 //func (c *CoordinateController)NMGdeladvice(){ // patient_id, _ := c.GetInt64("patient_id") // id, _ := c.GetInt64("id") // // // patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id) // result, _ := service.GetNMGHisPatientForCoordinate(0,0,0,patient.Name) // var res Data // if err := json.Unmarshal([]byte(result), &res); err != nil { // utils.ErrorLog("解析失败:%v", err) // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return // } // service.CancleNMGPrescriptionForCoordinate(res.List[0].Acf01,) // //} type ProjectStruct struct { Data []struct { Bbx01 int64 `json:"bbx01"` Bda02 string `json:"bda02"` Bby01 int64 `json:"bby01"` Bbx04 string `json:"bbx04"` Bbx05 string `json:"bbx05"` Bby06 string `json:"bby06"` Bdg02 string `json:"bdg02"` Acf01 int64 `json:"acf01"` Price float64 `json:"price"` Bck01 int64 `json:"bck01"` Lsqty float64 `json:"lsqty"` Bce03a string `json:"bce03a"` Bbx24 string `json:"bbx24"` Bbx25 string `json:"bbx25"` } `json:"data"` } type Medicine struct { Data []struct { Bby01 int `json:"bby01"` Ypmc string `json:"ypmc"` Gg string `json:"gg"` Dw string `json:"dw"` Jhj float64 `json:"jhj"` Pfj float64 `json:"pfj"` Lsj float64 `json:"lsj"` Sysl float64 `json:"sysl"` Ypjx string `json:"ypjx"` Jldw string `json:"jldw"` Sccj string `json:"sccj"` Cd string `json:"cd"` } `json:"data"` } func (c *CoordinatenetController)QueryStock(){ result, _ := service.GetDrugs() result2, _ := service.GetProject() fmt.Println(result) fmt.Println(result2) saveLog(result, "", "查询", "查询", "") saveLog(result2, "", "查询", "查询", "") //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(result2), &dat2); err == nil { // //} else { // //} //c.ServeSuccessJSON(map[string]interface{}{ // "drug": dat, // "project": dat2, //}) } //获取患者信息 func (c *CoordinatenetController) NMGpatientinfo() { name := c.GetString("name") //住院 result, _ := service.GetNMGHisPatientForCoordinate(0,0,2,name) ////门诊 //result1, request1 := service.GetNMGHisPatientForCoordinate(0,0,1,name) saveLog(result, "", "住院查询", "住院查询", "") //saveLog(result1, request1, "门诊查询", "门诊查询", "") 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(result1), &dat2); err == nil { // //} else { // //} c.ServeSuccessJSON(map[string]interface{}{ "res": dat, //"res1": dat2, }) } func (c *CoordinatenetController) NMGpatientinfotwo() { name := c.GetString("name") //住院 //result, request := service.GetNMGHisPatientForCoordinate(0,0,2,name) //门诊 result1, request1 := service.GetNMGHisPatientForCoordinate(0,0,1,name) //saveLog(result, request, "住院查询", "住院查询", "") saveLog(result1, request1, "门诊查询", "门诊查询", "") // //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(result1), &dat2); err == nil { } else { } c.ServeSuccessJSON(map[string]interface{}{ //"res": dat, "res": dat2, }) } type Responsexml1 struct { XMLName xml.Name `xml:"root"` ErrorCode int `xml:"errorcode"` ErrorMsg string `xml:"errormsg"` Data string `xml:"data"` } func (c *CoordinatenetController) NMGdelinfo() { body, _ := ioutil.ReadAll(c.Ctx.Request.Body) var respJSON map[string]interface{} if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil { utils.ErrorLog("接口返回: %v", err) return } //utils.ErrorLog() result, log := service.CancleNMGPrescriptionForCoordinatetwo("0002", respJSON["xmlStr"].(string)) saveLog(result, log, "删除", "删除", "") var res8 Responsexml1 if err2 := xml.Unmarshal([]byte(result), &res8); err2 != nil { fmt.Println(err2) return } if res8.ErrorCode == 0{ c.ServeSuccessJSON(map[string]interface{}{ "msg": "成功", }) }else{ c.ServeSuccessJSON(map[string]interface{}{ "msg": res8.ErrorMsg , }) } } func (c *CoordinatenetController) NMGuploadinfo() { 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 } result, request := service.UploadNMGPrescriptionForCoordinatetwo("0001", respJSON["xmlStr"].(string)) saveLog(result, request, "上传", "上传", "") var res3 Responsexml if err2 := xml.Unmarshal([]byte(result), &res3); err2 != nil { fmt.Println(err2) } if res3.ErrorCode == 0{ c.ServeSuccessJSON(map[string]interface{}{ "res": res3.Data, "msg": "成功", }) }else{ c.ServeSuccessJSON(map[string]interface{}{ "msg": res3.ErrorMsg , "res": "", }) } } func (c *CoordinatenetController) NMGsettle() { //xmlStr := c.GetString("xmlStr") 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["info"]) var info models.UploadInfo if err := json.Unmarshal(userJSONBytes, &info); err != nil { utils.ErrorLog("解析失败:%v", err) return } result, request := service.NMGSettleForCoordinate(info) var dat map[string]interface{} if err := json.Unmarshal([]byte(result), &dat); err == nil { } else { } saveLog(result, request, "记账", "记账", "") c.ServeSuccessJSON(map[string]interface{}{ "res": dat, }) } //func (c *CoordinateController)NMGgetcheck(){ // patient_id, _ := c.GetInt64("patient_id") // record_date := c.GetString("record_date") // admin_user_id, _ := c.GetInt64("admin_user_id") // //diagnosis_id := c.GetString("diagnosis") // //sick_type, _ := c.GetInt64("sick_type") // //reg_type, _ := c.GetInt64("p_type") // org_id, _ := c.GetInt64("org_id") // org_id = 10454 // org, _ := service.GetOrgById(org_id) // patient, _ := service.GetPatientByID(org.Id, patient_id) // settle_accounts_type, _ := c.GetInt64("settle_accounts_type") // result, request := service.GetNMGHisPatientForCoordinate(0,0,2,patient.Name) // result5, request5 := service.GetNMGHisPatientForCoordinate(0,0,1,patient.Name) // // saveLog(result, request, "查询", "查询", "") // saveLog(result5, request5, "查询", "查询", "") // // var res Data // if err := json.Unmarshal([]byte(result), &res); err != nil { // utils.ErrorLog("解析失败:%v", err) // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return // } // // var res8 Data // if err := json.Unmarshal([]byte(result5), &res8); err != nil { // utils.ErrorLog("解析失败:%v", err) // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return // } // // if res.Code == 200 || res8.Code == 200 { // var res9 Data // res9.List = append(res9.List,res.List...) // res9.List = append(res9.List,res8.List...) // // // var li ListItem // for _, item := range res9.List{ // cure_date := strings.Split(item.Vae11, " ") // if cure_date[0] == record_date && patient.Name == item.Vaa05{ // li = item // } // } // fmt.Println("11111111") // fmt.Println(li) // fmt.Println("11111111") // timeLayout := "2006-01-02" // loc, _ := time.LoadLocation("Local") // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc) // if err != nil { // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) // return // } // org_id := org.Id // recordDateTime := theTime.Unix() // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2) // if patientPrescription.ID == 0 { // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime) // } // //departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments) // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id) // //doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId) // // // // // //service.QueryNMGChenckForCoordinate(li.Acf01,li.Vaa01,li.Vaa07,"") // // // } else { // c.ServeSuccessJSON(map[string]interface{}{ // "failed_code": -10, // "msg": res.Msg, // }) // } // // //} //func (c *CoordinateController) SettleAccount() { // patient_id, _ := c.GetInt64("patient_id") // record_date := c.GetString("record_date") // admin_user_id, _ := c.GetInt64("admin_user_id") // diagnosis_id := c.GetString("diagnosis") // sick_type, _ := c.GetInt64("sick_type") // reg_type, _ := c.GetInt64("p_type") // org_id, _ := c.GetInt64("org_id") // org_id = 3877 // org, _ := service.GetOrgById(org_id) // patient, _ := service.GetPatientByID(org.Id, patient_id) // settle_accounts_type, _ := c.GetInt64("settle_accounts_type") // // result, request := service.GetHisPatientForCoordinate(patient.IdCardNo) // saveLog(result, request, "查询", "查询", org.OrgName) // var res ResultQuery // if err := json.Unmarshal([]byte(result), &res); err != nil { // utils.ErrorLog("解析失败:%v", err) // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return // } // if res.Code == "10000" { // if len(res.Result) == 0 { // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientNoRegException) // return // } // timeLayout := "2006-01-02" // loc, _ := time.LoadLocation("Local") // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc) // if err != nil { // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) // return // } // org_id := org.Id // recordDateTime := theTime.Unix() // patientPrescription, _ := service.FindPatientPrescriptionInfoTwo(org_id, patient.ID, recordDateTime, 2) // if patientPrescription.ID == 0 { // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(org_id, patient.ID, recordDateTime) // } // departmwnt, _ := service.GetDepartMentDetail(patientPrescription.Departments) // doctor_info, _ := service.GetAdminUserInfoByID(org_id, patientPrescription.DoctorId) // //admin_user_info, _ := service.GetAdminUserInfoByID(org_id, admin_user_id) // // var prescriptions []*models.HisPrescription // // if settle_accounts_type == 1 { //日结 // prescriptions, _ = service.GetUnSettleHisPrescriptionFive(org_id, patient_id, recordDateTime, 2) // } else { //月结 // // start_time_str := c.GetString("start_time") // end_time_str := c.GetString("end_time") // timeLayout := "2006-01-02" // loc, _ := time.LoadLocation("Local") // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc) // if err != nil { // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) // return // } // recordStartTime := theStartTime.Unix() // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc) // if err != nil { // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong) // return // } // recordEndTime := theEndTime.Unix() // prescriptions, _ = service.GetUnSettleMonthHisPrescription(org_id, patient_id, recordStartTime, recordEndTime) // } // var total float64 // // for _, item := range prescriptions { // fmt.Println(item) // if item.Type == 1 { //药品 // for _, subItem := range item.HisDoctorAdviceInfo { // total = total + (subItem.Price * subItem.PrescribingNumber) // } // } // if item.Type == 2 { //项目 // for _, subItem := range item.HisPrescriptionProject { // cnt, _ := strconv.ParseFloat(subItem.Count, 64) // total = total + (subItem.Price * cnt) // } // } // // } // // var ids []int64 // // for _, item := range prescriptions { // ids = append(ids, item.ID) // } // // var customs []*models.NewCustomTwo // for _, item := range prescriptions { // if item.Type == 1 { //药品 // for _, subItem := range item.HisDoctorAdviceInfo { // cus := &models.NewCustomTwo{ // AdviceId: subItem.ID, // ProjectId: 0, // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber), // Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber), // FeedetlSn: subItem.FeedetlSn, // Price: fmt.Sprintf("%.2f", subItem.Price), // MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber, // Type: 1, // } // customs = append(customs, cus) // } // } // if item.Type == 2 { //项目 // for _, subItem := range item.HisPrescriptionProject { // if subItem.Type == 2 { // cnt, _ := strconv.ParseFloat(subItem.Count, 64) // cus := &models.NewCustomTwo{ // AdviceId: 0, // ProjectId: subItem.ID, // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt), // Cut: fmt.Sprintf("%.4f", cnt), // FeedetlSn: subItem.FeedetlSn, // Price: fmt.Sprintf("%.4f", float64(subItem.Price)), // MedListCodg: subItem.HisProject.MedicalCode, // Type: 2, // } // customs = append(customs, cus) // // } else { // cnt, _ := strconv.ParseFloat(subItem.Count, 64) // cus := &models.NewCustomTwo{ // AdviceId: 0, // ProjectId: subItem.ID, // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt), // Cut: fmt.Sprintf("%.4f", cnt), // FeedetlSn: subItem.FeedetlSn, // Price: fmt.Sprintf("%.4f", float64(subItem.Price)), // MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber, // Type: 3, // } // customs = append(customs, cus) // } // // } // } // } // // var info models.UploadInfo // info.Vaa01 = int64(res.Result[0].Vaa01) // info.Fasong = "1" // info.Vaa07 = int64(res.Result[0].Vaa07) // info.Bck01c = departmwnt.Number // info.Bce02a = doctor_info.DoctorNumber // // diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",") // var config []*models.HisXtDiagnoseConfig // for _, item := range diagnosis_ids { // id, _ := strconv.ParseInt(item, 10, 64) // diagnosisConfig, _ := service.FindDiagnoseById(id) // config = append(config, &diagnosisConfig) // } // for index, item := range config { // var diag models.Diag // diag.Vao06 = strconv.FormatInt(int64(index+1), 10) // diag.Bak02 = item.CountryCode // info.Diag = append(info.Diag, &diag) // } // var presInfos []*models.PresInfo // var presDetails []*models.PresDetail // for index, item := range prescriptions { // var presDetail models.PresDetail // var presInfo models.PresInfo // presInfo.Cbmid = strconv.FormatInt(item.ID, 10) // if item.Type == 1 { // presInfo.Cbm06 = "0" // } else { // presInfo.Cbm06 = "5" // } // // if item.Type == 1 { // presInfo.Cbm07 = item.MedType // } else { // presInfo.Cbm07 = item.MedType // } // // presDetail.Vaf59 = strconv.FormatInt(int64(index+1), 10) // var infoItems []*models.Item // for _, subItem := range item.HisDoctorAdviceInfo { // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId) // // var infoItem models.Item // infoItem.Rownr = "0" // infoItem.Vaf11 = "1" // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05") // infoItem.Bbx01 = subItem.BaseDrugLib.MedicalInsuranceNumber // infoItem.Bda01 = "1" // infoItem.Bby01 = "" // if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit { // infoItem.Vaf22 = subItem.BaseDrugLib.DrugName + " " + subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit // } // infoItem.Vaf14 = subItem.BaseDrugLib.DrugName // infoItem.Bdi01 = ef.Code // infoItem.Vaf17 = strconv.FormatInt(subItem.Day, 10) // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose) // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.PrescribingNumber) // infoItem.Vaf35 = "0" // infoItem.Vaf32 = "0" // infoItem.Bck01b = departmwnt.Number // infoItem.Bck01d = departmwnt.Number // infoItem.Vaf58 = "0" // infoItem.Vaf61 = "1" // infoItems = append(infoItems, &infoItem) // } // for _, subItem := range item.HisPrescriptionProject { // ef, _ := service.GetExecutionFrequencyByName(subItem.ExecutionFrequency, subItem.UserOrgId) // // if subItem.Type == 2 { // var infoItem models.Item // infoItem.Rownr = "0" // infoItem.Vaf11 = "1" // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05") // infoItem.Bbx01 = subItem.HisProject.MedicalCode // // if subItem.HisProject.CostClassify == 2 { // infoItem.Bda01 = "T" // } else if subItem.HisProject.CostClassify == 3 { // infoItem.Bda01 = "L" // } else { // infoItem.Bda01 = "T" // } // infoItem.Bby01 = "" // infoItem.Vaf22 = subItem.HisProject.ProjectName // infoItem.Bdi01 = ef.Code // infoItem.Vaf17 = subItem.Day // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose) // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count) // infoItem.Vaf35 = "0" // infoItem.Vaf18 = "0" // infoItem.Vaf32 = "0" // infoItem.Bck01b = departmwnt.Number // infoItem.Bck01d = departmwnt.Number // infoItem.Vaf58 = "0" // infoItem.Vaf61 = "1" // infoItems = append(infoItems, &infoItem) // // } else { // var infoItem models.Item // infoItem.Rownr = "0" // infoItem.Vaf11 = "1" // infoItem.Vaf36 = time.Unix(subItem.ExecutionTime, 0).Format("2006-01-02 15:04:05") // infoItem.Bbx01 = subItem.GoodInfo.MedicalInsuranceNumber // infoItem.Bda01 = "M" // infoItem.Bby01 = "" // infoItem.Vaf22 = subItem.GoodInfo.GoodName + " " + subItem.GoodInfo.SpecificationName // infoItem.Bdi01 = ef.Code // infoItem.Vaf17 = subItem.Day // infoItem.Vaf20 = fmt.Sprintf("%.2f", subItem.SingleDose) // infoItem.Vaf21 = fmt.Sprintf("%.2f", subItem.Count) // infoItem.Vaf35 = "0" // infoItem.Vaf32 = "0" // infoItem.Bck01b = departmwnt.Number // infoItem.Bck01d = departmwnt.Number // infoItem.Vaf58 = "0" // infoItem.Vaf61 = "1" // infoItems = append(infoItems, &infoItem) // // } // // } // presDetail.Item = infoItems // presDetails = append(presDetails, &presDetail) // presInfo.PresDetail = presDetails // presInfos = append(presInfos, &presInfo) // } // info.PresInfo = presInfos // // result2, request2 := service.UploadPrescriptionForCoordinate(info) // saveLog(result2, request2, "上传明细", "上传明细", org.OrgName) // // var res2 ResultUpload // if err := json.Unmarshal([]byte(result2), &res2); err != nil { // utils.ErrorLog("解析失败:%v", err) // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException) // return // } // if res2.Code == "10000" { // // timestamp := time.Now().Unix() // tempTime := time.Unix(timestamp, 0) // timeFormat := tempTime.Format("20060102150405") // chrgBchno := rand.Intn(100000) + 10000 // ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(patient.ID, 10) // his := models.VMHisPatient{ // Name: patient.Name, // Gender: patient.Gender, // Birthday: patient.Birthday, // MedicalTreatmentType: 0, // IdType: 1, // IdCardNo: patient.IdCardNo, // BalanceAccountsType: 1, // MedicalInsuranceNumber: "", // RegisterType: 0, // RegisterCost: 0, // TreatmentCost: 0, // Status: 1, // Ctime: time.Now().Unix(), // Mtime: time.Now().Unix(), // PsnNo: strconv.FormatInt(int64(res.Result[0].Vaa01), 10), // PsnCertType: "", // Certno: patient.IdCardNo, // PsnName: patient.Name, // Gend: "", // Naty: "", // Brdy: "", // Age: 0, // Iinfo: "", // Idetinfo: "", // PatientId: patient.ID, // RecordDate: theTime.Unix(), // UserOrgId: org_id, // AdminUserId: admin_user_id, // IsReturn: 1, // Doctor: patientPrescription.DoctorId, // Departments: patientPrescription.Departments, // IptOtpNo: ipt_otp_no, // Number: strconv.FormatInt(int64(res.Result[0].Vaa07), 10), // PhoneNumber: patient.Phone, // } // service.UpdateHisPatientStatusten(&his) // service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, org_id) // tm := time.Unix(time.Now().Unix(), 0) // // order := &models.HisOrder{ // PsnNo: his.PsnNo, // UserOrgId: org_id, // HisPatientId: his.ID, // PatientId: patient_id, // SettleAccountsDate: recordDateTime, // Ctime: time.Now().Unix(), // Mtime: time.Now().Unix(), // Status: 1, // OrderStatus: 1, // MdtrtId: his.Number, // Number: ipt_otp_no, // SetlId: "", // MedfeeSumamt: total, // MedType: strconv.Itoa(int(reg_type)), // SettleEndTime: 0, // SettleStartTime: 0, // SettleType: settle_accounts_type, // Diagnosis: diagnosis_id, // PType: 2, // SetlTime: tm.Format("2006-01-02 15:04:05"), // } // err = service.CreateOrder(order) // if err != nil { // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException) // return // } // // for _, item := range customs { // var advice_id int64 = 0 // var project_id int64 = 0 // var item_id int64 = 0 // // var types int64 = 0 // // if item.Type == 1 { // advice_id = item.AdviceId // project_id = 0 // item_id = 0 // } else if item.Type == 2 { // advice_id = 0 // item_id = 0 // // project_id = item.ProjectId // } else if item.Type == 3 { // advice_id = 0 // item_id = item.ItemId // project_id = 0 // } // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32) // cut, _ := strconv.ParseFloat(item.Cut, 32) // pric, _ := strconv.ParseFloat(item.Price, 32) // info := &models.HisOrderInfo{ // OrderNumber: order.Number, // UploadDate: time.Now().Unix(), // AdviceId: advice_id, // DetItemFeeSumamt: detItemFeeSumamt, // Cnt: cut, // Pric: pric, // PatientId: patient_id, // Status: 1, // Mtime: time.Now().Unix(), // Ctime: time.Now().Unix(), // UserOrgId: org_id, // HisPatientId: his.ID, // OrderId: order.ID, // ProjectId: project_id, // Type: types, // ItemId: item_id, // } // service.CreateOrderInfo(info) // } // his.Diagnosis = diagnosis_id // his.SickType = sick_type // his.RegisterType = reg_type // his.MedicalTreatmentType = reg_type // service.UpdataHisPateintTwo(&his) // err = service.UpDatePrescriptionNumber(org_id, ids, strconv.FormatInt(int64(chrgBchno), 10)) // err = service.UpDateHisPrescriptionInfoNumbertwo(org_id, patient_id, strconv.FormatInt(int64(chrgBchno), 10), recordDateTime, his.ID) // err = service.UpdataOrderStatusThreef(strconv.FormatInt(int64(chrgBchno), 10), org_id) // // c.ServeSuccessJSON(map[string]interface{}{ // "msg": "医嘱保存成功", // }) // // } else { // c.ServeSuccessJSON(map[string]interface{}{ // "failed_code": -10, // "msg": res.Msg, // }) // // } // // } else { // c.ServeSuccessJSON(map[string]interface{}{ // "failed_code": -10, // "msg": res.Msg, // }) // // } // //} //func saveLog(result string, request string, infno string, desc string) { // // org_id, _ := beego.AppConfig.Int64("org_id") // miConfig, _ := service.FindMedicalInsuranceInfo(org_id) // dir := miConfig.OrgName + "日志" // 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 := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log" // file_name := file + ".txt" // file_path := miConfig.OrgName + "日志" + "/" + 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(miConfig.OrgName + "日志" + "/" + file_name) // defer f.Close() // if err != nil { // } else { // _, err = f.Write([]byte("记录日志")) // } // } // //} type Charset string const ( UTF8 = Charset("UTF-8") GB18030 = Charset("GB18030") ) func saveLog(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("记录日志")) } } }