|
@@ -158,11 +158,14 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|
|
public void updateInvoice() throws JsonProcessingException {
|
|
public void updateInvoice() throws JsonProcessingException {
|
|
|
|
|
|
|
|
//查询所有未开票的
|
|
//查询所有未开票的
|
|
|
- List<Map<String,Object>> invoiceList= jdbcTemplate.queryForList("SELECT bw_djbh FROM `rpt_financial_month_summary` where bw_djbh is not null and bw_dzfp_pdf_url is null");
|
|
|
|
|
|
|
+ List<Map<String,Object>> invoiceList= jdbcTemplate.queryForList("SELECT bw_djbh FROM `rpt_financial_month_summary` where bw_djbh <> ''\n" +
|
|
|
|
|
+ " and ( bw_dzfp_pdf_url = '' or bw_dzfp_pdf_url is null)");
|
|
|
for(int i=0;i<invoiceList.size();i++){
|
|
for(int i=0;i<invoiceList.size();i++){
|
|
|
// 1.组装查询的报文
|
|
// 1.组装查询的报文
|
|
|
JSONObject content = new JSONObject();
|
|
JSONObject content = new JSONObject();
|
|
|
- String djbh=invoiceList.get(i).get("bw_djbh").toString();
|
|
|
|
|
|
|
+ Object djbhObj = invoiceList.get(i).get("bw_djbh");
|
|
|
|
|
+ if(djbhObj == null) continue; // 跳过null值
|
|
|
|
|
+ String djbh=djbhObj.toString();
|
|
|
content.put("djbh",djbh);
|
|
content.put("djbh",djbh);
|
|
|
String contentBase64 = Base64Util.encode(content.toJSONString());
|
|
String contentBase64 = Base64Util.encode(content.toJSONString());
|
|
|
// 3. 构建签名参数,生成签名值
|
|
// 3. 构建签名参数,生成签名值
|
|
@@ -185,20 +188,29 @@ public class InvoiceServiceImpl implements InvoiceService {
|
|
|
new TypeReference<Map<String, Object>>() {}
|
|
new TypeReference<Map<String, Object>>() {}
|
|
|
);
|
|
);
|
|
|
Map<String, Object> dataMap= new HashMap<>();
|
|
Map<String, Object> dataMap= new HashMap<>();
|
|
|
- if(StringUtils.isNotBlank(invoiceMap.get("data").toString())){
|
|
|
|
|
|
|
+ // 安全地获取data字段
|
|
|
|
|
+ Object dataObj = invoiceMap.get("data");
|
|
|
|
|
+ if(dataObj != null && StringUtils.isNotBlank(dataObj.toString())){
|
|
|
dataMap = objectMapper.readValue(
|
|
dataMap = objectMapper.readValue(
|
|
|
- Base64Util.decode(invoiceMap.get("data").toString()),
|
|
|
|
|
|
|
+ Base64Util.decode(dataObj.toString()),
|
|
|
new TypeReference<Map<String, Object>>() {}
|
|
new TypeReference<Map<String, Object>>() {}
|
|
|
);
|
|
);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
//这里 需要将查询到的信息进行回写月度报表里面
|
|
//这里 需要将查询到的信息进行回写月度报表里面
|
|
|
- if("0".equals(invoiceMap.get("code").toString())){
|
|
|
|
|
|
|
+ Object codeObj = invoiceMap.get("code");
|
|
|
|
|
+ if(codeObj != null && "0".equals(codeObj.toString())){
|
|
|
RptFinancialMonthSummary rptFinancialMonthSummary= new RptFinancialMonthSummary();
|
|
RptFinancialMonthSummary rptFinancialMonthSummary= new RptFinancialMonthSummary();
|
|
|
rptFinancialMonthSummary.setBwDjbh(djbh);
|
|
rptFinancialMonthSummary.setBwDjbh(djbh);
|
|
|
- rptFinancialMonthSummary.setBwDzfpPdfUrl(dataMap.get("ofd").toString());
|
|
|
|
|
- rptFinancialMonthSummary.setBwDzfpOfdUrl(dataMap.get("pdf").toString());
|
|
|
|
|
- rptFinancialMonthSummary.setBwDzfpXmlUrl(dataMap.get("xml").toString());
|
|
|
|
|
|
|
+ // 安全地获取文件URL,避免空指针异常
|
|
|
|
|
+ if(dataMap.get("pdf") != null) {
|
|
|
|
|
+ rptFinancialMonthSummary.setBwDzfpPdfUrl(dataMap.get("pdf").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dataMap.get("ofd") != null) {
|
|
|
|
|
+ rptFinancialMonthSummary.setBwDzfpOfdUrl(dataMap.get("ofd").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ if(dataMap.get("xml") != null) {
|
|
|
|
|
+ rptFinancialMonthSummary.setBwDzfpXmlUrl(dataMap.get("xml").toString());
|
|
|
|
|
+ }
|
|
|
rptFinancialMonthSummaryService.updateRptFinancialMonthSummaryByInvoice(rptFinancialMonthSummary);
|
|
rptFinancialMonthSummaryService.updateRptFinancialMonthSummaryByInvoice(rptFinancialMonthSummary);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|