作者 tangxvhui

清理 代码

@@ -1208,15 +1208,6 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC @@ -1208,15 +1208,6 @@ func (srv *SummaryEvaluationService) getEvaluationSuperDefaultValue(transactionC
1208 "transactionContext": transactionContext, 1208 "transactionContext": transactionContext,
1209 }) 1209 })
1210 1210
1211 - // permissionRepository := factory.CreatePermissionRepository(map[string]interface{}{"transactionContext": transactionContext})  
1212 - // // 获取权限配置  
1213 - // _, permissionList, err := permissionRepository.Find(map[string]interface{}{"companyId": evaluationData.CompanyId})  
1214 - // if err != nil {  
1215 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
1216 - // }  
1217 - // if len(permissionList) == 0 {  
1218 - // return nil, nil  
1219 - // }  
1220 permissionData, err := getPermission(int64(evaluationData.CompanyId)) 1211 permissionData, err := getPermission(int64(evaluationData.CompanyId))
1221 if err != nil { 1212 if err != nil {
1222 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1213 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1977,13 +1968,6 @@ func (srv *SummaryEvaluationService) editEvaluationValue( @@ -1977,13 +1968,6 @@ func (srv *SummaryEvaluationService) editEvaluationValue(
1977 } 1968 }
1978 //完全更新itemValueList 1969 //完全更新itemValueList
1979 *itemValueList = evaluationValueSlice 1970 *itemValueList = evaluationValueSlice
1980 - // *itemValueList = (*itemValueList)[0:0]  
1981 - // for _, v := range evaluationValueMap {  
1982 - // *itemValueList = append(*itemValueList, v)  
1983 - // }  
1984 - // sort.Slice(*itemValueList, func(i, j int) bool {  
1985 - // return (*itemValueList)[i].EvaluationItemId < (*itemValueList)[j].EvaluationItemId  
1986 - // })  
1987 // 计算总得分 1971 // 计算总得分
1988 err := evaluationData.EvaluationTotalScore(*itemValueList) 1972 err := evaluationData.EvaluationTotalScore(*itemValueList)
1989 if err != nil { 1973 if err != nil {
@@ -745,239 +745,6 @@ func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) er @@ -745,239 +745,6 @@ func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) er
745 return nil 745 return nil
746 } 746 }
747 747
748 -// 员工绩效-任务管理-列表  
749 -// func (srv TaskService) ListTask2(param *command.SearchTaskCommand) (map[string]interface{}, error) {  
750 -// transactionContext, err := factory.CreateTransactionContext(nil)  
751 -// if err != nil {  
752 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
753 -// }  
754 -// if err := transactionContext.StartTransaction(); err != nil {  
755 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
756 -// }  
757 -// defer func() {  
758 -// _ = transactionContext.RollbackTransaction()  
759 -// }()  
760 -// hrbpFlag, err := roleService.GetHrBp(transactionContext, int(param.CompanyId), int(param.UserId))  
761 -// if err != nil {  
762 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取用户的角色信息"+err.Error())  
763 -// }  
764 -// if len(param.SearchWord) > 0 {  
765 -// param.SearchWord = "%" + param.SearchWord + "%"  
766 -// }  
767 -// if hrbpFlag == domain.RoleTypeSystem {  
768 -// listData, err := srv.listTask2ForHrbp(param)  
769 -// return listData, err  
770 -// }  
771 -// var limit = 20  
772 -// var offset = 0  
773 -// if param.PageSize > 0 {  
774 -// limit = param.PageSize  
775 -// if param.PageNumber > 0 {  
776 -// offset = (param.PageNumber - 1) * param.PageSize  
777 -// }  
778 -// }  
779 -// condition := dao.ListTaskCondition{  
780 -// Limit: limit,  
781 -// Offset: offset,  
782 -// UserId: param.UserId,  
783 -// CompanyId: param.CompanyId,  
784 -// OnlyMy: param.OnlyMy,  
785 -// SearchWord: param.SearchWord,  
786 -// }  
787 -  
788 -// taskDao := dao.NewTaskDao(map[string]interface{}{  
789 -// "transactionContext": transactionContext,  
790 -// })  
791 -// //任务列表数据  
792 -// tasklistData, err := taskDao.ListTaskStageNotHrbp(condition)  
793 -// if err != nil {  
794 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())  
795 -// }  
796 -// //查到的任务数据总数  
797 -// taskCount, err := taskDao.CountTaskNotHrbp(condition)  
798 -// if err != nil {  
799 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())  
800 -// }  
801 -// //  
802 -// taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyNotHrbp(condition)  
803 -// if err != nil {  
804 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())  
805 -// }  
806 -// taskAnomalyCnt, err := taskDao.CountTaskAnomalyNotHrbp(condition)  
807 -// if err != nil {  
808 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())  
809 -// }  
810 -// if err := transactionContext.CommitTransaction(); err != nil {  
811 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
812 -// }  
813 -  
814 -// taskResult := []*adapter.TaskItem{}  
815 -// taskMapResult := map[int]*adapter.TaskItem{}  
816 -// for _, val := range tasklistData {  
817 -// if _, ok := taskMapResult[val.TaskId]; ok {  
818 -// continue  
819 -// }  
820 -// tk := adapter.TaskItem{  
821 -// Id: val.TaskId,  
822 -// Name: val.TaskName,  
823 -// Alias: val.TaskAliasName,  
824 -// Leader: val.LeaderName,  
825 -// Status: val.TaskStatus,  
826 -// Level: val.Level,  
827 -// LevelName: val.LevelName,  
828 -// UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),  
829 -// Anomaly: val.Anomaly,  
830 -// WarnFlag: val.WarnFlag,  
831 -// }  
832 -// taskMapResult[val.TaskId] = &tk  
833 -// taskResult = append(taskResult, &tk)  
834 -// }  
835 -// for _, val := range tasklistData {  
836 -// taskData, ok := taskMapResult[val.TaskId]  
837 -// if !ok {  
838 -// continue  
839 -// }  
840 -// stage := adapter.TaskStage{  
841 -// Id: val.StageId,  
842 -// Name: val.StageName,  
843 -// SortBy: val.StageSortBy,  
844 -// PlanCompletedAt: time.Unix(int64(val.PlanCompletedAt), 0).Local().Format("2006-01-02"),  
845 -// RealCompletedAt: "",  
846 -// }  
847 -// if val.RealCompletedAt > 0 {  
848 -// stage.RealCompletedAt = time.Unix(int64(val.RealCompletedAt), 0).Local().Format("2006-01-02")  
849 -// }  
850 -// switch val.StageSortBy {  
851 -// case 1:  
852 -// taskData.StageA = stage  
853 -// case 2:  
854 -// taskData.StageB = stage  
855 -// case 3:  
856 -// taskData.StageC = stage  
857 -// case 4:  
858 -// taskData.StageD = stage  
859 -// case 5:  
860 -// taskData.StageE = stage  
861 -// }  
862 -  
863 -// }  
864 -// result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)  
865 -// result["taskStageAnomaly"] = taskStageAnomalyCnt  
866 -// result["taskAnomalyCnt"] = taskAnomalyCnt  
867 -// return result, nil  
868 -// }  
869 -  
870 -// 以hrbp角色权限获取任务列表  
871 -// 统计里程碑异常数,反馈异常数  
872 -// func (srv TaskService) listTask2ForHrbp(param *command.SearchTaskCommand) (map[string]interface{}, error) {  
873 -// var limit = 20  
874 -// var offset = 0  
875 -// if param.PageSize > 0 {  
876 -// limit = param.PageSize  
877 -// if param.PageNumber > 0 {  
878 -// offset = (param.PageNumber - 1) * param.PageSize  
879 -// }  
880 -// }  
881 -// condition := dao.ListTaskCondition{  
882 -// Limit: limit,  
883 -// Offset: offset,  
884 -// UserId: param.UserId,  
885 -// CompanyId: param.CompanyId,  
886 -// OnlyMy: param.OnlyMy,  
887 -// SearchWord: param.SearchWord,  
888 -// }  
889 -// transactionContext, err := factory.CreateTransactionContext(nil)  
890 -// if err != nil {  
891 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
892 -// }  
893 -// if err := transactionContext.StartTransaction(); err != nil {  
894 -// return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
895 -// }  
896 -// defer func() {  
897 -// _ = transactionContext.RollbackTransaction()  
898 -// }()  
899 -// taskDao := dao.NewTaskDao(map[string]interface{}{  
900 -// "transactionContext": transactionContext,  
901 -// })  
902 -// tasklistData, err := taskDao.ListTaskStageByHrbp(condition)  
903 -// if err != nil {  
904 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取任务列表"+err.Error())  
905 -// }  
906 -// taskCount, err := taskDao.CountTaskByHrbp(condition)  
907 -// if err != nil {  
908 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务总数"+err.Error())  
909 -// }  
910 -// taskStageAnomalyCnt, err := taskDao.CountTaskStageAnomalyByHrbp(condition)  
911 -// if err != nil {  
912 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())  
913 -// }  
914 -// taskAnomalyCnt, err := taskDao.CountTaskAnomalyByHrbp(condition)  
915 -// if err != nil {  
916 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "统计任务里程碑总数"+err.Error())  
917 -// }  
918 -// if err := transactionContext.CommitTransaction(); err != nil {  
919 -// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
920 -// }  
921 -// taskResult := []*adapter.TaskItem{}  
922 -// taskMapResult := map[int]*adapter.TaskItem{}  
923 -// for _, val := range tasklistData {  
924 -// if _, ok := taskMapResult[val.TaskId]; ok {  
925 -// continue  
926 -// }  
927 -// tk := adapter.TaskItem{  
928 -// Id: val.TaskId,  
929 -// Name: val.TaskName,  
930 -// Alias: val.TaskAliasName,  
931 -// Leader: val.LeaderName,  
932 -// Status: val.TaskStatus,  
933 -// Level: val.Level,  
934 -// LevelName: val.LevelName,  
935 -// UpdatedAt: val.UpdatedAt.Local().Format("2006-01-02 15:04:05"),  
936 -// Anomaly: val.Anomaly,  
937 -// WarnFlag: val.WarnFlag,  
938 -// // StageA: adapter.TaskStage{},  
939 -// // StageB: adapter.TaskStage{},  
940 -// // StageC: adapter.TaskStage{},  
941 -// // StageD: adapter.TaskStage{},  
942 -// // StageE: adapter.TaskStage{},  
943 -// }  
944 -// taskMapResult[val.TaskId] = &tk  
945 -// taskResult = append(taskResult, &tk)  
946 -// }  
947 -// for _, val := range tasklistData {  
948 -// taskData, ok := taskMapResult[val.TaskId]  
949 -// if !ok {  
950 -// continue  
951 -// }  
952 -// stage := adapter.TaskStage{  
953 -// Id: val.StageId,  
954 -// Name: val.StageName,  
955 -// SortBy: val.StageSortBy,  
956 -// PlanCompletedAt: time.Unix(int64(val.PlanCompletedAt), 0).Local().Format("2006-01-02"),  
957 -// RealCompletedAt: "",  
958 -// }  
959 -// if val.RealCompletedAt > 0 {  
960 -// stage.RealCompletedAt = time.Unix(int64(val.RealCompletedAt), 0).Local().Format("2006-01-02")  
961 -// }  
962 -// switch val.StageSortBy {  
963 -// case 1:  
964 -// taskData.StageA = stage  
965 -// case 2:  
966 -// taskData.StageB = stage  
967 -// case 3:  
968 -// taskData.StageC = stage  
969 -// case 4:  
970 -// taskData.StageD = stage  
971 -// case 5:  
972 -// taskData.StageE = stage  
973 -// }  
974 -// }  
975 -// result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)  
976 -// result["taskStageAnomaly"] = taskStageAnomalyCnt  
977 -// result["taskAnomalyCnt"] = taskAnomalyCnt  
978 -// return result, nil  
979 -// }  
980 -  
981 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑 748 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
982 func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error { 749 func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error {
983 taskRepo := factory.CreateTaskRepository(map[string]interface{}{ 750 taskRepo := factory.CreateTaskRepository(map[string]interface{}{
@@ -1002,17 +769,8 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction @@ -1002,17 +769,8 @@ func (srv TaskService) ReplyTaskStage(transactionContext application.Transaction
1002 if len(stageList) == 0 { 769 if len(stageList) == 0 {
1003 continue 770 continue
1004 } 771 }
1005 - // 避免当天多次编辑提交,数量递增  
1006 - // if isFirstSubmit && val.AnomalyState == domain.AnomalyState0 {  
1007 - // taskData.Anomaly += 1  
1008 - // }  
1009 - // trimSpace := strings.TrimLeft(val.AssistContent, "\n") // 去掉前换行符  
1010 - // trimSpace = strings.TrimRight(trimSpace, "\n") // 去掉后换行符  
1011 - // trimSpace = strings.TrimSpace(trimSpace) // 去掉前后空格符  
1012 - // // 上级填写内容有值,选项是已辅导,变为正常  
1013 - // if !(len(trimSpace) == 0 || trimSpace == "无") && val.AssistLevel >= domain.AssistLevel2 {  
1014 - // taskData.Anomaly = 0  
1015 - // } 772 +
  773 + //改为定时检查每日任务反馈,并计算反馈异常数
1016 for _, val2 := range stageList { 774 for _, val2 := range stageList {
1017 if val2.Id != val.TaskStageCheck.Id { 775 if val2.Id != val.TaskStageCheck.Id {
1018 continue 776 continue
@@ -116,37 +116,37 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed @@ -116,37 +116,37 @@ func (itemValue *SummaryEvaluationValue) valueTypeScore(item *EvaluationItemUsed
116 } 116 }
117 117
118 // 填写综合自评 118 // 填写综合自评
119 -func (itemValue *SummaryEvaluationValue) EvaluationSelfFillValue(item *EvaluationItemUsed, value string, remark string) error {  
120 - itemValue.Remark = remark  
121 - if item.Weight == 0 {  
122 - //使用评级的形式  
123 - err := itemValue.valueTypeRating(item, value)  
124 - return err  
125 - }  
126 - //综合自评 评分的形式,特殊处理  
127 - err := itemValue.valueTypeScoreEvaluationSelf(item, value)  
128 - return err  
129 -} 119 +// func (itemValue *SummaryEvaluationValue) EvaluationSelfFillValue(item *EvaluationItemUsed, value string, remark string) error {
  120 +// itemValue.Remark = remark
  121 +// if item.Weight == 0 {
  122 +// //使用评级的形式
  123 +// err := itemValue.valueTypeRating(item, value)
  124 +// return err
  125 +// }
  126 +// //综合自评 评分的形式,特殊处理
  127 +// err := itemValue.valueTypeScoreEvaluationSelf(item, value)
  128 +// return err
  129 +// }
130 130
131 -func (itemValue *SummaryEvaluationValue) valueTypeScoreEvaluationSelf(item *EvaluationItemUsed, value string) error {  
132 - if item.Weight <= 0 {  
133 - return errors.New("评分方式错误")  
134 - }  
135 - value = strings.TrimSpace(value)  
136 - itemValue.Value = value  
137 - //处理空值  
138 - if len(value) == 0 {  
139 - itemValue.Score = "0"  
140 - return nil  
141 - }  
142 - valueNumber, err := strconv.ParseFloat(value, 64)  
143 - if err != nil {  
144 - return fmt.Errorf("条目%d:%s-%s评分值异常", item.Id, item.Category, item.Name)  
145 - } 131 +// func (itemValue *SummaryEvaluationValue) valueTypeScoreEvaluationSelf(item *EvaluationItemUsed, value string) error {
  132 +// if item.Weight <= 0 {
  133 +// return errors.New("评分方式错误")
  134 +// }
  135 +// value = strings.TrimSpace(value)
  136 +// itemValue.Value = value
  137 +// //处理空值
  138 +// if len(value) == 0 {
  139 +// itemValue.Score = "0"
  140 +// return nil
  141 +// }
  142 +// valueNumber, err := strconv.ParseFloat(value, 64)
  143 +// if err != nil {
  144 +// return fmt.Errorf("条目%d:%s-%s评分值异常", item.Id, item.Category, item.Name)
  145 +// }
146 146
147 - // 分数保留2位小数  
148 - score := valueNumber * item.Weight  
149 - itemValue.Score = fmt.Sprintf("%.2f", score) 147 +// // 分数保留2位小数
  148 +// score := valueNumber * item.Weight
  149 +// itemValue.Score = fmt.Sprintf("%.2f", score)
150 150
151 - return nil  
152 -} 151 +// return nil
  152 +// }
@@ -86,51 +86,6 @@ func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int @@ -86,51 +86,6 @@ func (d *StaffAssessDao) CountTargetUserInviteAssess1(userIds []int, cycleId int
86 return result, err 86 return result, err
87 } 87 }
88 88
89 -// 根据评估的人执行人id,搜索 executorId参与的评估任务  
90 -// func (d *StaffAssessDao) SearchAssessTaskMe(executorId int, companyId int, limit int, offset int) ([]*domain.StaffAssessTask, error) {  
91 -  
92 -// if limit < 0 {  
93 -// limit = 20  
94 -// }  
95 -// if offset < 0 {  
96 -// offset = 0  
97 -// }  
98 -  
99 -// sqlStr := `SELECT DISTINCT staff_assess_task.* FROM staff_assess_task  
100 -// JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"  
101 -// WHERE staff_assess.company_id=?  
102 -// and staff_assess_task.deleted_at isnull  
103 -// and staff_assess.executor->>'userId'='?'  
104 -// order by staff_assess_task.id desc  
105 -// limit ? offset ?  
106 -// `  
107 -// tx := d.transactionContext.PgTx  
108 -// condition := []interface{}{  
109 -// companyId, executorId, limit, offset,  
110 -// }  
111 -// result := []*domain.StaffAssessTask{}  
112 -// _, err := tx.Query(&result, sqlStr, condition...)  
113 -// return result, err  
114 -  
115 -// }  
116 -  
117 -// 搜索 executorId 参与的评估任务  
118 -// func (d *StaffAssessDao) CountAssessTaskMe(executorId int, companyId int) (int, error) {  
119 -// sqlStr := `SELECT count( DISTINCT staff_assess_task."id") FROM staff_assess_task  
120 -// JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"  
121 -// WHERE staff_assess.company_id=?  
122 -// and staff_assess_task.deleted_at isnull  
123 -// and staff_assess.executor->>'userId'='?'  
124 -// `  
125 -// tx := d.transactionContext.PgTx  
126 -// condition := []interface{}{  
127 -// companyId, executorId,  
128 -// }  
129 -// result := 0  
130 -// _, err := tx.QueryOne(pg.Scan(&result), sqlStr, condition...)  
131 -// return result, err  
132 -// }  
133 -  
134 // 获取所以已经执行的评估周期 89 // 获取所以已经执行的评估周期
135 type AssessCycle struct { 90 type AssessCycle struct {
136 CycleId string `json:"cycleId"` //周期id 91 CycleId string `json:"cycleId"` //周期id
@@ -1043,38 +998,6 @@ type AssessCycleDayExecutor struct { @@ -1043,38 +998,6 @@ type AssessCycleDayExecutor struct {
1043 BeginTime string `pg:"begin_time"` 998 BeginTime string `pg:"begin_time"`
1044 } 999 }
1045 1000
1046 -// 根据评估的人执行人id,搜索 executorId参与的评估周期  
1047 -// func (d *StaffAssessDao) SearchAssessCycleMe(executorId int, companyId int, limit int, offset int) ([]AssessCycleDayExecutor, error) {  
1048 -// if limit < 0 {  
1049 -// limit = 20  
1050 -// }  
1051 -// if offset < 0 {  
1052 -// offset = 0  
1053 -// }  
1054 -// sqlStr := `  
1055 -// SELECT  
1056 -// distinct on(staff_assess_task.cycle_id,staff_assess_task.begin_day)  
1057 -// staff_assess_task.cycle_id,staff_assess_task.cycle_name ,  
1058 -// staff_assess_task.begin_day,  
1059 -// to_char(staff_assess_task.end_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as end_time,  
1060 -// to_char(staff_assess_task.begin_time at time zone 'PRC','YYYY-MM-DD HH24:MI:SS') as begin_time  
1061 -// FROM staff_assess_task  
1062 -// JOIN staff_assess ON staff_assess_task."id" = staff_assess."staff_assess_task_id"  
1063 -// WHERE staff_assess.company_id=?  
1064 -// and staff_assess_task.deleted_at isnull  
1065 -// and staff_assess.executor->>'userId'='?'  
1066 -// order by staff_assess_task.begin_day desc  
1067 -// limit ? offset ?  
1068 -// `  
1069 -// tx := d.transactionContext.PgTx  
1070 -// condition := []interface{}{  
1071 -// companyId, executorId, limit, offset,  
1072 -// }  
1073 -// result := []AssessCycleDayExecutor{}  
1074 -// _, err := tx.Query(&result, sqlStr, condition...)  
1075 -// return result, err  
1076 -// }  
1077 -  
1078 // 根据评估的人执行人id,统计executorId参与的评估周期 1001 // 根据评估的人执行人id,统计executorId参与的评估周期
1079 func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) { 1002 func (d *StaffAssessDao) CountAssessCycleMe(executorId int, companyId int) (int, error) {
1080 sqlStr := ` 1003 sqlStr := `
@@ -92,90 +92,6 @@ type ListTaskStage struct { @@ -92,90 +92,6 @@ type ListTaskStage struct {
92 RealCompletedAt int `pg:"real_completed_at"` 92 RealCompletedAt int `pg:"real_completed_at"`
93 } 93 }
94 94
95 -// (弃用) 获取任务以及里程碑列表,用于页面展示; 有过滤查看权限  
96 -// userid 谁要查看任务数据  
97 -// limit 分页  
98 -// offset 分页  
99 -// func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage, error) {  
100 -// task1 := d.catchTaskIdByPermission(param.UserId)  
101 -// withSql := task1 + `,  
102 -// -- 获取的里程碑数据,以及排序  
103 -// t_task_tage_1 as(  
104 -// select  
105 -// task.id as task_id,  
106 -// task."name" as task_name,  
107 -// task."alias" as task_alias_name,  
108 -// task.leader ->>'name' as leader_name,  
109 -// task.leader ->>'id' as leader_id,  
110 -// task.level_name ,  
111 -// task.anomaly ,  
112 -// task.updated_at ,  
113 -// task.created_at ,  
114 -// task."level" ,  
115 -// task."warn_flag",  
116 -// task."status" as task_status,  
117 -// task_stage."id" as stage_id,  
118 -// task_stage."name" as stage_name,  
119 -// task_stage.sort_by as stage_sort_by,  
120 -// task_stage.plan_completed_at,  
121 -// task_stage.real_completed_at,  
122 -// (case  
123 -// when task_stage.real_completed_at =0  
124 -// then task_stage.plan_completed_at - floor( extract(epoch from now()))  
125 -// else task_stage.plan_completed_at - task_stage.real_completed_at  
126 -// end) as diff_time  
127 -// from task  
128 -// join t_task_1 on task.id=t_task_1.id  
129 -// join task_stage on task.id =task_stage.task_id  
130 -// where 1=1 and task.company_id=?  
131 -// order by diff_time,task."level",task.created_at desc  
132 -// ),  
133 -// -- 按任务数据分页获取  
134 -// t_task_page as (  
135 -// select distinct t_task_tage_1.task_id  
136 -// from t_task_tage_1  
137 -// where 1=1  
138 -// %s  
139 -// limit ? offset ?  
140 -// )  
141 -// select  
142 -// t_task_tage_1.task_id,  
143 -// t_task_tage_1.task_name,  
144 -// t_task_tage_1.task_alias_name,  
145 -// t_task_tage_1.leader_name,  
146 -// t_task_tage_1.level_name ,  
147 -// t_task_tage_1.anomaly ,  
148 -// t_task_tage_1.updated_at ,  
149 -// t_task_tage_1.created_at ,  
150 -// t_task_tage_1."level" ,  
151 -// t_task_tage_1.plan_completed_at,  
152 -// t_task_tage_1.real_completed_at,  
153 -// t_task_tage_1.stage_name,  
154 -// t_task_tage_1.stage_id,  
155 -// t_task_tage_1.stage_sort_by,  
156 -// t_task_tage_1."warn_flag"  
157 -// from t_task_tage_1  
158 -// where t_task_tage_1.task_id in(  
159 -// select t_task_page.task_id from t_task_page  
160 -// )`  
161 -// condition := []interface{}{param.CompanyId}  
162 -// whereSql := ``  
163 -// if param.OnlyMy {  
164 -// condition = append(condition, param.UserId)  
165 -// whereSql += ` and t_task_tage_1.leader_id = '?' `  
166 -// }  
167 -// if param.SearchWord != "" {  
168 -// condition = append(condition, param.SearchWord, param.SearchWord)  
169 -// whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?)`  
170 -// }  
171 -// condition = append(condition, param.Limit, param.Offset)  
172 -// sqlStr := fmt.Sprintf(withSql, whereSql)  
173 -// result := []ListTaskStage{}  
174 -// tx := d.transactionContext.PgTx  
175 -// _, err := tx.Query(&result, sqlStr, condition...)  
176 -// return result, err  
177 -// }  
178 -  
179 // 获取任务总数,用于页面展示; 有过滤查看权限 95 // 获取任务总数,用于页面展示; 有过滤查看权限
180 func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { 96 func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) {
181 task1 := d.catchTaskIdByPermission(param.UserId) 97 task1 := d.catchTaskIdByPermission(param.UserId)
@@ -200,93 +116,6 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { @@ -200,93 +116,6 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) {
200 return cnt, err 116 return cnt, err
201 } 117 }
202 118
203 -// (弃用)获取任务以及里程碑列表,用于页面展示; 无过滤查看权限  
204 -// userid 谁要查看任务数据  
205 -// limit 分页  
206 -// offset 分页  
207 -// func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, error) {  
208 -// withSql := `with  
209 -// t_task_ignore as (  
210 -// select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?  
211 -// ),  
212 -// -- 获取的里程碑数据,以及排序  
213 -// t_task_tage_1 as(  
214 -// select  
215 -// task.id as task_id,  
216 -// task."name" as task_name,  
217 -// task."alias" as task_alias_name,  
218 -// task."status" as task_status,  
219 -// task.leader ->>'name' as leader_name,  
220 -// task.leader ->>'id' as leader_id,  
221 -// task.level_name ,  
222 -// task.anomaly ,  
223 -// task.updated_at ,  
224 -// task."warn_flag",  
225 -// task.created_at ,  
226 -// task."level" ,  
227 -// task_stage."id" as stage_id,  
228 -// task_stage."name" as stage_name,  
229 -// task_stage.sort_by as stage_sort_by,  
230 -// task_stage.plan_completed_at,  
231 -// task_stage.real_completed_at,  
232 -// (case  
233 -// when task_stage.real_completed_at =0  
234 -// then task_stage.plan_completed_at - floor( extract(epoch from now()))  
235 -// else task_stage.plan_completed_at - task_stage.real_completed_at  
236 -// end) as diff_time  
237 -// from task  
238 -// join task_stage on task.id =task_stage.task_id  
239 -// where 1=1 and task.company_id=?  
240 -// order by diff_time,task."level",task.created_at desc  
241 -// ),  
242 -// -- 按任务数据分页获取  
243 -// t_task_page as (  
244 -// select distinct t_task_tage_1.task_id  
245 -// from t_task_tage_1  
246 -// left join t_task_ignore on t_task_ignore.task_id=t_task_tage_1.task_id  
247 -// where t_task_ignore.id isnull  
248 -// %s  
249 -// limit ? offset ?  
250 -// )  
251 -// select  
252 -// t_task_tage_1.task_id,  
253 -// t_task_tage_1.task_name,  
254 -// t_task_tage_1.task_alias_name,  
255 -// t_task_tage_1.task_status,  
256 -// t_task_tage_1.leader_name,  
257 -// t_task_tage_1.level_name ,  
258 -// t_task_tage_1.anomaly ,  
259 -// t_task_tage_1.updated_at ,  
260 -// t_task_tage_1.created_at ,  
261 -// t_task_tage_1."level" ,  
262 -// t_task_tage_1.plan_completed_at,  
263 -// t_task_tage_1.real_completed_at,  
264 -// t_task_tage_1.stage_name,  
265 -// t_task_tage_1.stage_id,  
266 -// t_task_tage_1."warn_flag",  
267 -// t_task_tage_1.stage_sort_by  
268 -// from t_task_tage_1  
269 -// where t_task_tage_1.task_id in(  
270 -// select t_task_page.task_id from t_task_page  
271 -// )`  
272 -// condition := []interface{}{param.UserId, param.CompanyId}  
273 -// whereSql := ``  
274 -// if param.OnlyMy {  
275 -// condition = append(condition, param.UserId)  
276 -// whereSql += ` and t_task_tage_1.leader_id = '?' `  
277 -// }  
278 -// if param.SearchWord != "" {  
279 -// condition = append(condition, param.SearchWord, param.SearchWord)  
280 -// whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?) `  
281 -// }  
282 -// condition = append(condition, param.Limit, param.Offset)  
283 -// sqlStr := fmt.Sprintf(withSql, whereSql)  
284 -// result := []ListTaskStage{}  
285 -// tx := d.transactionContext.PgTx  
286 -// _, err := tx.Query(&result, sqlStr, condition...)  
287 -// return result, err  
288 -// }  
289 -  
290 // 获取任务总数,用于页面展示; 无过滤查看权限 119 // 获取任务总数,用于页面展示; 无过滤查看权限
291 func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { 120 func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) {
292 121
@@ -380,25 +209,6 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err @@ -380,25 +209,6 @@ func (d *TaskDao) CountTaskStageAnomalyByHrbp(param ListTaskCondition) (int, err
380 return cnt, err 209 return cnt, err
381 } 210 }
382 211
383 -// func (d *TaskDao) IncreaseAnomaly(id []int, incr int) error {  
384 -// if len(id) == 0 {  
385 -// return nil  
386 -// }  
387 -// sqlStr := `update task set anomaly=task.anomaly+?  
388 -// where id in(?)`  
389 -// tx := d.transactionContext.PgTx  
390 -// _, err := tx.Exec(sqlStr, incr, pg.In(id))  
391 -// return err  
392 -// }  
393 -  
394 -// TaskStageData  
395 -// type TaskStageData struct {  
396 -// TaskStageId int `pg:"task_stage_id"`  
397 -// TaskStageName string `pg:"task_stage_name"`  
398 -// LeaderName string `pg:"leader_name"`  
399 -// TaskAlias string `pg:"task_alias"`  
400 -// }  
401 -  
402 type TaskData3 struct { 212 type TaskData3 struct {
403 TaskId int `pg:"task_id"` 213 TaskId int `pg:"task_id"`
404 TaskName string `pg:"task_name"` 214 TaskName string `pg:"task_name"`
@@ -574,28 +384,6 @@ func (d *TaskDao) ListTask2ForHrbp(userId int, companyId int) ([]TaskData1, erro @@ -574,28 +384,6 @@ func (d *TaskDao) ListTask2ForHrbp(userId int, companyId int) ([]TaskData1, erro
574 384
575 } 385 }
576 386
577 -// 获取异常任务对应的公司  
578 -// func (d *TaskDao) TaskStageAnomalyForCompany() ([]int, error) {  
579 -// var companyIds []struct {  
580 -// CompanyId int `pg:"company_id"`  
581 -// }  
582 -// sqlStr := `select distinct company_id  
583 -// from task  
584 -// where 1=1  
585 -// and (task.warn_flag >0)`  
586 -// result := []TaskData1{}  
587 -// tx := d.transactionContext.PgTx  
588 -// _, err := tx.Query(&result, sqlStr)  
589 -// if err != nil {  
590 -// return nil, err  
591 -// }  
592 -// var ids []int  
593 -// for _, v := range companyIds {  
594 -// ids = append(ids, v.CompanyId)  
595 -// }  
596 -// return ids, nil  
597 -// }  
598 -  
599 type TaskData4 struct { 387 type TaskData4 struct {
600 TaskId int `pg:"task_id"` 388 TaskId int `pg:"task_id"`
601 TaskName string `pg:"task_name"` 389 TaskName string `pg:"task_name"`
@@ -48,16 +48,6 @@ func (d *UserDao) AllChildUser(userId int) ([]UserData1, error) { @@ -48,16 +48,6 @@ func (d *UserDao) AllChildUser(userId int) ([]UserData1, error) {
48 return result, err 48 return result, err
49 } 49 }
50 50
51 -// func (d *UserDao) ChildUser(userId int) ([]UserData1, error) {  
52 -// sqlStr := `select "user".id,"user".parent_id ,"user".account,"user".name  
53 -// from "user"  
54 -// where "user".parent_id=?`  
55 -// result := []UserData1{}  
56 -// tx := d.transactionContext.PgTx  
57 -// _, err := tx.Query(&result, sqlStr, userId)  
58 -// return result, err  
59 -// }  
60 -  
61 // AllParentUser 获取我的全上级 51 // AllParentUser 获取我的全上级
62 func (d *UserDao) AllParentUser(userId int) ([]UserData1, error) { 52 func (d *UserDao) AllParentUser(userId int) ([]UserData1, error) {
63 sqlStr := `with 53 sqlStr := `with