123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914 |
- 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 Post3501ForGoodInfo(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.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.DrugWarehouseInfo.ProductDate, 0).Format("2006-01-02 15:04:05")
- struct3501.ExpyEnd = time.Unix(infos.DrugWarehouseInfo.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.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.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.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.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.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 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.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.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.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
- }
|