|
|
@ -14,7 +14,10 @@ import javax.crypto.spec.SecretKeySpec; |
|
|
|
|
|
|
|
|
|
|
|
import com.dxhy.core.job.thread.InvoiceParseHandle; |
|
|
|
import com.dxhy.core.job.thread.InvoiceParseHandle; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
|
|
|
|
|
|
import org.redisson.api.RLock; |
|
|
|
|
|
|
|
import org.redisson.api.RedissonClient; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
@ -72,6 +75,16 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private Sender sender; |
|
|
|
private Sender sender; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private StringRedisTemplate stringRedisTemplate; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private RedissonClient redisson; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String REDIS_KEY = "collect_invoice_"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int MAX_SIZE = 1000; |
|
|
|
|
|
|
|
|
|
|
|
@Value("${jxjk.collectUrl}") |
|
|
|
@Value("${jxjk.collectUrl}") |
|
|
|
private String collectUrl; |
|
|
|
private String collectUrl; |
|
|
|
@Value("${jxjk.invoiceGet}") |
|
|
|
@Value("${jxjk.invoiceGet}") |
|
|
@ -644,6 +657,9 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { |
|
|
|
String company = tDxRecordInvoiceJobDao.findCompany(taxno); |
|
|
|
String company = tDxRecordInvoiceJobDao.findCompany(taxno); |
|
|
|
List<InvoiceLog> logList = new ArrayList<>(); |
|
|
|
List<InvoiceLog> logList = new ArrayList<>(); |
|
|
|
for (InvoiceSelectInfo invoiceSelectInfo : invoicesList) { |
|
|
|
for (InvoiceSelectInfo invoiceSelectInfo : invoicesList) { |
|
|
|
|
|
|
|
//加分布式锁
|
|
|
|
|
|
|
|
String lockKey = REDIS_KEY + invoiceSelectInfo.getUuid(); |
|
|
|
|
|
|
|
RLock lock = redisson.getLock(lockKey); |
|
|
|
invoiceSelectInfo.setUuid(invoiceSelectInfo.getInvoiceCode() + invoiceSelectInfo.getInvoiceNo()); |
|
|
|
invoiceSelectInfo.setUuid(invoiceSelectInfo.getInvoiceCode() + invoiceSelectInfo.getInvoiceNo()); |
|
|
|
if ("1".equals(invoiceSelectInfo.getLegalizeState())) { |
|
|
|
if ("1".equals(invoiceSelectInfo.getLegalizeState())) { |
|
|
|
//认证处理状态 0-未认证 1-已勾选未确认,2已确认 3 已发送认证 4 认证成功 5 认证失败
|
|
|
|
//认证处理状态 0-未认证 1-已勾选未确认,2已确认 3 已发送认证 4 认证成功 5 认证失败
|
|
|
@ -651,10 +667,15 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
invoiceSelectInfo.setAuthStatus("0"); |
|
|
|
invoiceSelectInfo.setAuthStatus("0"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
boolean isLock = lock.tryLock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!isLock){ |
|
|
|
|
|
|
|
log.info("当前已有线程获取到锁"); |
|
|
|
|
|
|
|
}else { |
|
|
|
// 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新
|
|
|
|
// 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao |
|
|
|
TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); |
|
|
|
.findInvoiceByUUid(invoiceSelectInfo.getUuid()); |
|
|
|
|
|
|
|
if (entity != null) { |
|
|
|
if (entity != null) { |
|
|
|
boolean flag = false; |
|
|
|
boolean flag = false; |
|
|
|
if (StringUtils.isBlank(entity.getCheckCode()) |
|
|
|
if (StringUtils.isBlank(entity.getCheckCode()) |
|
|
@ -765,6 +786,13 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { |
|
|
|
invoiceLog.setInputName("系统自动"); |
|
|
|
invoiceLog.setInputName("系统自动"); |
|
|
|
logList.add(invoiceLog); |
|
|
|
logList.add(invoiceLog); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}catch (Exception e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
//关锁
|
|
|
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
httpLog.setStatus("1"); |
|
|
|
httpLog.setStatus("1"); |
|
|
|
httpLog.setTotal(total); |
|
|
|
httpLog.setTotal(total); |
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|