|
|
package com.glxp.api.controller.basic;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.glxp.api.annotation.AuthRuleAnnotation;
|
|
|
import com.glxp.api.common.res.BaseResponse;
|
|
|
import com.glxp.api.common.util.ResultVOUtils;
|
|
|
import com.glxp.api.constant.AsyncDiDlHelper;
|
|
|
import com.glxp.api.dao.basic.BasicProductsDao;
|
|
|
import com.glxp.api.dao.basic.UdiProductDao;
|
|
|
import com.glxp.api.entity.basic.*;
|
|
|
import com.glxp.api.req.basic.*;
|
|
|
import com.glxp.api.http.sync.SpGetHttpClient;
|
|
|
import com.glxp.api.req.basic.*;
|
|
|
import com.glxp.api.res.PageSimpleResponse;
|
|
|
import com.glxp.api.service.basic.*;
|
|
|
import com.glxp.api.util.OkHttpCli;
|
|
|
import com.glxp.api.util.udi.FilterUdiUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.sourceforge.pinyin4j.PinyinHelper;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
|
|
|
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
|
|
|
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* 国家库产品信息相关接口
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@RestController
|
|
|
public class UdiSyncController {
|
|
|
|
|
|
@Resource
|
|
|
UdiRelevanceService udiRelevanceService;
|
|
|
@Resource
|
|
|
UdiProductService udiProductService;
|
|
|
@Resource
|
|
|
SyncUdiService syncUdiService;
|
|
|
@Resource
|
|
|
AsyncDiDlHelper asyncDiDlHelper;
|
|
|
@Resource
|
|
|
ProductInfoService productInfoService;
|
|
|
@Resource
|
|
|
UdiCompanyService udiCompanyService;
|
|
|
@Resource
|
|
|
BasicProductsDao basicProductsDao;
|
|
|
|
|
|
|
|
|
//获取同步库UDI信息
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/filterUdi")
|
|
|
public BaseResponse filterUdi(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
String nameCode;
|
|
|
if (StrUtil.isNotEmpty(filterUdiRelRequest.getUdiCode())) {
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiRelRequest.getUdiCode());
|
|
|
if (udiEntity != null) {
|
|
|
nameCode = udiEntity.getUdi();
|
|
|
} else {
|
|
|
return ResultVOUtils.error(500, "无效UDI码!");
|
|
|
}
|
|
|
} else
|
|
|
nameCode = filterUdiRelRequest.getNameCode();
|
|
|
|
|
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
|
|
BeanUtils.copyProperties(filterUdiRelRequest, productInfoFilterRequest);
|
|
|
if (StrUtil.isNotEmpty(nameCode)) {
|
|
|
productInfoFilterRequest.setNameCode(nameCode);
|
|
|
} else {
|
|
|
productInfoFilterRequest.setDiType("1");
|
|
|
}
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<ProductInfoEntity>> udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
|
|
|
if (udiDlDeviceResponse.getCode() == 20000) {
|
|
|
if (filterUdiRelRequest.getIsCheck() != null && filterUdiRelRequest.getIsCheck()) {
|
|
|
List<ProductInfoEntity> productInfoEntities = udiDlDeviceResponse.getData().getList();
|
|
|
if (productInfoEntities != null && productInfoEntities.size() > 0) {
|
|
|
for (ProductInfoEntity productInfoEntity : productInfoEntities) {
|
|
|
List<UdiRelevanceEntity> udiRelevanceEntities = udiRelevanceService.selectByUuid(productInfoEntity.getUuid());
|
|
|
if (udiRelevanceEntities != null && udiRelevanceEntities.size() > 0) {
|
|
|
for (UdiRelevanceEntity udiRelevanceEntity : udiRelevanceEntities) {
|
|
|
if (udiRelevanceEntity.getThirdId() == null &&
|
|
|
udiRelevanceEntity.getThirdId2() == null && udiRelevanceEntity.getThirdId1() == null &&
|
|
|
udiRelevanceEntity.getThirdId3() == null && udiRelevanceEntity.getThirdId4() == null) {
|
|
|
//不能添加
|
|
|
productInfoEntity.setCheck(true);
|
|
|
break;
|
|
|
} else
|
|
|
productInfoEntity.setCheck(false);
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
productInfoEntity.setCheck(false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//获取同步库医疗器械注册人信息
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/filterCompany")
|
|
|
public BaseResponse filterCompany(UdiCompanyRequest udiCompanyRequest) {
|
|
|
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<UdiCompanyEntity>> udiDlDeviceResponse = syncUdiService.filterCompany(udiCompanyRequest);
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Resource
|
|
|
SpGetHttpClient spGetHttpClient;
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("udiwms/udiinfo/superSearch")
|
|
|
public BaseResponse superSearch(FilterUdiInfoRequest filterUdiInfoRequest) {
|
|
|
|
|
|
if (StrUtil.isEmpty(filterUdiInfoRequest.getNameCode()) && StrUtil.isEmpty(filterUdiInfoRequest.getUdiCode())) {
|
|
|
return ResultVOUtils.error(500, "DI不能为空!");
|
|
|
}
|
|
|
|
|
|
if (StrUtil.isNotEmpty(filterUdiInfoRequest.getUdiCode())) {
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiInfoRequest.getUdiCode());
|
|
|
if (udiEntity == null)
|
|
|
return ResultVOUtils.error(500, "UDI码格式错误!");
|
|
|
filterUdiInfoRequest.setNameCode(udiEntity.getUdi());
|
|
|
}
|
|
|
|
|
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
|
|
productInfoFilterRequest.setNameCode(filterUdiInfoRequest.getNameCode());
|
|
|
productInfoFilterRequest.setPage(filterUdiInfoRequest.getPage());
|
|
|
productInfoFilterRequest.setLimit(filterUdiInfoRequest.getLimit());
|
|
|
try {
|
|
|
BaseResponse<PageSimpleResponse<ProductInfoEntity>> udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
|
|
|
if (udiDlDeviceResponse.getCode() != 20000) {
|
|
|
return udiDlDeviceResponse;
|
|
|
}
|
|
|
if (CollUtil.isEmpty(udiDlDeviceResponse.getData().getList())) {
|
|
|
BaseResponse<List<ProductInfoEntity>> listBaseResponse = asyncDiDlHelper.dlByDiRes(filterUdiInfoRequest.getNameCode());
|
|
|
|
|
|
if (listBaseResponse.getCode() == 20000) {
|
|
|
List<ProductInfoEntity> productInfoEntityList = listBaseResponse.getData();
|
|
|
if (CollUtil.isNotEmpty(productInfoEntityList)) {
|
|
|
productInfoService.insertProductInfos(productInfoEntityList);
|
|
|
udiDlDeviceResponse = syncUdiService.filterUdi(productInfoFilterRequest);
|
|
|
} else {
|
|
|
ResultVOUtils.error(500, "未查询到该产品DI");
|
|
|
}
|
|
|
} else {
|
|
|
return listBaseResponse;
|
|
|
}
|
|
|
}
|
|
|
return udiDlDeviceResponse;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return ResultVOUtils.error(500, "连接UDI数据下载服务出错!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/basic/instrument/maintain/filterProduct")
|
|
|
public BaseResponse filterProduct(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
List<UdiProductEntity> udiInfoEntities
|
|
|
= udiProductService.filterAllUdiInfo(filterUdiRelRequest);
|
|
|
PageInfo<UdiProductEntity> pageInfo;
|
|
|
pageInfo = new PageInfo<>(udiInfoEntities);
|
|
|
PageSimpleResponse<UdiProductEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
|
|
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
|
|
pageSimpleResponse.setList(udiInfoEntities);
|
|
|
return ResultVOUtils.success(pageSimpleResponse);
|
|
|
}
|
|
|
|
|
|
@AuthRuleAnnotation("")
|
|
|
@GetMapping("/udiwms/basic/findByCode")
|
|
|
public BaseResponse findByCode(FilterUdiRelRequest filterUdiRelRequest) {
|
|
|
|
|
|
UdiEntity udiEntity = FilterUdiUtils.getUdi(filterUdiRelRequest.getUdiCode());
|
|
|
UdiProductEntity udiProductEntity
|
|
|
= udiProductService.findByNameCode(udiEntity.getUdi());
|
|
|
return ResultVOUtils.success(udiProductEntity);
|
|
|
}
|
|
|
|
|
|
|
|
|
//出入库同步下载
|
|
|
@GetMapping("udidl/udiwms/syncUdi")
|
|
|
public BaseResponse syncUdi(ProductInfoFilterRequest productInfoFilterRequest) {
|
|
|
|
|
|
List<ProductInfoEntity> productInfoEntityList = productInfoService.syncDlUdi(productInfoFilterRequest);
|
|
|
return ResultVOUtils.success(productInfoEntityList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//出入库同步下载
|
|
|
@GetMapping("udidl/udiwms/syncCompany")
|
|
|
public BaseResponse syncCompany(UdiCompanyRequest udiCompanyRequest) {
|
|
|
|
|
|
List<UdiCompanyEntity> udiCompanyEntities = udiCompanyService.syncDlCompany(udiCompanyRequest);
|
|
|
return ResultVOUtils.success(udiCompanyEntities);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@GetMapping("udiwms/test")
|
|
|
public void filterUdi() {
|
|
|
FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest();
|
|
|
List<BasicProductsEntity> data = basicProductsDao.selectList();
|
|
|
int i = 0;
|
|
|
try {
|
|
|
for (BasicProductsEntity datum : data) {
|
|
|
if (StrUtil.isNotEmpty(datum.getCpmctymc()) && StrUtil.isEmpty(datum.getPinyinInitial()) && !datum.getCpmctymc().substring(0, 1).equals("α")) {
|
|
|
i++;
|
|
|
String a = datum.getCpmctymc().substring(0, 1);
|
|
|
datum.setPinyinInitial(converterToFirstSpell(datum.getCpmctymc()));
|
|
|
System.out.println("-----------------------------------------------------" + i);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
System.out.println("|||||||||||||||||||||||" + e.getMessage());
|
|
|
}
|
|
|
basicProductsDao.updateBatchById(data);
|
|
|
}
|
|
|
|
|
|
//汉字转换位汉语拼音首字母,英文字符不变
|
|
|
public static String converterToFirstSpell(String chines) {
|
|
|
chines = cleanChar(chines);
|
|
|
String pinyinName = "";
|
|
|
char[] nameChar = chines.toCharArray();
|
|
|
HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
|
|
|
defaultFormat.setCaseType(HanyuPinyinCaseType.UPPERCASE);
|
|
|
defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
|
|
|
for (int i = 0; i < nameChar.length; i++) {
|
|
|
if (nameChar[i] > 128) {
|
|
|
try {
|
|
|
pinyinName += PinyinHelper.toHanyuPinyinStringArray(nameChar[i], defaultFormat)[0].charAt(0);
|
|
|
} catch (BadHanyuPinyinOutputFormatCombination e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
pinyinName += nameChar[i];
|
|
|
}
|
|
|
}
|
|
|
return pinyinName;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 清理特殊字符以便得到
|
|
|
*
|
|
|
* @param chines
|
|
|
* @return
|
|
|
*/
|
|
|
public static String cleanChar(String chines) {
|
|
|
chines = chines.replaceAll("[\\p{Punct}\\p{Space}]+", ""); // 正则去掉所有字符操作
|
|
|
// 正则表达式去掉所有中文的特殊符号
|
|
|
String regEx = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}<>《》【】‘;:”“’。,、?ⅢγⅣβⅡⅠ×π]";
|
|
|
Pattern pattern = Pattern.compile(regEx);
|
|
|
Matcher matcher = pattern.matcher(chines);
|
|
|
chines = matcher.replaceAll("").trim();
|
|
|
return chines;
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
|