Commit ac5f58cd by 吴迪

【新增】修改代码

parent b18c4f67
......@@ -228,47 +228,55 @@ public class GLNController {
@RequestMapping("/api/domesticCodeProductionNews")
public R domesticCodeProductionNews(@RequestBody DomesticCodeVo domesticCodeVo, HttpServletRequest request) {
SearchgtinlogEntity searchgtinlogEntity = new SearchgtinlogEntity();
searchgtinlogEntity.setCreatedate(new Date());
searchgtinlogEntity.setIp(IPUtils.getIpAddr(request));
searchgtinlogEntity.setClassStr("境内商品条码信息查询");
searchgtinlogEntity.setKeyword(domesticCodeVo.getCode());
searchgtinlogEntity.setSearchsource(0);
//新增查询日志
searchgtinlogService.save(searchgtinlogEntity);
String urlMac = "/AAQI/v1/ProductData/gtin/${code}?targetMarket=156&dataVersion=1.1&clientGln=6901234503814";
String macStr = MacUtils.getMac(urlMac.replaceAll("\\$\\{code\\}",domesticCodeVo.getCode()));
String url = "http://api.chinatrace.org/AAQI/v1/ProductData/gtin/${code}?targetMarket=156&dataVersion=1.1&clientGln=6901234503814&mac=";
url = url.replaceAll("\\$\\{code\\}",domesticCodeVo.getCode())+macStr;
System.out.println(url);
RestTemplate restTemplate = new RestTemplate();
//创建请求头
//创建请求头
ResponseEntity<String> responseEntity = null;
try {
responseEntity = restTemplate.getForEntity(url, String.class);
} catch (RestClientException e) {
e.printStackTrace();
if(e.getLocalizedMessage().equals("400 Bad Request")) {
return R.error("无效的境内商品条码!");
}
else if(e.getLocalizedMessage().equals("403 Bad Request")) {
return R.error("安全异常!");
if(StringUtils.isNotBlank(domesticCodeVo.getCode())) {
if(domesticCodeVo.getCode().length()<13) {
return R.error("商品条码卡位数太少!请输入正确的13位或14位商品条码!");
}
}
if (responseEntity.getStatusCode().value() == 200) {
// 下面的是通过解析xml字符串的
String returnObjs = responseEntity.getBody().substring(responseEntity.getBody().indexOf("<productInformationLink>"),responseEntity.getBody().lastIndexOf("</productInformationLink>")+"</productInformationLink>".length());//注意 获取根节点的时候要查看返回的xml参数的形式是否为一个根节点
ProductInformationLink productInformationLink = JaxbUtil.converyToJavaBean(returnObjs, ProductInformationLink.class);
if(productInformationLink!=null)
{
if(StringUtils.isNotBlank(productInformationLink.getUrl())) {
return R.ok().put("data",productInformationLink.getUrl());
SearchgtinlogEntity searchgtinlogEntity = new SearchgtinlogEntity();
searchgtinlogEntity.setCreatedate(new Date());
searchgtinlogEntity.setIp(IPUtils.getIpAddr(request));
searchgtinlogEntity.setClassStr("境内商品条码信息查询");
searchgtinlogEntity.setKeyword(domesticCodeVo.getCode());
searchgtinlogEntity.setSearchsource(0);
//新增查询日志
searchgtinlogService.save(searchgtinlogEntity);
String urlMac = "/AAQI/v1/ProductData/gtin/${code}?targetMarket=156&dataVersion=1.1&clientGln=6901234503814";
String macStr = MacUtils.getMac(urlMac.replaceAll("\\$\\{code\\}",domesticCodeVo.getCode()));
String url = "http://api.chinatrace.org/AAQI/v1/ProductData/gtin/${code}?targetMarket=156&dataVersion=1.1&clientGln=6901234503814&mac=";
url = url.replaceAll("\\$\\{code\\}",domesticCodeVo.getCode())+macStr;
System.out.println(url);
RestTemplate restTemplate = new RestTemplate();
//创建请求头
//创建请求头
ResponseEntity<String> responseEntity = null;
try {
responseEntity = restTemplate.getForEntity(url, String.class);
} catch (RestClientException e) {
e.printStackTrace();
if(e.getLocalizedMessage().equals("400 Bad Request")) {
return R.error("无效的境内商品条码!");
}
else if(e.getLocalizedMessage().equals("403 Bad Request")) {
return R.error("安全异常!");
}
}
if (responseEntity.getStatusCode().value() == 200) {
// 下面的是通过解析xml字符串的
String returnObjs = responseEntity.getBody().substring(responseEntity.getBody().indexOf("<productInformationLink>"),responseEntity.getBody().lastIndexOf("</productInformationLink>")+"</productInformationLink>".length());//注意 获取根节点的时候要查看返回的xml参数的形式是否为一个根节点
ProductInformationLink productInformationLink = JaxbUtil.converyToJavaBean(returnObjs, ProductInformationLink.class);
if(productInformationLink!=null)
{
if(StringUtils.isNotBlank(productInformationLink.getUrl())) {
return R.ok().put("data",productInformationLink.getUrl());
}
}
}
}
return R.error("查询失败!");
}
......
......@@ -67,9 +67,6 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
@Value("${uploadFileQYOne}")
String uploadFileQYOne;
@Autowired
private DomainListProperties domainListProperties;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<TycpdmFirmEntity> page = this.page(
......@@ -129,7 +126,7 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
}else if (levels==1){
throw new RRException("无权访问");
}else if (String.valueOf(levels).length()==4){
//levels=-99;
//levels=-99;
}else {
throw new RRException("无权访问");
}
......@@ -184,8 +181,8 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
file.transferTo(dest);
//保存路径 firm_archivesFile
tycpdmFirmDao.updateByIdfirmArchivesFile(uploadFileQY + uuid+substring,id,0,DateUtils.getTime());
//tycpdm_vip_user表中新增数据
tycpdmFirmDao.updateByIdfirmArchivesFile(uploadFileQY + uuid+substring,id,0,DateUtils.getTime());
//tycpdm_vip_user表中新增数据
/*TycpdmFirmEntity tycpdmFirmEntity = tycpdmFirmDao.selectById(id);
String baseUser = tycpdmFirmEntity.getBaseUser();
String firmname = tycpdmFirmEntity.getFirmname();
......@@ -199,7 +196,7 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
}
}
return ;
return ;
} catch (IOException e) {
dir.delete();
e.printStackTrace();
......@@ -532,7 +529,7 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
File file = new File(filePath);
if (!file.exists()){
return "不存在";
return "不存在";
}
return "存在";
}
......@@ -632,7 +629,7 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
String phone_M = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(phone.getBytes(),"loginkey".getBytes()));
String password = memberUser.getPassword();//名文密码
String password_M = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(password.getBytes(),"loginkey".getBytes()));
String url=domainListProperties.getDomain()+"redirectBusinessHall/anccoh/login?method=gdsLoginSSO&gdsCode="+phone_M+"&password="+password_M;
String url="http://wsdt.gs1cn.org/anccoh/login?method=gdsLoginSSO&gdsCode="+phone_M+"&password="+password_M;
return url;
}else if (userType==3){
phone=memberUser.getPhone();//手机号
......@@ -641,7 +638,7 @@ public class TycpdmFirmServiceImpl extends ServiceImpl<TycpdmFirmDao, TycpdmFirm
}
String phone_M = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(phone.getBytes(),"loginkey".getBytes()));
String url=domainListProperties.getDomain()+"redirectBusinessHall/anccoh/login?method=phoneSSO&phone="+phone_M;
String url="http://wsdt.gs1cn.org/anccoh/login?method=phoneSSO&phone="+phone_M;
return url;
}
......
......@@ -72,18 +72,25 @@ public class DESUtils {
}
public static void main(String[] args) {
String userName="test_tru";
String password="123123";
//http://wsdt.ancc.org.cn/anccoh/loginOper.jsp?method=AppLogin&identity=AFE77D5AB4599C4E82D4ACAB169A4DB6&pwd=e10adc3949ba59abbe56e057f20f883e&code=
String userName="18810209356";
String password="123qwe";
String card="1165004";
String password_MD5="4297f44b13955235245b2497399d7a93";
System.out.println(MD5Util.unicodeToString("123qwe"));;
String userName_M = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(userName.getBytes(),"appsGdsn".getBytes()));
String password_M = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(password.getBytes(),"appsGdsn".getBytes()));
String password_M_MD5 = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(password_MD5.getBytes(),"appsGdsn".getBytes()));
String card_M_MD5 = DESUtils.byteToHexString(DESUtils.DES_CBC_Encrypt(card.getBytes(),"appsGdsn".getBytes()));
System.out.println(userName_M);
System.out.println(password_M);
System.out.println(password_M_MD5);
System.out.println(card_M_MD5);
String aaa="88DA15B9F9F602F0D32D46808652B06DC6E939D1424CE39F69A2AC39743F7ED7591975685B543E1D";
String aaa="AFE77D5AB4599C4E82D4ACAB169A4DB6";
//String s = new String(DESUtils.DES_CBC_Decrypt(aaa, "appsGdsn".getBytes()));
String s = new String(DESUtils.DES_CBC_Decrypt(aaa, "appsGdsn".getBytes()));
......
......@@ -27,4 +27,9 @@ public class HttpUtlis {
throw new RuntimeException(e.getMessage());
}
}
}
package io.office.modules.manage.webservice;
import cn.hutool.json.JSONUtil;
import io.office.modules.manage.webservice.newWebservice.JaxbUtil;
import io.office.modules.manage.webservice.newWebservice.ProductInformationLink;
import org.jdom.Document;
import org.jdom.Element;
import org.springframework.http.HttpEntity;
......@@ -28,38 +30,22 @@ public class Test {
public static void main(String[] args) throws JAXBException, IOException {
String smsTemplateXml = WebServiceXmlTemplate.SEND_MESSAGE_TEMPLATE.replaceAll("\\$\\{cascade\\}", "9").replaceAll("\\$\\{requestedKeyCode\\}", "GLN")
.replaceAll("\\$\\{requestedKeyValue\\}", "6973947140013").replaceAll("\\$\\{requestedLanguage\\}", "en");
String url = "http://webservice.anccnet.com:8080/gepir4/gepirv4.asmx";
String url = "http://api.chinatrace.org/AAQI/v1/ProductData/gtin/6920582200169?targetMarket=156&dataVersion=1.1&clientGln=6901234503814&mac=F562D581607A5582187B4231B2CEFC7BB94EC11FF5F0D0082AD013F2254103E1";
RestTemplate restTemplate = new RestTemplate();
//创建请求头
//创建请求头
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type","text/xml; charset=utf-8");
HttpEntity<String> entity = new HttpEntity<>(smsTemplateXml, headers);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, entity, String.class);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
if (responseEntity.getStatusCode().value() == 200) {
// 下面的是通过解析xml字符串的
Document doc = null;
String returnObjs = responseEntity.getBody().substring(responseEntity.getBody().indexOf("<partyDataLine>"),responseEntity.getBody().indexOf("</gepirParty>"));//注意 获取根节点的时候要查看返回的xml参数的形式是否为一个根节点
String returnObjs = responseEntity.getBody().substring(responseEntity.getBody().indexOf("<productInformationLink>"),responseEntity.getBody().lastIndexOf("</productInformationLink>")+"</productInformationLink>".length());//注意 获取根节点的时候要查看返回的xml参数的形式是否为一个根节点
System.out.println(returnObjs);
Object xmlObject = null;
Reader reader = null;
//利用JAXBContext将类转为一个实例
JAXBContext context = JAXBContext.newInstance(PartyDataLine.class);
//XMl 转为对象的接口
Unmarshaller unmarshaller = context.createUnmarshaller();
reader = new StringReader(returnObjs);
xmlObject = unmarshaller.unmarshal(reader);
if (reader != null) {
reader.close();
}
System.out.println(JSONUtil.toJsonStr(xmlObject));
ProductInformationLink book = JaxbUtil.converyToJavaBean(returnObjs, ProductInformationLink.class);
book.getUrl();
System.out.println(JSONUtil.toJsonStr(book));
System.out.println(book.getUrl());
/*Object xmlObject = null;
Reader reader = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment