基础信息更新重整
parent
85311a7f16
commit
c1de9b4b66
@ -0,0 +1,78 @@
|
|||||||
|
package com.glxp.api.http;
|
||||||
|
|
||||||
|
import com.glxp.api.constant.ConstantStatus;
|
||||||
|
import com.glxp.api.entity.basic.BasicUdiProductEntity;
|
||||||
|
import com.glxp.api.entity.basic.ProductInfoEntity;
|
||||||
|
import com.glxp.api.entity.basic.UdiProductEntity;
|
||||||
|
import com.glxp.api.req.basic.ProductInfoFilterRequest;
|
||||||
|
import com.glxp.api.service.basic.ProductInfoService;
|
||||||
|
import com.glxp.api.service.basic.UdiProductService;
|
||||||
|
import com.glxp.api.util.UuidUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取国家UDI同步库信息(nmpa:国家药品监督管理局)
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class NmpaUdiClient {
|
||||||
|
@Resource
|
||||||
|
ProductInfoService productInfoService;
|
||||||
|
@Resource
|
||||||
|
UdiProductService udiProductService;
|
||||||
|
|
||||||
|
public List<BasicUdiProductEntity> getUdiByUuid(String uuid) {
|
||||||
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
||||||
|
productInfoFilterRequest.setPage(1);
|
||||||
|
productInfoFilterRequest.setLimit(100);
|
||||||
|
productInfoFilterRequest.setUuid(uuid);
|
||||||
|
|
||||||
|
List<ProductInfoEntity> productInfoEntityList = productInfoService.findAll(productInfoFilterRequest);
|
||||||
|
List<BasicUdiProductEntity> udiInfoEntities = new ArrayList<>();
|
||||||
|
for (ProductInfoEntity productInfoEntity : productInfoEntityList) {
|
||||||
|
BasicUdiProductEntity udiProductEntity = new BasicUdiProductEntity();
|
||||||
|
BeanUtils.copyProperties(productInfoEntity, udiProductEntity);
|
||||||
|
udiProductEntity.setQxlb(productInfoEntity.getCplx());
|
||||||
|
udiProductEntity.setCplb(productInfoEntity.getHchzsb());
|
||||||
|
udiInfoEntities.add(udiProductEntity);
|
||||||
|
}
|
||||||
|
return udiInfoEntities;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<UdiProductEntity> getUdiByDi(String key) {
|
||||||
|
ProductInfoFilterRequest productInfoFilterRequest = new ProductInfoFilterRequest();
|
||||||
|
productInfoFilterRequest.setPage(1);
|
||||||
|
productInfoFilterRequest.setLimit(100);
|
||||||
|
productInfoFilterRequest.setNameCode(key);
|
||||||
|
|
||||||
|
List<ProductInfoEntity> productInfoEntityList = productInfoService.findAll(productInfoFilterRequest);
|
||||||
|
Map<String, List<ProductInfoEntity>> listMap = productInfoEntityList.stream().collect(Collectors.groupingBy(ProductInfoEntity::getUuid));
|
||||||
|
List<ProductInfoEntity> result = null;
|
||||||
|
for (List<ProductInfoEntity> value : listMap.values()) {
|
||||||
|
if (result == null || value.get(0).getVersionNumber() > result.get(0).getVersionNumber()) {
|
||||||
|
result = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
productInfoFilterRequest.setNameCode(null);
|
||||||
|
productInfoFilterRequest.setUuid(result.get(0).getUuid());
|
||||||
|
List<ProductInfoEntity> datas = productInfoService.findAll(productInfoFilterRequest);
|
||||||
|
List<UdiProductEntity> udiInfoEntities = new ArrayList<>();
|
||||||
|
for (ProductInfoEntity productInfoEntity : datas) {
|
||||||
|
UdiProductEntity udiProductEntity = new UdiProductEntity();
|
||||||
|
BeanUtils.copyProperties(productInfoEntity, udiProductEntity);
|
||||||
|
udiProductEntity.setQxlb(productInfoEntity.getCplx());
|
||||||
|
udiProductEntity.setCplb(productInfoEntity.getHchzsb());
|
||||||
|
udiProductEntity.setProductType(ConstantStatus.PRODUCT_TYPE_UDI);
|
||||||
|
udiInfoEntities.add(udiProductEntity);
|
||||||
|
}
|
||||||
|
return udiInfoEntities;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.glxp.api.req.basic;
|
||||||
|
|
||||||
|
import com.glxp.api.req.thrsys.FilterThrProductsRequest;
|
||||||
|
import com.glxp.api.res.thrsys.ThrProductsResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UdiCombineRequest {
|
||||||
|
|
||||||
|
List<String> keys;
|
||||||
|
private String thirdId;
|
||||||
|
private List<String> thirdIds;
|
||||||
|
private String erpName;
|
||||||
|
private ThrProductsResponse erpProductsResponse;
|
||||||
|
private Long relId;
|
||||||
|
private String thirdSys;
|
||||||
|
private Boolean isRlInv;
|
||||||
|
private FilterThrProductsRequest query;
|
||||||
|
private String erpId;
|
||||||
|
private Long customerId;
|
||||||
|
private Boolean supEnable;
|
||||||
|
private String manufactory;
|
||||||
|
private String measname;
|
||||||
|
private String supName;
|
||||||
|
private String price;
|
||||||
|
private boolean idSpliUdi;
|
||||||
|
private String uuid;
|
||||||
|
private String originUuid;
|
||||||
|
|
||||||
|
|
||||||
|
private String ybbm;
|
||||||
|
private String sptm;
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
package com.glxp.api.util;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import okhttp3.*;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenqf
|
||||||
|
*/
|
||||||
|
public class IDCUtils {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(IDCUtils.class);
|
||||||
|
private static String aliasNameChars = "_hijklmnopqrstuvwxyzabcdefg9876543210";
|
||||||
|
private static String realNamechars = "abcdefghijklmnopqrstuvwxyz_0123456789";
|
||||||
|
private final static String MONTH_EN = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||||
|
|
||||||
|
//判断是否json字符串
|
||||||
|
public static boolean isJson(String json) {
|
||||||
|
if(json!=null&&json.contains("{")&&json.contains("}")&&json.contains("\""))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public static Date parseDate(String str) {
|
||||||
|
return parseDate(str,"yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
public static Date parseDate(String str,String fmt) {
|
||||||
|
String dateStr=str.replace("?", " ");
|
||||||
|
SimpleDateFormat df = new SimpleDateFormat(fmt);
|
||||||
|
if(str!=null&&!str.contains("-")&&str.length()>7&&StringUtils.isNumeric(str.substring(0, 4))&&
|
||||||
|
Long.valueOf(str.substring(0,4))>1899&&Long.valueOf(str.substring(0,4))<2199&&
|
||||||
|
StringUtils.isNumeric(str.substring(4, 6))&&StringUtils.isNumeric(str.substring(6, 8))&&
|
||||||
|
(!str.contains(" ")||(str.contains(" ")&&str.indexOf(" ")>7))) {
|
||||||
|
dateStr = str.substring(0,4)+"-"+str.substring(4,6)+"-"+str.substring(6,8);
|
||||||
|
dateStr+=" ";
|
||||||
|
if(str.contains(" ")) {
|
||||||
|
if(str.length()>9) {
|
||||||
|
dateStr+= str.substring(9,11);
|
||||||
|
if(str.length()>11) {
|
||||||
|
dateStr+=":"+str.substring(11,13);
|
||||||
|
if(str.length()>13) {
|
||||||
|
dateStr+=":"+str.substring(13,15);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dateStr+=":00:00";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dateStr+="00:00:00";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(str.length()>8) {
|
||||||
|
dateStr+= str.substring(8,10);
|
||||||
|
if(str.length()>10) {
|
||||||
|
dateStr+=":"+str.substring(10,12);
|
||||||
|
if(str.length()>13) {
|
||||||
|
dateStr+=":"+str.substring(12,14);
|
||||||
|
} if(str.length()>12) {
|
||||||
|
dateStr+=":"+str.substring(12,13)+"0";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dateStr+=":00:00";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dateStr+="00:00:00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(str!=null&&str.contains("CST")) {
|
||||||
|
//Wed Feb 16 15:35:31 CST 2022
|
||||||
|
int index = str.indexOf("CST");
|
||||||
|
int month = (MONTH_EN.indexOf(str.substring(index -16,index -13))+3)/3;
|
||||||
|
dateStr = str.substring(index+4)+"-";
|
||||||
|
if(month<10)
|
||||||
|
dateStr+="0";
|
||||||
|
dateStr+= month+"-"+str.substring(index -12,index -10)+" "+str.substring(index -9,index -1);
|
||||||
|
} else if(str!=null&&str.contains("GMT")) {
|
||||||
|
int index = str.indexOf("GMT");
|
||||||
|
int month = (MONTH_EN.indexOf(str.substring(index -16,index -13))+3)/3;
|
||||||
|
if(str.contains("GMT+")) {
|
||||||
|
dateStr = str.substring(index+10)+"-";
|
||||||
|
} else {
|
||||||
|
dateStr = str.substring(index+4)+"-";
|
||||||
|
}
|
||||||
|
if(month<10)
|
||||||
|
dateStr+="0";
|
||||||
|
dateStr+= month+"-"+str.substring(index -12,index -10)+" "+str.substring(index -9,index -1);
|
||||||
|
} else if (str!=null&&str.equals("-30609820800000")) {
|
||||||
|
dateStr="1000-01-01 00:01:01";
|
||||||
|
} else if (str!=null&&str.length()==4&&StringUtils.isNumeric(str)&&Integer.valueOf(str)>999) {
|
||||||
|
dateStr=str+"-01-01 00:01:01";
|
||||||
|
} else if (str!=null&&str.length()==6&&StringUtils.isNumeric(str)) {
|
||||||
|
dateStr=str.substring(0, 4)+"-"+str.substring(4)+"-01 00:01:01";
|
||||||
|
} else if(str!=null&&StringUtils.isNumeric(str)&&str.length()>8&&(Long.valueOf(str.substring(0,4))<1899||Long.valueOf(str.substring(0,4))>2200)) {
|
||||||
|
dateStr=df.format(new Date(Long.valueOf(str)));
|
||||||
|
}
|
||||||
|
dateStr = dateStr.replace("T", " ");
|
||||||
|
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = df.parse(dateStr);
|
||||||
|
|
||||||
|
} catch (ParseException e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
public static void createDirectory(String directory) {
|
||||||
|
String dir = directory;
|
||||||
|
String path ="";
|
||||||
|
String[] breakChar ={"\\","/"};
|
||||||
|
for(String bk:breakChar) {
|
||||||
|
while(dir.indexOf(bk)>-1) {
|
||||||
|
path+=dir.substring(0,dir.indexOf(bk))+"\\";
|
||||||
|
File file = new File(path);
|
||||||
|
if (!(new File(path)).exists()) {
|
||||||
|
(new File(path)).mkdir();
|
||||||
|
}
|
||||||
|
if (dir.length()>dir.indexOf(bk)) {
|
||||||
|
dir = dir.substring(dir.indexOf(bk) +1);
|
||||||
|
} else {
|
||||||
|
dir = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String post(String url, Map<String, Object> params) {
|
||||||
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||||
|
.build();
|
||||||
|
MediaType mediaType = MediaType.parse("application/json");
|
||||||
|
RequestBody body = RequestBody.create(mediaType, "");
|
||||||
|
if (params != null)
|
||||||
|
body = RequestBody.create(mediaType, JSON.toJSONString(params));
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Content-Type", "application/json")
|
||||||
|
.build();
|
||||||
|
String result = "";
|
||||||
|
try {
|
||||||
|
Response response = client.newCall(request).execute();
|
||||||
|
result = response.body().string();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void writeFile(byte[] file, String filePath, String fileName) throws Exception {
|
||||||
|
File targetFile = new File(filePath);
|
||||||
|
if (!targetFile.exists()) {
|
||||||
|
targetFile.mkdirs();
|
||||||
|
}
|
||||||
|
FileOutputStream out = new FileOutputStream(filePath + fileName);
|
||||||
|
out.write(file);
|
||||||
|
out.flush();
|
||||||
|
out.close();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue