物料对称修改
This commit is contained in:
parent
e3aee87674
commit
3e0f30bcc0
|
@ -30,11 +30,14 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
import org.apache.http.ssl.SSLContextBuilder;
|
||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.checkerframework.checker.units.qual.A;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import com.hzya.frame.basedao.service.impl.BaseService;
|
import com.hzya.frame.basedao.service.impl.BaseService;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
@ -59,6 +62,7 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
||||||
this.incomeInvoiceDao = dao;
|
this.incomeInvoiceDao = dao;
|
||||||
this.dao = dao;
|
this.dao = dao;
|
||||||
}
|
}
|
||||||
|
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 tokenUrl = "http://oapi.nanofintax.com/api/getToken";
|
||||||
String accessKey = "6X3B526P5HqE6ums";
|
String accessKey = "6X3B526P5HqE6ums";
|
||||||
|
@ -83,7 +87,6 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
||||||
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);
|
||||||
times = "2025-03-25";
|
|
||||||
//2、调用接口获取数据
|
//2、调用接口获取数据
|
||||||
Integer queryCursor = 1;
|
Integer queryCursor = 1;
|
||||||
JSONArray datalist = new JSONArray();
|
JSONArray datalist = new JSONArray();
|
||||||
|
@ -727,95 +730,165 @@ public class IncomeInvoiceServiceImpl extends BaseService<IncomeInvoiceEntity, S
|
||||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||||
**/
|
**/
|
||||||
private JsonResultEntity sendFinancialReport(JSONObject businessData) {
|
private JsonResultEntity sendFinancialReport(JSONObject businessData) {
|
||||||
|
String access_token = getToken();
|
||||||
|
if (access_token == null) {
|
||||||
|
return BaseResult.getFailureMessageEntity("token获取失败");
|
||||||
|
}
|
||||||
|
String url = cbUrl+access_token;
|
||||||
|
String ztbm = businessData.getString("field0005");//账套编码
|
||||||
|
String sh = businessData.getString("field0006");//税号
|
||||||
|
String sjlx = businessData.getString("field0007");//数据类型
|
||||||
|
String cjzq = businessData.getString("field0008");//采集账期
|
||||||
|
String rwbm = businessData.getString("field0009");//任务编码
|
||||||
|
if(ztbm == null || "".equals(ztbm)){
|
||||||
|
return BaseResult.getSuccessMessageEntity("账套编码为空");
|
||||||
|
}
|
||||||
|
if(cjzq == null || "".equals(cjzq)){
|
||||||
|
return BaseResult.getSuccessMessageEntity("采集账期为空");
|
||||||
|
}
|
||||||
|
if(rwbm == null || "".equals(rwbm)){
|
||||||
|
return BaseResult.getSuccessMessageEntity("任务编码为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Date date = null;
|
||||||
|
String qncjzq = null;
|
||||||
|
|
||||||
|
IncomeInvoiceEntity dyAloneId = null;
|
||||||
|
JSONObject dydata = null;
|
||||||
|
JSONObject qndata = null;
|
||||||
|
IncomeInvoiceEntity qnAloneId = null;
|
||||||
|
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
||||||
|
try {
|
||||||
|
date = sdf.parse(cjzq);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
return BaseResult.getSuccessMessageEntity("采集账期格式错误");
|
||||||
|
}
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(date);
|
||||||
|
calendar.add(Calendar.YEAR, -1);
|
||||||
|
Date qn = calendar.getTime();
|
||||||
|
qncjzq = sdf.format(qn);
|
||||||
|
|
||||||
|
//查询当月帐套组织
|
||||||
|
IncomeInvoiceEntity jnentity = new IncomeInvoiceEntity();
|
||||||
|
jnentity.setDataSourceCode("");
|
||||||
|
jnentity.setSysData(cjzq);
|
||||||
|
jnentity.setOrgCode(ztbm);
|
||||||
|
List<IncomeInvoiceEntity> jnlist = incomeInvoiceDao.queryZtzz(jnentity);
|
||||||
|
if(jnlist != null && jnlist.size() == 1){
|
||||||
|
dyAloneId = jnlist.get(0);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getSuccessMessageEntity("未查询到当月的财报数据,不推送");
|
||||||
|
}
|
||||||
|
//查询去年当帐套组织
|
||||||
|
IncomeInvoiceEntity qnentity = new IncomeInvoiceEntity();
|
||||||
|
qnentity.setDataSourceCode("");
|
||||||
|
qnentity.setSysData(qncjzq);
|
||||||
|
qnentity.setOrgCode(ztbm);
|
||||||
|
List<IncomeInvoiceEntity> qnlist = incomeInvoiceDao.queryZtzz(qnentity);
|
||||||
|
if(qnlist != null && qnlist.size() == 1){
|
||||||
|
qnAloneId = qnlist.get(0);
|
||||||
|
}else {
|
||||||
|
logger.info("未查询到去年当期的财报数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
//查询当月的财报数据
|
||||||
|
IncomeInvoiceEntity jnquerydata = new IncomeInvoiceEntity();
|
||||||
|
jnquerydata.setDataSourceCode("");
|
||||||
|
jnquerydata.setAloneId(dyAloneId.getAloneId());
|
||||||
|
List<JSONObject> dydataList = incomeInvoiceDao.queryByAloneId(jnquerydata);
|
||||||
|
if(dydataList != null && dydataList.size() == 1){
|
||||||
|
dydata = dydataList.get(0);
|
||||||
|
}else {
|
||||||
|
return BaseResult.getSuccessMessageEntity("未查询到当月的财报数据,不推送");
|
||||||
|
}
|
||||||
|
//查询去年当期的财报数据
|
||||||
|
if(qnAloneId != null){
|
||||||
|
//查找去年数据
|
||||||
|
IncomeInvoiceEntity qnquerydata = new IncomeInvoiceEntity();
|
||||||
|
qnquerydata.setDataSourceCode("");
|
||||||
|
qnquerydata.setAloneId(qnAloneId.getAloneId());
|
||||||
|
List<JSONObject> qndataList = incomeInvoiceDao.queryByAloneId(qnquerydata);
|
||||||
|
if(qndataList != null && qndataList.size() == 1){
|
||||||
|
qndata = qndataList.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//拼接数据
|
||||||
|
JSONObject sendData = new JSONObject();
|
||||||
|
sendData.put("accessKey",accessKey);
|
||||||
|
long timestamp = System.currentTimeMillis();
|
||||||
|
sendData.put("timestamp",timestamp);
|
||||||
|
sendData.put("taskNo",rwbm);
|
||||||
|
sendData.put("period",cjzq);
|
||||||
|
|
||||||
|
JSONArray reportList = new JSONArray();
|
||||||
|
|
||||||
|
JSONObject zcfzb = new JSONObject();//资产负债表
|
||||||
|
zcfzb.put("period",cjzq);
|
||||||
|
zcfzb.put("reportType",1);
|
||||||
|
JSONArray reportSubjects1 = new JSONArray();
|
||||||
|
setDataToArray("subjectName","12312",1,reportSubjects1);
|
||||||
|
zcfzb.put("reportSubjects",reportSubjects1);
|
||||||
|
|
||||||
|
JSONObject llb = new JSONObject();//利润表
|
||||||
|
llb.put("period",cjzq);
|
||||||
|
llb.put("reportType",2);
|
||||||
|
JSONArray reportSubjects2 = new JSONArray();
|
||||||
|
llb.put("reportSubjects",reportSubjects2);
|
||||||
|
|
||||||
|
JSONObject xjll = new JSONObject();//现金流量表
|
||||||
|
xjll.put("period",cjzq);
|
||||||
|
xjll.put("reportType",3);
|
||||||
|
JSONArray reportSubjects3 = new JSONArray();
|
||||||
|
xjll.put("reportSubjects",reportSubjects3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
reportList.add(zcfzb);
|
||||||
|
reportList.add(llb);
|
||||||
|
reportList.add(xjll);
|
||||||
|
|
||||||
|
sendData.put("reportList",reportList);
|
||||||
|
String a = YzfSignUtil.signRequest(sendData,accessSecret);
|
||||||
|
sendData.put("sign",a);
|
||||||
|
|
||||||
//JSONObject jsonObject = requestJson.getJSONObject("jsonStr");
|
Map<String, String> headers = new HashMap<>();
|
||||||
//String cdDate = null;
|
headers.put("Content-Type", "application/json; charset=utf-8");
|
||||||
//String jnDate = null;
|
String returndata = sendPost(url, headers, sendData.toJSONString());
|
||||||
//String qnDate = null;
|
|
||||||
//String orgCode = "X0644";
|
|
||||||
//IncomeInvoiceEntity dyAloneId = null;
|
|
||||||
//JSONObject dydata = null;
|
|
||||||
//JSONObject qndata = null;
|
|
||||||
//IncomeInvoiceEntity qnAloneId = null;
|
|
||||||
//if(requestJson.getString("orgCode") != null){
|
|
||||||
// orgCode = requestJson.getString("orgCode");
|
|
||||||
//}
|
|
||||||
//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
|
|
||||||
//if(requestJson.getString("year") != null && requestJson.getString("month") != null){
|
|
||||||
// cdDate = requestJson.getString("year") + "-" + requestJson.getString("month");
|
|
||||||
// if("13".equals(requestJson.getString("month"))){
|
|
||||||
// cdDate = requestJson.getString("year") + "-12";
|
|
||||||
// qnDate = (requestJson.getInteger("year")-1) + "-12";
|
|
||||||
// }else {
|
|
||||||
// cdDate = requestJson.getString("year") + "-" + requestJson.getString("month");
|
|
||||||
// qnDate = (requestJson.getInteger("year")-1) + "-" + requestJson.getString("month");
|
|
||||||
// }
|
|
||||||
//}else {
|
|
||||||
// cdDate = sdf.format(new Date());
|
|
||||||
// jnDate = sdf.format(new Date());
|
|
||||||
// Calendar calendar = Calendar.getInstance();
|
|
||||||
// calendar.setTime(new Date());
|
|
||||||
// calendar.add(Calendar.YEAR, -1);
|
|
||||||
// Date qn = calendar.getTime();
|
|
||||||
// qnDate = sdf.format(qn);
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
////查询帐套组织
|
|
||||||
//IncomeInvoiceEntity jnentity = new IncomeInvoiceEntity();
|
|
||||||
//jnentity.setDataSourceCode("");
|
|
||||||
//jnentity.setSysData(jnDate);
|
|
||||||
//jnentity.setOrgCode(orgCode);
|
|
||||||
//List<IncomeInvoiceEntity> jnlist = incomeInvoiceDao.queryZtzz(jnentity);
|
|
||||||
//if(jnlist != null && jnlist.size() == 1){
|
|
||||||
// dyAloneId = jnlist.get(0);
|
|
||||||
//}else {
|
|
||||||
// return BaseResult.getSuccessMessageEntity("未查询到当月的财报数据,不推送");
|
|
||||||
//}
|
|
||||||
////查询帐套组织
|
|
||||||
//IncomeInvoiceEntity qnentity = new IncomeInvoiceEntity();
|
|
||||||
//qnentity.setDataSourceCode("");
|
|
||||||
//qnentity.setSysData(jnDate);
|
|
||||||
//qnentity.setOrgCode(orgCode);
|
|
||||||
//List<IncomeInvoiceEntity> qnlist = incomeInvoiceDao.queryZtzz(qnentity);
|
|
||||||
//if(qnlist != null && qnlist.size() == 1){
|
|
||||||
// qnAloneId = qnlist.get(0);
|
|
||||||
//}else {
|
|
||||||
// logger.info("未查询到当月的财报数据");
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
////查找今年数据
|
|
||||||
//IncomeInvoiceEntity jnquerydata = new IncomeInvoiceEntity();
|
|
||||||
//jnquerydata.setDataSourceCode("");
|
|
||||||
//jnquerydata.setAloneId(dyAloneId.getAloneId());
|
|
||||||
//List<JSONObject> dydataList = incomeInvoiceDao.queryByAloneId(jnquerydata);
|
|
||||||
//if(dydataList != null && dydataList.size() == 1){
|
|
||||||
// dydata = dydataList.get(0);
|
|
||||||
//}else {
|
|
||||||
// return BaseResult.getSuccessMessageEntity("未查询到当月的财报数据,不推送");
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
// //查找去年数据
|
|
||||||
//IncomeInvoiceEntity qnquerydata = new IncomeInvoiceEntity();
|
|
||||||
//qnquerydata.setDataSourceCode("");
|
|
||||||
//qnquerydata.setAloneId(qnAloneId.getAloneId());
|
|
||||||
//List<JSONObject> qndataList = incomeInvoiceDao.queryByAloneId(qnquerydata);
|
|
||||||
//if(qndataList != null && qndataList.size() == 1){
|
|
||||||
// qndata = qndataList.get(0);
|
|
||||||
//}
|
|
||||||
////拼接数据
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//return BaseResult.getSuccessMessageEntity("执行成功");
|
|
||||||
|
|
||||||
|
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 ){
|
||||||
|
if(data != null && data.getString("resultCode") != null && "0".equals( data.getString("resultCode"))){
|
||||||
|
return BaseResult.getSuccessMessageEntity("执行成功");
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("发送失败:"+returndata);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("发送失败:"+returndata);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("发送失败:"+returndata);
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
return BaseResult.getFailureMessageEntity("发送失败:"+returndata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
private void setDataToArray(String subjectName, String value, Integer valueType, JSONArray reportSubjects) {
|
||||||
|
if(value != null && !"".equals(value)){
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("subjectName",subjectName);
|
||||||
|
jsonObject.put("value",new BigDecimal(value));
|
||||||
|
jsonObject.put("valueType",valueType);
|
||||||
|
reportSubjects.add(jsonObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue