发票修改
This commit is contained in:
parent
32c21bdcb4
commit
c1edd7a55f
|
@ -194,6 +194,7 @@
|
|||
from formson_0702
|
||||
<trim prefix="where" prefixOverrides="and">
|
||||
<if test="field0128 != null and field0128 != ''"> and field0128 = #{field0128} </if>
|
||||
<if test="formmainId != null and formmainId != ''"> and formmain_id = #{formmainId} </if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
|
|
|
@ -51,9 +51,12 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.ParseException;
|
||||
|
@ -65,6 +68,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author makejava
|
||||
|
@ -515,10 +520,60 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
|||
return null;
|
||||
}
|
||||
|
||||
private String sendFileUpload(String url,String filename) {
|
||||
private String sendFileUpload(String fileurl) {
|
||||
try {
|
||||
// 获取文件字节数据
|
||||
byte[] fileBytes = downloadFileBytes(url);
|
||||
byte[] fileBytes = null;
|
||||
String filename = null;
|
||||
|
||||
// 创建信任所有证书的TrustManager
|
||||
TrustManager[] trustAllCerts = new TrustManager[]{
|
||||
new X509TrustManager() {
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return null;
|
||||
}
|
||||
public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException {
|
||||
}
|
||||
public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 安装信任管理器
|
||||
SSLContext sc = SSLContext.getInstance("TLS");
|
||||
sc.init(null, trustAllCerts, new java.security.SecureRandom());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
|
||||
|
||||
// 创建允许所有主机名的验证器
|
||||
HostnameVerifier allHostsValid = (hostname, session) -> true;
|
||||
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
|
||||
|
||||
|
||||
|
||||
URL url = new URL(fileurl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
// 从响应头获取Content-Disposition
|
||||
String contentDisposition = connection.getHeaderField("Content-Disposition");
|
||||
// 尝试从Content-Disposition中提取文件名
|
||||
if (contentDisposition != null) {
|
||||
filename = extractFileNameFromContentDisposition(contentDisposition);
|
||||
}else {
|
||||
// 提取结果为 "recv-open-input-1364609961183034880-1377757054294396417.ofd"
|
||||
filename = fileurl.substring(fileurl.lastIndexOf("/") + 1);
|
||||
}
|
||||
|
||||
try (InputStream inputStream = connection.getInputStream();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
byte[] buffer = new byte[4096];
|
||||
int bytesRead;
|
||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead);
|
||||
}
|
||||
fileBytes = outputStream.toByteArray();
|
||||
}
|
||||
|
||||
|
||||
if (fileBytes != null) {
|
||||
// 模拟一个文件
|
||||
File tempFile = new File(filename);
|
||||
|
@ -532,7 +587,7 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
|||
fileUrl = data.getString("fileUrl");
|
||||
}
|
||||
// 操作完成后删除临时文件
|
||||
tempFile.deleteOnExit();
|
||||
boolean asd = tempFile.delete();
|
||||
return fileUrl;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -570,6 +625,15 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
|||
URL url = new URL(fileUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
// 从响应头获取Content-Disposition
|
||||
String contentDisposition = connection.getHeaderField("Content-Disposition");
|
||||
String fileName = null;
|
||||
// 尝试从Content-Disposition中提取文件名
|
||||
if (contentDisposition != null) {
|
||||
fileName = extractFileNameFromContentDisposition(contentDisposition);
|
||||
}
|
||||
|
||||
|
||||
try (InputStream inputStream = connection.getInputStream();
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
byte[] buffer = new byte[4096];
|
||||
|
@ -580,6 +644,22 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
|||
return outputStream.toByteArray();
|
||||
}
|
||||
}
|
||||
private String extractFileNameFromContentDisposition(String contentDisposition) {
|
||||
// 处理Content-Disposition头中的filename
|
||||
try {
|
||||
Pattern pattern = Pattern.compile("fileName=\"?([^\"]+)\"?");
|
||||
Matcher matcher = pattern.matcher(contentDisposition);
|
||||
if (matcher.find()) {
|
||||
String filename = matcher.group(1);
|
||||
String a = URLDecoder.decode(filename, "UTF-8");
|
||||
return a;
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* seeyon流程事件监听后置方法,绑定修改文件
|
||||
|
@ -589,97 +669,156 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
|||
*/
|
||||
@Override
|
||||
public void setDataCallBack(SysMessageManageLogEntity entity) throws Exception {
|
||||
logger.error("999999发送后返回");
|
||||
try {
|
||||
JSONObject datas = JSONObject.parseObject(entity.getSourceData());
|
||||
logger.error("999999发送后返回data:"+datas.toJSONString());
|
||||
|
||||
String bodys = datas.getString("body");
|
||||
logger.error("999999发送后返回bodys:"+bodys);
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(bodys);
|
||||
logger.error("999999发送后返回jsonObject:"+jsonObject.toJSONString());
|
||||
|
||||
String urlData = null;
|
||||
String ofdurlData = null;
|
||||
String xmlurlData = null;
|
||||
logger.error("999999发送后返回url");
|
||||
|
||||
if(jsonObject.getString("url") != null){
|
||||
urlData = sendFileUpload(jsonObject.getString("url"),jsonObject.getString("fphm")+"url");
|
||||
urlData = sendFileUpload(jsonObject.getString("url"));
|
||||
}
|
||||
logger.error("999999发送后返回ofdurl");
|
||||
|
||||
if(jsonObject.getString("ofdurl") != null){
|
||||
ofdurlData = sendFileUpload(jsonObject.getString("ofdurl"),jsonObject.getString("fphm")+"ofdurl");
|
||||
ofdurlData = sendFileUpload(jsonObject.getString("ofdurl"));
|
||||
}
|
||||
logger.error("999999发送后返回xmlurl");
|
||||
|
||||
if(jsonObject.getString("xmlurl") != null){
|
||||
xmlurlData = sendFileUpload(jsonObject.getString("xmlurl"),jsonObject.getString("fphm")+"xmlurl");
|
||||
xmlurlData = sendFileUpload(jsonObject.getString("xmlurl"));
|
||||
}
|
||||
//urlData = "7908556313791579509";
|
||||
//ofdurlData = "7908556313791579509";
|
||||
//xmlurlData = "7908556313791579509";
|
||||
logger.error("999999发送后返回fphm");
|
||||
|
||||
|
||||
if(jsonObject.getString("fphm") != null){
|
||||
IncomeInvoiceEntity incomeInvoiceEntity = new IncomeInvoiceEntity();
|
||||
incomeInvoiceEntity.setDataSourceCode("HT-OA");
|
||||
incomeInvoiceEntity.setField0128(jsonObject.getString("fphm"));//发票号码
|
||||
incomeInvoiceEntity.setField0130(urlData);//发票文件
|
||||
incomeInvoiceEntity.setField0138(ofdurlData);//发票文件
|
||||
incomeInvoiceEntity.setField0139(xmlurlData);//发票文件
|
||||
List<IncomeInvoiceEntity> list = incomeInvoiceDao.queryOaFp(incomeInvoiceEntity);
|
||||
logger.error("999999查询formmain_0705"+list.size() );
|
||||
|
||||
if(list != null && list.size() == 1){
|
||||
incomeInvoiceEntity.setDataId(list.get(0).getDataId());
|
||||
logger.error("999999保存关联表url"+list.get(0).getDataId());
|
||||
|
||||
if(urlData != null){
|
||||
//保存关联表
|
||||
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
incomeInvoiceEntity.setField0130(urluuid);//发票文件
|
||||
ctpAttachmentService.saveAttachment(urlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
}
|
||||
logger.error("999999保存关联表ofdurlData"+list.get(0).getDataId());
|
||||
|
||||
if(ofdurlData != null){
|
||||
//保存关联表
|
||||
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
incomeInvoiceEntity.setField0138(urluuid);//发票文件
|
||||
ctpAttachmentService.saveAttachment(ofdurlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
}
|
||||
logger.error("999999保存关联表xmlurlData"+list.get(0).getDataId());
|
||||
|
||||
if(xmlurlData != null){
|
||||
//保存关联表
|
||||
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
incomeInvoiceEntity.setField0139(urluuid);//发票文件
|
||||
ctpAttachmentService.saveAttachment(xmlurlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
}
|
||||
logger.error("999999修改发票开始");
|
||||
|
||||
incomeInvoiceDao.updateFP(incomeInvoiceEntity);
|
||||
logger.error("999999修改发票结束");
|
||||
|
||||
}
|
||||
}
|
||||
//修改明细表
|
||||
logger.error("999999修改合同开始");
|
||||
|
||||
if(jsonObject.getString("htbh") != null){
|
||||
logger.error("999999修改合同开始1");
|
||||
|
||||
IncomeInvoiceEntity incomeInvoiceEntity = new IncomeInvoiceEntity();
|
||||
incomeInvoiceEntity.setDataSourceCode("HT-OA");
|
||||
incomeInvoiceEntity.setField0003(jsonObject.getString("htbh"));//合同号
|
||||
incomeInvoiceEntity.setField0127(jsonObject.getString("fpdm"));//发票代码
|
||||
incomeInvoiceEntity.setField0128(jsonObject.getString("fphm"));//发票号码
|
||||
incomeInvoiceEntity.setField0129(jsonObject.getString("jshj"));//发票总额
|
||||
incomeInvoiceEntity.setField0130(urlData);//发票文件
|
||||
incomeInvoiceEntity.setField0138(ofdurlData);//发票文件
|
||||
incomeInvoiceEntity.setField0139(xmlurlData);//发票文件
|
||||
|
||||
logger.error("999999查询合同明细");
|
||||
|
||||
List<IncomeInvoiceEntity> list = incomeInvoiceDao.queryOaZb(incomeInvoiceEntity);
|
||||
logger.error("999999查询合同明细"+list.size());
|
||||
|
||||
if(list != null && list.size() == 1){
|
||||
incomeInvoiceEntity.setFormmainId(list.get(0).getDataId());
|
||||
if(urlData != null){
|
||||
//保存关联表
|
||||
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
ctpAttachmentService.saveAttachment(urlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
}
|
||||
if(ofdurlData != null){
|
||||
//保存关联表
|
||||
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
ctpAttachmentService.saveAttachment(ofdurlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
}
|
||||
if(xmlurlData != null){
|
||||
//保存关联表
|
||||
String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
ctpAttachmentService.saveAttachment(xmlurlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
}
|
||||
//logger.error("999999保存合同附件"+list.get(0).getDataId());
|
||||
//
|
||||
//if(urlData != null){
|
||||
// //保存关联表
|
||||
// String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
//incomeInvoiceEntity.setField0130(urluuid);//发票文件
|
||||
|
||||
// ctpAttachmentService.saveAttachment(urlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
//}
|
||||
//logger.error("999999保存合同附件ofdurlData"+list.get(0).getDataId());
|
||||
//
|
||||
//if(ofdurlData != null){
|
||||
// //保存关联表
|
||||
// String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
|
||||
//incomeInvoiceEntity.setField0138(urluuid);//发票文件
|
||||
|
||||
// ctpAttachmentService.saveAttachment(ofdurlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
//}
|
||||
//logger.error("999999保存合同附件xmlurlData"+list.get(0).getDataId());
|
||||
//
|
||||
//if(xmlurlData != null){
|
||||
// //保存关联表
|
||||
// String urluuid = String.valueOf(UUID.randomUUID().getLeastSignificantBits());
|
||||
//incomeInvoiceEntity.setField0138(urluuid);//发票文件
|
||||
|
||||
// ctpAttachmentService.saveAttachment(xmlurlData,list.get(0).getDataId().toString(),urluuid,incomeInvoiceEntity.getDataSourceCode());
|
||||
//}
|
||||
logger.error("999999查询合同明细"+list.get(0).getDataId());
|
||||
|
||||
List<IncomeInvoiceEntity> mxlist = incomeInvoiceDao.queryOaMx(incomeInvoiceEntity);
|
||||
|
||||
logger.error("999999查询合同明细结果"+mxlist.size());
|
||||
|
||||
if(mxlist != null && mxlist.size() == 1){
|
||||
logger.error("999999修改合同明细结果"+mxlist.get(0).getDataId());
|
||||
|
||||
incomeInvoiceEntity.setDataId(mxlist.get(0).getDataId());
|
||||
incomeInvoiceDao.updateMx(incomeInvoiceEntity);
|
||||
logger.error("999999修改合同明细结果完成");
|
||||
|
||||
}
|
||||
if(mxlist == null || mxlist.size() == 0){
|
||||
|
||||
incomeInvoiceEntity.setDataId(String.valueOf(UUIDLong.longUUID()));
|
||||
logger.error("999999保存合同明细结果"+incomeInvoiceEntity.getDataId());
|
||||
|
||||
incomeInvoiceDao.saveMx(incomeInvoiceEntity);
|
||||
logger.error("999999保存合同明细结果完成");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
logger.error("999999结束");
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
logger.error("999999"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -804,7 +943,7 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
|||
stringBuffer.append("</value>").append("</column>");
|
||||
|
||||
stringBuffer.append("<column name=\"合同编号\">").append("<value>");
|
||||
stringBuffer.append(jsonObject.getString("htbm") != null?"<![CDATA["+jsonObject.getString("htbm")+"]]>":"");
|
||||
stringBuffer.append(jsonObject.getString("htbh") != null?"<![CDATA["+jsonObject.getString("htbh")+"]]>":"");
|
||||
stringBuffer.append("</value>").append("</column>");
|
||||
|
||||
stringBuffer.append("<column name=\"发票文件1\">").append("<value>");
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
|
@ -224,4 +225,13 @@ public class EntranceController {
|
|||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/option1")
|
||||
@ResponseBody
|
||||
public JsonResultEntity option1(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
|
||||
HttpServletRequest request = (HttpServletRequest) servletRequest;
|
||||
String queryString = request.getQueryString();
|
||||
|
||||
return BaseResult.getSuccessMessageEntity("成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import com.hzya.frame.seeyon.entity.CtpAttachmentEntity;
|
|||
public interface ICtpAttachmentService extends IBaseService<CtpAttachmentEntity, String> {
|
||||
/**
|
||||
* 保存附件关系表
|
||||
* @param fileUrl ctp_file id
|
||||
* @param col_summary_id col_summary id
|
||||
* @param fileUrl ctp_file id fileUrl
|
||||
* @param col_summary_id col_summary id oa表单id
|
||||
* @param sub_reference 随机uuid
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -61,7 +61,7 @@ public class CtpAttachmentServiceImpl extends BaseService<CtpAttachmentEntity, S
|
|||
ctpAttachmentEntity.setFile_url(ctpFile.getId());//ctp_file表的id
|
||||
ctpAttachmentEntity.setAtt_reference(col_summary_id);//业务表单的id
|
||||
ctpAttachmentEntity.setSub_reference(sub_reference);//这个字段要保存到业务表附件到字段上
|
||||
ctpAttachmentEntity.setCategory(ctpFile.getCategory());//这里写66 才可以显示图片
|
||||
ctpAttachmentEntity.setCategory("66");//这里写66 才可以显示图片
|
||||
ctpAttachmentEntity.setFilename(ctpFile.getFilename());
|
||||
ctpAttachmentEntity.setType(ctpFile.getType());
|
||||
ctpAttachmentEntity.setMime_type(ctpFile.getMime_type());
|
||||
|
|
Loading…
Reference in New Issue