release
WangQi 2 years ago
parent f1ed220213
commit c8226f4bb0
  1. 40
      order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/controller/InvoiceDetailsController.java
  2. 2
      order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/service/OfdToPngSDEnergyService.java
  3. 15
      order-management-invoice/src/main/java/com/dxhy/order/invoice/module/invoice/service/impl/OfdToPngSDEnergyServiceImpl.java

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.dxhy.order.constant.*;
import com.dxhy.order.exception.OrderReceiveException;
import com.dxhy.order.invoice.module.invoice.service.OfdToPngSDEnergyService;
import com.dxhy.order.model.CommonOrderInvoiceAndOrderMxInfo;
import com.dxhy.order.model.OrderInvoiceInfo;
import com.dxhy.order.model.R;
@ -28,15 +29,14 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@ -89,6 +89,36 @@ public class InvoiceDetailsController {
@Resource
private InvoiceConfig invoiceConfig;
@Autowired
private OfdToPngSDEnergyService ofdToPngSDEnergyService;
@GetMapping("priviewOfd")
public R priviewOfd() throws IOException {
File file = new File("C:\\Users\\10216\\Desktop\\042002200113_04440777.ofd");
FileInputStream fis = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
try {
fis = new FileInputStream(file);
byte[] b = new byte[1000];
int n;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
byte[] data = bos.toByteArray();
OfdToPngResponse ofdToPngResponse = ofdToPngSDEnergyService.getOfdPngBySDenergy(data);
return R.ok(ofdToPngResponse);
} catch (Exception e) {
System.out.println(e);
} finally {
if (fis != null){
fis.close();
}
bos.close();
}
return R.error();
}
/**
* 查询发票信息详情
*
@ -404,7 +434,9 @@ public class InvoiceDetailsController {
ofdToPngRequest.setOFDWJL(fileDownLoad.getFileContent());
// 解密后的文件流
byte[] fileByte = Base64Encoding.decode(fileDownLoad.getFileContent());
OfdToPngResponse ofdToPngResponse = HttpInvoiceRequestUtil.getOfdPng(invoiceConfig.configOfdToPngUrl(), ofdToPngRequest);
OfdToPngResponse ofdToPngResponse = ofdToPngSDEnergyService.getOfdPngBySDenergy(fileByte);
// OfdToPngResponse ofdToPngResponse = HttpInvoiceRequestUtil.getOfdPng(invoiceConfig.configOfdToPngUrl(), ofdToPngRequest);
if (ofdToPngResponse != null && ConfigureConstant.STRING_0000.equals(ofdToPngResponse.getZTDM()) && ObjectUtil.isNotEmpty(ofdToPngResponse.getPNGWJL())) {
pngBase64List.addAll(ofdToPngResponse.getPNGWJL());
}

@ -14,6 +14,6 @@ public interface OfdToPngSDEnergyService {
* @return
* @throws IOException
*/
OfdToPngResponse getOfdPngBySDenergy(byte[] bytes) throws IOException;
OfdToPngResponse getOfdPngBySDenergy(byte[] bytes);
}

@ -13,8 +13,10 @@ import org.springframework.stereotype.Service;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
@Slf4j
@ -28,22 +30,27 @@ public class OfdToPngSDEnergyServiceImpl implements OfdToPngSDEnergyService {
@Override
public OfdToPngResponse getOfdPngBySDenergy(byte[] bytes) throws IOException {
public OfdToPngResponse getOfdPngBySDenergy(byte[] bytes) {
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 {
log.info("调用影像接口ofd转png,url:{}",url);
String rs = HttpUtils.doPostUpload(url, bytes, IdUtil.fastSimpleUUID()+".ofd");
log.info("调用影像接口ofd转png,返回值 url:{},rs:{}",url,rs);
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();
List<String> data = new ArrayList<>();
for (int i = 0; i < res.getJSONArray("data").size();i++) {
data.add(res.getJSONArray("data").getString(i));
}
ofdToPngResponse.setPNGWJL(data);
}catch (Exception e) {
log.error("影像系统ofd转png接口异常,异常信息为:{}", e);
ofdToPngResponse.setZTDM(OrderInfoEnum.INTERFACE_ERROR.getKey());

Loading…
Cancel
Save