Merge branch 'ht' of http://ufidahz.com.cn:9015/hzya/kangarooDataCenterV3 into ht
This commit is contained in:
commit
c81ea615c0
|
@ -53,6 +53,7 @@ $RECYCLE.BIN/
|
|||
# Windows shortcuts
|
||||
*.lnk
|
||||
./idea/
|
||||
/.idea/
|
||||
/buildpackage/src/main/resources/banner.txt
|
||||
/webapp/target/
|
||||
/service/target/
|
||||
|
@ -66,3 +67,4 @@ $RECYCLE.BIN/
|
|||
/base-webapp/target/classes/com/hzya/frame/
|
||||
/fw-weixin/target/
|
||||
/E:/yongansystem/log/2024-10-15/
|
||||
/D:/
|
||||
|
|
|
@ -40,6 +40,14 @@ OA:
|
|||
data_source_code: yc_oa
|
||||
zt:
|
||||
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:
|
||||
# 测试用这个 这个是银行给的
|
||||
privateKey: MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgtzMo2o6THK3yLIm+83Ch/560+02l2hjjBSFGieWY/Z6gCgYIKoEcz1UBgi2hRANCAATKhwZX4P3XI8vYTKeCOLMVbanUNbaXjrIEZynshwdOzRVgzRQSiPNWo6OBBkAPvqE+2RS+5ABpS82DSlKl81z0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 10086
|
||||
port: 9999
|
||||
servlet:
|
||||
context-path: /kangarooDataCenterV3
|
||||
localIP: 127.0.0.1
|
||||
|
|
|
@ -172,6 +172,9 @@ public class temButtom {
|
|||
JSONObject queryParams = new JSONObject();
|
||||
queryParams.put("page",1);
|
||||
queryParams.put("size",50);
|
||||
//queryParams.put("kprqq","2025-04-06");
|
||||
//queryParams.put("kprqz","2025-04-06");
|
||||
queryParams.put("taxNo","91330110MAC5FPUY2U");
|
||||
dayabody.put("queryParams",queryParams);
|
||||
Map<String, Object> parametersMap = new HashMap<>();
|
||||
parametersMap.put("accessKey","6X3B526P5HqE6ums");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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.IInvoiceDetailsDao;
|
||||
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.util.YzfSignUtil;
|
||||
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.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.*;
|
||||
|
||||
@Service(value = "InvoiceServiceImpl")
|
||||
|
@ -44,6 +50,11 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
|
|||
@Value("${zt.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${invoice_pdf.url}")
|
||||
private String invoicePdfUrl;
|
||||
@Value("${invoice_ofd.url}")
|
||||
private String invoiceOfdUrl;
|
||||
|
||||
@Override
|
||||
public JsonResultEntity queryArchives(JSONObject json) {
|
||||
JSONObject jsonObject = json.getJSONObject("jsonStr");
|
||||
|
@ -108,7 +119,7 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
|
|||
parametersMap.put("timestamp",timestamp);
|
||||
String sign = YzfSignUtil.signRequest(parametersMap,"34e5fc32ac894a2ba2ade8c3852c7a0a");
|
||||
JSONObject jsonObject=new JSONObject();
|
||||
jsonObject.put("serialNumber",entity.getBusiness_no());
|
||||
jsonObject.put("serialNumber",entity.getId());
|
||||
jsonObject.put("accessKey","6X3B526P5HqE6ums");
|
||||
jsonObject.put("sign",sign);
|
||||
jsonObject.put("timestamp",timestamp);
|
||||
|
@ -123,6 +134,43 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
|
|||
execute().
|
||||
body();
|
||||
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){
|
||||
|
@ -132,6 +180,47 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
|
|||
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) {
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
|
|
|
@ -42,6 +42,7 @@ import java.util.*;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
|
@ -66,6 +67,7 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
|
|||
@Value("${zt.url}")
|
||||
private String url;
|
||||
|
||||
|
||||
@Value("${zx.privateKey}")
|
||||
private String privateKey;
|
||||
|
||||
|
@ -349,56 +351,57 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
|
|||
}
|
||||
|
||||
if (sourceFolder.isFile() && sourceFolder.getName().endsWith(".zip")) {
|
||||
unzipFile(sourceFolder.getAbsolutePath(), destinationFolder);
|
||||
|
||||
//将pdf文件上传OA
|
||||
File fileOut = new File(sourceFolder.getAbsolutePath());
|
||||
if (fileOut.exists()) {
|
||||
logger.info("=====开始上传中信司库回单到杭泰OA======");
|
||||
JSONObject jsonObject = fileUpload(fileOut);
|
||||
if (jsonObject.getString("fileUrl") != null) {
|
||||
//表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference
|
||||
String sub_reference = String.valueOf(UUIDLong.longUUID());
|
||||
zxBankEntity.setReceipt(sub_reference);
|
||||
zxBankEntity.setDataSourceCode("HT-OA");
|
||||
zxBankDao.updateElecStatusZX(zxBankEntity);
|
||||
//根据附件id查询附件业务数据
|
||||
String file_url = jsonObject.getString("fileUrl");
|
||||
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity();
|
||||
ctpAttachmentEntity.setFile_url(file_url);
|
||||
String att_reference = zxBankEntity.getSummaryId();//Summary_id
|
||||
ctpAttachmentEntity.setSub_reference(sub_reference);
|
||||
ctpAttachmentEntity.setAtt_reference(att_reference);
|
||||
ctpAttachmentEntity.setDataSourceCode("HT-OA");
|
||||
List<CtpAttachmentEntity> ctpAttachmentEntities = ctpAttachmentDao.queryCtpAttachment(ctpAttachmentEntity);
|
||||
//如果没有查询到数据,就新增附件业务,否则更新
|
||||
if (ctpAttachmentEntities.size() == 0) {
|
||||
String category = jsonObject.getString("category");
|
||||
String type = jsonObject.getString("type");
|
||||
String filename = jsonObject.getString("filename");
|
||||
String mime_type = jsonObject.getString("mimeType");
|
||||
String attachment_size = jsonObject.getString("size");
|
||||
String id = String.valueOf(UUIDLong.longUUID());
|
||||
ctpAttachmentEntity.setCategory(category);
|
||||
ctpAttachmentEntity.setFilename(filename);
|
||||
ctpAttachmentEntity.setType(type);
|
||||
ctpAttachmentEntity.setMime_type(mime_type);
|
||||
ctpAttachmentEntity.setAttachment_size(attachment_size);
|
||||
ctpAttachmentEntity.setId(id);
|
||||
ctpAttachmentEntity.setCategory("66");
|
||||
ctpAttachmentEntity.setCreatedate(new Date());
|
||||
List<File> files = unzipFile(sourceFolder.getAbsolutePath(), destinationFolder);
|
||||
// 上传 PDF 文件
|
||||
for (File pdfFile : files) {
|
||||
logger.info("pdf文件名称为:{}",pdfFile.getName());
|
||||
if (pdfFile.exists()) {
|
||||
logger.info("=====开始上传中信司库回单到杭泰OA======");
|
||||
JSONObject jsonObject = fileUpload(pdfFile);
|
||||
if (jsonObject.getString("fileUrl") != null) {
|
||||
//表单的附件字段=ctpAttachment的Sub_reference,表单的Summary_id=ctpAttachment的att_reference
|
||||
String sub_reference = String.valueOf(UUIDLong.longUUID());
|
||||
zxBankEntity.setReceipt(sub_reference);
|
||||
zxBankEntity.setDataSourceCode("HT-OA");
|
||||
zxBankDao.updateElecStatusZX(zxBankEntity);
|
||||
//根据附件id查询附件业务数据
|
||||
String file_url = jsonObject.getString("fileUrl");
|
||||
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity();
|
||||
ctpAttachmentEntity.setFile_url(file_url);
|
||||
String att_reference = zxBankEntity.getSummaryId();//Summary_id
|
||||
ctpAttachmentEntity.setSub_reference(sub_reference);
|
||||
ctpAttachmentEntity.setAtt_reference(att_reference);
|
||||
ctpAttachmentEntity.setDataSourceCode("HT-OA");
|
||||
ctpAttachmentDao.saveCtpAttachment(ctpAttachmentEntity);
|
||||
} else {
|
||||
if (ctpAttachmentEntities.size() > 1) {
|
||||
throw new BaseSystemException("OA附件业务表中查到多条记录");
|
||||
List<CtpAttachmentEntity> ctpAttachmentEntities = ctpAttachmentDao.queryCtpAttachment(ctpAttachmentEntity);
|
||||
//如果没有查询到数据,就新增附件业务,否则更新
|
||||
if (ctpAttachmentEntities.size() == 0) {
|
||||
String category = jsonObject.getString("category");
|
||||
String type = jsonObject.getString("type");
|
||||
String filename = jsonObject.getString("filename");
|
||||
String mime_type = jsonObject.getString("mimeType");
|
||||
String attachment_size = jsonObject.getString("size");
|
||||
String id = String.valueOf(UUIDLong.longUUID());
|
||||
ctpAttachmentEntity.setCategory(category);
|
||||
ctpAttachmentEntity.setFilename(filename);
|
||||
ctpAttachmentEntity.setType(type);
|
||||
ctpAttachmentEntity.setMime_type(mime_type);
|
||||
ctpAttachmentEntity.setAttachment_size(attachment_size);
|
||||
ctpAttachmentEntity.setId(id);
|
||||
ctpAttachmentEntity.setCategory("66");
|
||||
ctpAttachmentEntity.setCreatedate(new Date());
|
||||
ctpAttachmentEntity.setDataSourceCode("HT-OA");
|
||||
ctpAttachmentDao.saveCtpAttachment(ctpAttachmentEntity);
|
||||
} else {
|
||||
if (ctpAttachmentEntities.size() > 1) {
|
||||
throw new BaseSystemException("OA附件业务表中查到多条记录");
|
||||
}
|
||||
//更新数据到OA附件业务表中
|
||||
ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity);
|
||||
}
|
||||
//更新数据到OA附件业务表中
|
||||
ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity);
|
||||
logger.info("=====电子回单执行完毕=======");
|
||||
}
|
||||
logger.info("=====电子回单执行完毕=======");
|
||||
pdfFile.delete();
|
||||
}
|
||||
fileOut.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -469,29 +472,33 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
|
|||
return "unknown.zip";
|
||||
}
|
||||
|
||||
private void unzipFile(String zipFilePath, String destinationFolderPath) {
|
||||
try (FileInputStream fis = new FileInputStream(zipFilePath);
|
||||
ZipInputStream zis = new ZipInputStream(fis)) {
|
||||
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
while (zipEntry != null) {
|
||||
if (zipEntry.getName().endsWith(".pdf")) {
|
||||
String pdfFilePath = destinationFolderPath + zipEntry.getName();//File.separator:文件路径中增加一个斜杠
|
||||
try (FileOutputStream fos = new FileOutputStream(pdfFilePath)) {
|
||||
private List<File> unzipFile(String zipFilePath, String destinationFolderPath) {
|
||||
List<File> pdfFiles = new ArrayList<>();
|
||||
try (ZipFile zipFile = new ZipFile(zipFilePath)) {
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
File outputFile = new File(destinationFolderPath, entry.getName());
|
||||
if (entry.isDirectory()) {
|
||||
outputFile.mkdirs();
|
||||
} else {
|
||||
try (InputStream inputStream = zipFile.getInputStream(entry);
|
||||
OutputStream outputStream = new FileOutputStream(outputFile)) {
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = zis.read(buffer)) != -1) {
|
||||
fos.write(buffer, 0, bytesRead);
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return pdfFiles;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue