|
|
|
@ -7,6 +7,8 @@ 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;
|
|
|
|
@ -16,6 +18,11 @@ 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;
|
|
|
|
@ -23,6 +30,8 @@ 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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 国家库产品信息相关接口
|
|
|
|
@ -43,6 +52,9 @@ public class UdiSyncController {
|
|
|
|
|
ProductInfoService productInfoService;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiCompanyService udiCompanyService;
|
|
|
|
|
@Resource
|
|
|
|
|
BasicProductsDao basicProductsDao;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取同步库UDI信息
|
|
|
|
@ -183,5 +195,67 @@ public class UdiSyncController {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|