发票保存到业务数据中心

This commit is contained in:
lvleigang 2025-04-10 09:15:23 +08:00
parent 330d4ffbd5
commit a287f6e30e
14 changed files with 893 additions and 2 deletions

View File

@ -43,6 +43,12 @@
<profile.active>httest</profile.active>
</properties>
</profile>
<profile>
<id>llg</id> <!--开发环境-->
<properties>
<profile.active>llg</profile.active>
</properties>
</profile>
</profiles>
<build>
<finalName>kangarooDataCenterV3</finalName>

View File

@ -0,0 +1,24 @@
package com.hzya.frame.plugin.incomeInvoiceData.dao;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.dao.IBaseDao;
import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity;
import java.util.List;
/**
* 客户档案(mdm_customer: table)表数据库访问层
*
* @author makejava
* @since 2024-06-21 13:52:35
*/
public interface IIncomeInvoiceDao extends IBaseDao<IncomeInvoiceEntity, String> {
List<JSONObject> queryData(JSONObject saveData);
int saveDetailData(JSONObject saveDetailData);
int saveData(JSONObject saveData);
}

View File

@ -0,0 +1,32 @@
package com.hzya.frame.plugin.incomeInvoiceData.dao.impl;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.dao.MybatisGenericDao;
import com.hzya.frame.plugin.incomeInvoiceData.dao.IIncomeInvoiceDao;
import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity;
import java.util.List;
/**
*
* @author makejava
* @since 2024-06-21 13:52:35
*/
public class IncomeInvoiceDaoImpl extends MybatisGenericDao<IncomeInvoiceEntity, String> implements IIncomeInvoiceDao {
@Override
public List<JSONObject> queryData(JSONObject saveData) {
List<JSONObject> o = (List<JSONObject>) super.selectList(getSqlIdPrifx() + "queryData", saveData);
return o;
}
@Override
public int saveData(JSONObject saveData) {
return super.insert(getSqlIdPrifx() + "saveData", saveData);
}
@Override
public int saveDetailData(JSONObject saveData) {
return super.insert(getSqlIdPrifx() + "saveDetailData", saveData);
}
}

View File

@ -0,0 +1,14 @@
package com.hzya.frame.plugin.incomeInvoiceData.entity;
import com.hzya.frame.web.entity.BaseEntity;
/**
*
* @author makejava
* @since 2024-06-21 13:52:35
*/
public class IncomeInvoiceEntity extends BaseEntity {
}

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hzya.frame.plugin.incomeInvoiceData.dao.impl.IncomeInvoiceDaoImpl">
<select id="queryData" resultType="com.alibaba.fastjson.JSONObject" parameterType="com.alibaba.fastjson.JSONObject">
select
*
from mdm_fp
<trim prefix="where" prefixOverrides="and">
<if test="fphm != null and fphm != ''"> and fphm = #{fphm} </if>
and sts = 'Y' and data_status != 'N'
</trim>
</select>
<insert id="saveData" parameterType="com.alibaba.fastjson.JSONObject">
insert into mdm_fp(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> id , </if>
<if test="document_rule != null and document_rule != ''"> document_rule , </if>
<if test="document_rule_num != null"> document_rule_num , </if>
<if test="data_status != null and data_status != ''"> data_status , </if>
<if test="add_status != null and add_status != ''"> add_status , </if>
<if test="update_status != null and update_status != ''"> update_status , </if>
<if test="delete_status != null and delete_status != ''"> delete_status , </if>
<if test="sorts != null"> sorts , </if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="create_time != null"> create_time , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="modify_time != null"> modify_time , </if>
<if test="sts != null and sts != ''"> sts , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
<if test="fphm != null and fphm != ''"> fphm , </if>
</trim>
)values
(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> #{id} , </if>
<if test="document_rule != null and document_rule != ''"> #{document_rule} , </if>
<if test="document_rule_num != null"> #{document_rule_num} , </if>
<if test="data_status != null and data_status != ''"> #{data_status} , </if>
<if test="add_status != null and add_status != ''"> #{add_status} , </if>
<if test="update_status != null and update_status != ''"> #{update_status} , </if>
<if test="delete_status != null and delete_status != ''"> #{delete_status} , </if>
<if test="sorts != null"> #{sorts} , </if>
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} , </if>
<if test="create_time != null"> #{create_time} , </if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} , </if>
<if test="modify_time != null"> #{modify_time} , </if>
<if test="sts != null and sts != ''"> #{sts} , </if>
<if test="org_id != null and org_id != ''"> #{org_id} , </if>
<if test="companyId != null and companyId != ''"> #{company_id} , </if>
<if test="fphm != null and fphm != ''"> #{fphm} , </if>
</trim>
)
</insert>
<insert id="saveDetailData" parameterType="com.alibaba.fastjson.JSONObject">
insert into mdm_fp_detail(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> id , </if>
<if test="formmain_id != null and formmain_id != ''"> formmain_id , </if>
<if test="data_status != null and data_status != ''"> data_status , </if>
<if test="sorts != null"> sorts , </if>
<if test="create_user_id != null and create_user_id != ''"> create_user_id , </if>
<if test="create_time != null"> create_time , </if>
<if test="modify_user_id != null and modify_user_id != ''"> modify_user_id , </if>
<if test="modify_time != null"> modify_time , </if>
<if test="sts != null and sts != ''"> sts , </if>
<if test="org_id != null and org_id != ''"> org_id , </if>
<if test="companyId != null and companyId != ''"> company_id , </if>
<if test="remark != null and remark != ''"> remark , </if>
</trim>
)values
(
<trim suffix="" suffixOverrides=",">
<if test="id != null and id != ''"> #{id} , </if>
<if test="formmain_id != null and formmain_id != ''"> #{formmain_id} , </if>
<if test="data_status != null and data_status != ''"> #{data_status}, </if>
<if test="sorts != null"> #{sorts} , </if>
<if test="create_user_id != null and create_user_id != ''"> #{create_user_id} , </if>
<if test="create_time != null"> #{create_time} , </if>
<if test="modify_user_id != null and modify_user_id != ''"> #{modify_user_id} , </if>
<if test="modify_time != null"> #{modify_time} , </if>
<if test="sts != null and sts != ''"> #{sts} , </if>
<if test="org_id != null and org_id != ''"> #{org_id} , </if>
<if test="companyId != null and companyId != ''"> #{company_id} , </if>
<if test="remark != null and remark != ''"> #{remark} , </if>
</trim>
)
</insert>
</mapper>

View File

@ -0,0 +1,63 @@
package com.hzya.frame.plugin.incomeInvoiceData.plugin;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity;
import com.hzya.frame.plugin.incomeInvoiceData.service.IIncomeInvoiceService;
import com.hzya.frame.web.entity.JsonResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 主数据同步
*
* @author makejava
* @since 2024-06-21 13:52:35
*/
public class IncomeInvoicePluginInitializer extends PluginBaseEntity{
Logger logger = LoggerFactory.getLogger(IncomeInvoicePluginInitializer.class);
@Autowired
private IIncomeInvoiceService incomeInvoiceService;
@Override
public void initialize() {
logger.info(getPluginLabel() + "执行初始化方法initialize()");
}
@Override
public void destroy() {
logger.info(getPluginLabel() + "执行销毁方法destroy()");
}
@Override
public String getPluginId() {
return "IncomeInvoicePlugin";
}
@Override
public String getPluginName() {
return "IncomeInvoicePlugin插件";
}
@Override
public String getPluginLabel() {
return "IncomeInvoicePlugin";
}
@Override
public String getPluginType() {
return "1";
}
@Override
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行进项全量发票主数据信息同步========");
return incomeInvoiceService.getIncomeInvoiceData(requestJson);
}catch (Exception e){
logger.info("======执行进项全量发票主数据同步失败:{}========",e.getMessage());
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,17 @@
package com.hzya.frame.plugin.incomeInvoiceData.service;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.basedao.service.IBaseService;
import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.web.entity.JsonResultEntity;
/**
*
* @author makejava
* @since 2024-06-21 13:52:35
*/
public interface IIncomeInvoiceService extends IBaseService<IncomeInvoiceEntity, String> {
JsonResultEntity getIncomeInvoiceData(JSONObject requestJson);
SysExtensionApiEntity setData(SysExtensionApiEntity entity) throws Exception;
}

View File

@ -0,0 +1,526 @@
package com.hzya.frame.plugin.incomeInvoiceData.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.plugin.incomeInvoiceData.dao.IIncomeInvoiceDao;
import com.hzya.frame.plugin.incomeInvoiceData.entity.IncomeInvoiceEntity;
import com.hzya.frame.plugin.incomeInvoiceData.service.IIncomeInvoiceService;
import com.hzya.frame.seeyon.util.YzfSignUtil;
import com.hzya.frame.sysnew.application.entity.SysExtensionApiEntity;
import com.hzya.frame.sysnew.comparison.controlsLog.dao.impl.ControlsLogDaoImpl;
import com.hzya.frame.sysnew.comparison.controlsLog.entity.ControlsLogEntity;
import com.hzya.frame.sysnew.comparison.dao.IComparisonDao;
import com.hzya.frame.sysnew.comparison.entity.ComparisonEntity;
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 org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.TrustAllStrategy;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.hzya.frame.basedao.service.impl.BaseService;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author makejava
* @since 2024-06-21 13:52:35
*/
public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, String> implements IIncomeInvoiceService {
private IIncomeInvoiceDao incomeInvoiceDao;
@Autowired
private ControlsLogDaoImpl controlsLogDaoimpl;
@Autowired
private IComparisonDao comparisonDao;
@Autowired
public void setIncomeInvoiceDao(IIncomeInvoiceDao dao) {
this.incomeInvoiceDao = dao;
this.dao = dao;
}
String dataUrl = "http://oapi.nanofintax.com/api/invoice_receive/fp/v1/query?accessToken=";
String tokenUrl = "http://oapi.nanofintax.com/api/getToken";
String accessKey = "6X3B526P5HqE6ums";
String accessSecret = "34e5fc32ac894a2ba2ade8c3852c7a0a";
String taxNo = "91330110MAC5FPUY2U";
Integer size = 50;
@Override
public JsonResultEntity getIncomeInvoiceData(JSONObject requestJson) {
//1调用token
String access_token = getToken();
if (access_token == null) {
return BaseResult.getFailureMessageEntity("token获取失败");
}
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String times = sdf.format(date);
times = "2025-03-25";
//2调用接口获取数据
Integer queryCursor = 1;
JSONArray datalist = new JSONArray();
sendBusinessData(datalist, access_token, queryCursor,times);
if(datalist != null && datalist.size() > 0){
for (int i = 0; i < datalist.size(); i++) {
JSONObject saveData = new JSONObject();
//3对照数据
JSONObject jsonObject = datalist.getJSONObject(i);
//发票号码
String fphm = jsonObject.getString("fphm");
if(fphm == null || "".equals(fphm) ){
continue;
}
saveData.put("fphm",fphm);
//判断是否有这个数据
List<JSONObject> checkData = incomeInvoiceDao.queryData(saveData);
if(checkData != null && checkData.size() > 0){
continue;
}
saveData.put("id", String.valueOf(UUIDLong.longUUID()));
saveData.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
saveData.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
saveData.put("org_id", "0");
saveData.put("create_time", new Date());
saveData.put("modify_time", new Date());
saveData.put("sts", "Y");
saveData.put("data_status", "Y");//新增状态
saveData.put("add_status", "0");//新增状态
saveData.put("update_status", "1");//修改状态
saveData.put("delete_status", "1");//删除状态
ComparisonEntity comparisonEntityRule = new ComparisonEntity();
comparisonEntityRule.setRulePrefix("FP");
comparisonEntityRule.setRuleMiddle("%Y-%m-%d");
comparisonEntityRule.setRuleSuffix(5);
comparisonEntityRule.setDbName("mdm_fp");
ComparisonEntity comparisonEntityRuleGz = comparisonDao.queryComparisonRule(comparisonEntityRule);
saveData.put("document_rule", comparisonEntityRuleGz.getDocumentRule());//单据规则
saveData.put("document_rule_num", comparisonEntityRuleGz.getDocumentRuleNum());//单据规则流水号
JSONObject content = jsonObject.getJSONObject("content");
JSONArray detaildata = content.getJSONArray("items");
if(detaildata != null && detaildata.size() > 0){
for (int i1 = 0; i1 < detaildata.size(); i1++) {
JSONObject saveDetailData = new JSONObject();
saveDetailData.put("id", String.valueOf(UUIDLong.longUUID()));
saveDetailData.put("formmain_id", saveData.getString("id"));
saveDetailData.put("data_status", "Y");//新增状态
saveDetailData.put("create_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
saveDetailData.put("modify_user_id", "c796fd9ba4c9f5ff3cc2fa41a040e443");
saveDetailData.put("org_id", "0");
saveDetailData.put("create_time", new Date());
saveDetailData.put("modify_time", new Date());
saveDetailData.put("sts", "Y");
saveDetailData.put("remark", detaildata.getJSONObject(i1).getString("xmmc"));
incomeInvoiceDao.saveDetailData(saveDetailData);
}
}
incomeInvoiceDao.saveData(saveData);
//5保存写入日志
ControlsLogEntity controlsLogEntity=new ControlsLogEntity();
controlsLogEntity.setId(UUIDUtils.getUUID());
controlsLogEntity.setFormmainId(saveData.getString("id"));
controlsLogEntity.setSourceName("数智中台");
controlsLogEntity.setCode("800004");
controlsLogEntity.setSourceData(jsonObject.toString());
controlsLogEntity.setOptionType("接口新增");
controlsLogEntity.setOptionName("数智中台");
controlsLogEntity.setDbName("mdm_fp_option_log");
controlsLogEntity.setDataType("1");
controlsLogEntity.setCreate_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
controlsLogEntity.setModify_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443");
controlsLogEntity.setOrg_id("0");
controlsLogEntity.setRemark("插件新增");
controlsLogDaoimpl.saveControlsLog(saveData.getString("id"), "数智中台", "800004", jsonObject.toJSONString(), "接口新增", "数智中台", "mdm_fp_option_log", "1");
}
}
return BaseResult.getSuccessMessageEntity("处理成功");
}
/**
* @Author lvleigang
* @Description 获取业务数据
* @Date 4:31 下午 2025/4/9
* @param datalist
* @param access_token
* @param queryCursor
* @param dataTime
* @return void
**/
private void sendBusinessData(JSONArray datalist, String access_token, Integer queryCursor, String dataTime) {
String url = dataUrl+access_token;
JSONObject dayabody = new JSONObject();
dayabody.put("accessKey",accessKey);
long timestamp = System.currentTimeMillis();
dayabody.put("timestamp",timestamp);
JSONObject queryParams = new JSONObject();
queryParams.put("page",queryCursor);
queryParams.put("size",size);
queryParams.put("kprqq",dataTime);
queryParams.put("kprqz",dataTime);
queryParams.put("taxNo",taxNo);
dayabody.put("queryParams",queryParams);
Map<String, Object> parametersMap = new HashMap<>();
parametersMap.put("accessKey",accessKey);
parametersMap.put("timestamp",timestamp);
String a = YzfSignUtil.signRequest(parametersMap,accessSecret);
dayabody.put("sign",a);
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json; charset=utf-8");
String returndata = sendPost(url, headers, dayabody.toJSONString());
if (returndata != null && JSONObject.isValidObject(returndata)) {
JSONObject dataJson = JSONObject.parseObject(returndata);
if(dataJson != null && dataJson.getString("code") != null && "0".equals( dataJson.getString("code"))){
JSONObject data = dataJson.getJSONObject("result");
if(data != null ){
JSONArray businessList = data.getJSONArray("data");
if(data.getInteger("total") > queryCursor*size){
queryCursor = queryCursor+1;
sendBusinessData(datalist, access_token, queryCursor, dataTime);
}
if(businessList != null && businessList.size() > 0){
datalist.addAll(businessList);
}
}
}
}
}
private JSONObject getUser(String usercode,String access_token) {
JSONObject jsonObject = new JSONObject();
String url = "https://swoa.sunwave.com.cn:9999/seeyon/rest/orgMembers/code/"+usercode+"?pageNo=0&pageSize=100";
Map<String, String> headers = new HashMap<>();
headers.put("token",access_token);
String returndata = sendGet(url, headers);
if (returndata != null && JSONArray.isValidArray(returndata)) {
JSONArray dataJson = JSONObject.parseArray(returndata);
if(dataJson != null && dataJson.size() > 0){
for (int i = 0; i < dataJson.size(); i++) {
if(dataJson.getJSONObject(i).getString("code") != null && !"".equals(dataJson.getJSONObject(i).getString("code"))
&& usercode.toLowerCase().equals(dataJson.getJSONObject(i).getString("code").toLowerCase())){
jsonObject.put("telNumber",dataJson.getJSONObject(i).getString("telNumber"));
jsonObject.put("orgDepartmentName",dataJson.getJSONObject(i).getString("orgDepartmentName"));
jsonObject.put("orgPostName",dataJson.getJSONObject(i).getString("orgPostName"));
jsonObject.put("name",dataJson.getJSONObject(i).getString("name"));
break;
}
}
}
}
return jsonObject;
}
private String getOAToken(String name) {
String url = "https://swoa.sunwave.com.cn:9999/seeyon/rest/token";
Map<String, String> headers = null;
String bodys = "{\"password\":\"64de4de7-23ce-4946-ac91-dd9e322d86e5\",\"userName\":\"beis\",\"loginName\":\""+name+"\"}";
String tokenData = sendPost(url, headers, bodys);
String access_token = null;
if (tokenData != null && JSONObject.isValidObject(tokenData)) {
JSONObject tokendataJson = JSONObject.parseObject(tokenData);
if (tokendataJson != null && tokendataJson.getString("id") != null) {
access_token = tokendataJson.getString("id");
}
}
return access_token;
}
/**
* @Author lvleigang
* @Description 获取token
* @Date 4:18 下午 2025/4/9
* @param
* @return java.lang.String
**/
private String getToken() {
String url = tokenUrl;
JSONObject tokenJson = new JSONObject();
tokenJson.put("accessKey",accessKey);
tokenJson.put("accessSecret",accessSecret);
String bodys = tokenJson.toJSONString();
StringBuilder body = new StringBuilder();
SSLContext sslContext = null;
try {
sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();
} catch (Exception e) {
return null;
}
CloseableHttpClient closeableHttpClient = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
HttpPost post = new HttpPost(url);
CloseableHttpResponse response = null;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(6000).build();
post.setConfig(requestConfig);//设置请求参数超时时间
post.setHeader("Content-Type", "application/json; charset=utf-8");
try {
if (bodys != null && !"".equals(bodys)) {
ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8"));
entity.setContentType("application/json");
post.setEntity(entity);
}
response = closeableHttpClient.execute(post);
HttpEntity entity = response.getEntity();
body.append(EntityUtils.toString(entity, "UTF-8"));
} catch (Exception e) {
body.append(e.getMessage());
} finally {
try {
// 关闭响应对象
if (response != null) {
response.close();
}
// 关闭响应对象
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
logger.info("token返回结果{}",body);
JSONObject bodyJson = JSONObject.parseObject(body.toString());
if(bodyJson.getString("code") == null || !"0".equals(bodyJson.getString("code"))){
return null;
}
JSONObject resultJson = bodyJson.getJSONObject("result");
if(resultJson == null){
return null;
}
if(resultJson.getString("accessToken") != null && !"".equals(resultJson.getString("accessToken"))){
return resultJson.getString("accessToken");
}
return null;
}
private String sendPost(String url, Map<String, String> headers, String bodys) {
logger.info("url"+url+"。bodys"+bodys);
SSLContext sslContext = null;
try {
sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();
} catch (Exception e) {
}
CloseableHttpClient closeableHttpClient = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
HttpPost post = new HttpPost(url);
CloseableHttpResponse response = null;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build();
post.setConfig(requestConfig);//设置请求参数超时时间
if (headers != null && headers.size() > 0) {
for (String key : headers.keySet()) {
post.setHeader(key, headers.get(key));
}
}
StringBuilder body = new StringBuilder();
try {
if (bodys != null && !"".equals(bodys)) {
ByteArrayEntity entity = new ByteArrayEntity(bodys.getBytes("UTF-8"));
entity.setContentType("application/json");
post.setEntity(entity);
}
response = closeableHttpClient.execute(post);
HttpEntity entity = response.getEntity();
body.append(EntityUtils.toString(entity, "UTF-8"));
logger.info("返回结果:" + body);
} catch (Exception e) {
logger.error("请求错误:" + e.getMessage());
body = new StringBuilder();
} finally {
try {
// 关闭响应对象
if (response != null) {
response.close();
}
// 关闭响应对象
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
logger.info("url"+url+"。bodys"+bodys+"。body"+body);
return body.toString();
}
private String sendGet(String url, Map<String, String> headers) {
SSLContext sslContext = null;
try {
sslContext = new SSLContextBuilder()
.loadTrustMaterial(null, TrustAllStrategy.INSTANCE)
.build();
} catch (Exception e) {
}
CloseableHttpClient closeableHttpClient = HttpClients.custom()
.setSSLContext(sslContext)
.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE)
.build();
// HttpClient
HttpGet get = new HttpGet(url);
CloseableHttpResponse response = null;
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build();
get.setConfig(requestConfig);//设置请求参数超时时间
if (headers != null && headers.size() > 0) {
for (String key : headers.keySet()) {
get.setHeader(key, headers.get(key));
}
}
StringBuilder body = new StringBuilder();
try {
response = closeableHttpClient.execute(get);
HttpEntity entity = response.getEntity();
body.append(EntityUtils.toString(entity,"UTF-8"));
logger.info("返回结果:" + body);
} catch (Exception e) {
logger.error("请求错误:" + e.getMessage());
body.append(e.getMessage());
} finally {
try {
// 关闭响应对象
if (response != null) {
response.close();
}
// 关闭响应对象
if (closeableHttpClient != null) {
closeableHttpClient.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return body.toString();
}
/**
* seeyon流程事件监听前置方法绑定数据源
* @param entity
* @return
* @throws Exception
*/
@Override
public SysExtensionApiEntity setData(SysExtensionApiEntity entity) throws Exception {
try {
JSONObject sendBody = new JSONObject();
String bodys = entity.getBodys();
Map<String, String> headers = entity.getHeaders();
JSONObject jsonObject = JSONObject.parseObject(bodys);
String loginName = jsonObject.getString("field0002");
String dataXml = getXml(jsonObject);
//处理xml数据
String oaToken = getOAToken(loginName);
headers.put("token",oaToken);
sendBody.put("token",oaToken);
sendBody.put("loginName",loginName);
sendBody.put("dataXml",dataXml);
entity.setBodys(sendBody.toJSONString());
} catch (Exception e) {
e.printStackTrace();
}
return entity;
}
private String getXml(JSONObject jsonObject) {
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append("<forms version=\"2.1\"><formExport><summary id=\"-3743349685075685398\" name=\"formmain_11769\"/><definitions><column id=\"field0011\" type=\"0\" name=\"申请单号\" isNullable=\"false\" length=\"100\"/><column id=\"field0001\" type=\"0\" name=\"申请人\" isNullable=\"false\" length=\"255\"/><column id=\"field0002\" type=\"0\" name=\"申请人工号\" isNullable=\"false\" length=\"255\"/><column id=\"field0012\" type=\"0\" name=\"申请人职位\" isNullable=\"false\" length=\"255\"/><column id=\"field0013\" type=\"0\" name=\"申请人部门\" isNullable=\"false\" length=\"255\"/><column id=\"field0014\" type=\"0\" name=\"申请人手机号\" isNullable=\"false\" length=\"255\"/><column id=\"field0003\" type=\"3\" name=\"出差时间\" isNullable=\"false\" length=\"255\"/><column id=\"field0015\" type=\"0\" name=\"出差类型\" isNullable=\"false\" length=\"255\"/><column id=\"field0016\" type=\"0\" name=\"出差城市\" isNullable=\"false\" length=\"255\"/><column id=\"field0017\" type=\"4\" name=\"出差时长\" isNullable=\"false\" length=\"20\"/><column id=\"field0018\" type=\"0\" name=\"是否境外出差\" isNullable=\"false\" length=\"100\"/><column id=\"field0019\" type=\"0\" name=\"是否需要APEC卡\" isNullable=\"false\" length=\"100\"/><column id=\"field0020\" type=\"0\" name=\"是否展会出差\" isNullable=\"false\" length=\"100\"/><column id=\"field0021\" type=\"0\" name=\"出差事由\" isNullable=\"false\" length=\"255\"/></definitions><values>");
stringBuffer.append("<column name=\"申请单号\"><value>");
stringBuffer.append(jsonObject.getString("field0011") != null?"<![CDATA["+jsonObject.getString("field0011")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"申请人\"><value>");
stringBuffer.append(jsonObject.getString("field0001") != null?"<![CDATA["+jsonObject.getString("field0001")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"申请人工号\"><value>");
stringBuffer.append(jsonObject.getString("field0002") != null?"<![CDATA["+jsonObject.getString("field0002")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"申请人职位\"><value>");
stringBuffer.append(jsonObject.getString("field0012") != null?"<![CDATA["+jsonObject.getString("field0012")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"申请人部门\"><value>");
stringBuffer.append(jsonObject.getString("field0013") != null?"<![CDATA["+jsonObject.getString("field0013")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"申请人手机号\"><value>");
stringBuffer.append(jsonObject.getString("field0014") != null?"<![CDATA["+jsonObject.getString("field0014")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"出差时间\"><value>");
stringBuffer.append(jsonObject.getString("field0003") != null?"<![CDATA["+jsonObject.getString("field0003")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"出差类型\"><value>");
stringBuffer.append(jsonObject.getString("field0015") != null?"<![CDATA["+jsonObject.getString("field0015")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"出差城市\"><value>");
stringBuffer.append(jsonObject.getString("field0016") != null?"<![CDATA["+jsonObject.getString("field0016")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"出差时长\"><value>");
stringBuffer.append(jsonObject.getString("field0017") != null?"<![CDATA["+jsonObject.getString("field0017")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"是否境外出差\"><value>");
stringBuffer.append(jsonObject.getString("field0018") != null?"<![CDATA["+jsonObject.getString("field0018")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"是否需要APEC卡\"><value>");
stringBuffer.append(jsonObject.getString("field0019") != null?"<![CDATA["+jsonObject.getString("field0019")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"是否展会出差\"><value>");
stringBuffer.append(jsonObject.getString("field0020") != null?"<![CDATA["+jsonObject.getString("field0020")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("<column name=\"出差事由\"><value>");
stringBuffer.append(jsonObject.getString("field0021") != null?"<![CDATA["+jsonObject.getString("field0021")+"]]>":"");
stringBuffer.append("</value></column>");
stringBuffer.append("</values><subForms><subForm><definitions><column id=\"field0004\" type=\"2\" name=\"明细表-出发时间\" isNullable=\"false\" length=\"255\"/><column id=\"field0005\" type=\"2\" name=\"明细表-结束时间\" isNullable=\"false\" length=\"255\"/><column id=\"field0022\" type=\"4\" name=\"明细表-出差时长\" isNullable=\"false\" length=\"20\"/><column id=\"field0006\" type=\"0\" name=\"明细表-出发地\" isNullable=\"false\" length=\"255\"/><column id=\"field0007\" type=\"0\" name=\"明细表-目的地\" isNullable=\"false\" length=\"255\"/><column id=\"field0008\" type=\"0\" name=\"明细表-交通工具\" isNullable=\"false\" length=\"255\"/><column id=\"field0009\" type=\"4\" name=\"明细表-预计费用\" isNullable=\"false\" length=\"20\"/></definitions><values>");
//处理明细
JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("mdm_ccd_detail"));
if(jsonArray != null&& jsonArray.size() > 0){
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject detailObject = jsonArray.getJSONObject(i);
stringBuffer.append("<row>");
stringBuffer.append("<column name=\"明细表-出发时间\"><value>").append(detailObject.getString("field0004") != null?"<![CDATA["+detailObject.getString("field0004")+"]]>":"").append("</value></column>");
stringBuffer.append("<column name=\"明细表-结束时间\"><value>").append(detailObject.getString("field0005") != null?"<![CDATA["+detailObject.getString("field0005")+"]]>":"").append("</value></column>");
stringBuffer.append("<column name=\"明细表-出差时长\"><value>").append(detailObject.getString("field0022") != null?"<![CDATA["+detailObject.getString("field0022")+"]]>":"").append("</value></column>");
stringBuffer.append("<column name=\"明细表-出发地\"><value>").append(detailObject.getString("field0006") != null?"<![CDATA["+detailObject.getString("field0006")+"]]>":"").append("</value></column>");
stringBuffer.append("<column name=\"明细表-目的地\"><value>").append(detailObject.getString("field0007") != null?"<![CDATA["+detailObject.getString("field0007")+"]]>":"").append("</value></column>");
stringBuffer.append("<column name=\"明细表-交通工具\"><value>").append(detailObject.getString("field0008") != null?"<![CDATA["+detailObject.getString("field0008")+"]]>":"").append("</value></column>");
stringBuffer.append("<column name=\"明细表-预计费用\"><value>").append(detailObject.getString("field0009") != null?"<![CDATA["+detailObject.getString("field0009")+"]]>":"").append("</value></column>");
stringBuffer.append("</row>");
}
}
stringBuffer.append("</values></subForm></subForms></formExport></forms>");
return stringBuffer.toString();
}
}

View File

@ -0,0 +1,82 @@
#######################本地环境#######################
logging:
#日志级别 指定目录级别
level:
root: info
encodings: UTF-8
file:
# 日志保存路径
path: /Users/apple/Desktop/log/local
spring:
data:
mongodb:
# host: 192.168.2.237
# port: 27017
# database: businesscenter
# auto-index-creation: true
# password: hzya1314
# username: hzya
flyway:
# 启动flyway migration, 默认为true
enabled: false
datasource:
dynamic:
druid:
filters: stat,log4j2
datasource:
master:
# url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle
# username: hzyazt
# password: 62e4295b615a30dbf3b8ee96f41c820b
# driver-class-name: dm.jdbc.driver.DmDriver
# type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://ufidahz.com.cn:9014/businesscenter?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowLoadLocalInfile=false&autoReconnect=true&failOverReadOnly=false&connectTimeout=30000&socketTimeout=30000&autoReconnectForPools=true
username: root
password: bd993088e8a7c3dc5f44441617f9b4bf
driver-class-name: com.mysql.jdbc.Driver # 3.2.0开始支持SPI可省略此配置
# url: jdbc:dm://hzya.ufyct.com:9040/businesscenter?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
# url: jdbc:dm://hzya.ufyct.com:9040?schema=businesscenter&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8&compatibleMode=oracle
# username: hzyazt
# password: 62e4295b615a30dbf3b8ee96f41c820b
# driver-class-name: dm.jdbc.driver.DmDriver
savefile:
# 文件保存路径
path: /Users/apple/Desktop/log/local
tomcatpath: /Users/apple/Desktop/log/local
pluginpath: /Users/apple/Desktop/log/local
zt:
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
cbs8:
appId: 1P4AGrpz
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a
url: https://cbs8-openapi-reprd.csuat.cmburl.cn
# 测试用这个 这个是银行给的,和下面的公钥不是一对密钥
ya_private_key: 83BA7EC821D35F4CB31FF9A51C1EFA520FC52AF828C2337F88E91CF119B07F44
# 这个私钥到时候上传到cbs和下面到是同一对
#ya_private_key: e1eacfdee9b8d4184437d5a2071e17ce31befc3d93395f9f05709ed562e8dc46
ya_public_key: 044fa399d2223760f17b81b863cb482b009294c4516f8a605dea1475ec09e720eaa98468715e5ad509a592a0b426061551c5a3df236966c23253a7d894eac0dcde
cbs_public_key: 0469146F06BF3B01236E84632441E826
#电子回单下载临时存放位置
elec_path: /Users/xiangerlin/Downloads/
OA:
data_source_code: yc_oa
server:
port: 10086
# mysqldump -d mylm -hhzya.ufyct.com -p9096 -uroot -phzya1314 >%dirName%\table_view.sql
database:
databaseName: businesscenter
host: 192.168.2.237
port: 3306
username: root
password: hzya@1314
filePase: /Users/apple/Desktop/log
fileName: data.sql
#sftp:
# host: 192.168.2.237
# port: 9091
# username: cs237
# password: hzya@1314
# filePase: /databaseBack

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<id>IncomeInvoicePlugin</id>
<name>IncomeInvoicePlugin插件</name>
<category>202404080001</category>
</plugin>

View File

@ -0,0 +1,5 @@
<?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="incomeInvoiceDao" class="com.hzya.frame.plugin.incomeInvoiceData.dao.impl.IncomeInvoiceDaoImpl" />
</beans>

View File

@ -0,0 +1,5 @@
<?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="incomeInvoicePluginInitializer" class="com.hzya.frame.plugin.incomeInvoiceData.plugin.IncomeInvoicePluginInitializer" />
</beans>

View File

@ -0,0 +1,5 @@
<?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="incomeInvoiceService" class="com.hzya.frame.plugin.incomeInvoiceData.service.impl.IncomeInvoiceServiceImpl" />
</beans>

View File

@ -66,10 +66,10 @@ public class ZxBankServiceImpl extends BaseService<ZxBankEntity, String> impleme
@Value("${zt.url}")
private String url;
@Value("${zx.privateKey}")
@Value("${zx.privateKey:}")
private String privateKey;
@Value("${zx.publicKey}")
@Value("${zx.publicKey:}")
private String publicKey;
@Override
public JsonResultEntity queryArchives(JSONObject json) {