物料对称修改

This commit is contained in:
lvleigang 2025-04-27 17:12:31 +08:00
parent 3353efa831
commit e2e5e0ab26
4 changed files with 92 additions and 77 deletions

View File

@ -15,6 +15,8 @@ public class IncomeInvoiceEntity extends BaseEntity {
private String field0128;
private String field0129;
private String field0130;
private String field0138;
private String field0139;
private String field0003;
@ -121,5 +123,21 @@ public class IncomeInvoiceEntity extends BaseEntity {
public void setField0003(String field0003) {
this.field0003 = field0003;
}
public String getField0138() {
return field0138;
}
public void setField0138(String field0138) {
this.field0138 = field0138;
}
public String getField0139() {
return field0139;
}
public void setField0139(String field0139) {
this.field0139 = field0139;
}
}

View File

@ -195,6 +195,8 @@
<if test="field0128 != null and field0128 != ''"> field0128 = #{field0128},</if>
<if test="field0129 != null and field0129 != ''"> field0129 = #{field0129},</if>
<if test="field0130 != null and field0130 != ''"> field0130 = #{field0130},</if>
<if test="field0138 != null and field0138 != ''"> field0138 = #{field0138},</if>
<if test="field0139 != null and field0139 != ''"> field0139 = #{field0139},</if>
</trim>
where id = #{dataId}
</update>
@ -208,6 +210,8 @@
<if test="field0128 != null and field0128 != ''">field0128 ,</if>
<if test="field0129 != null and field0129 != ''">field0129 ,</if>
<if test="field0130 != null and field0130 != ''">field0130 ,</if>
<if test="field0138 != null and field0138 != ''">field0138 ,</if>
<if test="field0139 != null and field0139 != ''">field0139 ,</if>
</trim>
)values(
@ -218,6 +222,8 @@
<if test="field0128 != null and field0128 != ''">#{field0128} ,</if>
<if test="field0129 != null and field0129 != ''">#{field0129} ,</if>
<if test="field0130 != null and field0130 != ''">#{field0130} ,</if>
<if test="field0138 != null and field0138 != ''">#{field0138} ,</if>
<if test="field0139 != null and field0139 != ''">#{field0139} ,</if>
</trim>
)
</insert>

View File

@ -54,8 +54,8 @@ public class FinancialReportPluginInitializer extends PluginBaseEntity{
public JsonResultEntity executeBusiness(JSONObject requestJson) {
try {
logger.info("======开始执行财务信息同步========");
//return BaseResult.getSuccessMessageEntity("数据获取成功");
return incomeInvoiceService.sendFinancialReportPlugin(requestJson);
return BaseResult.getSuccessMessageEntity("数据获取成功");
//return incomeInvoiceService.sendFinancialReportPlugin(requestJson);
}catch (Exception e){
logger.info("======执行财务同步失败:{}========",e.getMessage());
e.printStackTrace();

View File

@ -63,13 +63,23 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
this.incomeInvoiceDao = dao;
this.dao = dao;
}
boolean flags = true;
String cbUrl = "http://oapi.nanofintax.com/api/collect/uploadFinancialReport?accessToken=";
String dataUrl = "http://oapi.nanofintax.com/api/invoice_receive/fp/v1/query?accessToken=";
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;
//String cbUrl = "http://oapi.nanofintax.com/api/collect/uploadFinancialReport";
//String dataUrl = "https://workbench.test.htszny.com/oapi/invoice_receive/fp/v1/query";//全量发票数据
//String tokenUrl = "http://oapi.nanofintax.com/api/getToken";
//String accessKey = "6X3B526P5HqE6ums";
//String accessSecret = "34e5fc32ac894a2ba2ade8c3852c7a0a";
//String taxNo = "91330110MAC5FPUY2U";
//Integer size = 50;
@Resource
private TaskExecutor taskExecutor;
/**
@ -82,10 +92,13 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
@Override
public JsonResultEntity getIncomeInvoiceData(JSONObject requestJson) {
//1调用token
String access_token = getToken();
String access_token = "";
if(flags){
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);
@ -227,21 +240,26 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
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();
if(flags) {
dayabody.put("accessKey",accessKey);
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("kprqq",dataTime);
queryParams.put("kprqz",dataTime);
queryParams.put("taxNo",taxNo);
dayabody.put("queryParams",queryParams);
if(flags) {
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());
@ -409,56 +427,6 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
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();
}
/**
@ -492,7 +460,9 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
incomeInvoiceEntity.setField0127(jsonObject.getString("fpdm"));//发票代码
incomeInvoiceEntity.setField0128(jsonObject.getString("fphm"));//发票号码
incomeInvoiceEntity.setField0129(jsonObject.getString("jshj"));//发票总额
incomeInvoiceEntity.setField0130(jsonObject.getString("fpwj"));//发票文件 todo
incomeInvoiceEntity.setField0130(jsonObject.getString("url"));//发票文件
incomeInvoiceEntity.setField0138(jsonObject.getString("ofdurl"));//发票文件
incomeInvoiceEntity.setField0139(jsonObject.getString("xmlurl"));//发票文件
List<IncomeInvoiceEntity> list = incomeInvoiceDao.queryOaZb(incomeInvoiceEntity);
if(list != null && list.size() == 1){
incomeInvoiceEntity.setFormmainId(list.get(0).getDataId());
@ -543,7 +513,9 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
stringBuffer.append("<column id=\"field0021\" type=\"0\" name=\"收款人\" isNullable=\"false\" length=\"100\"/>");
stringBuffer.append("<column id=\"field0022\" type=\"0\" name=\"复核人\" isNullable=\"false\" length=\"100\"/>");
stringBuffer.append("<column id=\"field0033\" type=\"0\" name=\"合同编号\" isNullable=\"false\" length=\"100\"/>");
stringBuffer.append("<column id=\"field0034\" type=\"0\" name=\"发票文件\" isNullable=\"false\" length=\"20\"/>");
stringBuffer.append("<column id=\"field0034\" type=\"0\" name=\"发票文件1\" isNullable=\"false\" length=\"20\"/>");
stringBuffer.append("<column id=\"field0035\" type=\"0\" name=\"发票文件2\" isNullable=\"false\" length=\"20\"/>");
stringBuffer.append("<column id=\"field0036\" type=\"0\" name=\"发票文件3\" isNullable=\"false\" length=\"20\"/>");
stringBuffer.append("</definitions>");
stringBuffer.append("<values>");
@ -635,8 +607,19 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
stringBuffer.append(jsonObject.getString("htbm") != null?"<![CDATA["+jsonObject.getString("htbm")+"]]>":"");
stringBuffer.append("</value>").append("</column>");
stringBuffer.append("<column name=\"发票文件\">").append("<value>");
stringBuffer.append(jsonObject.getString("fpwj") != null?"<![CDATA["+jsonObject.getString("url")+"]]>":"");
stringBuffer.append("<column name=\"发票文件1\">").append("<value>");
//stringBuffer.append(jsonObject.getString("url") != null?"<![CDATA["+jsonObject.getString("url")+"]]>":"");
stringBuffer.append("");
stringBuffer.append("</value>").append("</column>");
stringBuffer.append("<column name=\"发票文件2\">").append("<value>");
//stringBuffer.append(jsonObject.getString("ofdurl") != null?"<![CDATA["+jsonObject.getString("ofdurl")+"]]>":"");
stringBuffer.append("");
stringBuffer.append("</value>").append("</column>");
stringBuffer.append("<column name=\"发票文件3\">").append("<value>");
//stringBuffer.append(jsonObject.getString("xmlurl") != null?"<![CDATA["+jsonObject.getString("xmlurl")+"]]>":"");
stringBuffer.append("");
stringBuffer.append("</value>").append("</column>");
@ -749,10 +732,14 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
* @return com.hzya.frame.web.entity.JsonResultEntity
**/
private JsonResultEntity sendFinancialReport(String ztbm ,String cjzq,String rwbm) {
String access_token = getToken();
String access_token = "";
if(flags){
access_token = getToken();
if (access_token == null) {
return BaseResult.getFailureMessageEntity("token获取失败");
}
}
String url = cbUrl+access_token;
Date date = null;
@ -820,9 +807,12 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
}
//拼接数据
JSONObject sendData = new JSONObject();
sendData.put("accessKey",accessKey);
long timestamp = System.currentTimeMillis();
if(flags){
sendData.put("accessKey",accessKey);
sendData.put("timestamp",timestamp);
}
sendData.put("taskNo",rwbm);
sendData.put("period",cjzq);
@ -974,9 +964,10 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
reportList.add(xjll);
sendData.put("reportList",reportList);
if(flags) {
String a = YzfSignUtil.signRequest(sendData,accessSecret);
sendData.put("sign",a);
}
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json; charset=utf-8");
String returndata = sendPost(url, headers, sendData.toJSONString());