|
|
@ -8,6 +8,7 @@ import ( |
|
|
|
"leit.com/leit_seat_aps/config" |
|
|
|
"leit.com/leit_seat_aps/db" |
|
|
|
"leit.com/leit_seat_aps/glog" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"context" |
|
|
|
) |
|
|
@ -60,8 +61,26 @@ func CustProduct(conf *config.EnvConfig) { |
|
|
|
custorders []string |
|
|
|
oemorders []string |
|
|
|
) |
|
|
|
//时间控制
|
|
|
|
|
|
|
|
//停机时间
|
|
|
|
stime := "yyyy-MM-dd 02:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Begtime){ |
|
|
|
stime = conf.Begtime |
|
|
|
} |
|
|
|
etime := "yyyy-MM-dd 03:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Endtime){ |
|
|
|
etime = conf.Endtime |
|
|
|
} |
|
|
|
stime = common.TimeFormat(time.Now(), stime) |
|
|
|
etime = common.TimeFormat(time.Now(), etime) |
|
|
|
timeLayout := "2006-01-02 15:04:05" |
|
|
|
loc, _ := time.LoadLocation("Local") |
|
|
|
timeStart, _ := time.ParseInLocation(timeLayout, stime, loc) |
|
|
|
timeEnd, _ := time.ParseInLocation(timeLayout, etime, loc) |
|
|
|
now := time.Now() |
|
|
|
if now.After(timeStart) && now.Before(timeEnd) { |
|
|
|
time.Sleep(60 * time.Second) |
|
|
|
continue |
|
|
|
} |
|
|
|
//查询缓存记录表
|
|
|
|
cust, err := archive.SelectAll() |
|
|
|
if err != nil { |
|
|
@ -977,6 +996,28 @@ func Archive_Pln_workorder(custorder CustOrders) { |
|
|
|
//备份:Jit_shiporder
|
|
|
|
func ArchiveJit_shiporder(conf *config.EnvConfig) { |
|
|
|
for { |
|
|
|
|
|
|
|
//停机时间
|
|
|
|
stime := "yyyy-MM-dd 02:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Begtime){ |
|
|
|
stime = conf.Begtime |
|
|
|
} |
|
|
|
etime := "yyyy-MM-dd 03:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Endtime){ |
|
|
|
etime = conf.Endtime |
|
|
|
} |
|
|
|
stime = common.TimeFormat(time.Now(), stime) |
|
|
|
etime = common.TimeFormat(time.Now(), etime) |
|
|
|
timeLayout := "2006-01-02 15:04:05" |
|
|
|
loc, _ := time.LoadLocation("Local") |
|
|
|
timeStart, _ := time.ParseInLocation(timeLayout, stime, loc) |
|
|
|
timeEnd, _ := time.ParseInLocation(timeLayout, etime, loc) |
|
|
|
now := time.Now() |
|
|
|
if now.After(timeStart) && now.Before(timeEnd) { |
|
|
|
time.Sleep(60 * time.Second) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
var ( |
|
|
|
err error |
|
|
|
oneWeek time.Time |
|
|
@ -1289,6 +1330,28 @@ func ArchivePln_pickorder(conf *config.EnvConfig) { |
|
|
|
//备份:jit_packorder
|
|
|
|
func ArchiveJit_packorder(conf *config.EnvConfig) { |
|
|
|
for { |
|
|
|
|
|
|
|
//停机时间
|
|
|
|
stime := "yyyy-MM-dd 02:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Begtime){ |
|
|
|
stime = conf.Begtime |
|
|
|
} |
|
|
|
etime := "yyyy-MM-dd 03:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Endtime){ |
|
|
|
etime = conf.Endtime |
|
|
|
} |
|
|
|
stime = common.TimeFormat(time.Now(), stime) |
|
|
|
etime = common.TimeFormat(time.Now(), etime) |
|
|
|
timeLayout := "2006-01-02 15:04:05" |
|
|
|
loc, _ := time.LoadLocation("Local") |
|
|
|
timeStart, _ := time.ParseInLocation(timeLayout, stime, loc) |
|
|
|
timeEnd, _ := time.ParseInLocation(timeLayout, etime, loc) |
|
|
|
now := time.Now() |
|
|
|
if now.After(timeStart) && now.Before(timeEnd) { |
|
|
|
time.Sleep(60 * time.Second) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
var ( |
|
|
|
err error |
|
|
|
oneWeek time.Time |
|
|
@ -1415,11 +1478,34 @@ func ArchiveJit_packorder(conf *config.EnvConfig) { |
|
|
|
} |
|
|
|
|
|
|
|
//删除一个礼拜前的打印消息
|
|
|
|
func DelPrinterInfo() { |
|
|
|
func DelPrinterInfo(conf *config.EnvConfig) { |
|
|
|
tick := time.Tick(10 * time.Second) |
|
|
|
for { |
|
|
|
select { |
|
|
|
case <-tick: |
|
|
|
stime := "yyyy-MM-dd 02:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Begtime){ |
|
|
|
stime = conf.Begtime |
|
|
|
} |
|
|
|
etime := "yyyy-MM-dd 03:00:00" |
|
|
|
if !common.ValueIsEmpty(conf.Endtime){ |
|
|
|
etime = conf.Endtime |
|
|
|
} |
|
|
|
stime = common.TimeFormat(time.Now(), stime) |
|
|
|
etime = common.TimeFormat(time.Now(), etime) |
|
|
|
//停机时间
|
|
|
|
timeLayout := "2006-01-02 15:04:05" |
|
|
|
loc, _ := time.LoadLocation("Local") |
|
|
|
timeStart, _ := time.ParseInLocation(timeLayout, stime, loc) |
|
|
|
timeEnd, _ := time.ParseInLocation(timeLayout, etime, loc) |
|
|
|
now := time.Now() |
|
|
|
fmt.Println(timeStart) |
|
|
|
fmt.Println(timeEnd) |
|
|
|
if now.After(timeStart) && now.Before(timeEnd) { |
|
|
|
time.Sleep(60 * time.Second) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
var ( |
|
|
|
err error |
|
|
|
oneWeek time.Time |
|
|
@ -1428,7 +1514,11 @@ func DelPrinterInfo() { |
|
|
|
s := db.G_DbSalve |
|
|
|
data := make([]db.Printheadtab, 0) |
|
|
|
//获取七天前的字符串
|
|
|
|
oneWeek = time.Now().AddDate(0, 0, -7) |
|
|
|
if common.ValueIsEmpty(conf.Day) { |
|
|
|
oneWeek = time.Now().AddDate(0, 0, -14) |
|
|
|
} else { |
|
|
|
oneWeek = time.Now().AddDate(0, 0, -conf.Day) |
|
|
|
} |
|
|
|
|
|
|
|
oneWeekStr := common.TimeFormat(oneWeek, "yyyyMMddHHmmss") |
|
|
|
//查询出订单状态是80,并且是七天前的客户订单的信息,每次查询10条
|
|
|
@ -1444,7 +1534,6 @@ func DelPrinterInfo() { |
|
|
|
continue |
|
|
|
} |
|
|
|
for _, v := range data { |
|
|
|
itemlst := make([]db.Printdetailtab, 0) |
|
|
|
//转义为json
|
|
|
|
jsondata, err := json.Marshal(&v) |
|
|
|
if err != nil { |
|
|
@ -1456,7 +1545,7 @@ func DelPrinterInfo() { |
|
|
|
return |
|
|
|
} |
|
|
|
//判断是否需要备份
|
|
|
|
if v.Printobjtype == "BBAASN" { |
|
|
|
if strings.TrimSpace(v.Printobjtype) == conf.Printobjtype { |
|
|
|
//备份数据
|
|
|
|
InfoLog := new(db.TableDataInfoLog) |
|
|
|
InfoLog.Servername = "Archive_printheadtab" |
|
|
@ -1475,7 +1564,7 @@ func DelPrinterInfo() { |
|
|
|
glog.InfoExtln("archive数据printheadtab", "err:", err.Error()) |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
itemlst := make([]db.Printdetailtab, 0) |
|
|
|
//查询(printdetailtab)
|
|
|
|
err = e.Table("printdetailtab").Where("finr = ? and printheadid = ?", db.G_FINR, v.Printheadid).Find(&itemlst) |
|
|
|
if err != nil { |
|
|
|