This commit is contained in:
xiang2lin 2025-04-11 08:42:32 +08:00
commit c81ea615c0
7 changed files with 215 additions and 62 deletions

2
.gitignore vendored
View File

@ -53,6 +53,7 @@ $RECYCLE.BIN/
# Windows shortcuts # Windows shortcuts
*.lnk *.lnk
./idea/ ./idea/
/.idea/
/buildpackage/src/main/resources/banner.txt /buildpackage/src/main/resources/banner.txt
/webapp/target/ /webapp/target/
/service/target/ /service/target/
@ -66,3 +67,4 @@ $RECYCLE.BIN/
/base-webapp/target/classes/com/hzya/frame/ /base-webapp/target/classes/com/hzya/frame/
/fw-weixin/target/ /fw-weixin/target/
/E:/yongansystem/log/2024-10-15/ /E:/yongansystem/log/2024-10-15/
/D:/

View File

@ -40,6 +40,14 @@ OA:
data_source_code: yc_oa data_source_code: yc_oa
zt: zt:
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
file_oa:
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterfacefileUpload
#税务pdf附件下载存放路径
invoice_pdf:
url: D:\yongansystem\invoice\pdf\
#税务ofd附件下载存放路径
invoice_ofd:
url: D:\yongansystem\invoice\ofd\
zx: zx:
# 测试用这个 这个是银行给的 # 测试用这个 这个是银行给的
privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0 privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0

View File

@ -1,5 +1,5 @@
server: server:
port: 10086 port: 9999
servlet: servlet:
context-path: /kangarooDataCenterV3 context-path: /kangarooDataCenterV3
localIP: 127.0.0.1 localIP: 127.0.0.1

View File

@ -172,6 +172,9 @@ public class temButtom {
JSONObject queryParams = new JSONObject(); JSONObject queryParams = new JSONObject();
queryParams.put("page",1); queryParams.put("page",1);
queryParams.put("size",50); queryParams.put("size",50);
//queryParams.put("kprqq","2025-04-06");
//queryParams.put("kprqz","2025-04-06");
queryParams.put("taxNo","91330110MAC5FPUY2U");
dayabody.put("queryParams",queryParams); dayabody.put("queryParams",queryParams);
Map<String, Object> parametersMap = new HashMap<>(); Map<String, Object> parametersMap = new HashMap<>();
parametersMap.put("accessKey","6X3B526P5HqE6ums"); parametersMap.put("accessKey","6X3B526P5HqE6ums");

View File

@ -0,0 +1,44 @@
package com.hzya.frame.seeyon.invoice.entity;
import com.hzya.frame.seeyon.zxbank.entity.PayState;
public enum InvoiceState {
zero("0","申请单被关闭"),
one("1","申请单开票成功"),
two("2","申请单处理中"),
three("3","申请单开具异常");
private String type;
//
private String value;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
InvoiceState(String type, String value){
this.type=type;
this.value=value;
}
public static String invoiceStateGetValue(String type){
for (InvoiceState invoiceState : InvoiceState.values()){
if(invoiceState.getType()==type||invoiceState.getType().equals(type)){
return invoiceState.getValue().toString();
}
}
return null;
}
}

View File

@ -10,6 +10,7 @@ import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDao;
import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao; import com.hzya.frame.seeyon.invoice.dao.IInvoiceDetailsDao;
import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity; import com.hzya.frame.seeyon.invoice.entity.InvoiceEntity;
import com.hzya.frame.seeyon.invoice.entity.InvoiceState;
import com.hzya.frame.seeyon.invoice.service.IInvoiceService; import com.hzya.frame.seeyon.invoice.service.IInvoiceService;
import com.hzya.frame.seeyon.util.YzfSignUtil; import com.hzya.frame.seeyon.util.YzfSignUtil;
import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity; import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity;
@ -24,6 +25,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*; import java.util.*;
@Service(value = "InvoiceServiceImpl") @Service(value = "InvoiceServiceImpl")
@ -44,6 +50,11 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
@Value("${zt.url}") @Value("${zt.url}")
private String url; private String url;
@Value("${invoice_pdf.url}")
private String invoicePdfUrl;
@Value("${invoice_ofd.url}")
private String invoiceOfdUrl;
@Override @Override
public JsonResultEntity queryArchives(JSONObject json) { public JsonResultEntity queryArchives(JSONObject json) {
JSONObject jsonObject = json.getJSONObject("jsonStr"); JSONObject jsonObject = json.getJSONObject("jsonStr");
@ -108,7 +119,7 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
parametersMap.put("timestamp",timestamp); parametersMap.put("timestamp",timestamp);
String sign = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a"); String sign = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a");
JSONObject jsonObject=new JSONObject(); JSONObject jsonObject=new JSONObject();
jsonObject.put("serialNumber",entity.getBusiness_no()); jsonObject.put("serialNumber",entity.getId());
jsonObject.put("accessKey","6X3B526P5HqE6ums"); jsonObject.put("accessKey","6X3B526P5HqE6ums");
jsonObject.put("sign",sign); jsonObject.put("sign",sign);
jsonObject.put("timestamp",timestamp); jsonObject.put("timestamp",timestamp);
@ -123,6 +134,43 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
execute(). execute().
body(); body();
logger.info("=====调用杭泰税务查询申请单详情的返回参数为:{}===========",result); logger.info("=====调用杭泰税务查询申请单详情的返回参数为:{}===========",result);
JSONObject resultJson = JSONObject.parseObject(result);
if (!resultJson.getBoolean("flag")) {
saveTaskLivingDetails(entity.getId(), entity.getBusiness_no(), jsonObject.toJSONString(), resultJson.toJSONString(), false,"");
} else {
JSONObject attribute = resultJson.getJSONObject("attribute");
if("0".equals(attribute.getString("code"))){
JSONObject jsonResult=JSONObject.parseObject(attribute.getString("result"));
if(null !=jsonResult){
JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList");
if(CollectionUtils.isNotEmpty(jsonArray)){
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject invoiceInfo = jsonArray.getJSONObject(i);
String invoiceCode = invoiceInfo.getString("invoiceCode");//发票代码
String invoiceNumber = invoiceInfo.getString("invoiceNumber");//发票号码
String resultStatus = InvoiceState.invoiceStateGetValue(jsonResult.getString("resultStatus"));//开票结果
String pdfUrl = invoiceInfo.getString("url");//pdf文件
String ofdUrl = invoiceInfo.getString("ofdUrl");//ofd文件
String xmlUrl = invoiceInfo.getString("xmlUrl");//xml文件
//获取pdf文件到本地 并为pdf取名否则会报无法访问错误
logger.info("========开始将pdf文件保存到本地========");
String pdfFileName = generateFileName(pdfUrl,"pdf");
String pdfSavePath=invoicePdfUrl+pdfFileName;
downloadPdf(pdfUrl,pdfSavePath);
logger.info("========pdf文件保存到本地完成========");
File filePdf=new File(pdfSavePath);
//获取ofd文件到本地
logger.info("========开始将ofd文件保存到本地========");
String ofdFileName = generateFileName(ofdUrl, "ofd");
String ofdSavePath = ofdUrl + ofdFileName;
downloadPdf(ofdUrl,ofdSavePath);
logger.info("========ofd文件保存到本地完成========");
File fileOfd=new File(ofdSavePath);
}
}
}
}
}
} }
}catch (Exception e){ }catch (Exception e){
@ -132,6 +180,47 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
return null; return null;
} }
private void downloadPdf(String pdfUrl, String savePath) {
try {
URL url = new URL(pdfUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("Post");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
InputStream inputStream = connection.getInputStream();
FileOutputStream outputStream = new FileOutputStream(savePath);
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
outputStream.close();
inputStream.close();
} else {
logger.info("下载失败,响应码: {}" , responseCode);
}
connection.disconnect();
}catch (Exception e){
logger.info("====查询申请单详情获取税务pdf或ofd文件失败:{}========",e.getMessage());
e.printStackTrace();
}
}
private String generateFileName(String url, String extension) {
// 这里简单根据 URL 的参数生成文件名你可以根据实际需求调整
String[] parts = url.split("&");
String fphm = "";
for (String part : parts) {
if (part.startsWith("fphm=")) {
fphm = part.substring(5);
break;
}
}
return fphm + "." + extension;
}
private List<JSONObject> bindingInvoice(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) { private List<JSONObject> bindingInvoice(JSONObject jsonObject, MdmModuleSourceEntity mdmModuleSourceEntity, String dbCode) {
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
StringBuffer stringBuffer = new StringBuffer(); StringBuffer stringBuffer = new StringBuffer();

View File

@ -42,6 +42,7 @@ import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -66,6 +67,7 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
@Value("${zt.url}") @Value("${zt.url}")
private String url; private String url;
@Value("${zx.privateKey}") @Value("${zx.privateKey}")
private String privateKey; private String privateKey;
@ -349,13 +351,13 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
} }
if (sourceFolder.isFile() && sourceFolder.getName().endsWith(".zip")) { if (sourceFolder.isFile() && sourceFolder.getName().endsWith(".zip")) {
unzipFile(sourceFolder.getAbsolutePath(), destinationFolder); List<File> files = unzipFile(sourceFolder.getAbsolutePath(), destinationFolder);
// 上传 PDF 文件
//将pdf文件上传OA for (File pdfFile : files) {
File fileOut = new File(sourceFolder.getAbsolutePath()); logger.info("pdf文件名称为{}",pdfFile.getName());
if (fileOut.exists()) { if (pdfFile.exists()) {
logger.info("=====开始上传中信司库回单到杭泰OA======"); logger.info("=====开始上传中信司库回单到杭泰OA======");
JSONObject jsonObject = fileUpload(fileOut); JSONObject jsonObject = fileUpload(pdfFile);
if (jsonObject.getString("fileUrl") != null) { if (jsonObject.getString("fileUrl") != null) {
//表单的附件字段=ctpAttachment的Sub_reference表单的Summary_id=ctpAttachment的att_reference //表单的附件字段=ctpAttachment的Sub_reference表单的Summary_id=ctpAttachment的att_reference
String sub_reference = String.valueOf(UUIDLong.longUUID()); String sub_reference = String.valueOf(UUIDLong.longUUID());
@ -398,7 +400,8 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
} }
logger.info("=====电子回单执行完毕======="); logger.info("=====电子回单执行完毕=======");
} }
fileOut.delete(); pdfFile.delete();
}
} }
} }
} }
@ -469,29 +472,33 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
return "unknown.zip"; return "unknown.zip";
} }
private void unzipFile(String zipFilePath, String destinationFolderPath) { private List<File> unzipFile(String zipFilePath, String destinationFolderPath) {
try (FileInputStream fis = new FileInputStream(zipFilePath); List<File> pdfFiles = new ArrayList<>();
ZipInputStream zis = new ZipInputStream(fis)) { try (ZipFile zipFile = new ZipFile(zipFilePath)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
ZipEntry zipEntry = zis.getNextEntry(); while (entries.hasMoreElements()) {
while (zipEntry != null) { ZipEntry entry = entries.nextElement();
if (zipEntry.getName().endsWith(".pdf")) { File outputFile = new File(destinationFolderPath, entry.getName());
String pdfFilePath = destinationFolderPath + zipEntry.getName();//File.separator:文件路径中增加一个斜杠 if (entry.isDirectory()) {
try (FileOutputStream fos = new FileOutputStream(pdfFilePath)) { outputFile.mkdirs();
} else {
try (InputStream inputStream = zipFile.getInputStream(entry);
OutputStream outputStream = new FileOutputStream(outputFile)) {
byte[] buffer = new byte[4096]; byte[] buffer = new byte[4096];
int bytesRead; int bytesRead;
while ((bytesRead = zis.read(buffer)) != -1) { while ((bytesRead = inputStream.read(buffer)) != -1) {
fos.write(buffer, 0, bytesRead); outputStream.write(buffer, 0, bytesRead);
} }
} }
logger.info("已提取 PDF 文件:{} " ,pdfFilePath); if (outputFile.getName().endsWith(".pdf")) {
pdfFiles.add(outputFile);
}
} }
zis.closeEntry();
zipEntry = zis.getNextEntry();
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return pdfFiles;
} }