|
|
@@ -0,0 +1,133 @@
|
|
|
+package com.yw.hr.client.action;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+
|
|
|
+import org.springframework.context.ApplicationContext;
|
|
|
+
|
|
|
+import com.yw.core.clientImpl.model.ResultVo;
|
|
|
+import com.yw.core.clientImpl.service.RequestAbs;
|
|
|
+import com.yw.core.session.AppSession;
|
|
|
+import com.yw.core.utils.RegisterCodeImpl;
|
|
|
+import com.yw.hr.train.service.TrainImpleAssessService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 小程序端培训评估提交接口
|
|
|
+ */
|
|
|
+public class HrClientTrainAssessAction extends RequestAbs {
|
|
|
+
|
|
|
+ public final String serviceId = "hr_train_myTrainAssess";
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String url = "http://localhost:8080/ynet/clientServices.do?iscrypt=1";
|
|
|
+ String param="{\"serviceId\":\"hr_train_myTrainAssess\","
|
|
|
+ + "\"params\":{"
|
|
|
+ + "\"universalid\":\"123456\","
|
|
|
+ + "\"imple_id\":\"789\","
|
|
|
+ + "\"course_id\":\"456\","
|
|
|
+ + "\"trainees_id\":\"8945468387975\","
|
|
|
+ + "\"project_org\":\"4\","
|
|
|
+ + "\"course_score\":\"5\","
|
|
|
+ + "\"teacher_score\":\"5\","
|
|
|
+ + "\"advice\":\"课程很好\""
|
|
|
+ + "}}";
|
|
|
+ String rs = RegisterCodeImpl.requestPage(url,param);
|
|
|
+ System.out.println(rs);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ApplicationContext cxt = null;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getResult() {
|
|
|
+ ResultVo rv = new ResultVo();
|
|
|
+ String param = getParameters();
|
|
|
+ JSONObject json = JSONObject.fromObject(param);
|
|
|
+
|
|
|
+ String universalid = json.optString("universalid", "");
|
|
|
+ String impleId = json.getString("imple_id");
|
|
|
+ String courseId = json.getString("course_id");
|
|
|
+ String traineesId = json.getString("trainees_id");
|
|
|
+ String projectOrg = json.optString("project_org", "");
|
|
|
+ String courseScore = json.optString("course_score", "");
|
|
|
+ String teacherScore = json.optString("teacher_score", "");
|
|
|
+ String advice = json.optString("advice", "");
|
|
|
+
|
|
|
+ Map<String, String> map = new HashMap<String, String>();
|
|
|
+ map.put("universalid", universalid);
|
|
|
+ map.put("imple_id", impleId);
|
|
|
+ map.put("course_id", courseId);
|
|
|
+ map.put("trainees_id", traineesId);
|
|
|
+ map.put("project_org", projectOrg);
|
|
|
+ map.put("course_score", courseScore);
|
|
|
+ map.put("teacher_score", teacherScore);
|
|
|
+ map.put("advice", advice);
|
|
|
+
|
|
|
+ String result = this.saveTrainAssess(map);
|
|
|
+ if (!"".equals(result)) {
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("0");
|
|
|
+ rv.setReturnMsg("success");
|
|
|
+ rv.setReturnParams(result);
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+ rv = new ResultVo();
|
|
|
+ rv.setReturnCode("1");
|
|
|
+ rv.setReturnMsg("failed");
|
|
|
+ rv.setReturnParams("");
|
|
|
+ return JSONObject.fromObject(rv, config).toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String saveTrainAssess(Map<String, String> map) {
|
|
|
+ if(null == cxt){
|
|
|
+ cxt = AppSession.getApplicationContext();
|
|
|
+ }
|
|
|
+ TrainImpleAssessService trainImpleAssessService = (TrainImpleAssessService) cxt.getBean("hrTrainImpleAssessService");
|
|
|
+
|
|
|
+ try {
|
|
|
+ Long impleId = Long.parseLong(map.get("imple_id"));
|
|
|
+ Long courseId = Long.parseLong(map.get("course_id"));
|
|
|
+ Long traineesId = Long.parseLong(map.get("trainees_id"));
|
|
|
+
|
|
|
+ // 构建评估对象
|
|
|
+ com.yw.hr.train.model.TrainImpleAssess impleAssess = new com.yw.hr.train.model.TrainImpleAssess();
|
|
|
+ impleAssess.setImple_id(impleId);
|
|
|
+ impleAssess.setCourse_id(courseId);
|
|
|
+ impleAssess.setTrainees_id(traineesId);
|
|
|
+
|
|
|
+ if (map.get("project_org") != null && !map.get("project_org").isEmpty()) {
|
|
|
+ impleAssess.setProject_org(Integer.parseInt(map.get("project_org")));
|
|
|
+ }
|
|
|
+ if (map.get("course_score") != null && !map.get("course_score").isEmpty()) {
|
|
|
+ impleAssess.setCourse_score(Integer.parseInt(map.get("course_score")));
|
|
|
+ }
|
|
|
+ if (map.get("teacher_score") != null && !map.get("teacher_score").isEmpty()) {
|
|
|
+ impleAssess.setTeacher_score(Integer.parseInt(map.get("teacher_score")));
|
|
|
+ }
|
|
|
+ impleAssess.setAdvice(map.get("advice"));
|
|
|
+
|
|
|
+ String universalid = map.get("universalid");
|
|
|
+ int result = 0;
|
|
|
+
|
|
|
+ if (universalid != null && !universalid.isEmpty()) {
|
|
|
+ // 更新已有评估
|
|
|
+ impleAssess.setUniversalid(Long.parseLong(universalid));
|
|
|
+ result = trainImpleAssessService.editImpleAssess(impleAssess);
|
|
|
+ } else {
|
|
|
+ // 新增评估
|
|
|
+ result = trainImpleAssessService.addImpleAssess(impleAssess);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result > 0 ? "success" : "";
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getServiceId() {
|
|
|
+ return serviceId;
|
|
|
+ }
|
|
|
+}
|