|
@@ -40,21 +40,50 @@ public class ReviewJobService {
|
|
|
return jobDao.findJobs();
|
|
|
}
|
|
|
|
|
|
- public String uploadJob(String examId,String caseId,String name, String description, String paperId, String startTime, String endTime, List<String>workerList, String workerDistribution){
|
|
|
+ public JSONObject uploadJob(String examId,String caseId,String name, String description, String paperId, String startTime, String endTime, List<String>workerList, String workerDistribution){
|
|
|
+ JSONObject jsonObject=new JSONObject();
|
|
|
+ String checkResult=checkJobDistribution(workerDistribution);
|
|
|
+ if(!checkResult.equals("success")){
|
|
|
+ jsonObject.put("status","fail");
|
|
|
+ jsonObject.put("message",checkResult);
|
|
|
+ }
|
|
|
ReviewJob reviewJob=new ReviewJob(examId,caseId,name,description,Long.toString(System.currentTimeMillis()),paperId,startTime,endTime,"");
|
|
|
String jobId=jobDao.save(reviewJob);
|
|
|
- List<String>workerIds=new ArrayList<>();
|
|
|
- for(int i=0;i<workerList.size();i++){
|
|
|
- String workerIndex=workerList.get(i);
|
|
|
- String workerId=reviewWorkerDao.save(new ReviewWorker(workerIndex,paperId,"",jobId));
|
|
|
- workerIds.add(workerId);
|
|
|
+ if(workerDistribution.equals("")){
|
|
|
+ List<String>workerIds=new ArrayList<>();
|
|
|
+ for(int i=0;i<workerList.size();i++){
|
|
|
+ String workerIndex=workerList.get(i);
|
|
|
+ String workerId=reviewWorkerDao.save(new ReviewWorker(workerIndex,paperId,"",jobId));
|
|
|
+ workerIds.add(workerId);
|
|
|
+ }
|
|
|
+ List<ReviewReport>reviewReports=reportDao.getReportsByPaperId(paperId);
|
|
|
+ List<String>reportIds=new ArrayList<>();
|
|
|
+ for(int i=0;i<reviewReports.size();i++)
|
|
|
+ reportIds.add(reviewReports.get(i).getId());
|
|
|
+ groupDao.save(new ReviewGroup("default","",workerIds,jobId,reportIds));
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ saveJobDistribution(workerDistribution, jobId);
|
|
|
+ }
|
|
|
+ jsonObject.put("status","success");
|
|
|
+ jsonObject.put("jobId",jobId);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String checkJobDistribution(String workerDistribution){
|
|
|
+ try {
|
|
|
+ JSONArray jsonArray=new JSONArray(workerDistribution);
|
|
|
+ for(int i=0;i<jsonArray.length();i++){
|
|
|
+ JSONObject jsonObject=jsonArray.getJSONObject(i);
|
|
|
+ String name=jsonObject.getString("name");
|
|
|
+ String desciption=jsonObject.getString("description");
|
|
|
+ JSONArray jsonArray1=jsonObject.getJSONArray("worker");
|
|
|
+ JSONArray jsonArray2=jsonObject.getJSONArray("report");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ return e.getMessage();
|
|
|
}
|
|
|
- List<ReviewReport>reviewReports=reportDao.getReportsByPaperId(paperId);
|
|
|
- List<String>reportIds=new ArrayList<>();
|
|
|
- for(int i=0;i<reviewReports.size();i++)
|
|
|
- reportIds.add(reviewReports.get(i).getId());
|
|
|
- saveJobDistribution(workerDistribution,jobId);
|
|
|
- return jobId;
|
|
|
+ return "success";
|
|
|
}
|
|
|
|
|
|
private void saveJobDistribution(String workerDistribution,String jobId){
|
|
@@ -105,10 +134,16 @@ public class ReviewJobService {
|
|
|
for(int i=0;i<reports.size();i++){
|
|
|
reportIds.add(reports.get(i).getId());
|
|
|
}
|
|
|
- String jobId=uploadJob(examId,caseId,jobName,jobDescription,paperId,startTime,endTime,workerList,"");
|
|
|
- groupDao.save(new ReviewGroup("default","",workerList,jobId,reportIds));
|
|
|
- messageVO.setStatus("200");
|
|
|
- messageVO.setMessage(jobId);
|
|
|
+ JSONObject jsonObject=uploadJob(examId,caseId,jobName,jobDescription,paperId,startTime,endTime,workerList,"");
|
|
|
+ // groupDao.save(new ReviewGroup("default","",workerList,jobId,reportIds));
|
|
|
+ if(jsonObject.getString("status").equals("success")) {
|
|
|
+ messageVO.setStatus("200");
|
|
|
+ messageVO.setMessage(jsonObject.getString("jobId"));
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ messageVO.setStatus("500");
|
|
|
+ messageVO.setMessage(jsonObject.getString("message"));
|
|
|
+ }
|
|
|
} catch (IOException e) {
|
|
|
messageVO.setStatus("500");
|
|
|
messageVO.setMessage(e.getMessage());
|