作者 tangxvhui

更新 查询数据 时区的处理

... ... @@ -12,6 +12,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/staff_assess/query"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/log"
)
//员工绩效-项目管理
... ... @@ -154,7 +155,7 @@ func (srv StaffAssessServeice) ListUserAssessContentCycleDay(param *query.ListAs
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
log.Logger.Debug(fmt.Sprintf("获取到的数据列表%d", len(contentList)))
//可变的表格列
changeableHeader := []adapter.ListTableHeader{
{Key: "targetUserName", Name: "姓名"}, //固定列
... ...
... ... @@ -217,7 +217,7 @@ func (d *StaffAssessDao) SearchUserAssessContent(param SearchConditin1) ([]UserA
sqlStr0 := d.useTStaffAssess(param.CompanyId, param.CycleId, param.OperaterId, param.BeginDay, param.Hrbp, param.Limit, param.Offset)
sqlStr = sqlStr0 + sqlStr
tx := d.transactionContext.PgTx
var result []UserAssessContent
result := []UserAssessContent{}
_, err := tx.Query(&result, sqlStr, condition...)
return result, err
}
... ... @@ -259,6 +259,7 @@ func (d *StaffAssessDao) CountUserAssess(param SearchConditin1) (int, error) {
//offset int 分页偏移
func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int, beginDay string, hrbp int, limit int, offset int) string {
sqlstr := `
set time zone 'PRC';
with t_user_department as (
select "user".id as user_id ,jsonb_array_elements_text ("user".department_id) as depart_id from "user"
where "user".company_id= %d
... ... @@ -266,19 +267,16 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
t_department as (
select department.id::text as depart_id from department where charge_user_ids @>'[%d]'
),
-- 如果是部门管理员 获取用户列表
t_user_1 as (
select t_user_department.user_id::text from t_user_department
join t_department on t_user_department.depart_id = t_department.depart_id
),
-- 如果是hrbp
t_project_1 as(
select evaluation_project.id as project_id
from evaluation_project
where evaluation_project.cycle_id =%d
and evaluation_project.hr_bp = %d
),
-- 如果是项目管理员
t_project_2 as(
select evaluation_project.id as project_id
from evaluation_project
... ... @@ -286,13 +284,11 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
and evaluation_project.pmp =1
and evaluation_project.pmp_ids @>'["%d"]'
),
-- 合并数据
t_project_3 as (
select t_project_2.project_id from t_project_2
union
select t_project_1.project_id from t_project_1
),
-- 初步过滤评估列表数据
t_staff_assess_0 as (
select staff_assess.id as assess_id,
staff_assess.target_user->>'userId' as target_user_id,
... ... @@ -304,7 +300,6 @@ func (d *StaffAssessDao) useTStaffAssess(companyId int, cycleId int, userId int,
and to_char(staff_assess.begin_time,'YYYY-MM-DD')='%s'
and staff_assess."types" ='self'
),
-- 合并根据权限过滤后的数据
t_staff_assess_1 as (
(select t_staff_assess_0.assess_id,
t_staff_assess_0.target_user_id,
... ...
... ... @@ -15,6 +15,7 @@ import (
var DB *pg.DB
func init() {
DB = pg.Connect(&pg.Options{
User: constant.POSTGRESQL_USER,
Password: constant.POSTGRESQL_PASSWORD,
... ...