作者 tangxvhui

新加接口

@@ -986,37 +986,298 @@ func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext app @@ -986,37 +986,298 @@ func (srv StaffAssessServeice) getAssessInfoUncompletedV2(transactionContext app
986 return contentList, nil 986 return contentList, nil
987 } 987 }
988 988
989 -// 展示360评估内容  
990 -func (srv StaffAssessServeice) StaffAssess360Show() (*adapter.AssessInfoResp, error) {  
991 - return nil, nil  
992 -} 989 +// 展示360评估内容,未填写的评估项不展示
  990 +func (srv StaffAssessServeice) StaffAssess360Show(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  991 +
  992 + transactionContext, err := factory.CreateTransactionContext(nil)
  993 + if err != nil {
  994 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  995 + }
  996 + if err := transactionContext.StartTransaction(); err != nil {
  997 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  998 + }
  999 + defer func() {
  1000 + _ = transactionContext.RollbackTransaction()
  1001 + }()
  1002 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  1003 + "transactionContext": transactionContext,
  1004 + })
  1005 + //获取员工的评估
  1006 + _, assessList, err := assessReps.Find(map[string]interface{}{
  1007 + "companyId": param.CompanyId,
  1008 + "id": param.AssessId,
  1009 + })
  1010 + if err != nil {
  1011 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  1012 + }
  1013 + if len(assessList) == 0 {
  1014 + return &adapter.AssessInfoResp{}, nil
  1015 + }
  1016 + if assessList[0].Types != domain.AssessInviteSameSuper &&
  1017 + assessList[0].Types != domain.AssessInviteDiffSuper {
  1018 + return &adapter.AssessInfoResp{}, nil
  1019 + }
  1020 + assessData := assessList[0]
  1021 + //已完成
  1022 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  1023 + "transactionContext": transactionContext,
  1024 + })
  1025 + _, assessContentList, err := assessContentRepo.Find(map[string]interface{}{
  1026 + "staffAssessId": assessData.Id,
  1027 + })
  1028 + if err != nil {
  1029 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1030 + }
  1031 + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
  1032 + if err != nil {
  1033 + log.Logger.Error("获取员工描述" + err.Error())
  1034 + }
  1035 + if err := transactionContext.CommitTransaction(); err != nil {
  1036 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1037 + }
  1038 + result := adapter.AssessInfoResp{
  1039 + AssessId: assessData.Id,
  1040 + CycleId: assessData.CycleId,
  1041 + CycleName: assessData.CycleName,
  1042 + LinkNodeId: assessData.LinkNodeId,
  1043 + LinkNodeName: assessData.LinkNodeName,
  1044 + EvaluationProjectId: assessData.EvaluationProjectId,
  1045 + EvaluationProjectName: assessData.EvaluationProjectName,
  1046 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  1047 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  1048 + Status: string(assessData.Status),
  1049 + TargetUserId: assessData.TargetUser.UserId,
  1050 + TargetUserName: assessData.TargetUser.UserName,
  1051 + CompanyId: assessData.CompanyId,
  1052 + CompanyName: "",
  1053 + SupperUser: "",
  1054 + DutyTime: "",
  1055 + AssessContent: []*domain.StaffAssessContent{},
  1056 + }
  1057 + if targetUserDesc != nil {
  1058 + result.CompanyName = targetUserDesc.CompanyName
  1059 + result.SupperUser = targetUserDesc.SupperUserName
  1060 + result.CompanyLogo = targetUserDesc.CompanyLogo
  1061 + result.DutyTime = targetUserDesc.DutyTime
  1062 + }
993 1063
994 -// 展示上级评估内容  
995 -func (srv StaffAssessServeice) StaffAssessSuperShow() (*adapter.AssessInfoResp, error) {  
996 - return nil, nil 1064 + for _, val := range assessContentList {
  1065 + if len(val.Value) == 0 {
  1066 + //跳过不展示未填写的
  1067 + continue
  1068 + }
  1069 + result.AssessContent = append(result.AssessContent, val)
  1070 + }
  1071 +
  1072 + return &result, nil
997 } 1073 }
998 1074
999 -// 展示自评评估内容  
1000 -func (srv StaffAssessServeice) StaffAssessSelfShow() (*adapter.AssessInfoResp, error) {  
1001 - return nil, nil 1075 +// 展示上级评估内容,未填写的评估项不展示
  1076 +func (srv StaffAssessServeice) StaffAssessSuperShow(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  1077 + transactionContext, err := factory.CreateTransactionContext(nil)
  1078 + if err != nil {
  1079 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1080 + }
  1081 + if err := transactionContext.StartTransaction(); err != nil {
  1082 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1083 + }
  1084 + defer func() {
  1085 + _ = transactionContext.RollbackTransaction()
  1086 + }()
  1087 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  1088 + "transactionContext": transactionContext,
  1089 + })
  1090 + //获取员工的评估
  1091 + _, assessList, err := assessReps.Find(map[string]interface{}{
  1092 + "companyId": param.CompanyId,
  1093 + "id": param.AssessId,
  1094 + })
  1095 + if err != nil {
  1096 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  1097 + }
  1098 + if len(assessList) == 0 {
  1099 + return &adapter.AssessInfoResp{}, nil
  1100 + }
  1101 + if assessList[0].Types != domain.AssessSuper {
  1102 + return &adapter.AssessInfoResp{}, nil
  1103 + }
  1104 + assessData := assessList[0]
  1105 + //已完成
  1106 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  1107 + "transactionContext": transactionContext,
  1108 + })
  1109 + _, assessContentList, err := assessContentRepo.Find(map[string]interface{}{
  1110 + "staffAssessId": assessData.Id,
  1111 + })
  1112 + if err != nil {
  1113 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1114 + }
  1115 + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
  1116 + if err != nil {
  1117 + log.Logger.Error("获取员工描述" + err.Error())
  1118 + }
  1119 + if err := transactionContext.CommitTransaction(); err != nil {
  1120 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1121 + }
  1122 + result := adapter.AssessInfoResp{
  1123 + AssessId: assessData.Id,
  1124 + CycleId: assessData.CycleId,
  1125 + CycleName: assessData.CycleName,
  1126 + LinkNodeId: assessData.LinkNodeId,
  1127 + LinkNodeName: assessData.LinkNodeName,
  1128 + EvaluationProjectId: assessData.EvaluationProjectId,
  1129 + EvaluationProjectName: assessData.EvaluationProjectName,
  1130 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  1131 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  1132 + Status: string(assessData.Status),
  1133 + TargetUserId: assessData.TargetUser.UserId,
  1134 + TargetUserName: assessData.TargetUser.UserName,
  1135 + CompanyId: assessData.CompanyId,
  1136 + CompanyName: "",
  1137 + SupperUser: "",
  1138 + DutyTime: "",
  1139 + AssessContent: []*domain.StaffAssessContent{},
  1140 + }
  1141 + if targetUserDesc != nil {
  1142 + result.CompanyName = targetUserDesc.CompanyName
  1143 + result.SupperUser = targetUserDesc.SupperUserName
  1144 + result.CompanyLogo = targetUserDesc.CompanyLogo
  1145 + result.DutyTime = targetUserDesc.DutyTime
  1146 + }
  1147 +
  1148 + for _, val := range assessContentList {
  1149 + if len(val.Value) == 0 {
  1150 + //跳过不展示未填写的
  1151 + continue
  1152 + }
  1153 + result.AssessContent = append(result.AssessContent, val)
  1154 + }
  1155 +
  1156 + return &result, nil
1002 } 1157 }
1003 1158
1004 // 360评估内容编辑前 1159 // 360评估内容编辑前
1005 -func (srv StaffAssessServeice) StaffAssess360BeforeEdit() (*adapter.AssessInfoResp, error) {  
1006 - return nil, nil 1160 +func (srv StaffAssessServeice) StaffAssess360BeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  1161 + result, err := srv.getStaffAssessBeforeEdit(param)
  1162 + if err != nil {
  1163 + return &adapter.AssessInfoResp{}, err
  1164 + }
  1165 + //360评估全部是选填项
  1166 + for i := range result.AssessContent {
  1167 + result.AssessContent[i].Required = domain.NodeRequiredNo
  1168 + }
  1169 + return result, nil
1007 } 1170 }
1008 1171
1009 // 上级评估内容编辑前 1172 // 上级评估内容编辑前
1010 -func (srv StaffAssessServeice) StaffAssessSuperBeforeEdit() (*adapter.AssessInfoResp, error) {  
1011 - return nil, nil 1173 +func (srv StaffAssessServeice) StaffAssessSuperBeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  1174 + result, err := srv.getStaffAssessBeforeEdit(param)
  1175 + if err != nil {
  1176 + return &adapter.AssessInfoResp{}, err
  1177 + }
  1178 + //上级评估全部是选填项
  1179 + for i := range result.AssessContent {
  1180 + result.AssessContent[i].Required = domain.NodeRequiredNo
  1181 + }
  1182 + return result, nil
1012 } 1183 }
1013 1184
1014 // 自评评估内容编辑前 1185 // 自评评估内容编辑前
1015 -func (srv StaffAssessServeice) StaffAssessSelfBeforeEdit() (*adapter.AssessInfoResp, error) {  
1016 - return nil, nil 1186 +// func (srv StaffAssessServeice) StaffAssessSelfBeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  1187 +// result, err := srv.GetAssessInfo(param)
  1188 +// if err != nil {
  1189 +// return &adapter.AssessInfoResp{}, err
  1190 +// }
  1191 +// return result, nil
  1192 +// }
  1193 +
  1194 +func (srv StaffAssessServeice) getStaffAssessBeforeEdit(param *query.AssessInfoQuery) (*adapter.AssessInfoResp, error) {
  1195 + transactionContext, err := factory.CreateTransactionContext(nil)
  1196 + if err != nil {
  1197 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1198 + }
  1199 + if err := transactionContext.StartTransaction(); err != nil {
  1200 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  1201 + }
  1202 + defer func() {
  1203 + _ = transactionContext.RollbackTransaction()
  1204 + }()
  1205 + assessReps := factory.CreateStaffAssessRepository(map[string]interface{}{
  1206 + "transactionContext": transactionContext,
  1207 + })
  1208 + //获取员工的评估
  1209 + _, assessList, err := assessReps.Find(map[string]interface{}{
  1210 + "companyId": param.CompanyId,
  1211 + "id": param.AssessId,
  1212 + })
  1213 + if err != nil {
  1214 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取员工的评估"+err.Error())
  1215 + }
  1216 + if len(assessList) == 0 {
  1217 + return &adapter.AssessInfoResp{}, nil
  1218 + }
  1219 + assessData := assessList[0]
  1220 + assessContentList := []*domain.StaffAssessContent{}
  1221 + if assessData.Status == domain.StaffAssessCompleted {
  1222 + //已完成
  1223 + assessContentRepo := factory.CreateStaffAssessContentRepository(map[string]interface{}{
  1224 + "transactionContext": transactionContext,
  1225 + })
  1226 + _, assessContentList, err = assessContentRepo.Find(map[string]interface{}{
  1227 + "staffAssessId": assessData.Id,
  1228 + })
  1229 + if err != nil {
  1230 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1231 + }
  1232 + } else if assessData.Status == domain.StaffAssessUncompleted {
  1233 + //未完成
  1234 + assessContentList, err = srv.getAssessInfoUncompletedV2(transactionContext, assessData)
  1235 + if err != nil {
  1236 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取项目填写内容"+err.Error())
  1237 + }
  1238 + }
  1239 + // 恢复缓存数据
  1240 + srv.recoverAssessCache(transactionContext, assessData.Id, assessContentList)
  1241 + targetUserDesc, err := srv.getStaffDescrip(transactionContext, int64(assessData.TargetUser.UserId))
  1242 + if err != nil {
  1243 + log.Logger.Error("获取员工描述" + err.Error())
  1244 + }
  1245 + if err := transactionContext.CommitTransaction(); err != nil {
  1246 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1247 + }
  1248 +
  1249 + result := adapter.AssessInfoResp{
  1250 + AssessId: assessData.Id,
  1251 + CycleId: assessData.CycleId,
  1252 + CycleName: assessData.CycleName,
  1253 + LinkNodeId: assessData.LinkNodeId,
  1254 + LinkNodeName: assessData.LinkNodeName,
  1255 + EvaluationProjectId: assessData.EvaluationProjectId,
  1256 + EvaluationProjectName: assessData.EvaluationProjectName,
  1257 + BeginTime: assessData.BeginTime.Local().Format("2006-01-02 15:04:05"),
  1258 + EndTime: assessData.EndTime.Local().Format("2006-01-02 15:04:05"),
  1259 + Status: string(assessData.Status),
  1260 + TargetUserId: assessData.TargetUser.UserId,
  1261 + TargetUserName: assessData.TargetUser.UserName,
  1262 + CompanyId: assessData.CompanyId,
  1263 + CompanyName: "",
  1264 + SupperUser: "",
  1265 + DutyTime: "",
  1266 + AssessContent: assessContentList,
  1267 + }
  1268 + if len(assessContentList) == 0 {
  1269 + result.AssessContent = []*domain.StaffAssessContent{}
  1270 + }
  1271 + if targetUserDesc != nil {
  1272 + result.CompanyName = targetUserDesc.CompanyName
  1273 + result.SupperUser = targetUserDesc.SupperUserName
  1274 + result.CompanyLogo = targetUserDesc.CompanyLogo
  1275 + result.DutyTime = targetUserDesc.DutyTime
  1276 + }
  1277 + return &result, nil
1017 } 1278 }
1018 1279
1019 // 获取未完成评估任务的执行人员名单 1280 // 获取未完成评估任务的执行人员名单
1020 -func (srv StaffAssessServeice) ExcutorListUncompleted() error { 1281 +func (srv StaffAssessServeice) ListExcutorUncompleted() error {
1021 return nil 1282 return nil
1022 } 1283 }
@@ -23,7 +23,7 @@ type StaffAssessContent struct { @@ -23,7 +23,7 @@ type StaffAssessContent struct {
23 ReteResult string `json:"reteResult"` //评估的结果 23 ReteResult string `json:"reteResult"` //评估的结果
24 Rule EvaluationRule `json:"rule"` //评估的选项规则 24 Rule EvaluationRule `json:"rule"` //评估的选项规则
25 Weight float64 `json:"weight" ` //"权重" 25 Weight float64 `json:"weight" ` //"权重"
26 - Required int `json:"required"` // 必填项 26 + Required int `json:"required"` // 必填项 同EvaluationTemplate.go->NodeRequiredYes;NodeContent.Required
27 CreatedAt time.Time `json:"createdAt"` //数据创建时间 27 CreatedAt time.Time `json:"createdAt"` //数据创建时间
28 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间 28 UpdatedAt time.Time `json:"updatedAt"` //数据更新时间
29 DeletedAt *time.Time `json:"deletedAt"` 29 DeletedAt *time.Time `json:"deletedAt"`
@@ -184,3 +184,67 @@ func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() { @@ -184,3 +184,67 @@ func (c *StaffAssessControllerV2) GetAssessTargetUserSelfInfo() {
184 data, err := srv.GetAssessSelfInfoV2(paramReq) 184 data, err := srv.GetAssessSelfInfoV2(paramReq)
185 c.Response(data, err) 185 c.Response(data, err)
186 } 186 }
  187 +
  188 +// 展示360评估内容
  189 +func (c *StaffAssessControllerV2) StaffAssess360Show() {
  190 + srv := service.NewStaffAssessServeice()
  191 + paramReq := &query.AssessInfoQuery{}
  192 + err := c.BindJSON(paramReq)
  193 + if err != nil {
  194 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  195 + c.Response(nil, e)
  196 + return
  197 + }
  198 + userReq := middlewares.GetUser(c.Ctx)
  199 + paramReq.CompanyId = int(userReq.CompanyId)
  200 + data, err := srv.StaffAssess360Show(paramReq)
  201 + c.Response(data, err)
  202 +}
  203 +
  204 +// 展示上级评估内容
  205 +func (c *StaffAssessControllerV2) StaffAssessSuperShow() {
  206 + srv := service.NewStaffAssessServeice()
  207 + paramReq := &query.AssessInfoQuery{}
  208 + err := c.BindJSON(paramReq)
  209 + if err != nil {
  210 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  211 + c.Response(nil, e)
  212 + return
  213 + }
  214 + userReq := middlewares.GetUser(c.Ctx)
  215 + paramReq.CompanyId = int(userReq.CompanyId)
  216 + data, err := srv.StaffAssessSuperShow(paramReq)
  217 + c.Response(data, err)
  218 +}
  219 +
  220 +// 360评估内容编辑前
  221 +func (c *StaffAssessControllerV2) StaffAssess360BeforeEdit() {
  222 + srv := service.NewStaffAssessServeice()
  223 + paramReq := &query.AssessInfoQuery{}
  224 + err := c.BindJSON(paramReq)
  225 + if err != nil {
  226 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  227 + c.Response(nil, e)
  228 + return
  229 + }
  230 + userReq := middlewares.GetUser(c.Ctx)
  231 + paramReq.CompanyId = int(userReq.CompanyId)
  232 + data, err := srv.StaffAssess360BeforeEdit(paramReq)
  233 + c.Response(data, err)
  234 +}
  235 +
  236 +// 上级评估内容编辑前
  237 +func (c *StaffAssessControllerV2) StaffAssessSuperBeforeEdit() {
  238 + srv := service.NewStaffAssessServeice()
  239 + paramReq := &query.AssessInfoQuery{}
  240 + err := c.BindJSON(paramReq)
  241 + if err != nil {
  242 + e := application.ThrowError(application.ARG_ERROR, "json 解析错误"+err.Error())
  243 + c.Response(nil, e)
  244 + return
  245 + }
  246 + userReq := middlewares.GetUser(c.Ctx)
  247 + paramReq.CompanyId = int(userReq.CompanyId)
  248 + data, err := srv.StaffAssessSuperBeforeEdit(paramReq)
  249 + c.Response(data, err)
  250 +}
@@ -54,6 +54,10 @@ func init() { @@ -54,6 +54,10 @@ func init() {
54 web.NSCtrlPost("/target-user/supper/list", (*controllers.StaffAssessControllerV2).ListTargetUserSupperAssess), //获取被评估员工被上级评估的列表 54 web.NSCtrlPost("/target-user/supper/list", (*controllers.StaffAssessControllerV2).ListTargetUserSupperAssess), //获取被评估员工被上级评估的列表
55 web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessControllerV2).GetAssessSelfMeInfo), //获取当前周期里我的自评反馈详情 55 web.NSCtrlPost("/self/me/info", (*controllers.StaffAssessControllerV2).GetAssessSelfMeInfo), //获取当前周期里我的自评反馈详情
56 web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessControllerV2).ListTargetUserMeSupperAssess), //获取我被上级评估的列表 56 web.NSCtrlPost("/me/target-user/supper/list", (*controllers.StaffAssessControllerV2).ListTargetUserMeSupperAssess), //获取我被上级评估的列表
  57 + web.NSCtrlPost("/360/show", (*controllers.StaffAssessControllerV2).StaffAssess360Show), //展示360评估内容
  58 + web.NSCtrlPost("/super/show", (*controllers.StaffAssessControllerV2).StaffAssessSuperShow), //展示上级评估内容
  59 + web.NSCtrlPost("/360/befor-edit", (*controllers.StaffAssessControllerV2).StaffAssess360BeforeEdit), //360评估内容编辑前
  60 + web.NSCtrlPost("/super/befor-edit", (*controllers.StaffAssessControllerV2).StaffAssessSuperBeforeEdit), //上级评估内容编辑前
57 ) 61 )
58 62
59 web.AddNamespace(assessTaskNS) 63 web.AddNamespace(assessTaskNS)