|
|
@@ -1,10 +1,23 @@
|
|
|
package com.yw.hr.client.action;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import com.yw.core.framework.view.service.PagerService;
|
|
|
+import com.yw.hr.train.model.TrainCourse;
|
|
|
+import com.yw.hr.train.model.TrainImpleAssess;
|
|
|
+import com.yw.hr.train.model.TrainImpleCourse;
|
|
|
+import com.yw.hr.train.model.TrainImplement;
|
|
|
+import com.yw.hr.train.model.TrainImpleTrainees;
|
|
|
+import com.yw.hr.train.service.TrainCourseService;
|
|
|
+import com.yw.hr.train.service.TrainImpleCourseService;
|
|
|
+import com.yw.hr.train.service.TrainImplementService;
|
|
|
+import com.yw.hr.train.service.TrainImpleTraineesService;
|
|
|
import net.sf.json.JSONObject;
|
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
|
import com.yw.core.clientImpl.model.ResultVo;
|
|
|
@@ -12,6 +25,9 @@ import com.yw.core.clientImpl.service.RequestAbs;
|
|
|
import com.yw.core.session.AppSession;
|
|
|
import com.yw.core.utils.DateJson;
|
|
|
import com.yw.core.utils.RegisterCodeImpl;
|
|
|
+import com.yw.core.utils.StringUtil;
|
|
|
+import com.yw.eu.base.system.model.UploadFile;
|
|
|
+import com.yw.eu.base.system.service.UploadFileService;
|
|
|
import com.yw.hr.train.service.TrainImpleAssessService;
|
|
|
|
|
|
/**
|
|
|
@@ -44,11 +60,15 @@ public class HrClientTrainDetailAction extends RequestAbs {
|
|
|
String universalid = json.optString("universalid", "");
|
|
|
String impleId = json.optString("imple_id", "");
|
|
|
String courseId = json.optString("course_id", "");
|
|
|
+ String assessId = json.optString("assess_id", "");
|
|
|
+ String traineesId = json.optString("trainees_id", "");
|
|
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
map.put("universalid", universalid);
|
|
|
map.put("imple_id", impleId);
|
|
|
map.put("course_id", courseId);
|
|
|
+ map.put("assess_id", assessId);
|
|
|
+ map.put("trainees_id", traineesId);
|
|
|
|
|
|
String responseJson = this.getMyTrainDetail(map);
|
|
|
if (!"".equals(responseJson)) {
|
|
|
@@ -69,34 +89,135 @@ public class HrClientTrainDetailAction extends RequestAbs {
|
|
|
if(null == cxt){
|
|
|
cxt = AppSession.getApplicationContext();
|
|
|
}
|
|
|
- TrainImpleAssessService trainImpleAssessService = (TrainImpleAssessService) cxt.getBean("hrTrainImpleAssessService");
|
|
|
-
|
|
|
+
|
|
|
try {
|
|
|
- Long universalid = map.get("universalid") != null && !map.get("universalid").isEmpty()
|
|
|
- ? Long.parseLong(map.get("universalid")) : null;
|
|
|
- Long impleId = map.get("imple_id") != null && !map.get("imple_id").isEmpty()
|
|
|
- ? Long.parseLong(map.get("imple_id")) : null;
|
|
|
- Long courseId = map.get("course_id") != null && !map.get("course_id").isEmpty()
|
|
|
- ? Long.parseLong(map.get("course_id")) : null;
|
|
|
+ String universalidStr = map.get("universalid");
|
|
|
+ String assessIdStr = map.get("assess_id");
|
|
|
+ String impleIdStr = map.get("imple_id");
|
|
|
+ String traineesIdStr = map.get("trainees_id");
|
|
|
+
|
|
|
+ // 注入 Service
|
|
|
+ TrainImpleAssessService tiAssessService = (TrainImpleAssessService) cxt.getBean("hrTrainImpleAssessService");
|
|
|
+ TrainImpleCourseService impleCourseService = (TrainImpleCourseService) cxt.getBean("hrTrainImpleCourseService");
|
|
|
+ TrainCourseService courseService = (TrainCourseService) cxt.getBean("hrTrainCourseService");
|
|
|
+ UploadFileService uploadFileService = (UploadFileService) cxt.getBean("uploadFileService");
|
|
|
+ TrainImplementService implementService = (TrainImplementService) cxt.getBean("hrTrainImplementService");
|
|
|
+ TrainImpleTraineesService tiTraineesService = (TrainImpleTraineesService) cxt.getBean("hrTrainImpleTraineesService");
|
|
|
|
|
|
- // 直接通过列表查询获取完整的培训信息(包括课程、实施、学员信息)
|
|
|
- // 因为 toEditImpleAssess 只返回评估表的基础信息,缺少关联表的字段
|
|
|
- com.yw.hr.train.model.TrainImpleAssess queryParam = new com.yw.hr.train.model.TrainImpleAssess();
|
|
|
- if (universalid != null) {
|
|
|
- queryParam.setUniversalid(universalid);
|
|
|
+ // 1. 查询评估信息
|
|
|
+ TrainImpleAssess impleAssessInfo = new TrainImpleAssess();
|
|
|
+ if (StringUtils.isNotEmpty(assessIdStr) && !"null".equals(assessIdStr)) {
|
|
|
+ impleAssessInfo.setUniversalid(Long.parseLong(assessIdStr));
|
|
|
}
|
|
|
|
|
|
- // 调用列表查询,获取完整数据
|
|
|
- com.yw.core.framework.view.service.PagerService ps =
|
|
|
- trainImpleAssessService.getImpleAssessList("1", "1", queryParam);
|
|
|
+ TrainImpleAssess impleAssess = tiAssessService.toEditImpleAssess(impleAssessInfo);
|
|
|
|
|
|
- if (ps.getDatas() != null && !ps.getDatas().isEmpty()) {
|
|
|
- // getDatas() 返回的是 List<HashMap>,取第一条记录
|
|
|
- Object firstRecord = ps.getDatas().get(0);
|
|
|
- String data = DateJson.fromObject(firstRecord).toString().trim();
|
|
|
- return data;
|
|
|
+ // 2. 查询实施课程信息
|
|
|
+ TrainImpleCourse impleCourse = new TrainImpleCourse();
|
|
|
+ if (StringUtils.isNotEmpty(universalidStr)) {
|
|
|
+ impleCourse.setUniversalid(Long.parseLong(universalidStr));
|
|
|
}
|
|
|
- return "";
|
|
|
+ impleCourse = impleCourseService.toEditImpleCourse(impleCourse);
|
|
|
+
|
|
|
+ // 3. 获取课程附件信息
|
|
|
+ List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
|
|
|
+ String fileIds = "";
|
|
|
+
|
|
|
+ if (impleCourse != null && impleCourse.getCourse_id() != null) {
|
|
|
+ TrainCourse trainCourse = new TrainCourse();
|
|
|
+ trainCourse.setUniversalid(impleCourse.getCourse_id());
|
|
|
+ trainCourse = courseService.toEditCourse(trainCourse);
|
|
|
+
|
|
|
+ if (trainCourse != null && trainCourse.getAttachment() != null && !StringUtil.isEmpty(trainCourse.getAttachment())) {
|
|
|
+ String attachment = trainCourse.getAttachment();
|
|
|
+ // 解析附件ID(逗号分隔)
|
|
|
+ String[] fileIdArray = attachment.split(",");
|
|
|
+
|
|
|
+ for (String fileId : fileIdArray) {
|
|
|
+ if (!StringUtil.isEmpty(fileId)) {
|
|
|
+ try {
|
|
|
+ UploadFile uploadFile = new UploadFile();
|
|
|
+ uploadFile.setFileId(StringUtil.strToLong(fileId));
|
|
|
+ uploadFile = uploadFileService.loadUploadFile(uploadFile);
|
|
|
+ if (uploadFile != null) {
|
|
|
+ fileIds = fileIds + "," + fileId;
|
|
|
+ Map<String, String> fileMap = new HashMap<String, String>();
|
|
|
+ fileMap.put("fileId", uploadFile.getFileId().toString());
|
|
|
+ fileMap.put("fileName", uploadFile.getSrcFile());
|
|
|
+ fileMap.put("path", uploadFile.getPath());
|
|
|
+ fileList.add(fileMap);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4. 查询实施信息
|
|
|
+ TrainImplement implement = new TrainImplement();
|
|
|
+ if (StringUtils.isNotEmpty(impleIdStr)) {
|
|
|
+ implement.setUniversalid(Long.parseLong(impleIdStr));
|
|
|
+ }
|
|
|
+ implement = implementService.toEditImplement(implement);
|
|
|
+
|
|
|
+ // 5. 查询学员信息
|
|
|
+ TrainImpleTrainees impleTrainees = new TrainImpleTrainees();
|
|
|
+ if (StringUtils.isNotEmpty(traineesIdStr)) {
|
|
|
+ impleTrainees.setUniversalid(Long.parseLong(traineesIdStr));
|
|
|
+ }
|
|
|
+ impleTrainees = tiTraineesService.toEditImpleTrainees(impleTrainees);
|
|
|
+
|
|
|
+ // 6. 构建返回结果(合并所有信息)
|
|
|
+ Map<String, Object> resultMap = new HashMap<String, Object>();
|
|
|
+
|
|
|
+ // 从评估信息中获取字段
|
|
|
+ if (impleAssess != null) {
|
|
|
+ resultMap.put("universalid", impleAssess.getUniversalid());
|
|
|
+ resultMap.put("imple_id", impleAssess.getImple_id());
|
|
|
+ resultMap.put("course_id", impleAssess.getCourse_id());
|
|
|
+ resultMap.put("trainees_id", impleAssess.getTrainees_id());
|
|
|
+ resultMap.put("trainees_name", impleAssess.getTrainees_name());
|
|
|
+ resultMap.put("course_name", impleAssess.getCourse_name());
|
|
|
+ resultMap.put("project_org", impleAssess.getProject_org());
|
|
|
+ resultMap.put("course_score", impleAssess.getCourse_score());
|
|
|
+ resultMap.put("teacher_score", impleAssess.getTeacher_score());
|
|
|
+ resultMap.put("advice", impleAssess.getAdvice());
|
|
|
+ } else {
|
|
|
+ // 如果没有评估记录,设置标记(参考 PC 端第 553-555 行)
|
|
|
+ resultMap.put("no_assess", "1");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从实施课程中补充其他字段
|
|
|
+ if (impleCourse != null) {
|
|
|
+ resultMap.put("location_name", impleCourse.getLocation_name());
|
|
|
+ resultMap.put("teacher_name", impleCourse.getTeacher_name());
|
|
|
+ resultMap.put("class_name", impleCourse.getClass_name());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从实施信息中补充字段
|
|
|
+ if (implement != null) {
|
|
|
+ resultMap.put("train_name", implement.getTrain_name());
|
|
|
+ resultMap.put("responsible_people", implement.getResponsible_people());
|
|
|
+ resultMap.put("imple_start_time", implement.getImple_start_time());
|
|
|
+ resultMap.put("imple_end_time", implement.getImple_end_time());
|
|
|
+ resultMap.put("train_org", implement.getTrain_org());
|
|
|
+ resultMap.put("train_status", implement.getTrain_status());
|
|
|
+ resultMap.put("train_type", implement.getTrain_type());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从学员信息中补充字段
|
|
|
+ if (impleTrainees != null) {
|
|
|
+ resultMap.put("user_name", impleTrainees.getTrainees_name());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加附件信息
|
|
|
+ resultMap.put("fileIds", fileIds.startsWith(",") ? fileIds.substring(1) : fileIds);
|
|
|
+ resultMap.put("files", fileList);
|
|
|
+
|
|
|
+ String data = DateJson.fromObject(resultMap).toString().trim();
|
|
|
+ return data;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return "";
|