Commit 5d187fcd authored by 霍传世's avatar 霍传世

HaiNa---接口

parent 36e2fe85
...@@ -14,6 +14,6 @@ public class InterceptorConfig implements WebMvcConfigurer { ...@@ -14,6 +14,6 @@ public class InterceptorConfig implements WebMvcConfigurer {
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginInterceptor).addPathPatterns("/businessApi/**","/faceMatchApi/**","/commitmentLetterApi/**").excludePathPatterns("/login","/publicApi/**","/scripts/**");; registry.addInterceptor(loginInterceptor).addPathPatterns("/businessApi/**","/faceMatchApi/**","/commitmentLetterApi/**").excludePathPatterns("/login","/publicApi/**","/scripts/**","/callBackApi/**");;
} }
} }
...@@ -5,7 +5,8 @@ public class AppThirdPartUrls { ...@@ -5,7 +5,8 @@ public class AppThirdPartUrls {
public static final String examList = "https://openapi.hina.com/api/aiExam/examList"; public static final String examList = "https://openapi.hina.com/api/aiExam/examList";
public static final String candidateCreate = "https://openapi.hina.com/api/aiExam/candidateCreate"; public static final String candidateCreate = "https://openapi.hina.com/api/aiExam/candidateCreate";
public static final String candidateGet = "https://openapi.hina.com/api/aiExam/candidateCreate"; public static final String candidateGet = "https://openapi.hina.com/api/aiExam/candidateGet";
public static final String candidateSendMessage = "https://openapi.hina.com/api/aiExam/candidateCreate"; public static final String candidateGetV2 = "https://openapi.hina.com/api/aiExam/candidateGetV2";
public static final String candidateMDelete = "https://openapi.hina.com/api/aiExam/candidateCreate"; public static final String candidateSendMessage = "https://openapi.hina.com/api/aiExam/candidateSendMessag";
public static final String candidateMDelete = "https://openapi.hina.com/api/aiExam/candidateMDelete";
} }
...@@ -2,16 +2,20 @@ package com.yuda.hainafacetofaceai.controller; ...@@ -2,16 +2,20 @@ package com.yuda.hainafacetofaceai.controller;
import com.yuda.hainafacetofaceai.constant.AppThirdPartUrls; import com.yuda.hainafacetofaceai.constant.AppThirdPartUrls;
import com.yuda.hainafacetofaceai.entity.CandidateCreateQuery; import com.yuda.hainafacetofaceai.entity.CandidateCreateQuery;
import com.yuda.hainafacetofaceai.entity.CandidateExam;
import com.yuda.hainafacetofaceai.entity.CandidateMDelete; import com.yuda.hainafacetofaceai.entity.CandidateMDelete;
import com.yuda.hainafacetofaceai.entity.ExamQuery; import com.yuda.hainafacetofaceai.entity.ExamQuery;
import com.yuda.hainafacetofaceai.util.AppUtil; import com.yuda.hainafacetofaceai.util.AppUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
...@@ -21,14 +25,14 @@ import java.util.Map; ...@@ -21,14 +25,14 @@ import java.util.Map;
@RestController @RestController
@RequestMapping("/businessApi") @RequestMapping("/businessApi")
@Slf4j @Slf4j
public class businessController { public class BusinessController {
@Autowired @Autowired
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Autowired
private JdbcTemplate DBOperator;
@Autowired @Autowired
private AppUtil appUtil; private AppUtil appUtil;
@PostMapping("/examList") @PostMapping("/examList")
public ResponseEntity examList(@RequestBody ExamQuery examQuery){ public ResponseEntity examList(@RequestBody ExamQuery examQuery){
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
...@@ -73,6 +77,45 @@ public class businessController { ...@@ -73,6 +77,45 @@ public class businessController {
); );
return ResponseEntity.ok(response.getBody()); return ResponseEntity.ok(response.getBody());
} }
@PostMapping("/candidateGetV2")
public ResponseEntity candidateGetV2(@RequestBody String responseBody){
try{
CandidateExam candidateExam = DBOperator.queryForObject("select * from candidate_exam where exam_connection_code = ? order by create_time asc limit 1",new Object[]{new JSONObject(responseBody).getString("examConnectCode")},new BeanPropertyRowMapper<>(CandidateExam.class));
long timeStamp = candidateExam.getCreateTime().toInstant().getMillis()/1000;
JSONObject requestBody = new JSONObject(responseBody);
requestBody.put("fromTimeStamp",timeStamp);
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type","application/json");
HttpEntity<String> entity = new HttpEntity<>(requestBody.toString(),headers);
ResponseEntity<String> response = restTemplate.exchange(
appUtil.ApiUrlGen(AppThirdPartUrls.candidateGet),
HttpMethod.POST,
entity,
String.class
);
JSONObject data = new JSONObject(response.getBody());
if(data.getString("code").equals(0)){
JSONArray candidateList = data.getJSONArray("candidateList");
if(!candidateList.isEmpty()){
for (int i = 0; i < candidateList.length(); i++) {
JSONObject candidate = new JSONObject(candidateList.get(i));
DBOperator.update("update candiate_exam set result_back = 1,interview_results = ? where candidateConnectionCode = ? and result_back = 0",new Object[]{candidate.toString(),candidate.getString("candidateConnectCode")});
}
}
}
log.info("主动查询面试"+new JSONObject(responseBody).getString("examConnectCode")+"面试结果批量更新成功");
}catch (Exception e){
log.info("主动查询面试"+new JSONObject(responseBody).getString("examConnectCode")+"面试结果批量过程出错");
return ResponseEntity.ok(new JSONObject(new HashMap<String,Object>(){{
put("code",500);
put("message","面试结果批量更新过程出错");
}}));
}
return ResponseEntity.ok(new JSONObject(new HashMap<String,Object>()){{
put("code",200);
put("message","操作成功");
}});
}
@PostMapping("/candidateSendMessage") @PostMapping("/candidateSendMessage")
public ResponseEntity candidateSendMessage(@RequestParam("outId")String outId){ public ResponseEntity candidateSendMessage(@RequestParam("outId")String outId){
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
...@@ -103,4 +146,5 @@ public class businessController { ...@@ -103,4 +146,5 @@ public class businessController {
); );
return ResponseEntity.ok(response.getBody()); return ResponseEntity.ok(response.getBody());
} }
} }
package com.yuda.hainafacetofaceai.controller;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/callBackApi")
@Slf4j
public class CallBackApiController {
@Autowired
private JdbcTemplate DBOperator;
@PostMapping("/interviewResultReceiver")
public void interviewResultsReceiver(@RequestBody String data){
JSONObject result = JSONObject.parseObject(data);
String candidateConnectCode = result.getString("candidateConnectCode");
try{
DBOperator.update("update candidate_exam set result_back = 1,interview_results = ? where candidate_connect_code = ?",new Object[]{data,candidateConnectCode});
log.info("候选人链接码"+candidateConnectCode+"面试结果入库完成");
}catch (Exception e){
log.info("候选人链接码"+candidateConnectCode+"面试结果回调出错");
}
}
}
...@@ -39,8 +39,6 @@ public class ScriptInterfaceController { ...@@ -39,8 +39,6 @@ public class ScriptInterfaceController {
private ScriptInterfaceServiceImpl scriptInterfaceService; private ScriptInterfaceServiceImpl scriptInterfaceService;
@Autowired @Autowired
private JdbcTemplate DBOperator; private JdbcTemplate DBOperator;
@PostMapping("/batchGenCandidatesOftest") @PostMapping("/batchGenCandidatesOftest")
@Transactional @Transactional
public ResponseEntity batchGenTest(@RequestParam("examConnectionCode")String examConnectionCode){ public ResponseEntity batchGenTest(@RequestParam("examConnectionCode")String examConnectionCode){
...@@ -68,7 +66,6 @@ public class ScriptInterfaceController { ...@@ -68,7 +66,6 @@ public class ScriptInterfaceController {
} }
return ResponseEntity.ok(""); return ResponseEntity.ok("");
} }
@PostMapping("/{examConnectionCode}") @PostMapping("/{examConnectionCode}")
public ResponseEntity importCandidates(@PathVariable String examConnectionCode, @RequestParam(value = "file") MultipartFile file) { public ResponseEntity importCandidates(@PathVariable String examConnectionCode, @RequestParam(value = "file") MultipartFile file) {
ExcelUtil<CandidateExam> excelUtil = new ExcelUtil<>(); ExcelUtil<CandidateExam> excelUtil = new ExcelUtil<>();
...@@ -96,7 +93,6 @@ public class ScriptInterfaceController { ...@@ -96,7 +93,6 @@ public class ScriptInterfaceController {
bodyResponse.put("message","导入成功"); bodyResponse.put("message","导入成功");
return ResponseEntity.ok(""); return ResponseEntity.ok("");
} }
@PostMapping("/genCandidateConnectionCode") @PostMapping("/genCandidateConnectionCode")
public ResponseEntity genCandidateCode(@RequestParam("candidateConnectionCode")String candidateConnectionCode){ public ResponseEntity genCandidateCode(@RequestParam("candidateConnectionCode")String candidateConnectionCode){
try{ try{
...@@ -125,4 +121,11 @@ public class ScriptInterfaceController { ...@@ -125,4 +121,11 @@ public class ScriptInterfaceController {
requestData.put("message","指令发送成功"); requestData.put("message","指令发送成功");
return ResponseEntity.ok(requestData); return ResponseEntity.ok(requestData);
} }
@PostMapping("/genBatchJsonFile")
public ResponseEntity GenBatchJsonFile(@RequestBody String connecto){
return null;
}
} }
...@@ -2,6 +2,7 @@ package com.yuda.hainafacetofaceai.entity; ...@@ -2,6 +2,7 @@ package com.yuda.hainafacetofaceai.entity;
import com.yuda.hainafacetofaceai.annotations.ExcelColumn; import com.yuda.hainafacetofaceai.annotations.ExcelColumn;
import lombok.Data; import lombok.Data;
import org.joda.time.DateTime;
@Data @Data
public class CandidateExam { public class CandidateExam {
...@@ -20,4 +21,9 @@ public class CandidateExam { ...@@ -20,4 +21,9 @@ public class CandidateExam {
private String examImageFace; private String examImageFace;
private Integer statusFace; private Integer statusFace;
private Integer statusCommitment; private Integer statusCommitment;
private String interviewResults;
private Integer resultBack;
private Integer reportDone;
private DateTime updateTime;
private DateTime createTime;
} }
package com.yuda.hainafacetofaceai; package com.yuda.hainafacetofaceai;
import com.yuda.hainafacetofaceai.util.AppUtil; import com.yuda.hainafacetofaceai.util.AppUtil;
import org.apache.tomcat.util.security.MD5Encoder; import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest
@Slf4j
class HaiNaFaceToFaceAiApplicationTests { class HaiNaFaceToFaceAiApplicationTests {
@Autowired @Autowired
private AppUtil appUtil; private AppUtil appUtil;
@Test @Test
void contextLoads() { void contextLoads() {
Integer i = 0; for (int i = 0; i < 500; i++) {
if(setMessage(i)){ log.info("正在执行"+i+"/500");
System.out.println(i); try {
// 定义 Node.js 执行命令
String nodeCommand = "node D:/myWorkSpace/PDF_TEST.js";
// 启动命令行进程
ProcessBuilder processBuilder = new ProcessBuilder(nodeCommand.split(" "));
processBuilder.inheritIO(); // 继承命令行输入输出
// 启动进程并等待脚本执行完毕
Process process = processBuilder.start();
int exitCode = process.waitFor(); // 等待脚本执行完毕并返回退出码
if (exitCode == 0) {
log.info("succeed");
} else {
log.info("fail");
}
} catch (Exception e) {
e.printStackTrace();
log.info("error");
}
} }
} }
public boolean setMessage(Integer i){
i = 1;
return true;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment