|
@@ -1,10 +1,10 @@
|
|
|
package edu.nju.service;
|
|
|
|
|
|
import edu.nju.dao.*;
|
|
|
-import edu.nju.entities.ReviewGroup;
|
|
|
-import edu.nju.entities.ReviewJob;
|
|
|
-import edu.nju.entities.ReviewReport;
|
|
|
-import edu.nju.entities.ReviewWorker;
|
|
|
+import edu.nju.entities.*;
|
|
|
+import edu.nju.model.ReviewPaperVO;
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
@@ -22,6 +22,8 @@ public class ReviewJobService {
|
|
|
ReviewReportDao reportDao;
|
|
|
@Autowired
|
|
|
ReviewWorkerDao reviewWorkerDao;
|
|
|
+ @Autowired
|
|
|
+ ReviewPaperService reviewPaperService;
|
|
|
|
|
|
public ReviewJob getJob(String job_id){
|
|
|
return jobDao.findJob(job_id);
|
|
@@ -48,6 +50,56 @@ public class ReviewJobService {
|
|
|
return jobId;
|
|
|
}
|
|
|
|
|
|
+ public JSONObject uploadJobByJson(String jobJson){
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ JSONObject jsonObject = new JSONObject(jobJson);
|
|
|
+ String jobName = jsonObject.getString("job_name");
|
|
|
+ String jobDescription = jsonObject.getString("job_description");
|
|
|
+ String startTime = jsonObject.getString("start_time");
|
|
|
+ String endTime = jsonObject.getString("end_time");
|
|
|
+ JSONArray workerArray = jsonObject.getJSONArray("worker_list");
|
|
|
+ List<String>workerList=new ArrayList<>();
|
|
|
+ for(int i=0;i<workerArray.length();i++){
|
|
|
+ workerList.add(String.valueOf(workerArray.get(i)));
|
|
|
+ }
|
|
|
+ JSONObject paperObject = jsonObject.getJSONObject("paper");
|
|
|
+ String result=checkJob(jobJson);
|
|
|
+ if(!result.equals("success")){
|
|
|
+ object.put("status","fail");
|
|
|
+ object.put("message",result);
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+ JSONObject paperResult = reviewPaperService.savePaper(String.valueOf(paperObject));
|
|
|
+ if(!paperResult.has("paperId")){
|
|
|
+ object.put("status","fail");
|
|
|
+ object.put("message","创建paper失败");
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+ String paperId=paperResult.getString("paperId");
|
|
|
+ String jobId=uploadJob(jobName,jobDescription,paperId,startTime,endTime,workerList,"");
|
|
|
+ return object;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String checkJob(String jobJson){
|
|
|
+ String result="success";
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = new JSONObject(jobJson);
|
|
|
+ String jobName = jsonObject.getString("job_name");
|
|
|
+ String jobDescription = jsonObject.getString("job_description");
|
|
|
+ String startTime = jsonObject.getString("start_time");
|
|
|
+ String endTime = jsonObject.getString("end_time");
|
|
|
+ JSONArray workerList = jsonObject.getJSONArray("worker_list");
|
|
|
+ JSONObject paperObject = jsonObject.getJSONObject("paper");
|
|
|
+ String paperCheck=reviewPaperService.checkPaper(String.valueOf(paperObject));
|
|
|
+ if(!paperCheck.equals("success")){
|
|
|
+ result=paperCheck;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ result=e.getMessage();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public boolean updateJob(String jobId,String name, String description, String paperId,String startTime, String endTime,List<String>workerList,String workerDistribution){
|
|
|
try {
|
|
|
ReviewJob reviewJob=jobDao.findJob(jobId);
|