税务开票申请和查询开票结果

This commit is contained in:
hecan 2025-04-16 09:23:54 +08:00
parent 75bb5f87ad
commit adf2c70d74
10 changed files with 1817 additions and 30 deletions

View File

@ -0,0 +1,58 @@
package com.hzya.frame.plugin.ht.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.zxBank.plugin.ZxBankResultPluginInitializer;
import com.hzya.frame.seeyon.invoice.service.impl.InvoiceServiceImpl;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
public class QueryInvoiceResultPluginInitializer extends PluginBaseEntity {
Logger logger = LoggerFactory.getLogger(ZxBankResultPluginInitializer.class);
@Autowired
private InvoiceServiceImpl invoiceService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
}
@Override
public String getPluginId() {
return "QueryInvoiceResultPluginInitializer";
}
@Override
public String getPluginName() {
return "查询开票申请详情插件";
}
@Override
public String getPluginLabel() {
return "QueryInvoiceResultPluginInitializer";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行查询税务开票申请详情返回结果========");
return invoiceService.queryInvoiceResult(requestJson);
}catch (Exception e){
logger.info("======执行查询税务开票申请详情返回结果失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<bean name="deliveryOrderPluginInitializer" class="com.hzya.frame.plugin.ht.plugin.MakeInvoicePluginInitializer" />
<bean name="MakeInvoicePluginInitializer" class="com.hzya.frame.plugin.ht.plugin.MakeInvoicePluginInitializer" />
<bean name="InvoiceDistributePluginInitializer" class="com.hzya.frame.plugin.ht.plugin.InvoiceDistributePluginInitializer" />
<bean name="QueryInvoiceResultPluginInitializer" class="com.hzya.frame.plugin.ht.plugin.QueryInvoiceResultPluginInitializer" />
</beans>

View File

@ -29,4 +29,34 @@ public interface IInvoiceDao extends IBaseDao<InvoiceEntity,String> {
* @Date 2025-04-07 14:05
* **/
List<InvoiceEntity> queryInvoiceResult(InvoiceEntity entity);
/**
*
* @content 更新推送标识
* @Param
* @Return
* @Author hecan
* @Date 2025-04-15 15:37
* **/
Integer updateInvoicePush(InvoiceEntity entity);
/**
*
* @content 更新pdf和ofd附件到OA
* @Param
* @Return
* @Author hecan
* @Date 2025-04-14 10:27
* **/
Integer updateInvoiceUrl(InvoiceEntity entity);
/**
*
* @content 更新发票代码发票号码以及开票结果
* @Param
* @Return
* @Author hecan
* @Date 2025-04-14 16:35
* **/
Integer updateInvoiceResult(InvoiceEntity entity);
}

View File

@ -38,4 +38,22 @@ public class InvoiceDaoImpl extends MybatisGenericDao<InvoiceEntity,String> impl
public List<InvoiceEntity> queryInvoiceResult(InvoiceEntity entity) {
return (List<InvoiceEntity>) super.selectList("queryInvoiceResult",entity);
}
@DS("#entity.dataSourceCode")
@Override
public Integer updateInvoicePush(InvoiceEntity entity) {
return super.update("updateInvoicePush",entity);
}
@DS("#entity.dataSourceCode")
@Override
public Integer updateInvoiceUrl(InvoiceEntity entity) {
return super.update("updateInvoiceUrl",entity);
}
@DS("#entity.dataSourceCode")
@Override
public Integer updateInvoiceResult(InvoiceEntity entity) {
return super.update("updateInvoiceResult",entity);
}
}

View File

@ -72,6 +72,16 @@ public class InvoiceEntity extends BaseEntity {
private String url;// 发票文件
private String result_status;// 开票结果
private String summaryId;//
public String getSummaryId() {
return summaryId;
}
public void setSummaryId(String summaryId) {
this.summaryId = summaryId;
}
public String getPush_status_filed() {
return push_status_filed;
}

View File

@ -87,6 +87,27 @@
from v_hzya_invoice where push_status is not null and url is null and (result_status is null or result_status='申请单处理中')
</select>
<!--通过主键修改方法-->
<update id="updateInvoiceUrl" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" >
update ${tabName} set ${url_field} =#{url} where id=#{id}
</update>
<!--通过主键修改方法-->
<update id="updateInvoicePush" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" >
update formmain_0331 set field0206 =#{push_status} where id=#{id}
</update>
<!--通过主键修改方法-->
<update id="updateInvoiceResult" parameterType = "com.hzya.frame.seeyon.invoice.entity.InvoiceEntity" >
update ${tabName} set
<trim suffix="" suffixOverrides=",">
<if test="invoiceCode != null and invoiceCode != ''"> invoice_code_field = #{invoiceCode},</if>
<if test="invoiceNumber != null and invoiceNumber != ''"> invoice_number_field = #{invoiceNumber},</if>
<if test="resultStatus != null and resultStatus != ''"> result_status_field = #{resultStatus},</if>
</trim>
where id=#{id}
</update>
</mapper>

View File

@ -7,19 +7,24 @@ import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.impl.BaseService;
import com.hzya.frame.mdm.mdmModuleSource.dao.impl.MdmModuleSourceDaoImpl;
import com.hzya.frame.mdm.mdmModuleSource.entity.MdmModuleSourceEntity;
import com.hzya.frame.seeyon.dao.ICtpAttachmentDao;
import com.hzya.frame.seeyon.entity.CtpAttachmentEntity;
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.OARestUtil;
import com.hzya.frame.seeyon.util.YzfSignUtil;
import com.hzya.frame.seeyon.zxbank.entity.ZxBankEntity;
import com.hzya.frame.sysnew.comparison.service.impl.ComparisonServiceImpl;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
import com.hzya.frame.uuid.UUIDLong;
import com.hzya.frame.uuid.UUIDUtils;
import com.hzya.frame.web.entity.BaseResult;
import com.hzya.frame.web.entity.JsonResultEntity;
import com.hzya.frame.web.exception.BaseSystemException;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -46,6 +51,8 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Autowired
private ComparisonServiceImpl comparisonServiceimpl;
@Autowired
private ICtpAttachmentDao ctpAttachmentDao;
@Value("${zt.url}")
private String url;
@ -89,6 +96,37 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
//将查询出来的数据进行组装调用通用方法新增或者更新
if (null != listAll && listAll.size() > 0) {
object = ParametricDocument(listAll, mdmCode, tableName);
if (CollectionUtils.isNotEmpty(object)) {
for (Object obj : object) {
//更新单据视图推送标识不再抽取
JSONObject attributeResult = (JSONObject) JSON.toJSON(obj);
if (attributeResult.getString("status").equals("200")) {
String resultString = attributeResult.getString("list");
if ("10049".equals(mdmCode)) {
JSONArray jsonArray = JSONArray.parseArray(resultString);
if (CollectionUtils.isNotEmpty(jsonArray)) {
for (Object o : jsonArray) {
JSONObject attributeArray = (JSONObject) JSON.toJSON(o);
String cmpApply = attributeArray.getString(tableName);
JSONObject jsonObjectCmpApply = JSONObject.parseObject(cmpApply);
String id = jsonObjectCmpApply.getString("data_id");//主表id
String vdef1 = jsonObjectCmpApply.getString("business_no");//主表id
logger.info("=====开始根据单据id:{},单据号:{},更新表formmain_0331的推送标识", id, vdef1);
InvoiceEntity invoiceEntity = new InvoiceEntity();
invoiceEntity.setPush_status("1");
invoiceEntity.setId(id);
invoiceEntity.setDataSourceCode(mdmModuleSourceEntity.getDataSourceCode());
invoiceDao.updateInvoicePush(invoiceEntity);
//保存业务数据日志
saveTaskLivingDetails(id, jsonObjectCmpApply.getString("business_no"), listAll.get(0).toString(), object.toString(), true,"MakeInvoicePluginInitializer");
}
}
}
} else {
saveTaskLivingDetails(JSONObject.parseObject(listAll.get(0).getString("mdm_invoice_application")).getString("data_id"), JSONObject.parseObject(listAll.get(0).getString("mdm_invoice_application")).getString("business_no"), listAll.get(0).toString(), JSON.parseObject(JSON.toJSONString(object)).getString("msg"), false,"MakeInvoicePluginInitializer");
}
}
}
} else {
logger.info("三维单据视图数据没有需要同步中台的数据");
}
@ -145,27 +183,43 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
JSONArray jsonArray = jsonResult.getJSONArray("invoiceInfoVOList");
if(CollectionUtils.isNotEmpty(jsonArray)){
for (int i = 0; i < jsonArray.size(); i++) {
//表单的附件字段=ctpAttachment的Sub_reference表单的Summary_id=ctpAttachment的att_reference
String sub_reference = String.valueOf(UUIDLong.longUUID());
String att_reference = entity.getSummaryId();//Summary_id
JSONObject invoiceInfo = jsonArray.getJSONObject(i);
String invoiceCode = invoiceInfo.getString("invoiceCode");//发票代码
String invoiceNumber = invoiceInfo.getString("invoiceNumber");//发票号码
String resultStatus = InvoiceState.invoiceStateGetValue(jsonResult.getString("resultStatus"));//开票结果
entity.setInvoice_code(invoiceCode);
entity.setInvoice_number(invoiceNumber);
entity.setResult_status(resultStatus);
//将开票结果发票号码发票代码回写OA
invoiceDao.updateInvoiceResult(entity);
if (null != invoiceInfo.getString("url") || null != invoiceInfo.getString("ofdUrl")) {
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);
String pdfFileName = generateFileName(pdfUrl, "pdf");
String pdfSavePath = invoicePdfUrl + pdfFileName;
downloadPdf(pdfUrl, pdfSavePath);
logger.info("========pdf文件保存到本地完成========");
File filePdf=new File(pdfSavePath);
File filePdf = new File(pdfSavePath);
logger.info("========开始将pdf文件上传OA========");
ManyfileUpload(filePdf, entity, sub_reference, att_reference, jsonObject);
logger.info("========pdf文件上传OA完成========");
//获取ofd文件到本地
logger.info("========开始将ofd文件保存到本地========");
String ofdFileName = generateFileName(ofdUrl, "ofd");
String ofdSavePath = ofdUrl + ofdFileName;
downloadPdf(ofdUrl,ofdSavePath);
downloadPdf(ofdUrl, ofdSavePath);
logger.info("========ofd文件保存到本地完成========");
File fileOfd=new File(ofdSavePath);
File fileOfd = new File(ofdSavePath);
logger.info("========开始将ofd文件上传OA========");
ManyfileUpload(fileOfd, entity, sub_reference, att_reference, jsonObject);
logger.info("========ofd文件上传OA完成========");
}
}
}
}
@ -180,6 +234,50 @@ public class InvoiceServiceImpl extends BaseService<InvoiceEntity, String> imple
return null;
}
private void ManyfileUpload(File file,InvoiceEntity entity,String sub_reference,String att_reference,JSONObject jsonObject){
JSONObject jsonObjectOfd = OARestUtil.fileUpload(file,"8000590003","8000590001");
if (jsonObjectOfd.getString("fileUrl") != null) {
entity.setUrl(sub_reference);
entity.setDataSourceCode("HT-OA");
invoiceDao.updateInvoiceUrl(entity);
//根据附件id查询附件业务数据
String file_url = jsonObjectOfd.getString("fileUrl");
CtpAttachmentEntity ctpAttachmentEntity = new CtpAttachmentEntity();
ctpAttachmentEntity.setFile_url(file_url);
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());
ctpAttachmentEntity.setDataSourceCode("HT-OA");
ctpAttachmentDao.saveCtpAttachment(ctpAttachmentEntity);
} else {
if (ctpAttachmentEntities.size() > 1) {
throw new BaseSystemException("OA附件业务表中查到多条记录");
}
//更新数据到OA附件业务表中
ctpAttachmentDao.updateCtpAttachment(ctpAttachmentEntity);
}
logger.info("=====电子回单执行完毕=======");
}
file.delete();
}
private void downloadPdf(String pdfUrl, String savePath) {
try {
URL url = new URL(pdfUrl);

View File

@ -28,7 +28,7 @@ import java.util.List;
@Component
public class OARestUtil {
@Autowired
private ISysApplicationApiService sysApplicationApiService;
private static ISysApplicationApiService sysApplicationApiService;
static Logger logger = LoggerFactory.getLogger(OARestUtil.class);
private OARestUtil() {
@ -41,14 +41,14 @@ public class OARestUtil {
* @param api_code 接口编码
* @return
*/
public JSONObject fileUpload(File file,String api_code) {
if (StrUtil.isNotEmpty(api_code)){
public static JSONObject fileUpload(File file,String api_code_upload,String api_code_token) {
if (StrUtil.isNotEmpty(api_code_upload)){
//1查询附件上传api接口信息
SysApplicationApiEntity sysApp = getByCode(api_code);
SysApplicationApiEntity sysApp = getByCode(api_code_upload);
if (null != sysApp){
String app_url = sysApp.getAppUrl();
String url = app_url+"/seeyon/rest/attachment?token=@token@";
String token = getToken(null,"8000240000");
String token = getToken(null,api_code_token);
url = url.replaceAll("@token@",token);
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("file", file);
@ -147,7 +147,7 @@ public class OARestUtil {
* @param api_code
* @return
*/
public String getToken(String login_name,String api_code){
public static String getToken(String login_name,String api_code){
if (StrUtil.isNotEmpty(api_code)){
SysApplicationApiEntity sysApp = getByCode(api_code);
return getToken(login_name,sysApp);
@ -162,7 +162,7 @@ public class OARestUtil {
* @param sysApp 应用信息
* @return
*/
public String getToken(String login_name,SysApplicationApiEntity sysApp){
public static String getToken(String login_name,SysApplicationApiEntity sysApp){
if (null != sysApp){
HashMap<String, String> hashMap = new HashMap<>();
String app_url = StrUtil.removeSuffix(sysApp.getAppUrl(), "/");
@ -190,7 +190,7 @@ public class OARestUtil {
}
return null;
}
private SysApplicationApiEntity getByCode(String api_code){
private static SysApplicationApiEntity getByCode(String api_code){
if (StrUtil.isNotEmpty(api_code)){
SysApplicationApiEntity sysApp = new SysApplicationApiEntity();
sysApp.setApiCode(Long.valueOf(api_code));

View File

@ -142,7 +142,7 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
}
}
} else {
logger.info("三维单据视图数据没有需要同步中台的数据");
logger.info("杭泰付款单没有需要同步中信的数据");
}
}catch (Exception e){
logger.info("杭泰付款单同步失败:{}",e.getMessage());
@ -301,8 +301,8 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
logger.info("====调用中信电子回单下载得请求参数密文为:{}=======",objectData.toJSONString());
//因为电子回单下载返回的只有文件流所以无法在中台上注册接口只能代码中调用第三方接口
//将文件流的zip下载到文件夹中之后解压该文件夹得到pdf文件上传OA
String downloadFolder ="D:\\yongansystem\\pdf\\";
String destinationFolder ="D:\\yongansystem\\pdf\\";
String downloadFolder ="D:\\yongansystem\\zxbank\\pdf\\";
String destinationFolder ="D:\\yongansystem\\zxbank\\pdf\\";
URL url = new URL("http://202.108.57.65:11370/access/treasury/hangtai/bill/down");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();