|
@@ -0,0 +1,132 @@
|
|
|
+package com.lantone.qc.kernel;
|
|
|
+
|
|
|
+import com.lantone.qc.kernel.analysis.QCAnalysis;
|
|
|
+import com.lantone.qc.pub.jdbc.MysqlJdbc;
|
|
|
+import com.lantone.qc.pub.model.OutputInfo;
|
|
|
+import com.lantone.qc.pub.model.vo.MedrecVo;
|
|
|
+import com.lantone.qc.pub.model.vo.QueryVo;
|
|
|
+import com.lantone.qc.pub.res.Response;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.sql.Connection;
|
|
|
+import java.sql.ResultSet;
|
|
|
+import java.sql.SQLException;
|
|
|
+import java.sql.Statement;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @ClassName : QCTestController
|
|
|
+ * @Description : 测试
|
|
|
+ * @Author : 楼辉荣
|
|
|
+ * @Date: 2020-03-11 16:03
|
|
|
+ */
|
|
|
+@Api(value = "质控测试接口", tags = { "质控测试接口" })
|
|
|
+@RestController
|
|
|
+@RequestMapping(value = "test")
|
|
|
+public class QCTestController {
|
|
|
+ @Autowired
|
|
|
+ private QCAnalysis qCAnalysis;
|
|
|
+
|
|
|
+ @ApiOperation(value = "质控测试接口,无需token信息", notes = "")
|
|
|
+ @PostMapping("rec_test")
|
|
|
+ public Response<OutputInfo> extract(String caseIds) {
|
|
|
+ Response response = new Response();
|
|
|
+
|
|
|
+ MysqlJdbc mysqlJdbc = new MysqlJdbc("root", "lantone", "jdbc:mysql://192.168.2.236:3306/sys-mrqc?useUnicode=true&characterEncoding=UTF-8");
|
|
|
+ Connection conn = mysqlJdbc.connect();
|
|
|
+ Statement st = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ String r1, r2, r3, r4, r5;
|
|
|
+ List<Map<String, Object>> updates = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> wheres = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ st = conn.createStatement();
|
|
|
+ //测试数据查询
|
|
|
+ String sql = "SELECT qmap.id, qi.id text_id, qi.text, ca.name, entry.code FROM \n" +
|
|
|
+ "qc_inputcases_mapping qmap, qc_inputcases qi, qc_cases_entry entry, qc_cases ca\n" +
|
|
|
+ "where qmap.cases_id = qi.id and qmap.cases_entry_id = entry.id and entry.cases_id = ca.id ";
|
|
|
+
|
|
|
+ if (!StringUtils.isNotEmpty(caseIds)) {
|
|
|
+ sql = sql + " and cases_id in (" + caseIds + ")";
|
|
|
+ }
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ rs = st.executeQuery(sql);
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> catalogueMap = new HashMap<>();
|
|
|
+ Map<String, String> updateMap = new HashMap<>();
|
|
|
+
|
|
|
+ List<Map<String, Map<String, String>>> catalogueList = new ArrayList<>();
|
|
|
+ List<String> textList = new ArrayList<>();
|
|
|
+ List<String> caseList = new ArrayList<>();
|
|
|
+ List<Map<String, String>> updateList = new ArrayList<>();
|
|
|
+ String textId = "";
|
|
|
+ while (rs.next()) {
|
|
|
+ r1 = rs.getString(1);
|
|
|
+ r2 = rs.getString(2);
|
|
|
+ r3 = rs.getString(3);
|
|
|
+ r4 = rs.getString(4);
|
|
|
+ r5 = rs.getString(5);
|
|
|
+ if (!textId.equals(r1)) {
|
|
|
+ if (StringUtils.isNotEmpty(textId)) {
|
|
|
+ catalogueList.add(catalogueMap);
|
|
|
+ updateList.add(updateMap);
|
|
|
+ textList.add(r3);
|
|
|
+ caseList.add(r4);
|
|
|
+ }
|
|
|
+ catalogueMap = new HashMap<>();
|
|
|
+ }
|
|
|
+ catalogueMap.put(r5, new HashMap<>());
|
|
|
+ updateMap.put(r5, r1);
|
|
|
+ textId = r2;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < textList.size(); i++) {
|
|
|
+ MedrecVo medrecVo = new MedrecVo();
|
|
|
+ medrecVo.setTitle(caseList.get(i));
|
|
|
+ Map<String, Object> content = new HashMap<>();
|
|
|
+ content.put("content", textList.get(i));
|
|
|
+ medrecVo.setContent(content);
|
|
|
+
|
|
|
+ List<MedrecVo> medrec = new ArrayList<>();
|
|
|
+ medrec.add(medrecVo);
|
|
|
+
|
|
|
+ QueryVo queryVo = new QueryVo();
|
|
|
+ queryVo.setMedrec(medrec);
|
|
|
+ queryVo.setInputCatalogueMap(catalogueList.get(i));
|
|
|
+
|
|
|
+ OutputInfo outputInfo = qCAnalysis.anlysis(queryVo);
|
|
|
+
|
|
|
+ Map<String, String> catalogue_map = updateList.get(i);
|
|
|
+ for (Map.Entry<String, String> entry : catalogue_map.entrySet()) {
|
|
|
+ Map<String, Object> m = new HashMap<>();
|
|
|
+ Map<String, Object> w = new HashMap<>();
|
|
|
+ m.put("pass", outputInfo.getResult().get(entry.getKey()).get("status"));
|
|
|
+ w.put("id", catalogue_map.get(entry.getKey()));
|
|
|
+
|
|
|
+ updates.add(m);
|
|
|
+ wheres.add(w);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ mysqlJdbc.update("qc_inputcases_mapping", updates, wheres);
|
|
|
+
|
|
|
+ } catch (SQLException sqle) {
|
|
|
+ sqle.printStackTrace();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ mysqlJdbc.close(rs, st, conn);
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+}
|