|
|
@@ -4,7 +4,6 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/robfig/cron"
|
|
|
"kpt.xdmy/apiserver/model"
|
|
|
- "kpt.xdmy/apiserver/service/cownum_sqlserver"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
@@ -12,71 +11,14 @@ var s *Service
|
|
|
|
|
|
func SapJobInit() {
|
|
|
|
|
|
- duetimecst, _ := time.ParseInLocation("15:04:05", "00:01:00", time.Local)
|
|
|
- duetimecst1, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
- spec := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
|
|
|
- c := cron.New()
|
|
|
- c.AddFunc(spec, func() {
|
|
|
- AutoSapOrderJob()
|
|
|
- AutoSrmOrderJob()
|
|
|
- AutoSapReturnOrderJob()
|
|
|
- AutoSrmReturnOrderJob()
|
|
|
- })
|
|
|
- //c.Start()
|
|
|
-
|
|
|
- t := time.Now()
|
|
|
- i := 20
|
|
|
- pastureList := make([]*model.Pasture, 0)
|
|
|
- s.d.DB.Table("pasture").Find(&pastureList)
|
|
|
-
|
|
|
- for {
|
|
|
- for _, pasture := range pastureList {
|
|
|
- s.SapAsset(t.AddDate(0, 0, -i), "", pasture.CompanyCode)
|
|
|
- }
|
|
|
-
|
|
|
- if i == 0 {
|
|
|
- panic("break")
|
|
|
- }
|
|
|
- i--
|
|
|
- }
|
|
|
- //var t time.Time
|
|
|
- //t = time.Now()
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -1), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -2), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -3), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -4), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -5), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -6), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -7), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -8), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -9), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -10), "")
|
|
|
- //s.SapMaterial(t.AddDate(0, 0, -11), "")
|
|
|
c1 := cron.New()
|
|
|
c1.AddFunc("0 40 23 * * ?", func() {
|
|
|
- fmt.Println(time.Now())
|
|
|
- //更新设备维修和保养费用
|
|
|
- var t time.Time
|
|
|
- t = time.Now()
|
|
|
- var code string
|
|
|
- pastureList := make([]*model.Pasture, 0)
|
|
|
- err := s.d.DB.Table("pasture").Find(&pastureList)
|
|
|
- fmt.Println(err)
|
|
|
- for _, pasture := range pastureList {
|
|
|
- s.SapSupplier(t, pasture.CompanyCode, pasture.ID)
|
|
|
- s.SapAsset(t, code, pasture.CompanyCode)
|
|
|
- s.SapAssetSalvage(t, pasture.CompanyCode, pasture.ID)
|
|
|
- }
|
|
|
- s.SapMaterial(t, code)
|
|
|
- s.SapMaterial(t.AddDate(0, 0, -1), code)
|
|
|
- s.SapMaterial(t.AddDate(0, 0, -2), code)
|
|
|
- s.SapMaterial(t.AddDate(0, 0, -3), code)
|
|
|
s.d.DB.Exec(`call createEqstatus()`)
|
|
|
})
|
|
|
|
|
|
//保养计划
|
|
|
- duetimecst, _ = time.ParseInLocation("15:04:05", "01:00:00", time.Local)
|
|
|
- duetimecst1, _ = time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
+ duetimecst, _ := time.ParseInLocation("15:04:05", "01:00:00", time.Local)
|
|
|
+ duetimecst1, _ := time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
spec1 := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
|
|
|
c1.AddFunc(spec1, func() {
|
|
|
pastureList := make([]*model.Pasture, 0)
|
|
|
@@ -86,47 +28,41 @@ func SapJobInit() {
|
|
|
s.d.DB.Exec(`call createRUcode(?)`, pasture.ID)
|
|
|
}
|
|
|
})
|
|
|
- duetimecst, _ = time.ParseInLocation("15:04:05", "00:05:00", time.Local)
|
|
|
- duetimecst1, _ = time.ParseInLocation("15:04:05", "00:00:00", time.Local)
|
|
|
- spec2 := fmt.Sprintf("@every %v", duetimecst.Sub(duetimecst1))
|
|
|
- c1.AddFunc(spec2, func() {
|
|
|
- s.d.DB.Exec(`call wxmsg()`)
|
|
|
- })
|
|
|
-
|
|
|
- c1.AddFunc("0 50 01 * * ?", func() {
|
|
|
- //更新设备维修和保养费用
|
|
|
- pastureList := make([]*model.Pasture, 0)
|
|
|
- s.d.DB.Table("pasture").Where("vendor = 1 ").Where("id != 18 ").Find(&pastureList)
|
|
|
- now := time.Now()
|
|
|
- start := now.AddDate(-1, 0, 0).Format("2006-01-02")
|
|
|
- end := now.Format("2006-01-02")
|
|
|
- for _, pasture := range pastureList {
|
|
|
- updateEqYearMaintainCostAndYearUpkeepCost(pasture.ID, start, end)
|
|
|
- }
|
|
|
- })
|
|
|
|
|
|
- c1.AddFunc("0 20 18 * * ?", func() {
|
|
|
- cownum_sqlserver.SyncCownum(s.sqlserver, s.d, time.Now().AddDate(0, 0, -3).Format("2006-01-02"))
|
|
|
- cownum_sqlserver.SyncCownum(s.sqlserver, s.d, time.Now().AddDate(0, 0, -2).Format("2006-01-02"))
|
|
|
- cownum_sqlserver.SyncCownum(s.sqlserver, s.d, time.Now().AddDate(0, 0, -1).Format("2006-01-02"))
|
|
|
- pastureList := make([]*model.Pasture, 0)
|
|
|
- s.d.DB.Table("pasture").Where("vendor = 1 ").Where("factory_code != '' ").Where("factory_code is not null ").Find(&pastureList)
|
|
|
- for _, item := range pastureList {
|
|
|
- AutoFeeQuery(item.FactoryCode, item.ID)
|
|
|
- }
|
|
|
- })
|
|
|
+ //c1.AddFunc("0 50 01 * * ?", func() {
|
|
|
+ // //更新设备维修和保养费用
|
|
|
+ // pastureList := make([]*model.Pasture, 0)
|
|
|
+ // s.d.DB.Table("pasture").Where("vendor = 1 ").Where("id != 18 ").Find(&pastureList)
|
|
|
+ // now := time.Now()
|
|
|
+ // start := now.AddDate(-1, 0, 0).Format("2006-01-02")
|
|
|
+ // end := now.Format("2006-01-02")
|
|
|
+ // for _, pasture := range pastureList {
|
|
|
+ // updateEqYearMaintainCostAndYearUpkeepCost(pasture.ID, start, end)
|
|
|
+ // }
|
|
|
+ //})
|
|
|
|
|
|
- c1.AddFunc("0 10 12 * * ?", func() {
|
|
|
- AutoContractToASP()
|
|
|
- })
|
|
|
+ //c1.AddFunc("0 20 18 * * ?", func() {
|
|
|
+ // cownum_sqlserver.SyncCownum(s.sqlserver, s.d, time.Now().AddDate(0, 0, -3).Format("2006-01-02"))
|
|
|
+ // cownum_sqlserver.SyncCownum(s.sqlserver, s.d, time.Now().AddDate(0, 0, -2).Format("2006-01-02"))
|
|
|
+ // cownum_sqlserver.SyncCownum(s.sqlserver, s.d, time.Now().AddDate(0, 0, -1).Format("2006-01-02"))
|
|
|
+ // pastureList := make([]*model.Pasture, 0)
|
|
|
+ // s.d.DB.Table("pasture").Where("vendor = 1 ").Where("factory_code != '' ").Where("factory_code is not null ").Find(&pastureList)
|
|
|
+ // for _, item := range pastureList {
|
|
|
+ // AutoFeeQuery(item.FactoryCode, item.ID)
|
|
|
+ // }
|
|
|
+ //})
|
|
|
|
|
|
- c1.AddFunc("0 20 23 * * ?", func() {
|
|
|
- s.SyncPasture()
|
|
|
- s.SyncEquipmentDate()
|
|
|
- AutoContractToASP()
|
|
|
- })
|
|
|
+ //c1.AddFunc("0 10 12 * * ?", func() {
|
|
|
+ // AutoContractToASP()
|
|
|
+ //})
|
|
|
+ //
|
|
|
+ //c1.AddFunc("0 20 23 * * ?", func() {
|
|
|
+ // s.SyncPasture()
|
|
|
+ // s.SyncEquipmentDate()
|
|
|
+ // AutoContractToASP()
|
|
|
+ //})
|
|
|
//AutoContractToASP()
|
|
|
- //c1.Start()
|
|
|
+ c1.Start()
|
|
|
//s.SyncEquipmentDate()
|
|
|
}
|
|
|
|