zoie il y a 1 an
Parent
commit
0b816a5a5e
6 fichiers modifiés avec 37 ajouts et 17 suppressions
  1. 6 6
      Nats/Nats.go
  2. 7 6
      Nats/NatsServer/NatsERP_user.go
  3. 8 3
      conf/app.conf
  4. 5 0
      conf/config.go
  5. 10 1
      controllers/Reimburse.go
  6. 1 1
      controllers/Salary.go

+ 6 - 6
Nats/Nats.go

@@ -33,7 +33,7 @@ func init() {
 func NatsInit() {
 
 	// 发布-订阅 模式,异步订阅 test1
-	_, _ = Nats.Subscribe(conf.Sys_Name+"_Read_Menu_List", func(m *nats.Msg) {
+	_, _ = Nats.Subscribe(conf.NatsSubj_Prefix+conf.Sys_Name+"_Read_Menu_List", func(m *nats.Msg) {
 
 		var t_R lib.JSONS
 
@@ -58,7 +58,7 @@ func NatsInit() {
 
 	})
 
-	_, _ = Nats.Subscribe(conf.Sys_Name+"_Read_User_Bind_Menu_List", func(m *nats.Msg) {
+	_, _ = Nats.Subscribe(conf.NatsSubj_Prefix+conf.Sys_Name+"_Read_User_Bind_Menu_List", func(m *nats.Msg) {
 
 		var t_R lib.JSONS
 
@@ -94,7 +94,7 @@ func NatsInit() {
 
 	})
 
-	_, _ = Nats.Subscribe(conf.Sys_Name+"_Add_Power", func(m *nats.Msg) {
+	_, _ = Nats.Subscribe(conf.NatsSubj_Prefix+conf.Sys_Name+"_Add_Power", func(m *nats.Msg) {
 
 		var t_Req powerlibs.Power
 		var t_R lib.JSONS
@@ -130,7 +130,7 @@ func NatsInit() {
 
 	})
 
-	_, _ = Nats.Subscribe(conf.Sys_Name+"_Read_Power_ByT_id", func(m *nats.Msg) {
+	_, _ = Nats.Subscribe(conf.NatsSubj_Prefix+conf.Sys_Name+"_Read_Power_ByT_id", func(m *nats.Msg) {
 		fmt.Printf("ERP_salary_Read_Power_ByT_id message: %+v\n", string(m.Data))
 
 		var t_R lib.JSONS
@@ -155,7 +155,7 @@ func NatsInit() {
 
 	})
 
-	_, _ = Nats.Subscribe(conf.Sys_Name+"_Update_Power", func(m *nats.Msg) {
+	_, _ = Nats.Subscribe(conf.NatsSubj_Prefix+conf.Sys_Name+"_Update_Power", func(m *nats.Msg) {
 
 		var t_Req powerlibs.Power
 		var t_R lib.JSONS
@@ -193,7 +193,7 @@ func NatsInit() {
 
 	})
 
-	_, _ = Nats.Subscribe(conf.Sys_Name+"_Delete_Power", func(m *nats.Msg) {
+	_, _ = Nats.Subscribe(conf.NatsSubj_Prefix+conf.Sys_Name+"_Delete_Power", func(m *nats.Msg) {
 
 		var t_Req powerlibs.Power
 		var t_R lib.JSONS

+ 7 - 6
Nats/NatsServer/NatsERP_user.go

@@ -2,6 +2,7 @@ package NatsServer
 
 import (
 	"ERP_salary/Nats"
+	"ERP_salary/conf"
 	"ERP_salary/logs"
 	natslibs "git.baozhida.cn/ERP_libs/Nats"
 	userlibs "git.baozhida.cn/ERP_libs/User"
@@ -11,7 +12,7 @@ import (
 // 验证TOKEY
 func Verification(GetCookie string, GetString string) (user userlibs.User, err error) {
 
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	user, err = nats.Verification(GetCookie, GetString)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -22,7 +23,7 @@ func Verification(GetCookie string, GetString string) (user userlibs.User, err e
 }
 
 func Read_User_List_All() (user []userlibs.User, err error) {
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	user, err = nats.Read_User_List_All()
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -32,7 +33,7 @@ func Read_User_List_All() (user []userlibs.User, err error) {
 
 }
 func Read_User_List_T_uuid(T_name string, T_uuid_list []string, page, page_z int) (user []userlibs.User, cnt int64, err error) {
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	user, cnt, err = nats.Read_User_List_T_uuid(T_name, T_uuid_list, page, page_z)
 	if err != nil {
 		logs.Error(lib.FuncName(), err)
@@ -44,18 +45,18 @@ func Read_User_List_T_uuid(T_name string, T_uuid_list []string, page, page_z int
 
 // 添加系统日志
 func AddSysLogs(T_class, T_title string, T_txt interface{}) {
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	nats.AddSysLogs(T_class, T_title, T_txt)
 }
 
 // 添加用户日志
 func AddUserLogs(T_uuid, T_class, T_title string, T_txt interface{}) {
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	nats.AddUserLogs(T_uuid, T_class, T_title, T_txt)
 }
 
 // 添加用户日志
 func AddNews(T_uuid, T_title, T_Url string) {
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	nats.AddNews(T_uuid, T_title, T_Url)
 }

+ 8 - 3
conf/app.conf

@@ -7,8 +7,8 @@ copyrequestbody = true
 
 Sys_Name = "ERP_SALARY"
 # Nats
-NatsServer_Url = "175.178.229.79:4222"
-# NatsServer_Url = "127.0.0.1:4223"
+NatsServer_Url = "127.0.0.1:4222"
+NatsSubj_Prefix = "Test_"
 # Mysql 线上
 MysqlServer_UrlPort = "127.0.0.1:3316"
 MysqlServer_Database = "erp_salary_test"
@@ -23,7 +23,7 @@ Redis_password = ""
 Redis_dbNum = "1"
 
 # 路由排除信息
-FilterExcludeURL = 
+FilterExcludeURL =
 FilterOnlyLoginCheckURL =
 
 # 静态资源
@@ -34,3 +34,8 @@ Qiniu_Url = https://erposs.baozhida.cn/
 
 # 消息通知路由
 MySalaryNewsUrl = "/salaryMy"
+
+ReimburseApprovalUrl = "/reimburse"
+MyReimburseUrl = "/reimburseMy"
+# 财务uuid
+FinanceUuid = "NeGSMvREXA8xDZWo6q1YjLHTm0dJg7zc"

+ 5 - 0
conf/config.go

@@ -4,6 +4,8 @@ import beego "github.com/beego/beego/v2/server/web"
 
 var Page_size = 10
 var NatsServer_Url, _ = beego.AppConfig.String("NatsServer_Url")
+var NatsSubj_Prefix, _ = beego.AppConfig.String("NatsSubj_Prefix")
+
 var RunMode, _ = beego.AppConfig.String("RunMode")
 
 var Sys_Name, _ = beego.AppConfig.String("Sys_Name")
@@ -32,3 +34,6 @@ var OssQiniu, _ = beego.AppConfig.String("OssQiniu")
 
 // 消息通知路由
 var MySalaryNewsUrl, _ = beego.AppConfig.String("MySalaryNewsUrl")
+var ReimburseApprovalUrl, _ = beego.AppConfig.String("ReimburseApprovalUrl")
+var MyReimburseUrl, _ = beego.AppConfig.String("MyReimburseUrl")
+var FinanceUuid, _ = beego.AppConfig.String("FinanceUuid")

+ 10 - 1
controllers/Reimburse.go

@@ -515,6 +515,9 @@ func (c *ReimburseController) Reimburse_Submit_Audit() {
 		c.ServeJSON()
 		return
 	}
+
+	NatsServer.AddNews(conf.FinanceUuid, fmt.Sprintf("【报销审核】您有一条%s的报销审核待处理", c.User.T_name), conf.ReimburseApprovalUrl)
+
 	NatsServer.AddUserLogs(c.User.T_uuid, "报销", "提交审核", err)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
@@ -566,6 +569,9 @@ func (c *ReimburseController) Reimburse_Edit_Audit() {
 		c.ServeJSON()
 		return
 	}
+
+	NatsServer.AddNews(reimburse.T_uid, fmt.Sprintf("【报销申请】您的报销申请%s", Reimburse.Read_Audit_Get(T_State)), conf.MyReimburseUrl)
+
 	NatsServer.AddUserLogs(c.User.T_uuid, "报销", "修改审核状态", err)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}
@@ -610,7 +616,7 @@ func (c *ReimburseController) Reimburse_Edit_Remit() {
 
 	if T_remit == reimburse.T_money {
 		reimburse.T_State = Reimburse.RemitAll
-	} else if T_remit < reimburse.T_money {
+	} else if T_remit < reimburse.T_money && T_remit > 0 {
 		reimburse.T_State = Reimburse.RemitPart
 	}
 
@@ -622,6 +628,9 @@ func (c *ReimburseController) Reimburse_Edit_Remit() {
 		c.ServeJSON()
 		return
 	}
+
+	NatsServer.AddNews(reimburse.T_uid, fmt.Sprintf("【报销打款】您的报销申请已%s", Reimburse.Read_Audit_Get(reimburse.T_State)), conf.MyReimburseUrl)
+
 	NatsServer.AddUserLogs(c.User.T_uuid, "报销", "修改打款明细", err)
 
 	c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_id}

+ 1 - 1
controllers/Salary.go

@@ -526,7 +526,7 @@ func (c *SalaryController) Salary_Excel() {
 	}
 
 	// 上传 OSS
-	nats := natslibs.NewNats(Nats.Nats)
+	nats := natslibs.NewNats(Nats.Nats, conf.NatsSubj_Prefix)
 	url, is := nats.Qiniu_UploadFile(lib.GetCurrentDirectory()+"/ofile/"+filename+".xlsx", "ofile/"+filename+".xlsx")
 	if !is {
 		c.Data["json"] = lib.JSONS{Code: 202, Msg: "oss!"}