修改查询提问历史记录接口

master
xiaoCJ 5 months ago
parent ef40e3e7f5
commit a5e91cff38

@ -49,268 +49,268 @@ public class IlabController {
Map<String,String> map=iIlabService.getAccessToken(ticket); Map<String,String> map=iIlabService.getAccessToken(ticket);
} }
//
@PostMapping("dataUpload") // @PostMapping("dataUpload")
@AnonymousAccess // @AnonymousAccess
@ApiOperation("数据上传+实验报告上传") // @ApiOperation("数据上传+实验报告上传")
public void dataUpload(@ApiParam("access_token") @RequestParam String accessToken, // public void dataUpload(@ApiParam("access_token") @RequestParam String accessToken,
@ApiParam("un") @RequestParam String un, // @ApiParam("un") @RequestParam String un,
@ApiParam("userId") @RequestParam String userId) throws IOException { // @ApiParam("userId") @RequestParam String userId) throws IOException {
accessToken = URLEncoder.encode(accessToken, "UTF-8");
String accessTokenRepalce = accessToken.replaceAll("\\+", "%2B");
// long nowTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis()-10000;
long startTime = endTime- 1000 * 100;
//定义发送数据
String requestBody = "{\n" +
" \"username\": \""+un+"\",\n" +
" \"title\": \"股权基金投资虚拟仿真实验\",\n" +
" \"status\": 1,\n" +
" \"score\": 100,\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"appid\": \"107223\",\n" +
" \"originId\": \""+userId+"\",\n" +
" \"steps\": [\n" +
" {\n" +
" \"seq\": 1,\n" +
" \"title\": \"实验步骤1\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 2,\n" +
" \"title\": \"实验步骤2\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 3,\n" +
" \"title\": \"实验步骤3\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 4,\n" +
" \"title\": \"实验步骤4\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 5,\n" +
" \"title\": \"实验步骤5\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 6,\n" +
" \"title\": \"实验步骤6\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 7,\n" +
" \"title\": \"实验步骤7\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 8,\n" +
" \"title\": \"实验步骤8\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 9,\n" +
" \"title\": \"实验步骤9\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" },\n" +
" {\n" +
" \"seq\": 10,\n" +
" \"title\": \"实验步骤10\",\n" +
" \"startTime\": "+startTime+",\n" +
" \"endTime\": "+endTime+",\n" +
" \"timeUsed\": 100,\n" +
" \"expectTime\": 2,\n" +
" \"maxScore\": 10,\n" +
" \"score\": 10,\n" +
" \"repeatCount\": 1,\n" +
" \"evaluation\": \"优\",\n" +
" \"scoringModel\": \"赋分模型\",\n" +
" \"remarks\": \"备注\"\n" +
" }\n" +
" ]\n" +
"}\n" +
"\n";
//定义接收数据
JSONObject result = new JSONObject();
String url = "https://www.ilab-x.com/open/api/v2/data_upload?access_token="+accessTokenRepalce;
HttpPost httpPost = new HttpPost(url);
CloseableHttpClient client = HttpClients.createDefault();
//请求参数转JOSN字符串
StringEntity entity = new StringEntity(requestBody, "UTF-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
httpPost.setEntity(entity);
try {
HttpResponse response = client.execute(httpPost);
if (response.getStatusLine().getStatusCode() == 200) {
result = JSON.parseObject(EntityUtils.toString(response.getEntity(), "UTF-8"));
System.out.println(result.toString());
}
} catch (IOException e) {
e.printStackTrace();
result.put("error", "连接错误!");
}
//关闭连接
try {
client.close();
} catch (Exception e) {
System.out.println(e.getMessage());
}
try {
Thread.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
}
attachmentUpload(accessTokenRepalce,userId);
}
//实验报告上传
@PostMapping("attachmentUpload")
@AnonymousAccess
public void attachmentUpload(@ApiParam("access_token") @RequestParam String accessToken,
@ApiParam("userId")@RequestParam String userId) throws IOException {
// accessToken = URLEncoder.encode(accessToken, "UTF-8"); // accessToken = URLEncoder.encode(accessToken, "UTF-8");
// String accessTokenRepalce = accessToken.replaceAll("\\+", "%2B"); // String accessTokenRepalce = accessToken.replaceAll("\\+", "%2B");
String url = "https://www.ilab-x.com/open/api/v2/attachment_upload" + //// long nowTime = System.currentTimeMillis();
"?access_token=" + accessToken + // long endTime = System.currentTimeMillis()-10000;
"&appid=" + appid + // long startTime = endTime- 1000 * 100;
"&originId=" + userId+ // //定义发送数据
"&filename=abc.pdf&title=%E6%B5%8B%E8%AF%95%E5%AE%9E%E9%AA%8C%E6%8A%A5%E5%91%8A"; // String requestBody = "{\n" +
// " \"username\": \""+un+"\",\n" +
String pdfFilePath = filePath +"/abc.pdf"; // " \"title\": \"股权基金投资虚拟仿真实验\",\n" +
// String pdfFilePath = "C:\\Users\\86132\\Desktop\\abc.pdf"; // " \"status\": 1,\n" +
// " \"score\": 100,\n" +
File file = new File(pdfFilePath); // " \"startTime\": "+startTime+",\n" +
URL apiUrl = new URL(url); // " \"endTime\": "+endTime+",\n" +
HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); // " \"timeUsed\": 100,\n" +
// " \"appid\": \"107223\",\n" +
connection.setRequestMethod("POST"); // " \"originId\": \""+userId+"\",\n" +
connection.setDoOutput(true); // " \"steps\": [\n" +
// " {\n" +
String boundary = Long.toHexString(System.currentTimeMillis()); // " \"seq\": 1,\n" +
connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary); // " \"title\": \"实验步骤1\",\n" +
// " \"startTime\": "+startTime+",\n" +
try ( // " \"endTime\": "+endTime+",\n" +
DataOutputStream request = new DataOutputStream(connection.getOutputStream()); // " \"timeUsed\": 100,\n" +
FileInputStream fileInput = new FileInputStream(file) // " \"expectTime\": 2,\n" +
) { // " \"maxScore\": 10,\n" +
request.writeBytes("--" + boundary + "\r\n"); // " \"score\": 10,\n" +
request.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n"); // " \"repeatCount\": 1,\n" +
request.writeBytes("Content-Type: application/pdf\r\n\r\n"); // " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
byte[] buffer = new byte[4096]; // " \"remarks\": \"备注\"\n" +
int bytesRead; // " },\n" +
while ((bytesRead = fileInput.read(buffer)) != -1) { // " {\n" +
request.write(buffer, 0, bytesRead); // " \"seq\": 2,\n" +
} // " \"title\": \"实验步骤2\",\n" +
// " \"startTime\": "+startTime+",\n" +
request.writeBytes("\r\n--" + boundary + "--\r\n"); // " \"endTime\": "+endTime+",\n" +
} // " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
int responseCode = connection.getResponseCode(); // " \"maxScore\": 10,\n" +
System.out.println("Response Code : " + responseCode); // " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
InputStream responseStream; // " \"evaluation\": \"优\",\n" +
if (responseCode == HttpURLConnection.HTTP_OK) { // " \"scoringModel\": \"赋分模型\",\n" +
responseStream = connection.getInputStream(); // " \"remarks\": \"备注\"\n" +
} else { // " },\n" +
responseStream = connection.getErrorStream(); // " {\n" +
} // " \"seq\": 3,\n" +
// " \"title\": \"实验步骤3\",\n" +
if (responseStream != null) { // " \"startTime\": "+startTime+",\n" +
try (Scanner scanner = new Scanner(responseStream)) { // " \"endTime\": "+endTime+",\n" +
String responseBody = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : ""; // " \"timeUsed\": 100,\n" +
System.out.println("Response : " + responseBody); // Entire response from the server // " \"expectTime\": 2,\n" +
} // " \"maxScore\": 10,\n" +
} // " \"score\": 10,\n" +
} // " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 4,\n" +
// " \"title\": \"实验步骤4\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 5,\n" +
// " \"title\": \"实验步骤5\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 6,\n" +
// " \"title\": \"实验步骤6\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 7,\n" +
// " \"title\": \"实验步骤7\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 8,\n" +
// " \"title\": \"实验步骤8\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 9,\n" +
// " \"title\": \"实验步骤9\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " },\n" +
// " {\n" +
// " \"seq\": 10,\n" +
// " \"title\": \"实验步骤10\",\n" +
// " \"startTime\": "+startTime+",\n" +
// " \"endTime\": "+endTime+",\n" +
// " \"timeUsed\": 100,\n" +
// " \"expectTime\": 2,\n" +
// " \"maxScore\": 10,\n" +
// " \"score\": 10,\n" +
// " \"repeatCount\": 1,\n" +
// " \"evaluation\": \"优\",\n" +
// " \"scoringModel\": \"赋分模型\",\n" +
// " \"remarks\": \"备注\"\n" +
// " }\n" +
// " ]\n" +
// "}\n" +
// "\n";
// //定义接收数据
// JSONObject result = new JSONObject();
// String url = "https://www.ilab-x.com/open/api/v2/data_upload?access_token="+accessTokenRepalce;
// HttpPost httpPost = new HttpPost(url);
// CloseableHttpClient client = HttpClients.createDefault();
// //请求参数转JOSN字符串
// StringEntity entity = new StringEntity(requestBody, "UTF-8");
// entity.setContentEncoding("UTF-8");
// entity.setContentType("application/json");
// httpPost.setEntity(entity);
// try {
// HttpResponse response = client.execute(httpPost);
// if (response.getStatusLine().getStatusCode() == 200) {
// result = JSON.parseObject(EntityUtils.toString(response.getEntity(), "UTF-8"));
// System.out.println(result.toString());
// }
// } catch (IOException e) {
// e.printStackTrace();
// result.put("error", "连接错误!");
// }
// //关闭连接
// try {
// client.close();
// } catch (Exception e) {
// System.out.println(e.getMessage());
// }
//
// try {
// Thread.sleep(5);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// attachmentUpload(accessTokenRepalce,userId);
// }
//
// //实验报告上传
// @PostMapping("attachmentUpload")
// @AnonymousAccess
// public void attachmentUpload(@ApiParam("access_token") @RequestParam String accessToken,
// @ApiParam("userId")@RequestParam String userId) throws IOException {
//// accessToken = URLEncoder.encode(accessToken, "UTF-8");
//// String accessTokenRepalce = accessToken.replaceAll("\\+", "%2B");
// String url = "https://www.ilab-x.com/open/api/v2/attachment_upload" +
// "?access_token=" + accessToken +
// "&appid=" + appid +
// "&originId=" + userId+
// "&filename=abc.pdf&title=%E6%B5%8B%E8%AF%95%E5%AE%9E%E9%AA%8C%E6%8A%A5%E5%91%8A";
//
// String pdfFilePath = filePath +"/abc.pdf";
//// String pdfFilePath = "C:\\Users\\86132\\Desktop\\abc.pdf";
//
// File file = new File(pdfFilePath);
// URL apiUrl = new URL(url);
// HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection();
//
// connection.setRequestMethod("POST");
// connection.setDoOutput(true);
//
// String boundary = Long.toHexString(System.currentTimeMillis());
// connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
//
// try (
// DataOutputStream request = new DataOutputStream(connection.getOutputStream());
// FileInputStream fileInput = new FileInputStream(file)
// ) {
// request.writeBytes("--" + boundary + "\r\n");
// request.writeBytes("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\"\r\n");
// request.writeBytes("Content-Type: application/pdf\r\n\r\n");
//
// byte[] buffer = new byte[4096];
// int bytesRead;
// while ((bytesRead = fileInput.read(buffer)) != -1) {
// request.write(buffer, 0, bytesRead);
// }
//
// request.writeBytes("\r\n--" + boundary + "--\r\n");
// }
//
// int responseCode = connection.getResponseCode();
// System.out.println("Response Code : " + responseCode);
//
// InputStream responseStream;
// if (responseCode == HttpURLConnection.HTTP_OK) {
// responseStream = connection.getInputStream();
// } else {
// responseStream = connection.getErrorStream();
// }
//
// if (responseStream != null) {
// try (Scanner scanner = new Scanner(responseStream)) {
// String responseBody = scanner.useDelimiter("\\A").hasNext() ? scanner.next() : "";
// System.out.println("Response : " + responseBody); // Entire response from the server
// }
// }
// }

@ -102,6 +102,9 @@ public class TeaTopicManageServiceImpl implements TeaTopicManageService {
QuestionAnswerExample questionAnswerExample = new QuestionAnswerExample(); QuestionAnswerExample questionAnswerExample = new QuestionAnswerExample();
questionAnswerExample.createCriteria().andSchoolidEqualTo(schoolId); questionAnswerExample.createCriteria().andSchoolidEqualTo(schoolId);
List<QuestionAnswerWithBLOBs> questionAnswers = questionAnswerMapper.selectByExampleWithBLOBs(questionAnswerExample); List<QuestionAnswerWithBLOBs> questionAnswers = questionAnswerMapper.selectByExampleWithBLOBs(questionAnswerExample);
if (questionAnswers.isEmpty()) {
return new PageInfo<>();
}
UserExample userTableExample = new UserExample(); UserExample userTableExample = new UserExample();
UserExample.Criteria criteria = userTableExample.createCriteria(); UserExample.Criteria criteria = userTableExample.createCriteria();
UserExample.Criteria or = userTableExample.createCriteria(); UserExample.Criteria or = userTableExample.createCriteria();
@ -119,6 +122,9 @@ public class TeaTopicManageServiceImpl implements TeaTopicManageService {
for (User userTable : userTables) { for (User userTable : userTables) {
Flow flow = flowMapper.selectByPrimaryKey(userTable.getUserid()); Flow flow = flowMapper.selectByPrimaryKey(userTable.getUserid());
if (flow == null) {
continue;
}
String flowId = flow.getFlowId(); String flowId = flow.getFlowId();
for (QuestionAnswer questionAnswer : questionAnswers) { for (QuestionAnswer questionAnswer : questionAnswers) {
if (questionAnswer.getFlowId().equals(flowId)) { if (questionAnswer.getFlowId().equals(flowId)) {

Loading…
Cancel
Save