|
@@ -84,7 +84,7 @@ public class NodeService {
|
|
|
node.put("location", jobId + "/" + reportId + "/" + itemId+"/"+i);
|
|
|
node.put("description", reviewItem.getType());
|
|
|
node.put("category", "CrowdReview");
|
|
|
- node.put("weight", String.valueOf(Double.parseDouble(correctAnswer.getGrade())/num));
|
|
|
+ node.put("weight", String.valueOf(Integer.parseInt(correctAnswer.getGrade())/num));
|
|
|
nodesArray.put(node);
|
|
|
}
|
|
|
}
|
|
@@ -156,13 +156,15 @@ public class NodeService {
|
|
|
|
|
|
System.out.println(catchNodeArray);
|
|
|
|
|
|
- AnswerNode answerNode=new AnswerNode(jobId,workerId,catchNodeArray.toString(),"0");
|
|
|
-// answerNodeDao.save(answerNode);
|
|
|
+ AnswerNode answerNode=answerNodeDao.findByJobWorker(jobId,workerId);
|
|
|
+ if(answerNode==null){
|
|
|
+ answerNode=new AnswerNode(jobId,workerId,catchNodeArray.toString(),"0");
|
|
|
+ }else{
|
|
|
+ answerNode.setCatchNodeJson(catchNodeArray.toString());
|
|
|
+ }
|
|
|
+ answerNodeDao.save(answerNode);
|
|
|
+// test();
|
|
|
return answerNode;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void generateCatchNodeMultiple(JSONArray catchNodeArray,ReviewAnswer reviewAnswer,ReviewCorrectAnswer reviewCorrectAnswer,String jobId,String reportId,String itemId){
|
|
@@ -353,6 +355,7 @@ public class NodeService {
|
|
|
}
|
|
|
|
|
|
public JSONObject uploadCatchNodeToMoocTest(String jobId){
|
|
|
+ //todo 异步调用
|
|
|
ReviewJob reviewJob=reviewJobDao.findJob(jobId);
|
|
|
List<ReviewWorker> reviewWorkerList=reviewWorkerDao.getWorkersByJob(jobId);
|
|
|
JSONObject result=new JSONObject();
|
|
@@ -390,11 +393,11 @@ public class NodeService {
|
|
|
"workerID=" + workerOriginalId + "&" +
|
|
|
"caseName=CrowdReview";
|
|
|
String result = HTTP.sendGet(url, "");
|
|
|
- if(result != null && !result.equals("")) {
|
|
|
+ if(!result.equals("")) {
|
|
|
JSONObject json = new JSONObject(result);
|
|
|
if(json.has("data")){
|
|
|
JSONObject data=json.getJSONObject("data");
|
|
|
- return data.getString("uploadId");
|
|
|
+ return String.valueOf(data.getInt("uploadId"));
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
@@ -441,6 +444,64 @@ public class NodeService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ public void test(){
|
|
|
+ String result = "";
|
|
|
+ String uploadTime=String.valueOf(System.currentTimeMillis());
|
|
|
+ System.out.println(uploadTime);
|
|
|
+ String source="CrowdReview";
|
|
|
+ String url="http://www.mooctest.net/api/common/generalUploadCaughtNode/"+"2664"+"/"+uploadTime+"/"+"298714"+"/"+source;
|
|
|
+ try{
|
|
|
+ URL realUrl = new URL(url);
|
|
|
+ // 打开和URL之间的连接
|
|
|
+ HttpURLConnection connection;
|
|
|
+ connection = (HttpURLConnection)realUrl.openConnection();
|
|
|
+ connection.setDoInput(true);
|
|
|
+ connection.setDoOutput(true);
|
|
|
+ // 设置请求属性,必须要设置contentType
|
|
|
+ connection.setRequestProperty("accept", "*/*");
|
|
|
+ connection.setRequestProperty("Content-Type","application/json");
|
|
|
+ connection.setRequestMethod("PUT");
|
|
|
+ connection.setRequestProperty("user-agent",
|
|
|
+ "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
|
|
+ // 建立实际的连接
|
|
|
+ connection.connect();
|
|
|
+ //写入body数据,catchNode
|
|
|
+ OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "UTF-8"); // utf-8编码
|
|
|
+ out.append("[{\n" +
|
|
|
+ "\t\"nodeName\": \"5e3932aa4cedfd000d4e371b/5e3932aa4cedfd000d4e3716/5e3932aa4cedfd000d4e3717/0\",\n" +
|
|
|
+ "\t\"ifCatch\": false,\n" +
|
|
|
+ "\t\"category\": \"CrowdReview\"\n" +
|
|
|
+ "}, {\n" +
|
|
|
+ "\t\"nodeName\": \"5e3932aa4cedfd000d4e371b/5e3932aa4cedfd000d4e3716/5e3932aa4cedfd000d4e3717/1\",\n" +
|
|
|
+ "\t\"ifCatch\": true,\n" +
|
|
|
+ "\t\"category\": \"CrowdReview\"\n" +
|
|
|
+ "}, {\n" +
|
|
|
+ "\t\"nodeName\": \"5e3932aa4cedfd000d4e371b/5e3932aa4cedfd000d4e3716/5e3932aa4cedfd000d4e3718\",\n" +
|
|
|
+ "\t\"ifCatch\": true,\n" +
|
|
|
+ "\t\"category\": \"CrowdReview\"\n" +
|
|
|
+ "}, {\n" +
|
|
|
+ "\t\"nodeName\": \"5e3932aa4cedfd000d4e371b/5e3932aa4cedfd000d4e3716/5e3932aa4cedfd000d4e3719\",\n" +
|
|
|
+ "\t\"ifCatch\": false,\n" +
|
|
|
+ "\t\"category\": \"CrowdReview\"\n" +
|
|
|
+ "}]");
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+
|
|
|
+ BufferedReader in = new BufferedReader(new InputStreamReader(
|
|
|
+ connection.getInputStream()));
|
|
|
+ String line;
|
|
|
+ while ((line = in.readLine()) != null) {
|
|
|
+ result += line;
|
|
|
+ }
|
|
|
+ System.out.println(result);
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|