Przeglądaj źródła

资质到期提醒

lining 6 lat temu
rodzic
commit
2a8d1b4ec1

+ 15 - 6
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplier.go

@@ -4,7 +4,6 @@ import (
 	"time"
 )
 
-
 type OilSupplier struct {
 	Id                  int       `xorm:"not null pk autoincr INT(10)"`
 	SupplierName        string    `xorm:"comment('企业名称') VARCHAR(255)"`
@@ -133,7 +132,7 @@ type OilSupplierView struct {
 }
 
 type OilSupplierSelect struct {
-	Id               int		//Oilsupplier表id
+	Id               int       //Oilsupplier表id
 	AccessCardNo     string    //准入证号
 	SupplierName     string    //企业名称
 	OldSupplierName  string    //企业曾用名
@@ -161,7 +160,7 @@ type OilSupplierSelect struct {
 	BusinessScope    string    //营业范围
 	NeedFileType     string    //资质
 	CerSubName       string    //准入范围
-	InStyle		  	 string		//准入方式
+	InStyle          string    //准入方式
 }
 
 //type NeedFileTypeStruct struct {
@@ -245,6 +244,16 @@ type OilSupplierApply struct {
 	ModifiedBy          string    `xorm:"VARCHAR(50)"`
 	PACNumber           string    `xorm:"comment('中石油准入证编号') VARCHAR(50)"`
 	SupplierCertificate string    `xorm:"comment('中石油物资供应商证书') VARCHAR(200)"`
-	InFlag            string    `xorm:"default '0' comment('准入标识') VARCHAR(10)"`
-	Status            string    `xorm:"not null default '0' comment('状态标识(0未申请,1办理完毕)') VARCHAR(10)"`
-}
+	InFlag              string    `xorm:"default '0' comment('准入标识') VARCHAR(10)"`
+	Status              string    `xorm:"not null default '0' comment('状态标识(0未申请,1办理完毕)') VARCHAR(10)"`
+}
+
+type ExpireFile struct {
+	Id            int
+	SupplierName  string
+	Mobile        string
+	ExpireAllFile string
+	CreateBy      string
+	ContactName   string
+	CreateUserId  int
+}

+ 11 - 0
src/dashoo.cn/backend/api/business/oilsupplier/supplier/oilsupplierService.go

@@ -212,4 +212,15 @@ func (s *OilSupplierService) GetMyTodoEntitie(supplierTableName, supplierCertTab
 	return has
 }
 
+func (s *OilSupplierService) GetExpireFile(supplierTableName, supplierFileTableName string, entitiesPtr interface{}, where string) error {
+
+	var sql string
+	sql = `SELECT a.Id, a.SupplierName, a.Mobile, a.CreateBy, a.ContactName, a.CreateUserId, GROUP_CONCAT(b.NeedFileType SEPARATOR ';' ) NeedAllFile  `
+	sql += ` FROM ` + supplierTableName + ` a `
+	sql += ` left join ` + supplierFileTableName + " b ON a.Id=b.SupplierId "
+	sql += ` where ` + where
+    sql += ` GROUP BY a.Id, a.SupplierName, a.Mobile `
+	err := s.DBE.SQL(sql).Find(entitiesPtr)
+	return err
+}
 

+ 67 - 1
src/dashoo.cn/backend/api/controllers/oilsupplier/suppliercert.go

@@ -1411,4 +1411,70 @@ func (this *OilSupplierCertController) SendingSMS() {
 	fmt.Println(elapsed, "快到期提醒")
 
 
-}
+}
+
+
+// @Title 资质快到期短信通知
+// @Description
+// @Success 200 {object} controllers.Request
+// @router /sendingSMSSupplierFile/ [get]
+func (this *OilSupplierCertController) SendingSMSSupplierFile() {
+	t := time.Now()
+	svcsupp := supplier.GetOilSupplierService(utils.DBE)
+	var expireFile  []supplier.ExpireFile
+	where := " b.EffectDate LIKE '%" + time.Now().AddDate(0,1,0).Format("2006-01-02") + "%'"
+	err := svcsupp.GetExpireFile(OilSupplierName, OilSupplierFileName, &expireFile, where)
+
+	if err == nil {
+		for _, item := range expireFile {
+			toMobile := "15288965998,15863081686,15563862958"//item.Mobile
+			msg:= "您的" + item.ExpireAllFile + "还有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, "资质到期提醒")
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 10 - 1
src/dashoo.cn/backend/api/controllers/toolbox/toolbox.go

@@ -33,7 +33,16 @@ func TimingTask(){
 	}
 	toolbox.AddTask("myTaskSMSnotice", tkSMSnotice)
 
-
+	//  资质到期提醒
+	tkSupplierFile := toolbox.NewTask("myTaskSupplierFile", "0 0 14 * * *", func() error {
+		c.SendingSMSSupplierFile()
+		return nil
+	})
+	err = tkSupplierFile.Run()
+	if err != nil {
+		fmt.Println(err)
+	}
+	toolbox.AddTask("myTaskSupplierFile", tkSupplierFile)
 
 
 	toolbox.StartTask()