123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610 |
- package service
-
- import (
- "bytes"
- "encoding/json"
- "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
-
- readDb.Model(&models.NewWarehousingInfo{}).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(&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("user_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(&NewDrugWarehouse)
- readDb.Model(&models.NewDrugWarehouseOutInfo{}).Where("user_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(&NewDrugWarehouseOut)
- readDb.Model(&models.NewDrugCancelStockInfo{}).Where("user_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)
-
- 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 Post3503ForGoodInfo(org_id int64, infos *models.NewWarehousingInfo) ResultSix {
-
- 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.FixmedinsHilistName = miConfig.OrgName
- struct3503.FixmedinsBchno = infos.Number
- struct3503.SplerName = infos.Dealers.DealerName
- struct3503.ManuLotnum = infos.Number
- struct3503.ProdentpName = infos.Manufacturers.ManufacturerName
- struct3503.Aprvno = infos.LicenseNumber
- 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.TotalCount, 10)
- struct3503.RxFlag = "0"
- struct3503.PurcRetnStoinTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
- struct3503.PurcRetnOpterName = "仓管员"
- struct3503.OrgName = miConfig.OrgName
- struct3503.AccessKey = miConfig.AccessKey
- struct3503.RequestUrl = miConfig.Url
- struct3503.SecretKey = miConfig.SecretKey
- struct3503.Memo = ""
- struct3503s = append(struct3503s, struct3503)
- data["struct_3501s"] = struct3503s
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- 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 Post3503ForDrug(org_id int64, infos *models.NewDrugWarehouseInfo) ResultSix {
- var res ResultSix
- miConfig, _ := FindMedicalInsuranceInfo(org_id)
- data := make(map[string]interface{})
- var struct3501s []models.Struct3503
- var struct3501 models.Struct3503
- struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
- struct3501.FixmedinsHilistId = miConfig.Code
- struct3501.FixmedinsHilistName = miConfig.OrgName
- struct3501.FixmedinsBchno = infos.BatchNumber
- struct3501.SplerName = infos.Dealers.DealerName
- struct3501.ManuLotnum = infos.BatchNumber
- struct3501.ProdentpName = infos.Manufacturers.ManufacturerName
- struct3501.Aprvno = infos.BaseDrugLib.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.PurcRetnCnt = strconv.FormatInt(infos.WarehousingCount, 10)
- struct3501.RxFlag = "0"
- struct3501.PurcRetnStoinTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
- struct3501.PurcRetnOpterName = "仓管员"
- struct3501.OrgName = miConfig.OrgName
- struct3501.AccessKey = miConfig.AccessKey
- struct3501.RequestUrl = miConfig.Url
- struct3501.SecretKey = miConfig.SecretKey
- struct3501.Memo = ""
- struct3501s = append(struct3501s, struct3501)
- data["struct_3501s"] = struct3501s
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- 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.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 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.BaseDrugLib.MedicalInsuranceNumber
- struct3501.FixmedinsHilistId = miConfig.Code
- struct3501.FixmedinsHilistName = miConfig.OrgName
- struct3501.FixmedinsBchno = infos.BatchNumber
- 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.BatchNumber
- 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.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 struct3501s []models.Struct3506
- var struct3501 models.Struct3506
-
- 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
- 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.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10)
- struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
- struct3501.SelRetnOpterName = "仓管员"
- struct3501.Memo = ""
-
- struct3501s = append(struct3501s, struct3501)
- data["struct_3501s"] = struct3501s
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- 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 Post3506ForDrug(org_id int64, infos *models.NewDrugCancelStockInfo) ResultSix {
- var res ResultSix
-
- miConfig, _ := FindMedicalInsuranceInfo(org_id)
- data := make(map[string]interface{})
- var struct3501s []models.Struct3506
- var struct3501 models.Struct3506
- struct3501.OrgName = miConfig.OrgName
- struct3501.AccessKey = miConfig.AccessKey
- struct3501.RequestUrl = miConfig.Url
- struct3501.SecretKey = miConfig.SecretKey
- struct3501.MedListCodg = infos.BaseDrugLib.MedicalInsuranceNumber
- struct3501.FixmedinsHilistId = miConfig.Code
- struct3501.FixmedinsHilistName = miConfig.OrgName
- struct3501.FixmedinsBchno = infos.BatchNumber
- struct3501.ManuLotnum = infos.BatchNumber
- struct3501.ManuDate = time.Unix(infos.ProductDate, 0).Format("2006-01-02 15:04:05")
- struct3501.RxFlag = "0"
- struct3501.TrdnFlag = "1"
- struct3501.SelRetnCnt = strconv.FormatInt(int64(infos.Count), 10)
- struct3501.SelRetnTime = time.Unix(infos.Ctime, 0).Format("2006-01-02 15:04:05")
- struct3501.SelRetnOpterName = "仓管员"
- struct3501.Memo = ""
- struct3501s = append(struct3501s, struct3501)
- data["struct_3501s"] = struct3501s
- client := &http.Client{}
- bytesData, _ := json.Marshal(data)
- var req *http.Request
-
- 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
- }
|