1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318 |
- 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("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("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 ", 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", 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 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
- }
- }
-
-
-
- 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
- }
- }
-
-
-
- }
-
- 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
- }
- }
|