作者 tangxvhui

调整 统计

@@ -11,4 +11,5 @@ test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login @@ -11,4 +11,5 @@ test环境 https://enterprise-platform-dev.fjmaimaimai.com/#/login
11 测试账号 17708397664 密码 123456 11 测试账号 17708397664 密码 123456
12 12
13 13
14 -短信模板ID:5475050 短信内容: 您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦  
  14 +短信模板ID:5475050 短信内容:您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦
  15 +短信模板ID:5824230 短信内容:您好,#name#,百忙之中不要忘记填写#date#的绩效自评反馈哦
@@ -20,8 +20,12 @@ func RunTaskSmsNotify() { @@ -20,8 +20,12 @@ func RunTaskSmsNotify() {
20 20
21 // 每日自评短信通知 ,预创建待发送的短信消息 21 // 每日自评短信通知 ,预创建待发送的短信消息
22 func AddNotifyStaffAssess(param *domain.StaffAssess) { 22 func AddNotifyStaffAssess(param *domain.StaffAssess) {
  23 +
23 newNotify := notifyStaffAssess{} 24 newNotify := notifyStaffAssess{}
24 newSms := newNotify.makeNotify(param) 25 newSms := newNotify.makeNotify(param)
  26 + if newSms == nil {
  27 + return
  28 + }
25 taskSmsNotify.addTask(newSms) 29 taskSmsNotify.addTask(newSms)
26 } 30 }
27 31
@@ -29,6 +33,9 @@ func AddNotifyStaffAssess(param *domain.StaffAssess) { @@ -29,6 +33,9 @@ func AddNotifyStaffAssess(param *domain.StaffAssess) {
29 func AddNotifySummaryEvaluation(param *domain.SummaryEvaluation) { 33 func AddNotifySummaryEvaluation(param *domain.SummaryEvaluation) {
30 newNotify := notifySummaryEvaluation{} 34 newNotify := notifySummaryEvaluation{}
31 newSms := newNotify.makeNotify(param) 35 newSms := newNotify.makeNotify(param)
  36 + if newSms == nil {
  37 + return
  38 + }
32 taskSmsNotify.addTask(newSms) 39 taskSmsNotify.addTask(newSms)
33 } 40 }
34 41
@@ -59,5 +66,8 @@ func AddNotifyConfirmEvaluationScore(param *domain.SummaryEvaluation) error { @@ -59,5 +66,8 @@ func AddNotifyConfirmEvaluationScore(param *domain.SummaryEvaluation) error {
59 } 66 }
60 67
61 newSms := newNotify.makeNotify(param) 68 newSms := newNotify.makeNotify(param)
  69 + if newSms == nil {
  70 + return nil
  71 + }
62 return taskSmsNotify.addTask(newSms) 72 return taskSmsNotify.addTask(newSms)
63 } 73 }
@@ -19,28 +19,57 @@ func (notices notifyStaffAssess) from() string { @@ -19,28 +19,57 @@ func (notices notifyStaffAssess) from() string {
19 } 19 }
20 20
21 // makeNotify 生成待执行的短信通知内容 21 // makeNotify 生成待执行的短信通知内容
  22 +// func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.LogSms {
  23 +// newSms := domain.LogSms{
  24 +// Id: 0,
  25 +// Phone: param.Executor.Account,
  26 +// TemplateId: 5475050,
  27 +// Template: "您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦",
  28 +// Value: map[string]string{
  29 +// "name": param.Executor.UserName,
  30 +// },
  31 +// Result: "",
  32 +// Status: domain.SmsWait,
  33 +// From: notices.from(),
  34 +// Index: param.Id,
  35 +// // ExecuteAt: executeAt,
  36 +// CreatedAt: time.Now(),
  37 +// }
  38 +// // 每日自评 结束前30 分钟
  39 +// // newSms.ExecuteAt = param.EndTime.Add(-1800 * time.Second)
  40 +// //改为 固定在截止时间 那天的 前一天晚上10
  41 +// y, m, d := param.EndTime.Local().Date()
  42 +// dayTime := time.Date(y, m, d, 0, 0, 0, 0, time.Local)
  43 +// newSms.ExecuteAt = dayTime.Add(-2 * time.Hour)
  44 +
  45 +// return &newSms
  46 +// }
  47 +//
  48 +// makeNotify 生成待执行的短信通知内容
22 func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.LogSms { 49 func (notices notifyStaffAssess) makeNotify(param *domain.StaffAssess) *domain.LogSms {
  50 + year, month, dayNumber := param.BeginTime.Local().Date()
  51 + // 限制只有 在每月的15号进行每日评估填报时,才进行短信消息提醒
  52 + if dayNumber != 15 {
  53 + return nil
  54 + }
  55 + // 每月15日的每日评估必做,未填写的在晚上10点下发短信提醒
  56 + dayTime := time.Date(year, month, dayNumber, 22, 0, 0, 0, time.Local)
23 newSms := domain.LogSms{ 57 newSms := domain.LogSms{
24 Id: 0, 58 Id: 0,
25 Phone: param.Executor.Account, 59 Phone: param.Executor.Account,
26 - TemplateId: 5475050,  
27 - Template: "您好,#name#,百忙之中不要忘记填写今天的绩效自评反馈哦", 60 + TemplateId: 5824230,
  61 + Template: "您好,#name#,百忙之中不要忘记填写#date#的绩效自评反馈哦",
28 Value: map[string]string{ 62 Value: map[string]string{
29 "name": param.Executor.UserName, 63 "name": param.Executor.UserName,
  64 + "data": "本月15日",
30 }, 65 },
31 Result: "", 66 Result: "",
32 Status: domain.SmsWait, 67 Status: domain.SmsWait,
33 From: notices.from(), 68 From: notices.from(),
34 Index: param.Id, 69 Index: param.Id,
35 - // ExecuteAt: executeAt, 70 + ExecuteAt: dayTime,
36 CreatedAt: time.Now(), 71 CreatedAt: time.Now(),
37 } 72 }
38 - // 每日自评 结束前30 分钟  
39 - // newSms.ExecuteAt = param.EndTime.Add(-1800 * time.Second)  
40 - //改为 固定在截止时间 那天的 前一天晚上10  
41 - y, m, d := param.EndTime.Local().Date()  
42 - dayTime := time.Date(y, m, d, 0, 0, 0, 0, time.Local)  
43 - newSms.ExecuteAt = dayTime.Add(-2 * time.Hour)  
44 return &newSms 73 return &newSms
45 } 74 }
46 75
@@ -49,11 +78,6 @@ func (notices notifyStaffAssess) ifSend(index int) (bool, error) { @@ -49,11 +78,6 @@ func (notices notifyStaffAssess) ifSend(index int) (bool, error) {
49 if constant.Env != "prd" { 78 if constant.Env != "prd" {
50 return false, nil 79 return false, nil
51 } 80 }
52 - nowDay := time.Now().Weekday()  
53 - if nowDay == time.Sunday || nowDay == time.Saturday {  
54 - //周末不发  
55 - return false, nil  
56 - }  
57 transactionContext, err := factory.CreateTransactionContext(nil) 81 transactionContext, err := factory.CreateTransactionContext(nil)
58 if err != nil { 82 if err != nil {
59 return false, err 83 return false, err
@@ -1191,6 +1191,7 @@ type CountUncompletedSelfAssess struct { @@ -1191,6 +1191,7 @@ type CountUncompletedSelfAssess struct {
1191 } 1191 }
1192 1192
1193 // CountUncompletedSelfAssess 统计整个项目周期内,相关人自评未完成数量 1193 // CountUncompletedSelfAssess 统计整个项目周期内,相关人自评未完成数量
  1194 +// 按照 每月15日自评完成情况 统计自评未完成数量
1194 func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds []int) ([]CountUncompletedSelfAssess, error) { 1195 func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds []int) ([]CountUncompletedSelfAssess, error) {
1195 sqlStr := ` 1196 sqlStr := `
1196 SELECT 1197 SELECT
@@ -1205,6 +1206,7 @@ func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds [] @@ -1205,6 +1206,7 @@ func (d *StaffAssessDao) CountUncompletedSelfAssess(companyId int, projectIds []
1205 AND staff_assess.evaluation_project_id IN (?) 1206 AND staff_assess.evaluation_project_id IN (?)
1206 AND staff_assess.status = 'uncompleted' 1207 AND staff_assess.status = 'uncompleted'
1207 AND staff_assess.end_time < now() 1208 AND staff_assess.end_time < now()
  1209 + AND date_part('day',staff_assess.created_at) = 15
1208 GROUP BY 1210 GROUP BY
1209 evaluation_project_id, target_user_id` 1211 evaluation_project_id, target_user_id`
1210 1212