作者 tangxvhui

清理代码

@@ -746,237 +746,237 @@ func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) er @@ -746,237 +746,237 @@ func (srv TaskService) CancelAttention(param *command.CancelAttentionCommand) er
746 } 746 }
747 747
748 // 员工绩效-任务管理-列表 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 - } 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 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 - } 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 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 - } 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 862
863 - }  
864 - result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)  
865 - result["taskStageAnomaly"] = taskStageAnomalyCnt  
866 - result["taskAnomalyCnt"] = taskAnomalyCnt  
867 - return result, nil  
868 -} 863 +// }
  864 +// result := tool_funs.SimpleWrapGridMap(int64(taskCount), taskResult)
  865 +// result["taskStageAnomaly"] = taskStageAnomalyCnt
  866 +// result["taskAnomalyCnt"] = taskAnomalyCnt
  867 +// return result, nil
  868 +// }
869 869
870 // 以hrbp角色权限获取任务列表 870 // 以hrbp角色权限获取任务列表
871 // 统计里程碑异常数,反馈异常数 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 -} 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 980
981 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑 981 // ReplyTaskStage 根据每日的任务反馈 ,更新任务里程碑
982 func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error { 982 func (srv TaskService) ReplyTaskStage(transactionContext application.TransactionContext, param []*domain.TaskRecord, isFirstSubmit bool) error {
@@ -95,85 +95,85 @@ type ListTaskStage struct { @@ -95,85 +95,85 @@ type ListTaskStage struct {
95 // userid 谁要查看任务数据 95 // userid 谁要查看任务数据
96 // limit 分页 96 // limit 分页
97 // offset 分页 97 // offset 分页
98 -func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage, error) {  
99 - task1 := d.catchTaskIdByPermission(param.UserId)  
100 - withSql := task1 + `,  
101 - -- 获取的里程碑数据,以及排序  
102 - t_task_tage_1 as(  
103 - select  
104 - task.id as task_id,  
105 - task."name" as task_name,  
106 - task."alias" as task_alias_name,  
107 - task.leader ->>'name' as leader_name,  
108 - task.leader ->>'id' as leader_id,  
109 - task.level_name ,  
110 - task.anomaly ,  
111 - task.updated_at ,  
112 - task.created_at ,  
113 - task."level" ,  
114 - task."warn_flag",  
115 - task."status" as task_status,  
116 - task_stage."id" as stage_id,  
117 - task_stage."name" as stage_name,  
118 - task_stage.sort_by as stage_sort_by,  
119 - task_stage.plan_completed_at,  
120 - task_stage.real_completed_at,  
121 - (case  
122 - when task_stage.real_completed_at =0  
123 - then task_stage.plan_completed_at - floor( extract(epoch from now()))  
124 - else task_stage.plan_completed_at - task_stage.real_completed_at  
125 - end) as diff_time  
126 - from task  
127 - join t_task_1 on task.id=t_task_1.id  
128 - join task_stage on task.id =task_stage.task_id  
129 - where 1=1 and task.company_id=?  
130 - order by diff_time,task."level",task.created_at desc  
131 - ),  
132 - -- 按任务数据分页获取  
133 - t_task_page as (  
134 - select distinct t_task_tage_1.task_id  
135 - from t_task_tage_1  
136 - where 1=1  
137 - %s  
138 - limit ? offset ?  
139 - )  
140 - select  
141 - t_task_tage_1.task_id,  
142 - t_task_tage_1.task_name,  
143 - t_task_tage_1.task_alias_name,  
144 - t_task_tage_1.leader_name,  
145 - t_task_tage_1.level_name ,  
146 - t_task_tage_1.anomaly ,  
147 - t_task_tage_1.updated_at ,  
148 - t_task_tage_1.created_at ,  
149 - t_task_tage_1."level" ,  
150 - t_task_tage_1.plan_completed_at,  
151 - t_task_tage_1.real_completed_at,  
152 - t_task_tage_1.stage_name,  
153 - t_task_tage_1.stage_id,  
154 - t_task_tage_1.stage_sort_by,  
155 - t_task_tage_1."warn_flag"  
156 - from t_task_tage_1  
157 - where t_task_tage_1.task_id in(  
158 - select t_task_page.task_id from t_task_page  
159 - )`  
160 - condition := []interface{}{param.CompanyId}  
161 - whereSql := ``  
162 - if param.OnlyMy {  
163 - condition = append(condition, param.UserId)  
164 - whereSql += ` and t_task_tage_1.leader_id = '?' `  
165 - }  
166 - if param.SearchWord != "" {  
167 - condition = append(condition, param.SearchWord, param.SearchWord)  
168 - whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?)`  
169 - }  
170 - condition = append(condition, param.Limit, param.Offset)  
171 - sqlStr := fmt.Sprintf(withSql, whereSql)  
172 - result := []ListTaskStage{}  
173 - tx := d.transactionContext.PgTx  
174 - _, err := tx.Query(&result, sqlStr, condition...)  
175 - return result, err  
176 -} 98 +// func (d *TaskDao) ListTaskStageNotHrbp(param ListTaskCondition) ([]ListTaskStage, error) {
  99 +// task1 := d.catchTaskIdByPermission(param.UserId)
  100 +// withSql := task1 + `,
  101 +// -- 获取的里程碑数据,以及排序
  102 +// t_task_tage_1 as(
  103 +// select
  104 +// task.id as task_id,
  105 +// task."name" as task_name,
  106 +// task."alias" as task_alias_name,
  107 +// task.leader ->>'name' as leader_name,
  108 +// task.leader ->>'id' as leader_id,
  109 +// task.level_name ,
  110 +// task.anomaly ,
  111 +// task.updated_at ,
  112 +// task.created_at ,
  113 +// task."level" ,
  114 +// task."warn_flag",
  115 +// task."status" as task_status,
  116 +// task_stage."id" as stage_id,
  117 +// task_stage."name" as stage_name,
  118 +// task_stage.sort_by as stage_sort_by,
  119 +// task_stage.plan_completed_at,
  120 +// task_stage.real_completed_at,
  121 +// (case
  122 +// when task_stage.real_completed_at =0
  123 +// then task_stage.plan_completed_at - floor( extract(epoch from now()))
  124 +// else task_stage.plan_completed_at - task_stage.real_completed_at
  125 +// end) as diff_time
  126 +// from task
  127 +// join t_task_1 on task.id=t_task_1.id
  128 +// join task_stage on task.id =task_stage.task_id
  129 +// where 1=1 and task.company_id=?
  130 +// order by diff_time,task."level",task.created_at desc
  131 +// ),
  132 +// -- 按任务数据分页获取
  133 +// t_task_page as (
  134 +// select distinct t_task_tage_1.task_id
  135 +// from t_task_tage_1
  136 +// where 1=1
  137 +// %s
  138 +// limit ? offset ?
  139 +// )
  140 +// select
  141 +// t_task_tage_1.task_id,
  142 +// t_task_tage_1.task_name,
  143 +// t_task_tage_1.task_alias_name,
  144 +// t_task_tage_1.leader_name,
  145 +// t_task_tage_1.level_name ,
  146 +// t_task_tage_1.anomaly ,
  147 +// t_task_tage_1.updated_at ,
  148 +// t_task_tage_1.created_at ,
  149 +// t_task_tage_1."level" ,
  150 +// t_task_tage_1.plan_completed_at,
  151 +// t_task_tage_1.real_completed_at,
  152 +// t_task_tage_1.stage_name,
  153 +// t_task_tage_1.stage_id,
  154 +// t_task_tage_1.stage_sort_by,
  155 +// t_task_tage_1."warn_flag"
  156 +// from t_task_tage_1
  157 +// where t_task_tage_1.task_id in(
  158 +// select t_task_page.task_id from t_task_page
  159 +// )`
  160 +// condition := []interface{}{param.CompanyId}
  161 +// whereSql := ``
  162 +// if param.OnlyMy {
  163 +// condition = append(condition, param.UserId)
  164 +// whereSql += ` and t_task_tage_1.leader_id = '?' `
  165 +// }
  166 +// if param.SearchWord != "" {
  167 +// condition = append(condition, param.SearchWord, param.SearchWord)
  168 +// whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?)`
  169 +// }
  170 +// condition = append(condition, param.Limit, param.Offset)
  171 +// sqlStr := fmt.Sprintf(withSql, whereSql)
  172 +// result := []ListTaskStage{}
  173 +// tx := d.transactionContext.PgTx
  174 +// _, err := tx.Query(&result, sqlStr, condition...)
  175 +// return result, err
  176 +// }
177 177
178 // 获取任务总数,用于页面展示; 有过滤查看权限 178 // 获取任务总数,用于页面展示; 有过滤查看权限
179 func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { 179 func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) {
@@ -203,88 +203,88 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) { @@ -203,88 +203,88 @@ func (d *TaskDao) CountTaskNotHrbp(param ListTaskCondition) (int, error) {
203 // userid 谁要查看任务数据 203 // userid 谁要查看任务数据
204 // limit 分页 204 // limit 分页
205 // offset 分页 205 // offset 分页
206 -func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, error) {  
207 - withSql := `with  
208 - t_task_ignore as (  
209 - select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?  
210 - ),  
211 - -- 获取的里程碑数据,以及排序  
212 - t_task_tage_1 as(  
213 - select  
214 - task.id as task_id,  
215 - task."name" as task_name,  
216 - task."alias" as task_alias_name,  
217 - task."status" as task_status,  
218 - task.leader ->>'name' as leader_name,  
219 - task.leader ->>'id' as leader_id,  
220 - task.level_name ,  
221 - task.anomaly ,  
222 - task.updated_at ,  
223 - task."warn_flag",  
224 - task.created_at ,  
225 - task."level" ,  
226 - task_stage."id" as stage_id,  
227 - task_stage."name" as stage_name,  
228 - task_stage.sort_by as stage_sort_by,  
229 - task_stage.plan_completed_at,  
230 - task_stage.real_completed_at,  
231 - (case  
232 - when task_stage.real_completed_at =0  
233 - then task_stage.plan_completed_at - floor( extract(epoch from now()))  
234 - else task_stage.plan_completed_at - task_stage.real_completed_at  
235 - end) as diff_time  
236 - from task  
237 - join task_stage on task.id =task_stage.task_id  
238 - where 1=1 and task.company_id=?  
239 - order by diff_time,task."level",task.created_at desc  
240 - ),  
241 - -- 按任务数据分页获取  
242 - t_task_page as (  
243 - select distinct t_task_tage_1.task_id  
244 - from t_task_tage_1  
245 - left join t_task_ignore on t_task_ignore.task_id=t_task_tage_1.task_id  
246 - where t_task_ignore.id isnull  
247 - %s  
248 - limit ? offset ?  
249 - )  
250 - select  
251 - t_task_tage_1.task_id,  
252 - t_task_tage_1.task_name,  
253 - t_task_tage_1.task_alias_name,  
254 - t_task_tage_1.task_status,  
255 - t_task_tage_1.leader_name,  
256 - t_task_tage_1.level_name ,  
257 - t_task_tage_1.anomaly ,  
258 - t_task_tage_1.updated_at ,  
259 - t_task_tage_1.created_at ,  
260 - t_task_tage_1."level" ,  
261 - t_task_tage_1.plan_completed_at,  
262 - t_task_tage_1.real_completed_at,  
263 - t_task_tage_1.stage_name,  
264 - t_task_tage_1.stage_id,  
265 - t_task_tage_1."warn_flag",  
266 - t_task_tage_1.stage_sort_by  
267 - from t_task_tage_1  
268 - where t_task_tage_1.task_id in(  
269 - select t_task_page.task_id from t_task_page  
270 - )`  
271 - condition := []interface{}{param.UserId, param.CompanyId}  
272 - whereSql := ``  
273 - if param.OnlyMy {  
274 - condition = append(condition, param.UserId)  
275 - whereSql += ` and t_task_tage_1.leader_id = '?' `  
276 - }  
277 - if param.SearchWord != "" {  
278 - condition = append(condition, param.SearchWord, param.SearchWord)  
279 - whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?) `  
280 - }  
281 - condition = append(condition, param.Limit, param.Offset)  
282 - sqlStr := fmt.Sprintf(withSql, whereSql)  
283 - result := []ListTaskStage{}  
284 - tx := d.transactionContext.PgTx  
285 - _, err := tx.Query(&result, sqlStr, condition...)  
286 - return result, err  
287 -} 206 +// func (d *TaskDao) ListTaskStageByHrbp(param ListTaskCondition) ([]ListTaskStage, error) {
  207 +// withSql := `with
  208 +// t_task_ignore as (
  209 +// select task_ignore.task_id,task_ignore.id from task_ignore where task_ignore.user_id =?
  210 +// ),
  211 +// -- 获取的里程碑数据,以及排序
  212 +// t_task_tage_1 as(
  213 +// select
  214 +// task.id as task_id,
  215 +// task."name" as task_name,
  216 +// task."alias" as task_alias_name,
  217 +// task."status" as task_status,
  218 +// task.leader ->>'name' as leader_name,
  219 +// task.leader ->>'id' as leader_id,
  220 +// task.level_name ,
  221 +// task.anomaly ,
  222 +// task.updated_at ,
  223 +// task."warn_flag",
  224 +// task.created_at ,
  225 +// task."level" ,
  226 +// task_stage."id" as stage_id,
  227 +// task_stage."name" as stage_name,
  228 +// task_stage.sort_by as stage_sort_by,
  229 +// task_stage.plan_completed_at,
  230 +// task_stage.real_completed_at,
  231 +// (case
  232 +// when task_stage.real_completed_at =0
  233 +// then task_stage.plan_completed_at - floor( extract(epoch from now()))
  234 +// else task_stage.plan_completed_at - task_stage.real_completed_at
  235 +// end) as diff_time
  236 +// from task
  237 +// join task_stage on task.id =task_stage.task_id
  238 +// where 1=1 and task.company_id=?
  239 +// order by diff_time,task."level",task.created_at desc
  240 +// ),
  241 +// -- 按任务数据分页获取
  242 +// t_task_page as (
  243 +// select distinct t_task_tage_1.task_id
  244 +// from t_task_tage_1
  245 +// left join t_task_ignore on t_task_ignore.task_id=t_task_tage_1.task_id
  246 +// where t_task_ignore.id isnull
  247 +// %s
  248 +// limit ? offset ?
  249 +// )
  250 +// select
  251 +// t_task_tage_1.task_id,
  252 +// t_task_tage_1.task_name,
  253 +// t_task_tage_1.task_alias_name,
  254 +// t_task_tage_1.task_status,
  255 +// t_task_tage_1.leader_name,
  256 +// t_task_tage_1.level_name ,
  257 +// t_task_tage_1.anomaly ,
  258 +// t_task_tage_1.updated_at ,
  259 +// t_task_tage_1.created_at ,
  260 +// t_task_tage_1."level" ,
  261 +// t_task_tage_1.plan_completed_at,
  262 +// t_task_tage_1.real_completed_at,
  263 +// t_task_tage_1.stage_name,
  264 +// t_task_tage_1.stage_id,
  265 +// t_task_tage_1."warn_flag",
  266 +// t_task_tage_1.stage_sort_by
  267 +// from t_task_tage_1
  268 +// where t_task_tage_1.task_id in(
  269 +// select t_task_page.task_id from t_task_page
  270 +// )`
  271 +// condition := []interface{}{param.UserId, param.CompanyId}
  272 +// whereSql := ``
  273 +// if param.OnlyMy {
  274 +// condition = append(condition, param.UserId)
  275 +// whereSql += ` and t_task_tage_1.leader_id = '?' `
  276 +// }
  277 +// if param.SearchWord != "" {
  278 +// condition = append(condition, param.SearchWord, param.SearchWord)
  279 +// whereSql += ` and (t_task_tage_1.leader_name like ? or t_task_tage_1.task_alias_name like ?) `
  280 +// }
  281 +// condition = append(condition, param.Limit, param.Offset)
  282 +// sqlStr := fmt.Sprintf(withSql, whereSql)
  283 +// result := []ListTaskStage{}
  284 +// tx := d.transactionContext.PgTx
  285 +// _, err := tx.Query(&result, sqlStr, condition...)
  286 +// return result, err
  287 +// }
288 288
289 // 获取任务总数,用于页面展示; 无过滤查看权限 289 // 获取任务总数,用于页面展示; 无过滤查看权限
290 func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) { 290 func (d *TaskDao) CountTaskByHrbp(param ListTaskCondition) (int, error) {