TestApiController.java
3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.yoho.search.consumer.test;
import com.yoho.search.consumer.index.increment.bulks.CommonBulkService;
import com.yoho.search.consumer.job.CleanDataJob;
import com.yoho.search.consumer.service.logicService.RecallStrategyLogicService;
import com.yoho.search.dal.SknImageVectorsMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
@Controller
public class TestApiController {
private static final Logger logger = LoggerFactory.getLogger(TestApiController.class);
@Autowired
private CleanDataJob cleanDataJobJob;
@Autowired
private CommonBulkService commonBulkService;
@Autowired
private SknImageVectorsMapper sknImageVectorsMapper;
@RequestMapping(value = "/test")
@ResponseBody
public Map<String, Object> test() {
Map<String, Object> testResult = new HashMap<String, Object>();
testResult.put("data", null);
testResult.put("code", 200);
testResult.put("message", "success");
return testResult;
}
// @RequestMapping(value = "/putImageVectorDataToDB")
// @ResponseBody
// public Map<String, Object> putData() throws UnsupportedEncodingException {
// for (int j = 1; j <= 10; j++) {
// String fileName = j + "_feat_out_32_.txt";
// String filePath = this.getClass().getResource("/").getPath();
// List<String> lines = FileUtils.readFile(filePath + fileName);
// System.out.println("lines done " + j);
// try {
// List<SknImageVectors> sknImageVectorsList = new ArrayList<>();
// for (int i = 0; i < lines.size(); i++) {
// String skn = lines.get(i).substring(0, 8);
// String factors = lines.get(i).substring(9);
// //Map<String, Object> indexData = new HashMap<String, Object>();
// //indexData.put("bin_sigs", factors);
// SknImageVectors sknImageVectors = new SknImageVectors();
// sknImageVectors.setProductSkn(Integer.valueOf(skn));
// sknImageVectors.setImgUrl("url");
// sknImageVectors.setVectors_32(factors);
// sknImageVectors.setVectors_128("");
// sknImageVectors.setCreateTime(DateUtil.getCurrentTimeSecond());
// sknImageVectorsList.add(sknImageVectors);
// //updateProductIndexWithDataMap(indexData, skn);
// if (i > 0) {
// if (i % 1000 == 0 || i == 9999) {
// sknImageVectorsMapper.insertBatch(sknImageVectorsList);
// sknImageVectorsList.clear();
// System.out.println("batch done_" + j + "_" + i);
// }
// }
// }
// } catch (Exception e) {
// System.out.print(e.getMessage());
// }
// }
// Map<String, Object> result = new HashMap<>();
// result.put("code", 200);
// result.put("message", "success");
// return result;
// }
//
// protected final void updateProductIndexWithDataMap(Map<String, Object> indexData, String skn) {
// JSONObject jsonObject = new JSONObject(indexData);
// commonBulkService.add(new ESBluk(jsonObject.toJSONString(), skn, "images_test", "images_test", false));
// }
@Autowired
private RecallStrategyLogicService recallStrategyLogicService;
@RequestMapping(value = "/test2")
@ResponseBody
public String test2() {
String result = recallStrategyLogicService.getRecallStrategyConfigInZk();
return result;
}
}