package service import ( "bytes" "encoding/json" "fmt" "gdyb/models" "gdyb/utils" "github.com/astaxie/beego" "github.com/robfig/cron" "io/ioutil" "math/rand" "net/http" "strconv" "time" ) type ResultSix struct { Cainfo interface{} `json:"cainfo"` ErrMsg string `json:"err_msg"` InfRefmsgid string `json:"inf_refmsgid"` Infcode int64 `json:"infcode"` Output struct { } `json:"output"` RefmsgTime string `json:"refmsg_time"` RespondTime string `json:"respond_time"` Signtype interface{} `json:"signtype"` WarnMsg interface{} `json:"warn_msg"` } type ResultSix10265 struct { Cainfo interface{} `json:"cainfo"` ErrMsg string `json:"err_msg"` InfRefmsgid string `json:"inf_refmsgid"` Infcode string `json:"infcode"` Output struct { } `json:"output"` RefmsgTime string `json:"refmsg_time"` RespondTime string `json:"respond_time"` Signtype interface{} `json:"signtype"` WarnMsg interface{} `json:"warn_msg"` } // cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html var createWeekSchedulesCronJob *cron.Cron func init() { utils.InfoLog("开启自动排班定时任务") createWeekSchedulesCronJob = cron.New() spec := "0 0 18 * * ?" // 每天6点上传当天数据 //spec := "0 */1 * * * ?" createWeekSchedulesCronJob.AddFunc(spec, func() { AutoCreateStock() }) } func BeginAutoCreateWeekSchedulesJob() { createWeekSchedulesCronJob.Start() } func AutoCreateStock() { org_id, _ := beego.AppConfig.Int64("org_id") var NewWarehousing []*models.NewWarehousingInfo var NewWarehouseOut []*models.NewWarehouseOutInfo var NewCancelStock []*models.NewCancelStockInfo var NewDrugWarehouse []*models.NewDrugWarehouseInfo var NewDrugWarehouseOut []*models.NewDrugWarehouseOutInfo var NewDrugCancelStock []*models.NewDrugCancelStockInfo var XtDrugInventorys []*models.XtDrugInventory var NewDrugWarehouseOutTwo []*models.NewDrugWarehouseOutInfo //var XtDrugInventorys2 []*models.XtDrugInventory //readDb.Model(&models.XtDrugInventory{}).Where("user_org_id = ? and status = 1 and is_upload <> 1 AND stock_max_number > 0", org_id).Preload("BaseDrugLib", "status = 1").Find(&XtDrugInventorys) //readDb.Model(&models.NewWarehousingInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).First(&NewWarehousing) //readDb.Model(&models.NewWarehouseOutInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewWarehouseOut) //readDb.Model(&models.NewCancelStockInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewCancelStock) ////大丰 //readDb.Model(&models.NewDrugWarehouseInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1 AND id >= 4778", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouse) //readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1 AND id >= 360136", org_id).Preload("NewDrugWarehouseInfo","status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOut) //readDb.Model(&models.NewDrugCancelStockInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugCancelStock) //响水 //readDb.Model(&models.NewDrugWarehouseInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1 AND id >= 5720", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouse) //readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1 AND id >= 366003", org_id).Preload("NewDrugWarehouseInfo","status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOut) //readDb.Model(&models.NewDrugCancelStockInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1 ", org_id).Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugCancelStock) //3502 //readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload = 1 ", org_id).Preload("NewDrugWarehouseInfo","status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOut) //3502 readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload = 1 ", org_id).Preload("NewDrugWarehouseInfo", "status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOutTwo) for _, item := range XtDrugInventorys { res := Post3501ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewDrugWarehouseOutTwo { res := Post3502ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewWarehousing { res := Post3503ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewWarehousingInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewWarehouseOut { res := Post3505ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewWarehouseOutInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewCancelStock { res := Post3506ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewCancelStockInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewDrugWarehouse { res := Post3503ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewDrugWarehouseInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewDrugWarehouseOut { res := Post3505ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } } for _, item := range NewDrugCancelStock { res := Post3506ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewDrugCancelStockInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } } func AutoGdybCreateStock() { org_id, _ := beego.AppConfig.Int64("org_id") var NewWarehousing []*models.NewWarehousingInfo var NewWarehouseOut []*models.NewWarehouseOutInfo var NewCancelStock []*models.NewCancelStockInfo var NewDrugWarehouse []*models.NewDrugWarehouseInfo var NewDrugWarehouseOut []*models.NewDrugWarehouseOutInfo var NewDrugCancelStock []*models.NewDrugCancelStockInfo var XtDrugInventorys []*models.XtDrugInventory var XtStockInventorys []*models.XtStockInventoryTwo var NewDrugWarehouseOutTwo []*models.NewDrugWarehouseOutInfo readDb.Model(&models.NewWarehousingInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).First(&NewWarehousing) readDb.Model(&models.NewCancelStockInfo{}).Where("org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewCancelStock) //3501,药品和耗材 readDb.Model(&models.XtDrugInventory{}).Where("user_org_id = ? and status = 1 and is_upload <> 1 AND stock_max_number > 0", org_id).Preload("BaseDrugLib", "status = 1").Find(&XtDrugInventorys) readDb.Model(&models.XtStockInventoryTwo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1 ", org_id).Preload("GoodInfo", "status = 1").Find(&XtStockInventorys) for _, item := range XtDrugInventorys { res := Post3501ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range XtStockInventorys { res := Post3501ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } //3502 readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload = 1 ", org_id).Preload("NewDrugWarehouseInfo", "status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOutTwo) //readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("org_id = ? and status = 1 and is_upload = 1 ", org_id).Preload("NewDrugWarehouseInfo", "status = 1").Preload("BaseDrugLib", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewDrugWarehouseOutTwo) readDb.Model(&models.NewWarehouseOutInfo{}).Where("user_org_id = ? and status = 1 and is_upload <> 1", org_id).Preload("GoodInfo", "status = 1").Preload("Manufacturers", "status = 1 AND org_id = ?", org_id).Preload("Dealers", "status = 1 AND org_id = ?", org_id).Find(&NewWarehouseOut) for _, item := range NewDrugWarehouseOutTwo { res := Post3502ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewWarehouseOut { res := Post3502ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.XtDrugInventory{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } //3503 for _, item := range NewWarehousing { res := Post3503ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewWarehousingInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewDrugWarehouse { res := Post3503ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewDrugWarehouseInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } //3505 for _, item := range NewWarehouseOut { res := Post3505ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewWarehouseOutInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewDrugWarehouseOut { res := Post3505ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } } //3506 for _, item := range NewCancelStock { res := Post3506ForGoodInfo(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewCancelStockInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } for _, item := range NewDrugCancelStock { res := Post3506ForDrug(org_id, item) if res.Infcode == 0 { writeDb.Model(&models.NewDrugCancelStockInfo{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ "is_upload": 1, }) } else { continue } } } //耗材库盘上传 func Post3501ForGoodInfo(org_id int64, infos *models.XtStockInventoryTwo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3501s []models.Struct3501 var struct3501 models.Struct3501 struct3501.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber struct3501.FixmedinsHilistId = miConfig.Code struct3501.FixmedinsHilistName = miConfig.OrgName struct3501.FixmedinsBchno = infos.Number struct3501.RxFlag = "0" struct3501.Invdate = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") struct3501.OrgName = miConfig.OrgName struct3501.AccessKey = miConfig.AccessKey struct3501.RequestUrl = miConfig.Url struct3501.SecretKey = miConfig.SecretKey struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3501.InvCnt = strconv.FormatInt(infos.Count, 10) struct3501.ManuDate = time.Unix(infos.WarehousingInfo.ProductDate, 0).Format("2006-01-02 15:04:05") struct3501.ExpyEnd = time.Unix(infos.WarehousingInfo.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3501s = append(struct3501s, struct3501) data["struct_3501s"] = struct3501s[0] client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3501(struct3501, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } //药品库盘上传 func Post3501ForDrug(org_id int64, infos *models.XtDrugInventory) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3501s []models.Struct3501 var struct3501 models.Struct3501 struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber struct3501.FixmedinsHilistId = miConfig.Code struct3501.FixmedinsHilistName = miConfig.OrgName struct3501.FixmedinsBchno = infos.BatchNumber struct3501.FixmedinsCode = miConfig.Code struct3501.RxFlag = "0" struct3501.Invdate = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") struct3501.OrgName = miConfig.OrgName struct3501.AccessKey = miConfig.AccessKey struct3501.RequestUrl = miConfig.Url struct3501.SecretKey = miConfig.SecretKey struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3501.InvCnt = strconv.FormatInt(infos.StockMaxNumber, 10) struct3501.ManuDate = time.Unix(infos.DrugWarehouseInfo.ProductDate, 0).Format("2006-01-02 15:04:05") struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3501s = append(struct3501s, struct3501) data["struct_3501s"] = struct3501s[0] client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3501(struct3501, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } //商品库存变更 func Post3502ForDrug(org_id int64, infos *models.NewDrugWarehouseOutInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) //var struct3502s []models.Struct3502 var struct3502 models.Struct3502 struct3502.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber struct3502.FixmedinsHilistId = miConfig.Code struct3502.FixmedinsHilistName = miConfig.OrgName struct3502.FixmedinsBchno = infos.NewDrugWarehouseInfo.BatchNumber struct3502.FixmedinsCode = miConfig.Code struct3502.RxFlag = "0" struct3502.InvChgTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") struct3502.OrgName = miConfig.OrgName struct3502.AccessKey = miConfig.AccessKey struct3502.RequestUrl = miConfig.Url struct3502.SecretKey = miConfig.SecretKey struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3502.InvChgType = "102" struct3502.Cnt = strconv.FormatInt(infos.Count, 10) struct3502.Pric = fmt.Sprintf("%.2f", infos.BaseDrugLib.RetailPrice) data["struct_3502s"] = struct3502 client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3502(struct3502, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3502", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } func Post3502ForGoodInfo(org_id int64, infos *models.NewWarehouseOutInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) //var struct3502s []models.Struct3502 var struct3502 models.Struct3502 struct3502.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber struct3502.FixmedinsHilistId = miConfig.Code struct3502.FixmedinsHilistName = miConfig.OrgName struct3502.FixmedinsBchno = infos.WarehousingInfo.Number struct3502.FixmedinsCode = miConfig.Code struct3502.RxFlag = "0" struct3502.InvChgTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") struct3502.OrgName = miConfig.OrgName struct3502.AccessKey = miConfig.AccessKey struct3502.RequestUrl = miConfig.Url struct3502.SecretKey = miConfig.SecretKey struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3502.InvChgType = "102" struct3502.Cnt = strconv.FormatInt(infos.Count, 10) struct3502.Pric = fmt.Sprintf("%.2f", infos.GoodInfo.RetailPrice) data["struct_3502s"] = struct3502 client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3502(struct3502, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3502", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3502", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } //采购 func Post3503ForGoodInfo(org_id int64, infos *models.NewWarehousingInfo) ResultSix { fmt.Println(&infos) var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3503s []models.Struct3503 var struct3503 models.Struct3503 struct3503.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber struct3503.FixmedinsHilistId = miConfig.Code struct3503.FixmedinsCode = miConfig.Code struct3503.FixmedinsHilistName = miConfig.OrgName struct3503.FixmedinsBchno = infos.Number var d models.Dealers readDb.Model(&models.Dealers{}).Where("id = ?", infos.Dealer).First(&d) if d.ID == 0 { struct3503.SplerName = infos.Manufacturers.ManufacturerName } else { struct3503.SplerName = d.DealerName } struct3503.ManuLotnum = infos.Number struct3503.ProdentpName = infos.Manufacturers.ManufacturerName struct3503.Aprvno = infos.GoodInfo.Number struct3503.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02") struct3503.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02") struct3503.PurcRetnCnt = strconv.FormatInt(infos.TotalCount, 10) struct3503.RxFlag = "0" struct3503.PurcRetnStoinTime = time.Unix(infos.Ctime, 0).Format("2006-01-02") if org_id == 10217 { struct3503.PurcRetnOpterName = "施实芹" } else { struct3503.PurcRetnOpterName = "" } struct3503.OrgName = miConfig.OrgName struct3503.AccessKey = miConfig.AccessKey struct3503.RequestUrl = miConfig.Url struct3503.SecretKey = miConfig.SecretKey struct3503.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3503.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3503.Memo = "" struct3503s = append(struct3503s, struct3503) data["struct_3503s"] = struct3503s[0] client := &http.Client{} bytesData, _ := json.Marshal(data) fmt.Println(string(bytesData)) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3503(struct3503, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3503", bytes.NewReader(bytesData)) } else { fmt.Println("111111") req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3503", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } func Post3503ForDrug(org_id int64, infos *models.NewDrugWarehouseInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3503s []models.Struct3503 var struct3503 models.Struct3503 struct3503.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber struct3503.FixmedinsHilistId = miConfig.Code struct3503.FixmedinsHilistName = miConfig.OrgName struct3503.FixmedinsBchno = infos.BatchNumber var d models.Dealers readDb.Model(&models.Dealers{}).Where("id = ?", infos.Dealer).First(&d) struct3503.SplerName = d.DealerName struct3503.ManuLotnum = infos.BatchNumber struct3503.ProdentpName = infos.Manufacturers.ManufacturerName struct3503.Aprvno = infos.BaseDrugLib.Number struct3503.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05") struct3503.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3503.PurcRetnCnt = strconv.FormatInt(infos.WarehousingCount, 10) struct3503.RxFlag = "0" struct3503.PurcRetnStoinTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") if org_id == 10217 { struct3503.PurcRetnOpterName = "施实芹" } else { struct3503.PurcRetnOpterName = "顾林玲" } struct3503.OrgName = miConfig.OrgName struct3503.AccessKey = miConfig.AccessKey struct3503.RequestUrl = miConfig.Url struct3503.SecretKey = miConfig.SecretKey struct3503.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3503.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3503.Memo = "" struct3503s = append(struct3503s, struct3503) data["struct_3503s"] = struct3503s[0] client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3503(struct3503, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3503", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3503", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } //销售 func Post3505ForGoodInfo(org_id int64, infos *models.NewWarehouseOutInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3501s []models.Struct3505 var struct3501 models.Struct3505 struct3501.OrgName = miConfig.OrgName struct3501.AccessKey = miConfig.AccessKey struct3501.RequestUrl = miConfig.Url struct3501.SecretKey = miConfig.SecretKey struct3501.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber struct3501.FixmedinsHilistId = miConfig.Code struct3501.FixmedinsHilistName = miConfig.OrgName struct3501.FixmedinsBchno = infos.Number if org_id == 10188 { struct3501.PrscDrName = "王曙光" struct3501.PharName = "王曙光" struct3501.PharPracCertNo = "" } else if org_id == 10217 { struct3501.PrscDrName = "王云刚" struct3501.PharName = "王云刚" struct3501.PharPracCertNo = "" } 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) struct3501.MdtrtSn = ipt_otp_no struct3501.ManuLotnum = infos.Number struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05") struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3501.RxFlag = "0" struct3501.TrdnFlag = "1" struct3501.RtalDocno = strconv.FormatInt(int64(infos.ID), 10) struct3501.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10) struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") struct3501.SelRetnOpterName = "仓管员" struct3501s = append(struct3501s, struct3501) data["struct_3501s"] = struct3501s client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3505(struct3501, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3501", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } func Post3505ForDrug(org_id int64, infos *models.NewDrugWarehouseOutInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3505s []models.Struct3505 var struct3505 models.Struct3505 struct3505.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber struct3505.FixmedinsHilistId = miConfig.Code struct3505.FixmedinsHilistName = miConfig.OrgName struct3505.FixmedinsBchno = infos.NewDrugWarehouseInfo.BatchNumber struct3505.FixmedinsCode = miConfig.Code struct3505.OrgName = miConfig.OrgName struct3505.AccessKey = miConfig.AccessKey struct3505.RequestUrl = miConfig.Url struct3505.SecretKey = miConfig.SecretKey struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3505.FixmedinsBchno = infos.NewDrugWarehouseInfo.BatchNumber if org_id == 10188 { struct3505.PrscDrName = "王曙光" struct3505.PharName = "顾林玲" struct3505.PharPracCertNo = "K0404020449" } else if org_id == 10217 { struct3505.PrscDrName = "王云刚" struct3505.PharName = "施实芹" struct3505.PharPracCertNo = "1532050832051512010002" } 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) struct3505.MdtrtSn = ipt_otp_no struct3505.ManuLotnum = infos.NewDrugWarehouseInfo.BatchNumber struct3505.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05") //struct3505.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3505.RxFlag = "0" struct3505.TrdnFlag = "1" struct3505.RtalDocno = strconv.FormatInt(int64(infos.ID), 10) struct3505.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10) struct3505.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") if org_id == 10188 { struct3505.SelRetnOpterName = "孙欣欣" } else if org_id == 10217 { struct3505.SelRetnOpterName = "晁海燕" } struct3505s = append(struct3505s, struct3505) data["struct_3505s"] = struct3505s[0] client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3505(struct3505, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3505", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3505", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } //销售退货 func Post3506ForGoodInfo(org_id int64, infos *models.NewCancelStockInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3506s []models.Struct3506 var struct3506 models.Struct3506 struct3506.OrgName = miConfig.OrgName struct3506.AccessKey = miConfig.AccessKey struct3506.RequestUrl = miConfig.Url struct3506.SecretKey = miConfig.SecretKey struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3506.MedListCodg = infos.GoodInfo.MedicalInsuranceNumber struct3506.FixmedinsHilistId = miConfig.Code struct3506.FixmedinsHilistName = miConfig.OrgName struct3506.FixmedinsBchno = infos.Number struct3506.ManuLotnum = infos.Number struct3506.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05") //struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3506.RxFlag = "0" struct3506.TrdnFlag = "1" struct3506.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10) struct3506.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") //struct3506.SelRetnOpterName = "仓管员" if org_id == 10188 { struct3506.SelRetnOpterName = "孙欣欣" } else if org_id == 10217 { struct3506.SelRetnOpterName = "晁海燕" } struct3506.Memo = "" struct3506s = append(struct3506s, struct3506) data["struct_3506s"] = struct3506s client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3506(struct3506, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3506", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } } func Post3506ForDrug(org_id int64, infos *models.NewDrugCancelStockInfo) ResultSix { var res ResultSix miConfig, _ := FindMedicalInsuranceInfo(org_id) data := make(map[string]interface{}) var struct3506s []models.Struct3506 var struct3506 models.Struct3506 struct3506.FixmedinsCode = miConfig.Code struct3506.OrgName = miConfig.OrgName struct3506.AccessKey = miConfig.AccessKey struct3506.RequestUrl = miConfig.Url struct3506.SecretKey = miConfig.SecretKey struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs struct3506.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber struct3506.FixmedinsHilistId = miConfig.Code struct3506.FixmedinsHilistName = miConfig.OrgName struct3506.FixmedinsBchno = infos.BatchNumber struct3506.ManuLotnum = infos.BatchNumber struct3506.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05") //struct3501.ExpyEnd = time.Unix(infos.ExpiryDate, 0).Format("2006-01-02 15:04:05") struct3506.RxFlag = "0" struct3506.TrdnFlag = "1" struct3506.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10) struct3506.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05") //struct3506.SelRetnOpterName = "仓管员" if org_id == 10188 { struct3506.SelRetnOpterName = "孙欣欣" } else if org_id == 10217 { struct3506.SelRetnOpterName = "晁海燕" } struct3506.Memo = "" struct3506s = append(struct3506s, struct3506) data["struct_3506s"] = struct3506s[0] client := &http.Client{} bytesData, _ := json.Marshal(data) var req *http.Request if miConfig.UserOrgId == 10215 { result := Gdyb3506(struct3506, miConfig.SecretKey) 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) if err := json.Unmarshal(userJSONBytes, &res); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } return res } else { if miConfig.MdtrtareaAdmvs == "320921" { req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3506", bytes.NewReader(bytesData)) } else { req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3506", bytes.NewReader(bytesData)) } resp, _ := client.Do(req) defer resp.Body.Close() body, ioErr := ioutil.ReadAll(resp.Body) if ioErr != nil { utils.ErrorLog("接口返回数据读取失败: %v", ioErr) res.Infcode = -1 return res } var respJSON map[string]interface{} if err := json.Unmarshal([]byte(body), &respJSON); err != nil { utils.ErrorLog("接口返回数据解析JSON失败: %v", err) res.Infcode = -1 return res } var resSix10265 ResultSix10265 //1101结果 respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{}) result, _ := json.Marshal(respJSON) if err := json.Unmarshal([]byte(result), &resSix10265); err != nil { utils.ErrorLog("解析失败:%v", err) res.Infcode = -1 return res } res.InfRefmsgid = resSix10265.InfRefmsgid res.Output = resSix10265.Output res.ErrMsg = resSix10265.ErrMsg res.Cainfo = resSix10265.Cainfo res.WarnMsg = resSix10265.WarnMsg infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64) res.Infcode = infocode return res } }