|
@@ -33,7 +33,13 @@ public class ExtraService {
|
|
|
ReviewItemDao itemDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ ReviewAnswerDao answerDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
ReviewService reviewService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ReviewReportDao reviewReportDao;
|
|
|
|
|
|
//测试用例相关
|
|
|
public String saveTestCase(String report_id, String name, String front, String behind, String description) {
|
|
@@ -147,39 +153,70 @@ public class ExtraService {
|
|
|
String requirement_location=jsonObject.getString("requirement_location");
|
|
|
String report_num=jsonObject.getString("report_num");
|
|
|
String worker_num=jsonObject.getString("worker_num");
|
|
|
-
|
|
|
String job_id=jobDao.save(new ReviewJob(description,name,time,type,application_location,requirement_location,report_num,worker_num));
|
|
|
|
|
|
+
|
|
|
+ JSONArray reportArray=jsonObject.getJSONArray("report_list");
|
|
|
+ HashMap<String,String>report_index_to_id=new HashMap<>();
|
|
|
+ for(int i=0;i<reportArray.length();i++){
|
|
|
+ JSONObject reportObject=reportArray.getJSONObject(i);
|
|
|
+ String report_index=reportObject.getString("index");
|
|
|
+ String id=saveReport(reportObject,job_id);
|
|
|
+ report_index_to_id.put(report_index,id);
|
|
|
+ }
|
|
|
+
|
|
|
JSONArray itemGroupArray=jsonObject.getJSONArray("item_group_list");
|
|
|
//save item
|
|
|
//item index-id
|
|
|
HashMap<String,Integer>item_id_to_option_num=new HashMap<>();
|
|
|
+ HashMap<String,String>item_index_to_id=new HashMap<>();
|
|
|
for(int i=0;i<itemGroupArray.length();i++) {
|
|
|
JSONObject itemGroupObject = itemGroupArray.getJSONObject(i);
|
|
|
- saveItem(itemGroupObject,job_id,item_id_to_option_num);
|
|
|
+ saveItem(itemGroupObject,job_id,item_id_to_option_num,report_index_to_id,item_index_to_id);
|
|
|
}
|
|
|
|
|
|
//worker_id-item_id_list
|
|
|
JSONArray groupArray=jsonObject.getJSONArray("group_list");
|
|
|
- createWorkerToItem(groupArray,job_id,item_id_to_option_num);
|
|
|
+ createWorkerToItem(groupArray,job_id,report_index_to_id,item_id_to_option_num);
|
|
|
|
|
|
return job_id;
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void saveItem(JSONObject itemGroupObject,String job_id,HashMap<String,Integer>item_id_to_option_num){
|
|
|
+ private String saveReport(JSONObject reportObject,String job_id){
|
|
|
+ JSONArray imgArray=reportObject.getJSONArray("img_url");
|
|
|
+ List<String> img_urls=new ArrayList<>();
|
|
|
+ for(int i=0;i<imgArray.length();i++){
|
|
|
+ JSONObject imgUrlObject=imgArray.getJSONObject(i);
|
|
|
+ img_urls.add(imgUrlObject.getString("url"));
|
|
|
+ }
|
|
|
+ JSONArray fileArray=reportObject.getJSONArray("file_url");
|
|
|
+ List<String> file_urls=new ArrayList<>();
|
|
|
+ for(int i=0;i<fileArray.length();i++){
|
|
|
+ JSONObject fileUrlObject=fileArray.getJSONObject(i);
|
|
|
+ file_urls.add(fileUrlObject.getString("url"));
|
|
|
+ }
|
|
|
+ String name=reportObject.getString("name");
|
|
|
+ String description=reportObject.getString("description");
|
|
|
+ ReviewReport reviewReport=new ReviewReport(job_id,name,description,img_urls,file_urls);
|
|
|
+ return reviewReportDao.save(reviewReport);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void saveItem(JSONObject itemGroupObject,String job_id,HashMap<String,Integer>item_id_to_option_num,HashMap<String,String>report_index_to_id,HashMap<String,String>item_index_to_id){
|
|
|
|
|
|
// JSONObject itemObject=itemArray.getJSONObject(i);
|
|
|
- List<String> urls=new ArrayList<>();
|
|
|
+ List<String> reportIds=new ArrayList<>();
|
|
|
JSONArray reportArray=itemGroupObject.getJSONArray("report_list");
|
|
|
- List<String> reports=new ArrayList<>();
|
|
|
for (int j=0;j<reportArray.length();j++){
|
|
|
- JSONObject reportIdObject=reportArray.getJSONObject(j);
|
|
|
- urls.add(reportIdObject.getString("report_id"));
|
|
|
+ JSONObject reportIndexObject=reportArray.getJSONObject(j);
|
|
|
+ reportIds.add(report_index_to_id.get(reportIndexObject.getString("report_index")));
|
|
|
}
|
|
|
JSONArray itemArray=itemGroupObject.getJSONArray("item_list");
|
|
|
+ List<String>itemIds=new ArrayList<>();
|
|
|
for (int j=0;j<itemArray.length();j++){
|
|
|
JSONObject itemObject=itemArray.getJSONObject(j);
|
|
|
+ String index=itemObject.getString("index");
|
|
|
String isMultiple=itemObject.getString("is_multiple");
|
|
|
String isRequired=itemObject.getString("is_required");
|
|
|
String description=itemObject.getString("description");
|
|
@@ -189,14 +226,21 @@ public class ExtraService {
|
|
|
for(int k=0;k<optionArray.length();k++){
|
|
|
options.add(optionArray.getJSONObject(k).getString("option"));
|
|
|
}
|
|
|
- ReviewItem item=new ReviewItem(job_id,isRequired,isMultiple,options,description,reports,type);
|
|
|
+ ReviewItem item=new ReviewItem(job_id,isRequired,isMultiple,options,description,reportIds,type);
|
|
|
String item_id = itemDao.saveItem(item);
|
|
|
+ itemIds.add(item_id);
|
|
|
item_id_to_option_num.put(item_id,options.size());
|
|
|
+ item_index_to_id.put(index,item_id);
|
|
|
+ }
|
|
|
+ for(int j=0;j<reportIds.size();j++){
|
|
|
+ ReviewReport report=reviewReportDao.findReviewReport(reportIds.get(j));
|
|
|
+ report.setItem_id(itemIds);
|
|
|
+ reviewReportDao.save(report);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void createWorkerToItem(JSONArray groupArray,String job_id,HashMap<String,Integer>item_id_to_option_num){
|
|
|
+ private void createWorkerToItem(JSONArray groupArray,String job_id,HashMap<String,String>report_index_to_id,HashMap<String,Integer>item_id_to_option_num){
|
|
|
for(int i=0;i<groupArray.length();i++){
|
|
|
JSONObject groupObject=groupArray.getJSONObject(i);
|
|
|
String description=groupObject.getString("description");
|
|
@@ -211,7 +255,7 @@ public class ExtraService {
|
|
|
List<String> reportIdList=new ArrayList<>();
|
|
|
for (int j=0;j<reportIndexArray.length();j++){
|
|
|
JSONObject reportIndexObject=reportIndexArray.getJSONObject(j);
|
|
|
- reportIdList.add(reportIndexObject.getString("report_id"));
|
|
|
+ reportIdList.add(report_index_to_id.get(reportIndexObject.getString("report_index")));
|
|
|
}
|
|
|
reviewService.saveGroup(name,description,workerList,job_id,reportIdList);
|
|
|
for(int j=0;j<workerList.size();j++){
|
|
@@ -223,7 +267,8 @@ public class ExtraService {
|
|
|
for(int l=0;l<items.size();l++) {
|
|
|
String item_id=items.get(l).getId();
|
|
|
int optionNum=item_id_to_option_num.get(item_id);
|
|
|
- reviewService.initAnswer(item_id,report_id, worker_id, job_id, optionNum);
|
|
|
+ ReviewAnswer answer=new ReviewAnswer(item_id,report_id,worker_id,job_id,optionNum);
|
|
|
+ answerDao.save(answer);
|
|
|
}
|
|
|
}
|
|
|
}
|