作者 tangxvhui

Merge branch 'test'

@@ -12,6 +12,7 @@ import ( @@ -12,6 +12,7 @@ import (
12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query" 12 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain" 13 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
14 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao" 14 "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
  15 + "gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
15 ) 16 )
16 17
17 //员工绩效-项目管理 18 //员工绩效-项目管理
@@ -154,7 +155,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs @@ -154,7 +155,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
154 if err := transactionContext.CommitTransaction(); err != nil { 155 if err := transactionContext.CommitTransaction(); err != nil {
155 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 156 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
156 } 157 }
157 - 158 + log.Logger.Debug(fmt.Sprintf("获取到的数据列表%d", len(contentList)))
158 //可变的表格列 159 //可变的表格列
159 changeableHeader := []adapter.ListTableHeader{ 160 changeableHeader := []adapter.ListTableHeader{
160 {Key: "targetUserName", Name: "姓名"}, //固定列 161 {Key: "targetUserName", Name: "姓名"}, //固定列
@@ -217,7 +217,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA @@ -217,7 +217,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA
217 sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset) 217 sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
218 sqlStr = sqlStr0 + sqlStr 218 sqlStr = sqlStr0 + sqlStr
219 tx := d.transactionContext.PgTx 219 tx := d.transactionContext.PgTx
220 - var result []UserAssessContent 220 + result := []UserAssessContent{}
221 _, err := tx.Query(&result, sqlStr, condition...) 221 _, err := tx.Query(&result, sqlStr, condition...)
222 return result, err 222 return result, err
223 } 223 }
@@ -259,6 +259,7 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) { @@ -259,6 +259,7 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) {
259 //offset int 分页偏移 259 //offset int 分页偏移
260 func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string { 260 func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string {
261 sqlstr := ` 261 sqlstr := `
  262 + set time zone 'PRC';
262 with t_user_department as ( 263 with t_user_department as (
263 select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user" 264 select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
264 where "user".company_id= %d 265 where "user".company_id= %d
@@ -266,19 +267,16 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -266,19 +267,16 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
266 t_department as ( 267 t_department as (
267 select department.id::text as depart_id from department where charge_user_ids @>'[%d]' 268 select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
268 ), 269 ),
269 - -- 如果是部门管理员 获取用户列表  
270 t_user_1 as ( 270 t_user_1 as (
271 select t_user_department.user_id::text from t_user_department 271 select t_user_department.user_id::text from t_user_department
272 join t_department on t_user_department.depart_id = t_department.depart_id 272 join t_department on t_user_department.depart_id = t_department.depart_id
273 ), 273 ),
274 - -- 如果是hrbp  
275 t_project_1 as( 274 t_project_1 as(
276 select evaluation_project.id as project_id 275 select evaluation_project.id as project_id
277 from evaluation_project 276 from evaluation_project
278 where evaluation_project.cycle_id =%d 277 where evaluation_project.cycle_id =%d
279 and evaluation_project.hr_bp = %d 278 and evaluation_project.hr_bp = %d
280 ), 279 ),
281 - -- 如果是项目管理员  
282 t_project_2 as( 280 t_project_2 as(
283 select evaluation_project.id as project_id 281 select evaluation_project.id as project_id
284 from evaluation_project 282 from evaluation_project
@@ -286,13 +284,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -286,13 +284,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
286 and evaluation_project.pmp =1 284 and evaluation_project.pmp =1
287 and evaluation_project.pmp_ids @>'["%d"]' 285 and evaluation_project.pmp_ids @>'["%d"]'
288 ), 286 ),
289 - -- 合并数据  
290 t_project_3 as ( 287 t_project_3 as (
291 select t_project_2.project_id from t_project_2 288 select t_project_2.project_id from t_project_2
292 union 289 union
293 select t_project_1.project_id from t_project_1 290 select t_project_1.project_id from t_project_1
294 ), 291 ),
295 - -- 初步过滤评估列表数据  
296 t_staff_assess_0 as ( 292 t_staff_assess_0 as (
297 select staff_assess.id as assess_id, 293 select staff_assess.id as assess_id,
298 staff_assess.target_user->>'userId' as target_user_id, 294 staff_assess.target_user->>'userId' as target_user_id,
@@ -304,7 +300,6 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, @@ -304,7 +300,6 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
304 and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s' 300 and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
305 and staff_assess."types" ='self' 301 and staff_assess."types" ='self'
306 ), 302 ),
307 - -- 合并根据权限过滤后的数据  
308 t_staff_assess_1 as ( 303 t_staff_assess_1 as (
309 (select t_staff_assess_0.assess_id, 304 (select t_staff_assess_0.assess_id,
310 t_staff_assess_0.target_user_id, 305 t_staff_assess_0.target_user_id,
@@ -15,6 +15,7 @@ import ( @@ -15,6 +15,7 @@ import (
15 var DB *pg.DB 15 var DB *pg.DB
16 16
17 func init() { 17 func init() {
  18 +
18 DB = pg.Connect(&pg.Options{ 19 DB = pg.Connect(&pg.Options{
19 User: constant.POSTGRESQL_USER, 20 User: constant.POSTGRESQL_USER,
20 Password: constant.POSTGRESQL_PASSWORD, 21 Password: constant.POSTGRESQL_PASSWORD,
@@ -45,7 +45,7 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time { @@ -45,7 +45,7 @@ func NextTime(now0 time.Time, start time.Time, kpiCycle int) time.Time {
45 var nextTime time.Time 45 var nextTime time.Time
46 switch kpiCycle { 46 switch kpiCycle {
47 case domain.KpiCycleDay: 47 case domain.KpiCycleDay:
48 - nextTime = timeconv.AddDate(now0, 0, 0, 1) // 当前时间的下一天0点开始发送 48 + nextTime = timeconv.AddDate(now0, 0, 0, 0) // 当前时间的0点开始发送
49 break 49 break
50 case domain.KpiCycleWeek: 50 case domain.KpiCycleWeek:
51 offsetSeconds := int64(now0.Sub(start0).Seconds()) 51 offsetSeconds := int64(now0.Sub(start0).Seconds())