|
@@ -2,6 +2,7 @@ package thyyxxk.webserver.service.examinations;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.text.StringEscapeUtils;
|
|
|
import org.dom4j.Document;
|
|
@@ -14,10 +15,8 @@ import org.springframework.http.HttpHeaders;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import thyyxxk.webserver.config.exception.BizException;
|
|
|
-import thyyxxk.webserver.entity.examinations.adicon.AdiconInquiry;
|
|
|
-import thyyxxk.webserver.entity.examinations.adicon.BarcodeType;
|
|
|
-import thyyxxk.webserver.entity.examinations.adicon.ListTableItem;
|
|
|
-import thyyxxk.webserver.entity.examinations.adicon.ReportDetail;
|
|
|
+import thyyxxk.webserver.dao.adicon.AdiconDao;
|
|
|
+import thyyxxk.webserver.entity.examinations.adicon.*;
|
|
|
import thyyxxk.webserver.service.externalhttp.AdiconHttpSrvc;
|
|
|
import thyyxxk.webserver.utils.FilterUtil;
|
|
|
import thyyxxk.webserver.utils.StringUtil;
|
|
@@ -28,19 +27,19 @@ import javax.xml.bind.Unmarshaller;
|
|
|
import java.io.StringReader;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
+@DS("adicon")
|
|
|
public class AdiconService {
|
|
|
private final AdiconHttpSrvc adiconHttpSrvc;
|
|
|
-
|
|
|
- private static final String URL = "http://222.240.235.22/CSWebService/ADReportWebService.asmx";
|
|
|
+ private final AdiconDao dao;
|
|
|
|
|
|
@Autowired
|
|
|
- public AdiconService(AdiconHttpSrvc adiconHttpSrvc) {
|
|
|
+ public AdiconService(AdiconHttpSrvc adiconHttpSrvc, AdiconDao dao) {
|
|
|
this.adiconHttpSrvc = adiconHttpSrvc;
|
|
|
+ this.dao = dao;
|
|
|
}
|
|
|
|
|
|
public String login(String type) throws Exception {
|
|
@@ -160,6 +159,99 @@ public class AdiconService {
|
|
|
return xmlString.replaceAll("<\\?xml.*?\\?>", "");
|
|
|
}
|
|
|
|
|
|
+ public List<ItemMatch> getUnMatchedList(List<ItemMatch> request) {
|
|
|
+ StringBuilder inCodeStatementBuilder = new StringBuilder();
|
|
|
+ for (ItemMatch item : request) {
|
|
|
+ inCodeStatementBuilder.append(",'").append(item.getItemCode()).append("'");
|
|
|
+ }
|
|
|
+ String inCodeStatement = inCodeStatementBuilder.substring(1);
|
|
|
+ List<String> matchedItems = dao.selectMatchedItems(inCodeStatement);
|
|
|
+ request.removeIf(item -> matchedItems.contains(item.getItemCode()));
|
|
|
+ if (request.isEmpty()) {
|
|
|
+ return request;
|
|
|
+ }
|
|
|
+ StringBuilder inNameStatementBuilder = new StringBuilder();
|
|
|
+ for (ItemMatch item : request) {
|
|
|
+ inNameStatementBuilder.append(",'").append(item.getItemName()).append("'");
|
|
|
+ }
|
|
|
+ String inNameStatement = inNameStatementBuilder.substring(1);
|
|
|
+ List<ItemMatch> autoMatchableItems = dao.selectAutoMatchableItems(inNameStatement);
|
|
|
+ if (!autoMatchableItems.isEmpty()) {
|
|
|
+ Map<String, String> autoMatchableMap = new HashMap<>();
|
|
|
+ for (ItemMatch item : autoMatchableItems) {
|
|
|
+ autoMatchableMap.put(item.getMatchName(), item.getMatchCode());
|
|
|
+ }
|
|
|
+ for (ItemMatch item : request) {
|
|
|
+ if (autoMatchableMap.containsKey(item.getItemName())) {
|
|
|
+ item.setMatchName(item.getItemName());
|
|
|
+ item.setMatchCode(autoMatchableMap.get(item.getItemName()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ executeMatch(request);
|
|
|
+ request.removeIf(item -> StringUtil.notBlank(item.getMatchCode()));
|
|
|
+ }
|
|
|
+ return request;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ItemMatch> getZdItems() {
|
|
|
+ return dao.selectZdItems();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ItemMatch> executeMatch(List<ItemMatch> request) {
|
|
|
+ List<ItemMatch> validList = new ArrayList<>();
|
|
|
+ for (ItemMatch item : request) {
|
|
|
+ if (StringUtil.notBlank(item.getMatchCode())) {
|
|
|
+ validList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dao.insertMatchItem(validList);
|
|
|
+ request.removeIf(item -> StringUtil.notBlank(item.getMatchCode()));
|
|
|
+ return request;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String saveToTjResult(List<ReportDetail> request) {
|
|
|
+ if (request.isEmpty()) {
|
|
|
+ throw new BizException("报告内容为空!");
|
|
|
+ }
|
|
|
+ int count = dao.selectExistCount(request.get(0).getAdiconBarcode());
|
|
|
+ if (count == request.size()) {
|
|
|
+ return "已存在相同的报告,请勿重复提取。";
|
|
|
+ }
|
|
|
+ StringBuilder inCodeStatementBuilder = new StringBuilder();
|
|
|
+ for (ReportDetail item : request) {
|
|
|
+ inCodeStatementBuilder.append(",'").append(item.getItemCode()).append("'");
|
|
|
+ }
|
|
|
+ String inCodeStatement = inCodeStatementBuilder.substring(1);
|
|
|
+ List<ItemMatch> matchedItems = dao.selectMatchedItems2(inCodeStatement);
|
|
|
+ if (matchedItems.isEmpty()) {
|
|
|
+ throw new BizException("有未匹配的检验项目,请刷新页面后重试。");
|
|
|
+ }
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ for (ItemMatch item : matchedItems) {
|
|
|
+ map.put(item.getItemCode(), item.getMatchCode());
|
|
|
+ }
|
|
|
+ for (ReportDetail item : request) {
|
|
|
+ if (null == map.get(item.getItemCode())) {
|
|
|
+ throw new BizException("有未匹配的检验项目,请刷新页面后重试。");
|
|
|
+ }
|
|
|
+ item.setItemCode(map.get(item.getItemCode()));
|
|
|
+ item.setStr3(UUID.randomUUID().toString());
|
|
|
+ if (StringUtil.notBlank(item.getResultReference())
|
|
|
+ && item.getResultReference().contains("-")) {
|
|
|
+ String[] arr = item.getResultReference().split("-");
|
|
|
+ item.setStr4(arr[0]);
|
|
|
+ item.setStr5(arr[1]);
|
|
|
+ } else {
|
|
|
+ item.setStr4(null);
|
|
|
+ item.setStr5(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count > 0) {
|
|
|
+ dao.deleteExistResult(request.get(0).getAdiconBarcode());
|
|
|
+ }
|
|
|
+ dao.insertNewResult(request);
|
|
|
+ return "操作成功。";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|