Compare commits

...

4 Commits

Author SHA1 Message Date
lvleigang 8ab88a9acb 物料对称修改 2025-04-27 18:04:44 +08:00
lvleigang 3e83641a27 Merge branch 'ht' of http://ufidahz.com.cn:9015/hzya/kangarooDataCenterV3 into ht
 Conflicts:
	base-buildpackage/src/main/java/com/hzya/frame/plugin/incomeInvoiceData/service/impl/IncomeInvoiceServiceImpl.java
2025-04-27 17:14:32 +08:00
lvleigang e2e5e0ab26 物料对称修改 2025-04-27 17:12:31 +08:00
lvleigang 3353efa831 财报代码编写 2025-04-27 08:43:12 +08:00
5 changed files with 139 additions and 107 deletions

View File

@ -15,6 +15,8 @@ public class IncomeInvoiceEntity extends BaseEntity {
private String field0128; private String field0128;
private String field0129; private String field0129;
private String field0130; private String field0130;
private String field0138;
private String field0139;
private String field0003; private String field0003;
@ -121,5 +123,21 @@ public class IncomeInvoiceEntity extends BaseEntity {
public void setField0003(String field0003) { public void setField0003(String field0003) {
this.field0003 = 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="field0128 != null and field0128 != ''"> field0128 = #{field0128},</if>
<if test="field0129 != null and field0129 != ''"> field0129 = #{field0129},</if> <if test="field0129 != null and field0129 != ''"> field0129 = #{field0129},</if>
<if test="field0130 != null and field0130 != ''"> field0130 = #{field0130},</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> </trim>
where id = #{dataId} where id = #{dataId}
</update> </update>
@ -208,6 +210,8 @@
<if test="field0128 != null and field0128 != ''">field0128 ,</if> <if test="field0128 != null and field0128 != ''">field0128 ,</if>
<if test="field0129 != null and field0129 != ''">field0129 ,</if> <if test="field0129 != null and field0129 != ''">field0129 ,</if>
<if test="field0130 != null and field0130 != ''">field0130 ,</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> </trim>
)values( )values(
@ -218,6 +222,8 @@
<if test="field0128 != null and field0128 != ''">#{field0128} ,</if> <if test="field0128 != null and field0128 != ''">#{field0128} ,</if>
<if test="field0129 != null and field0129 != ''">#{field0129} ,</if> <if test="field0129 != null and field0129 != ''">#{field0129} ,</if>
<if test="field0130 != null and field0130 != ''">#{field0130} ,</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> </trim>
) )
</insert> </insert>

View File

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

View File

@ -63,14 +63,24 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
this.incomeInvoiceDao = dao; this.incomeInvoiceDao = dao;
this.dao = dao; this.dao = dao;
} }
boolean flags = true;
String uploadBalanceTableUrl = "http://oapi.nanofintax.com/api/collect/uploadBalanceTable?accessToken";
String cbUrl = "http://oapi.nanofintax.com/api/collect/uploadFinancialReport?accessToken="; 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 uploadBalanceTableUrl = "http://oapi.nanofintax.com/api/collect/uploadBalanceTable?accessToken";
String tokenUrl = "http://oapi.nanofintax.com/api/getToken"; String tokenUrl = "http://oapi.nanofintax.com/api/getToken";
String accessKey = "6X3B526P5HqE6ums"; String accessKey = "6X3B526P5HqE6ums";
String accessSecret = "34e5fc32ac894a2ba2ade8c3852c7a0a"; String accessSecret = "34e5fc32ac894a2ba2ade8c3852c7a0a";
String taxNo = "91330110MAC5FPUY2U"; String taxNo = "91330110MAC5FPUY2U";
Integer size = 50; 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 @Resource
private TaskExecutor taskExecutor; private TaskExecutor taskExecutor;
/** /**
@ -83,10 +93,13 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
@Override @Override
public JsonResultEntity getIncomeInvoiceData(JSONObject requestJson) { public JsonResultEntity getIncomeInvoiceData(JSONObject requestJson) {
//1调用token //1调用token
String access_token = getToken(); String access_token = "";
if(flags){
access_token = getToken();
if (access_token == null) { if (access_token == null) {
return BaseResult.getFailureMessageEntity("token获取失败"); return BaseResult.getFailureMessageEntity("token获取失败");
} }
}
Date date = new Date(); Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String times = sdf.format(date); String times = sdf.format(date);
@ -155,9 +168,9 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
saveData.put("kpr",content.getString("kpr")); saveData.put("kpr",content.getString("kpr"));
saveData.put("skr",content.getString("skr")); saveData.put("skr",content.getString("skr"));
saveData.put("fhr",content.getString("fhr")); saveData.put("fhr",content.getString("fhr"));
saveData.put("url",content.getString("url")); saveData.put("url",content.getOrDefault("url","http://prd-cabinet-1257122416.cos.ap-shanghai.myqcloud.com/recv-open-input-1313818348185971712-1362629996254053632.pdf"));
saveData.put("ofdurl",content.getString("ofdUrl")); saveData.put("ofdurl",content.getOrDefault("ofdUrl","http://prd-cabinet-1257122416.cos.ap-shanghai.myqcloud.com/recv-open-input-1313818348185971712-1362629996254053632.pdf"));
saveData.put("xmlurl",content.getString("xmlUrl")); saveData.put("xmlurl",content.getOrDefault("xmlUrl","http://prd-cabinet-1257122416.cos.ap-shanghai.myqcloud.com/recv-open-input-1313818348185971712-1362630000427386112.xml"));
saveData.put("htbh",content.getString("contraceNumber")); saveData.put("htbh",content.getString("contraceNumber"));
JSONArray detaildata = content.getJSONArray("items"); JSONArray detaildata = content.getJSONArray("items");
@ -210,6 +223,8 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
} }
} }
return BaseResult.getSuccessMessageEntity("处理成功"); return BaseResult.getSuccessMessageEntity("处理成功");
} }
@ -226,21 +241,26 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
private void sendBusinessData(JSONArray datalist, String access_token, Integer queryCursor, String dataTime) { private void sendBusinessData(JSONArray datalist, String access_token, Integer queryCursor, String dataTime) {
String url = dataUrl+access_token; String url = dataUrl+access_token;
JSONObject dayabody = new JSONObject(); JSONObject dayabody = new JSONObject();
dayabody.put("accessKey",accessKey);
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
if(flags) {
dayabody.put("accessKey",accessKey);
dayabody.put("timestamp",timestamp); dayabody.put("timestamp",timestamp);
}
JSONObject queryParams = new JSONObject(); JSONObject queryParams = new JSONObject();
queryParams.put("page",queryCursor); queryParams.put("page",queryCursor);
queryParams.put("size",size); queryParams.put("size",size);
//queryParams.put("kprqq",dataTime); queryParams.put("kprqq",dataTime);
//queryParams.put("kprqz",dataTime); queryParams.put("kprqz",dataTime);
queryParams.put("taxNo",taxNo); queryParams.put("taxNo",taxNo);
dayabody.put("queryParams",queryParams); dayabody.put("queryParams",queryParams);
if(flags) {
Map<String, Object> parametersMap = new HashMap<>(); Map<String, Object> parametersMap = new HashMap<>();
parametersMap.put("accessKey",accessKey); parametersMap.put("accessKey",accessKey);
parametersMap.put("timestamp",timestamp); parametersMap.put("timestamp",timestamp);
String a = YzfSignUtil.signRequest(parametersMap,accessSecret); String a = YzfSignUtil.signRequest(parametersMap,accessSecret);
dayabody.put("sign",a); dayabody.put("sign",a);
}
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json; charset=utf-8"); headers.put("Content-Type", "application/json; charset=utf-8");
String returndata = sendPost(url, headers, dayabody.toJSONString()); String returndata = sendPost(url, headers, dayabody.toJSONString());
@ -408,56 +428,6 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
return body.toString(); 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();
}
/** /**
@ -491,7 +461,9 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
incomeInvoiceEntity.setField0127(jsonObject.getString("fpdm"));//发票代码 incomeInvoiceEntity.setField0127(jsonObject.getString("fpdm"));//发票代码
incomeInvoiceEntity.setField0128(jsonObject.getString("fphm"));//发票号码 incomeInvoiceEntity.setField0128(jsonObject.getString("fphm"));//发票号码
incomeInvoiceEntity.setField0129(jsonObject.getString("jshj"));//发票总额 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); List<IncomeInvoiceEntity> list = incomeInvoiceDao.queryOaZb(incomeInvoiceEntity);
if(list != null && list.size() == 1){ if(list != null && list.size() == 1){
incomeInvoiceEntity.setFormmainId(list.get(0).getDataId()); incomeInvoiceEntity.setFormmainId(list.get(0).getDataId());
@ -542,7 +514,9 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
stringBuffer.append("<column id=\"field0021\" type=\"0\" name=\"收款人\" isNullable=\"false\" length=\"100\"/>"); 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=\"field0022\" type=\"0\" name=\"复核人\" isNullable=\"false\" length=\"100\"/>");
stringBuffer.append("<column id=\"field0033\" 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("</definitions>");
stringBuffer.append("<values>"); stringBuffer.append("<values>");
@ -634,8 +608,19 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
stringBuffer.append(jsonObject.getString("htbm") != null?"<![CDATA["+jsonObject.getString("htbm")+"]]>":""); stringBuffer.append(jsonObject.getString("htbm") != null?"<![CDATA["+jsonObject.getString("htbm")+"]]>":"");
stringBuffer.append("</value>").append("</column>"); stringBuffer.append("</value>").append("</column>");
stringBuffer.append("<column name=\"发票文件\">").append("<value>"); stringBuffer.append("<column name=\"发票文件1\">").append("<value>");
stringBuffer.append(jsonObject.getString("fpwj") != null?"<![CDATA["+jsonObject.getString("url")+"]]>":""); //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>"); stringBuffer.append("</value>").append("</column>");
@ -798,10 +783,14 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
* @return com.hzya.frame.web.entity.JsonResultEntity * @return com.hzya.frame.web.entity.JsonResultEntity
**/ **/
private JsonResultEntity sendFinancialReport(String ztbm ,String cjzq,String rwbm) { 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) { if (access_token == null) {
return BaseResult.getFailureMessageEntity("token获取失败"); return BaseResult.getFailureMessageEntity("token获取失败");
} }
}
String url = cbUrl+access_token; String url = cbUrl+access_token;
Date date = null; Date date = null;
@ -869,9 +858,12 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
} }
//拼接数据 //拼接数据
JSONObject sendData = new JSONObject(); JSONObject sendData = new JSONObject();
sendData.put("accessKey",accessKey);
long timestamp = System.currentTimeMillis(); long timestamp = System.currentTimeMillis();
if(flags){
sendData.put("accessKey",accessKey);
sendData.put("timestamp",timestamp); sendData.put("timestamp",timestamp);
}
sendData.put("taskNo",rwbm); sendData.put("taskNo",rwbm);
sendData.put("period",cjzq); sendData.put("period",cjzq);
@ -1023,9 +1015,10 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
reportList.add(xjll); reportList.add(xjll);
sendData.put("reportList",reportList); sendData.put("reportList",reportList);
if(flags) {
String a = YzfSignUtil.signRequest(sendData,accessSecret); String a = YzfSignUtil.signRequest(sendData,accessSecret);
sendData.put("sign",a); sendData.put("sign",a);
}
Map<String, String> headers = new HashMap<>(); Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json; charset=utf-8"); headers.put("Content-Type", "application/json; charset=utf-8");
String returndata = sendPost(url, headers, sendData.toJSONString()); String returndata = sendPost(url, headers, sendData.toJSONString());

69
pom.xml
View File

@ -125,6 +125,11 @@
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>${httpclient.version}</version> <version>${httpclient.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId> <artifactId>spring-boot-starter-cache</artifactId>
@ -417,6 +422,16 @@
<artifactId>alibaba-dingtalk-service-sdk</artifactId> <artifactId>alibaba-dingtalk-service-sdk</artifactId>
<version>2.0.0</version> <version>2.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version> <!-- 这里的版本号可根据实际情况修改 -->
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -467,33 +482,33 @@
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<configuration> <configuration>
<webResources> <webResources>
<resource> <!-- <resource>-->
<directory>${basedir}/../base-service/src/main/webapp/WEB-INF/lib</directory> <!-- <directory>${basedir}/../base-service/src/main/webapp/WEB-INF/lib</directory>-->
<targetPath>WEB-INF/lib/</targetPath> <!-- <targetPath>WEB-INF/lib/</targetPath>-->
<filtering>false</filtering> <!-- <filtering>false</filtering>-->
<includes> <!-- <includes>-->
<!-- 匹配所有jar包 --> <!-- &lt;!&ndash; 匹配所有jar包 &ndash;&gt;-->
<include>**/*.jar</include> <!-- <include>**/*.jar</include>-->
</includes> <!-- </includes>-->
</resource> <!-- </resource>-->
<resource> <!-- <resource>-->
<directory>${basedir}/../fw-bip/src/main/webapp/WEB-INF/lib</directory> <!-- <directory>${basedir}/../fw-bip/src/main/webapp/WEB-INF/lib</directory>-->
<targetPath>WEB-INF/lib/</targetPath> <!-- <targetPath>WEB-INF/lib/</targetPath>-->
<filtering>false</filtering> <!-- <filtering>false</filtering>-->
<includes> <!-- <includes>-->
<!-- 匹配所有jar包 --> <!-- &lt;!&ndash; 匹配所有jar包 &ndash;&gt;-->
<include>**/*.jar</include> <!-- <include>**/*.jar</include>-->
</includes> <!-- </includes>-->
</resource> <!-- </resource>-->
<resource> <!-- <resource>-->
<directory>${basedir}/../fw-ningbobank/src/main/webapp/WEB-INF/lib</directory> <!-- <directory>${basedir}/../fw-ningbobank/src/main/webapp/WEB-INF/lib</directory>-->
<targetPath>WEB-INF/lib/</targetPath> <!-- <targetPath>WEB-INF/lib/</targetPath>-->
<filtering>false</filtering> <!-- <filtering>false</filtering>-->
<includes> <!-- <includes>-->
<!-- 匹配所有jar包 --> <!-- &lt;!&ndash; 匹配所有jar包 &ndash;&gt;-->
<include>**/*.jar</include> <!-- <include>**/*.jar</include>-->
</includes> <!-- </includes>-->
</resource> <!-- </resource>-->
</webResources> </webResources>
</configuration> </configuration>
</plugin> </plugin>