parent
c98a2b72d5
commit
f1ed220213
@ -0,0 +1,19 @@ |
|||||||
|
package com.dxhy.order.invoice.module.invoice.service; |
||||||
|
|
||||||
|
import com.dxhy.order.model.ofd.OfdToPngResponse; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public interface OfdToPngSDEnergyService { |
||||||
|
|
||||||
|
/** |
||||||
|
* OFD转png |
||||||
|
* @param url |
||||||
|
* @param bytes |
||||||
|
* @return |
||||||
|
* @throws IOException |
||||||
|
*/ |
||||||
|
OfdToPngResponse getOfdPngBySDenergy(byte[] bytes) throws IOException; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,54 @@ |
|||||||
|
package com.dxhy.order.invoice.module.invoice.service.impl; |
||||||
|
|
||||||
|
import cn.hutool.core.util.IdUtil; |
||||||
|
import cn.hutool.crypto.digest.DigestUtil; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.dxhy.order.constant.OrderInfoEnum; |
||||||
|
import com.dxhy.order.invoice.module.invoice.service.OfdToPngSDEnergyService; |
||||||
|
import com.dxhy.order.model.ofd.OfdToPngResponse; |
||||||
|
import com.dxhy.order.utils.HttpUtils; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.lang.reflect.Array; |
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.Date; |
||||||
|
|
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
public class OfdToPngSDEnergyServiceImpl implements OfdToPngSDEnergyService { |
||||||
|
|
||||||
|
@Value("${yx.url}") |
||||||
|
private String yxurl; |
||||||
|
|
||||||
|
@Value("${yx.simsSalt}") |
||||||
|
private String simsSalt; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public OfdToPngResponse getOfdPngBySDenergy(byte[] bytes) throws IOException { |
||||||
|
Long timestamp = new Date().getTime(); |
||||||
|
String md5Str = DigestUtil.md5Hex(timestamp + simsSalt); |
||||||
|
String url = yxurl + "/yxSims/ofdToImage?timestamp="+timestamp+"&md5Str="+md5Str; |
||||||
|
OfdToPngResponse ofdToPngResponse = new OfdToPngResponse(); |
||||||
|
try { |
||||||
|
String rs = HttpUtils.doPostUpload(url, bytes, IdUtil.fastSimpleUUID()+".ofd"); |
||||||
|
JSONObject res = JSONObject.parseObject(rs); |
||||||
|
if (!"200".equals(res.getString("status"))) { |
||||||
|
ofdToPngResponse.setZTDM(OrderInfoEnum.INTERFACE_ERROR.getKey()); |
||||||
|
ofdToPngResponse.setZTXX(res.getString("message")); |
||||||
|
return ofdToPngResponse; |
||||||
|
} |
||||||
|
Arrays.asList(res.getJSONArray("data")); |
||||||
|
// ofdToPngResponse.setPNGWJL();
|
||||||
|
|
||||||
|
}catch (Exception e) { |
||||||
|
log.error("影像系统ofd转png接口异常,异常信息为:{}", e); |
||||||
|
ofdToPngResponse.setZTDM(OrderInfoEnum.INTERFACE_ERROR.getKey()); |
||||||
|
ofdToPngResponse.setZTXX(e.getMessage()); |
||||||
|
} |
||||||
|
return ofdToPngResponse; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue