作者 tangxvhui
... ... @@ -17,6 +17,7 @@ type EvaluationProjectAdapter struct {
}
func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []*domain.User) {
adapter.RecipientList = make([]*UserAdapter, 0)
for i := range recipients {
adapter.RecipientList = append(adapter.RecipientList, &UserAdapter{
Id: recipients[i].Id,
... ... @@ -26,6 +27,7 @@ func (adapter *EvaluationProjectAdapter) TransformRecipientAdapter(recipients []
}
func (adapter *EvaluationProjectAdapter) TransformPmpAdapter(pms []*domain.User) {
adapter.PmpList = make([]*UserAdapter, 0)
for i := range pms {
adapter.PmpList = append(adapter.PmpList, &UserAdapter{
Id: pms[i].Id,
... ... @@ -46,6 +48,8 @@ func TransformProjectListAdapter(projects []*domain.EvaluationProject, users []*
epa := &EvaluationProjectAdapter{}
epa.EvaluationProject = project
epa.PmpList = make([]*UserAdapter, 0)
projectAdapters = append(projectAdapters, epa)
for j := range project.PmpIds {
... ...
... ... @@ -185,18 +185,20 @@ func (rs *EvaluationProjectService) UpdateTemplate(in *command.UpdateProjectTemp
// 重新计算
if task.NextSentAt == nil {
// 环节起始和截止本地时间
startLocal := task.TimeStart
endLocal := task.TimeEnd
startLocal := task.TimeStart.Local()
sYear, sMonth, sDay := startLocal.Date()
startLocal = time.Date(sYear, sMonth, sDay, 0, 0, 0, 0, time.Local) // 开始时间以0点开始计算
endLocal := task.TimeEnd.Local()
// 在当前时间之前,则计算下一个周期时间
if startLocal.Before(now) {
nextTime := utils.NextTime(nowO, startLocal, task.KpiCycle)
task.NextSentAt = &nextTime
} else {
task.NextSentAt = startLocal
task.NextSentAt = &startLocal
}
// 如果超出截至时间,则周期置空
if task.NextSentAt.After(endLocal.Local()) {
if task.NextSentAt.After(endLocal) {
task.NextSentAt = nil
}
} else {
... ... @@ -435,6 +437,7 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}()
projectRepository := factory.CreateEvaluationProjectRepository(map[string]interface{}{"transactionContext": transactionContext})
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
project, err := projectRepository.FindOne(map[string]interface{}{"id": in.Id})
if err != nil {
... ... @@ -456,8 +459,6 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
taskRepository := factory.CreateNodeTaskRepository(map[string]interface{}{"transactionContext": transactionContext})
now := time.Now().Local()
nowO := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) // 当前时间0点0分0秒时刻
... ... @@ -479,18 +480,20 @@ func (rs *EvaluationProjectService) Activate(in *command.ActivateProjectCommand)
}
// 环节起始和截止本地时间
startLocal := node.TimeStart
endLocal := node.TimeEnd
startLocal := task.TimeStart.Local()
sYear, sMonth, sDay := startLocal.Date()
startLocal = time.Date(sYear, sMonth, sDay, 0, 0, 0, 0, time.Local) // 开始时间以0点开始计算
endLocal := task.TimeEnd.Local()
// 在当前时间之前,则计算下一个周期时间
if startLocal.Before(now) {
nextTime := utils.NextTime(nowO, startLocal, node.KpiCycle)
task.NextSentAt = &nextTime
} else {
task.NextSentAt = startLocal
task.NextSentAt = &startLocal
}
// 如果超出截至时间,则周期置空
if task.NextSentAt.After(endLocal.Local()) {
if task.NextSentAt.After(endLocal) {
task.NextSentAt = nil
}
... ...
... ... @@ -87,7 +87,7 @@ func (rs *NodeTaskService) SendEvaluationNode() error {
maxTime := task.TimeEnd.Local()
// 当前周起始时间和截止时间
var cycleTimeStart = task.NextSentAt
var cycleTimeStart = task.NextSentAt.Local()
var cycleTimeEnd time.Time
// 下个周期起始时间
... ...
... ... @@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/user/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)
type UserService struct{}
... ... @@ -26,6 +27,7 @@ func (service *UserService) ListUsers(listUserQuery *query.ListUserQuery) (inter
count, list, err := userRepo.Find(map[string]interface{}{
"companyId": listUserQuery.CompanyId,
"name": listUserQuery.Name,
"status": domain.UserStatusEnable,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -24,7 +24,7 @@ const (
UserTypeCommon int = 1
UserTypeManager int = 2
UserStatusEnable int = 1
UserStatusEnable int = 1 // 正常用户 2禁用用户
)
type UserRepository interface {
... ...
... ... @@ -21,9 +21,6 @@ func NewNodeTaskRepository(transactionContext *pgTransaction.TransactionContext)
}
func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.NodeTask {
timeStart := m.TimeStart.Local()
timeEnd := m.TimeEnd.Local()
nextSentAt := m.NextSentAt.Local()
return domain.NodeTask{
Id: m.Id,
CompanyId: m.CompanyId,
... ... @@ -34,10 +31,10 @@ func (repo *NodeTaskRepository) TransformToDomain(m *models.NodeTask) domain.Nod
NodeName: m.NodeName,
NodeDescribe: m.NodeDescribe,
NodeSort: m.NodeSort,
TimeStart: &timeStart,
TimeEnd: &timeEnd,
TimeStart: m.TimeStart,
TimeEnd: m.TimeEnd,
KpiCycle: m.KpiCycle,
NextSentAt: &nextSentAt,
NextSentAt: m.NextSentAt,
CreatedAt: m.CreatedAt.Local(),
UpdatedAt: m.UpdatedAt.Local(),
DeletedAt: m.DeletedAt,
... ...
... ... @@ -119,6 +119,9 @@ func (repo *UserRepository) Find(queryOptions map[string]interface{}) (int, []*d
if v, ok := queryOptions["account"]; ok {
query.Where("account like ?", v)
}
if v, ok := queryOptions["status"]; ok {
query.Where("status=?", v)
}
if v, ok := queryOptions["name"].(string); ok && len(v) > 0 {
query.Where("name like ?", fmt.Sprintf("%%%v%%", v))
}
... ...
... ... @@ -37,7 +37,7 @@ func ValidateCommand(commandType interface{}) error {
}
// NextTime 0点时刻为标准计算
func NextTime(now0 time.Time, start *time.Time, kpiCycle int) time.Time {
func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time {
year, month, day := start.Date()
// 起始时间0点时刻
start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
... ... @@ -141,7 +141,7 @@ func SubMonth(t1, t2 time.Time) (month int) {
}
// NextTimeInc 0点时刻为标准计算
func NextTimeInc(start *time.Time, kpiCycle int) time.Time {
func NextTimeInc(start time.Time, kpiCycle int) time.Time {
year, month, day := start.Date()
// 起始时间0点时刻
start0 := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
... ...