lining %!s(int64=6) %!d(string=hai) anos
pai
achega
4667d00dbd

+ 6 - 4
src/dashoo.cn/backend/api/business/tmpzcgf/tmpzcgfSession.go

@@ -225,10 +225,12 @@ func (s *TmpzcgtSession) UpdateBadRecord() error {
 	return err
 }
 
-func (s *TmpzcgtSession) Selectsuo() int {
-	var id int
-	s.Session.Table("BadRecord").Where("Id=64").Find(&id)
-	return id
+func (s *TmpzcgtSession) UpdateOilAnnualAudit() error {
+	sql := "UPDATE OilAnnualAudit b SET b.SupplierId = (SELECT a.SupplierId FROM OilSupplierCert a WHERE a.GfId =b.OldId AND a.SupplierTypeCode = b.SupplierTypeName )," +
+	"b.CerId = (SELECT a.Id FROM OilSupplierCert a WHERE a.GfId =b.OldId AND a.SupplierTypeCode = b.SupplierTypeName ),"+
+	"b.AccessCardNo = (SELECT a.AccessCardNo FROM OilSupplierCert a WHERE a.GfId =b.OldId AND a.SupplierTypeCode = b.SupplierTypeName )"
+	_,err := s.Session.Query(sql)
+	return err
 }
 
 

+ 65 - 8
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercert.go

@@ -1,7 +1,7 @@
 package oilsupplier
 
 import (
-	"dashoo.cn/backend/api/business/msg"
+	msg2 "dashoo.cn/backend/api/business/msg"
 	"dashoo.cn/backend/api/business/audithistory"
 	"dashoo.cn/backend/api/business/codecsequence"
 	"dashoo.cn/backend/api/business/oilsupplier/supplier"
@@ -12,6 +12,7 @@ import (
 	"fmt"
 	"strconv"
 	"strings"
+	"supplier_system/src/dashoo.cn/backend/api/business/msg"
 	"time"
 
 	"dashoo.cn/backend/api/business/auditsetting"
@@ -1217,24 +1218,42 @@ func (this *OilSupplierCertController) CreateAccessCardNo() {
 // @Success 200 {object} controllers.Request
 // @router /updatainflag/ [get]
 func (this *OilSupplierCertController) UpdataInFlag() {
+	t := time.Now()
+	session := utils.DBE.NewSession()
 	var certentitys []suppliercert.OilSupplierCert
-	svc := suppliercert.GetOilSupplierCertService(utils.DBE)
-	svc.GetEntities(&certentitys, "")
+	svc := suppliercert.GetOilSupplierCertSession(session)
+	defer func() {
+		session.Close()
+	}()
+	err := session.Begin()
+	svc.GetEntities(&certentitys, "InFlag!='3'")
+	currenttime := time.Now()
+	//.Format("2006-01-02")
 	for i := 0; i < len(certentitys); i++ {
-		if time.Now().Format("2006-01-02") == certentitys[i].ApplyTime.Format("2006-01-02") {
+		if currenttime.After(certentitys[i].ApplyTime) && !currenttime.After(certentitys[i].ApplyTime.AddDate(1,0,0)) && certentitys[i].InFlag != "2" {
 			var certentity suppliercert.OilSupplierCert
 			certentity.InFlag = "2"
 			cols := []string{"InFlag"}
-			svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
+			_,err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
+			if err != nil {
+				session.Rollback()
+			}
 		}
-		if certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02") == time.Now().Format("2006-01-02") {
-			fmt.Println(certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02"), time.Now().Format("2006-01-02"))
+		if currenttime.After(certentitys[i].ApplyTime.AddDate(1, 0, 0)) {
+			fmt.Println(time.Now().Format("2006-01-02"), certentitys[i].ApplyTime.AddDate(1, 0, 0).Format("2006-01-02"))
 			var certentity suppliercert.OilSupplierCert
 			certentity.InFlag = "3"
 			cols := []string{"InFlag"}
-			svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
+			_,err = svc.UpdateEntityByIdCols(certentitys[i].Id, &certentity, cols)
+			if err != nil {
+				session.Rollback()
+			}
 		}
 	}
+	err = session.Commit()
+	fmt.Println(err)
+	elapsed := time.Since(t)
+	fmt.Println(elapsed, "更新准入标识")
 }
 
 // @Title 保存准入编码
@@ -1281,4 +1300,42 @@ func (this *OilSupplierCertController) SaveAccessCardNo() {
 		this.Data["json"] = &errinfo
 		this.ServeJSON()
 	}
+}
+
+// @Title 快到期短信通知
+// @Description 修改准入标识
+// @Success 200 {object} controllers.Request
+// @router /sendingSMS/ [get]
+func (this *OilSupplierCertController) SendingSMS() {
+	t := time.Now()
+	svcsupp := supplier.GetOilSupplierService(utils.DBE)
+	var list []supplier.OilSupplierView
+	where := "b.InFlag = '1'"
+	svcsupp.GetMyPagingEntitiesWithOrderBytbl(OilSupplierName, OilSupplierCertName, 0, 0, "Id", true, &list, where)
+	currenttime := time.Now()
+
+	for _,item := range list {
+		if currenttime.AddDate(0,3,0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
+			toMobile := item.Mobile
+			msg:= "您的" + item.SupplierTypeName + "准入还有3个月到期"
+			msgService := msg2.GetMsgService(utils.DBE)
+			msgService.HandleMsg(toMobile,msg,"1-1",item.CreateBy,item.ContactName,strconv.Itoa(item.CreateUserId))
+		}
+		if currenttime.AddDate(0,2,0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
+			toMobile := item.Mobile
+			msg:= "您的" + item.SupplierTypeName + "准入还有2个月到期"
+			msgService := msg2.GetMsgService(utils.DBE)
+			msgService.HandleMsg(toMobile,msg,"1-1",item.CreateBy,item.ContactName,strconv.Itoa(item.CreateUserId))
+		}
+		if currenttime.AddDate(0,1,0).Format("2006-01-02") == (item.ApplyTime.Format("2006-01-02")) {
+			toMobile := item.Mobile
+			msg:= "您的" + item.SupplierTypeName + "准入还有1个月到期"
+			msgService := msg2.GetMsgService(utils.DBE)
+			msgService.HandleMsg(toMobile,msg,"1-1",item.CreateBy,item.ContactName,strconv.Itoa(item.CreateUserId))
+		}
+	}
+	elapsed := time.Since(t)
+	fmt.Println(elapsed, "快到期提醒")
+
+
 }

+ 26 - 28
src/dashoo.cn/backend/api/controllers/tmpzcgf/tmpzcgf.go

@@ -1,7 +1,6 @@
 package tmpzcgf
 
 import (
-	"dashoo.cn/backend/api/business/oilsupplier/annualaudit"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercert"
 	"dashoo.cn/backend/api/business/oilsupplier/suppliercertappend"
 	"dashoo.cn/backend/api/business/tmpzcgf"
@@ -160,32 +159,33 @@ func (this *TmpzcgfController) UpdateAnnualAudit(){
 	defer session.Close()
 	err := session.Begin()
 	svc := tmpzcgf.GetTmpzcgtService(session)
-	var annus []annualaudit.OilAnnualAudit
-	var certs  []suppliercert.OilSupplierCert
-	var  annual  annualaudit.OilAnnualAudit
-
-	svc.GetEntitysByWhere("OilAnnualAudit", "1=1" ,&annus )
-	svc.GetEntitysByWhere("OilSupplierCert", "CreateBy='导入'", &certs)
-	var aff int64
-	for _,annu := range annus {
-		for _,sup := range certs {
-			if annu.OldId == sup.GfId {
-				fmt.Println(annu.OldId, sup.GfId, sup.OutsideFlog)
-				col := []string{"SupplierId", "CerId"}
-				annual.SupplierId = sup.SupplierId
-				annual.CerId = sup.Id
-				//where := "Id=" + strconv.Itoa(annu.Id)
-				aff,err = svc.UpdateEntityByIdCols(annu.Id, &annual, col)
-				if err != nil {
-					session.Rollback()
-				}
-				break
-			}
-		}
-	}
+	err = svc.UpdateOilAnnualAudit()
+	//var annus []annualaudit.OilAnnualAudit
+	//var certs  []suppliercert.OilSupplierCert
+	//var  annual  annualaudit.OilAnnualAudit
+	//
+	//svc.GetEntitysByWhere("OilAnnualAudit", "1=1" ,&annus )
+	//svc.GetEntitysByWhere("OilSupplierCert", "CreateBy='导入'", &certs)
+	//var aff int64
+	//for _,annu := range annus {
+	//	for _,sup := range certs {
+	//		if annu.OldId == sup.GfId {
+	//			fmt.Println(annu.OldId, sup.GfId, sup.OutsideFlog)
+	//			col := []string{"SupplierId", "CerId"}
+	//			annual.SupplierId = sup.SupplierId
+	//			annual.CerId = sup.Id
+	//			//where := "Id=" + strconv.Itoa(annu.Id)
+	//			aff,err = svc.UpdateEntityByIdCols(annu.Id, &annual, col)
+	//			if err != nil {
+	//				session.Rollback()
+	//			}
+	//			break
+	//		}
+	//	}
+	//}
 
 	err = session.Commit()
-	fmt.Println(err,aff)
+	fmt.Println(err)
 	elapsed := time.Since(t)
 	fmt.Println(elapsed)
 }
@@ -271,9 +271,7 @@ func (this *TmpzcgfController) InsterBadRecord(){
 	}()
 	err := session.Begin()
 	svc := tmpzcgf.GetTmpzcgtService(session)
-	ids := svc.Selectsuo()
-	fmt.Println(ids)
-	//err = svc.InsterBadRecord()
+	err = svc.InsterBadRecord()
 
 	if err != nil {
 		session.Rollback()

+ 44 - 0
src/dashoo.cn/backend/api/controllers/toolbox/toolbox.go

@@ -0,0 +1,44 @@
+package toolbox
+
+import (
+	"dashoo.cn/backend/api/controllers/oilsupplier"
+	"fmt"
+	"github.com/astaxie/beego/toolbox"
+)
+
+//type ToolboxController struct {
+//	BaseController
+//}
+
+func TimingTask(){
+	c := new(oilsupplier.OilSupplierCertController)
+	//c.UpdataInFlag52456564546
+	tkInFlag := toolbox.NewTask("myTaskInFlag", "0 0 1 * * *", func() error {
+		c.UpdataInFlag()
+		return nil
+		})
+	err := tkInFlag.Run()
+	if err != nil {
+		fmt.Println(err)
+	}
+	toolbox.AddTask("myTaskInFlag", tkInFlag)
+
+	tkSMSnotice := toolbox.NewTask("myTaskSMSnotice", "0 0 10 * * *", func() error {
+		c.SendingSMS()
+		return nil
+	})
+	err = tkSMSnotice.Run()
+	if err != nil {
+		fmt.Println(err)
+	}
+	toolbox.AddTask("myTaskSMSnotice", tkSMSnotice)
+
+
+
+
+	toolbox.StartTask()
+
+	//toolbox.StopTask()
+	//beego.Run()
+
+}

+ 5 - 1
src/dashoo.cn/backend/api/main.go

@@ -1,6 +1,7 @@
 package main
 
 import (
+	"dashoo.cn/backend/api/controllers/toolbox"
 	"github.com/astaxie/beego"
 
 	"dashoo.cn/backend/api/controllers"
@@ -17,7 +18,10 @@ func main() {
 	// Initialize casbin.
 	utils.InitCasbin()
 
-	//	controllers.InitRedis()
+		//controllers.InitRedis()
+
+	// 定时任务
+	toolbox.TimingTask()
 
 	// 输出API文档
 	beego.BConfig.WebConfig.DirectoryIndex = true

BIN=BIN
src/dashoo.cn/backend/api/static/limsdoc/dataentry/template/word/tmp_1559524625.docx


BIN=BIN
src/dashoo.cn/backend/api/static/limsdoc/dataentry/template/word/tmp_1559524634.docx


BIN=BIN
src/dashoo.cn/backend/api/static/limsdoc/dataentry/template/word/tmp_1559524671.docx


BIN=BIN
src/dashoo.cn/backend/api/static/limsdoc/dataentry/template/word/tmp_1559524793.docx