|
|
|
@ -175,7 +175,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
// 随机生成32位批次号
|
|
|
|
|
String batchNo = getBatchNo(); |
|
|
|
|
stateData.setBatchNo(batchNo); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
stateData.setStatusChangeDateBegin(getStateBeginTime(taxno, "12")); |
|
|
|
|
stateData.setStatusChangeDateEnd(getEndTime()); |
|
|
|
|
stateData.setStartRow(1); |
|
|
|
@ -246,16 +245,13 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// 查询数据库 遍历数据源
|
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
List<String> dbList = confirmDao.getDbSource(); |
|
|
|
|
for (String db : dbList) { |
|
|
|
|
String dataExchangeId = getDataExchangeId(); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
// 查询认证申请记录表中状态为N的批次号
|
|
|
|
|
List<TDxCustomsApplyRecord> list = tDxCustomsRecordDao.getBatchNo("1"); |
|
|
|
|
if (list != null && list.size() > 0) { |
|
|
|
|
for (TDxCustomsApplyRecord tDxCustomsApplyRecord : list) { |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
//判断是否为大企业税号
|
|
|
|
|
BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper<BasisSysDeptCfg>().eq("nsrsbh", tDxCustomsApplyRecord.getGfTaxNo())); |
|
|
|
|
if (baseSysDeptCfg != null) { |
|
|
|
@ -314,7 +310,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
// 转换失败原因
|
|
|
|
|
String failCode = exchangeFailCode(legalizeResult.getFailureReason()); |
|
|
|
|
legalizeResult.setFailureReason(failCode); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
if ("2".equals(legalizeResult.getRzlx())) { |
|
|
|
|
// 退税认证
|
|
|
|
|
customsLog.setType("7"); |
|
|
|
@ -382,7 +377,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxHttpLog.setStatus("2"); |
|
|
|
|
confirmDao.insert(tDxHttpLog); |
|
|
|
|
e.printStackTrace(); |
|
|
|
@ -408,22 +402,18 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
tDxHttpLog.setType("13"); |
|
|
|
|
try { |
|
|
|
|
// 查询数据库 遍历数据源
|
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
List<String> dbList = confirmDao.getDbSource(); |
|
|
|
|
for (String db : dbList) { |
|
|
|
|
String dataExchangeId = getDataExchangeId(); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
// 查询汇总需要发送认证缴款书的税号
|
|
|
|
|
List<String> taxList = tDxCustomsRecordDao.getNeedSendTaxNo(); |
|
|
|
|
for (String taxno : taxList) { |
|
|
|
|
TAcOrg org = selectIdAndKey(taxno); |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
//判断是否为大企业税号
|
|
|
|
|
BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper<BasisSysDeptCfg>().eq("nsrsbh", taxno)); |
|
|
|
|
if (baseSysDeptCfg != null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
// 通过税号查询发票数据
|
|
|
|
|
// 查询需要发送认证的缴款书
|
|
|
|
|
int count = tDxCustomsRecordDao.getApplyCustomsCount(taxno); |
|
|
|
@ -482,7 +472,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
tDxHttpLog.setResText(responseJson); |
|
|
|
|
tDxHttpLog.setResDate(new Date()); |
|
|
|
|
log.info("响应请求数据为=" + responseJson); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
try { |
|
|
|
|
if (responseJson != null) { |
|
|
|
|
ResponesJson gatherData = |
|
|
|
@ -530,23 +519,19 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
tDxHttpLog.setType("15"); |
|
|
|
|
try { |
|
|
|
|
// 查询数据库 遍历数据源
|
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
List<String> dbList = confirmDao.getDbSource(); |
|
|
|
|
for (String db : dbList) { |
|
|
|
|
// 流水号
|
|
|
|
|
String dataExchangeId = getDataExchangeId(); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
// 查询汇总需要发送录入缴款书的税号
|
|
|
|
|
List<String> taxList = tDxCustomsRecordDao.getNeedUploadTaxNo(); |
|
|
|
|
for (String taxno : taxList) { |
|
|
|
|
TAcOrg org = selectIdAndKey(taxno); |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
//判断是否为大企业税号
|
|
|
|
|
BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper<BasisSysDeptCfg>().eq("nsrsbh",taxno)); |
|
|
|
|
if (baseSysDeptCfg != null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
// 通过税号查询发票数据// 查询需要发送录入的缴款书
|
|
|
|
|
int count = tDxCustomsRecordDao.getUploadCustomsCount(taxno); |
|
|
|
|
if (count > 0) { |
|
|
|
@ -594,7 +579,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
tDxHttpLog.setResText(responseJson); |
|
|
|
|
tDxHttpLog.setResDate(new Date()); |
|
|
|
|
log.info("响应请求数据为=" + responseJson); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
try { |
|
|
|
|
if (responseJson != null) { |
|
|
|
|
ResponesJson gatherData = |
|
|
|
@ -644,16 +628,13 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// 查询数据库 遍历数据源
|
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
List<String> dbList = confirmDao.getDbSource(); |
|
|
|
|
for (String db : dbList) { |
|
|
|
|
String dataExchangeId = getDataExchangeId(); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
// 查询录入申请记录表中状态为N的批次号
|
|
|
|
|
List<TDxCustomsApplyRecord> list = tDxCustomsRecordDao.getBatchNo("2"); |
|
|
|
|
if (list != null && list.size() > 0) { |
|
|
|
|
for (TDxCustomsApplyRecord tDxCustomsApplyRecord : list) { |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
//判断是否为大企业税号
|
|
|
|
|
BasisSysDeptCfg baseSysDeptCfg = basisSysDeptCfgDao.selectOne(new QueryWrapper<BasisSysDeptCfg>().eq("nsrsbh", tDxCustomsApplyRecord.getGfTaxNo())); |
|
|
|
|
if (baseSysDeptCfg != null) { |
|
|
|
@ -723,7 +704,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} else if ("5".equals(uploadBackInfo.getAuthState())) { |
|
|
|
|
updateRecord.setCollectUploadStatus("3"); |
|
|
|
|
} |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxCustomsRecordDao.updateUploadResult(updateRecord); |
|
|
|
|
tDxCustomsRecordDao.updateApply(uploadBackInfo.getCustomsCode(), "2"); |
|
|
|
|
|
|
|
|
@ -732,7 +712,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
DynamicContextHolder.push(DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxHttpLog.setStatus("2"); |
|
|
|
|
confirmDao.insert(tDxHttpLog); |
|
|
|
|
e.printStackTrace(); |
|
|
|
@ -778,7 +757,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getBeginTime(String taxno, String db) { |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
String lastTime = tDxCustomsRecordDao.selectLastCustomsDate(taxno); |
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); |
|
|
|
|
if (lastTime == null || "".equals(lastTime)) { |
|
|
|
@ -852,7 +830,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private TAcOrg selectIdAndKey(String taxno) { |
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
// 通过税号查询id和Key
|
|
|
|
|
return confirmDao.findIdAndKeyByTaxno(taxno); |
|
|
|
|
} |
|
|
|
@ -874,7 +851,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
for (CustomsInfo info : list) { |
|
|
|
|
|
|
|
|
|
// 判断库里是否已经存在,存在则只更新状态更新时间,认证状态以及相关字段更新
|
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); |
|
|
|
|
TDxCustomsRecordJob entity = tDxCustomsRecordDao.getByCustomsCode(info.getCustomsNo()); |
|
|
|
|
int export = tDxCustomsRecordDao.getExportByCustomsCode(info.getCustomsNo()); |
|
|
|
|
|
|
|
|
@ -960,7 +936,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (flag) { |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxCustomsRecordDao.updateCustoms(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -974,7 +949,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
record.setCompany(company); |
|
|
|
|
record.setGfName(taxName); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxCustomsRecordDao.insert(record); |
|
|
|
|
CustomsLog customsLog = new CustomsLog(); |
|
|
|
|
customsLog.setCustomsCode(info.getCustomsNo()); |
|
|
|
@ -988,7 +962,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
httpLog.setStatus("1"); |
|
|
|
|
httpLog.setTotal(total); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
confirmDao.insert(httpLog); |
|
|
|
|
|
|
|
|
|
if (logList.size() > 0) { |
|
|
|
@ -996,7 +969,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
httpLog.setStatus("2"); |
|
|
|
|
httpLog.setTotal(total); |
|
|
|
|
confirmDao.insert(httpLog); |
|
|
|
@ -1045,13 +1017,11 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxCustomsRecordDao.updateCustomsState(state); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
// 更新发票数据
|
|
|
|
|
state.setBdkStatus("0"); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
tDxCustomsRecordDao.updateCustomsState(state); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1066,7 +1036,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} |
|
|
|
|
tDxHttpLog.setStatus("1"); |
|
|
|
|
tDxHttpLog.setTotal(total); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
confirmDao.insert(tDxHttpLog); |
|
|
|
|
if (logList.size() > 0) { |
|
|
|
|
logService.toCustomsLog(logList); |
|
|
|
@ -1075,7 +1044,6 @@ public class CustomsInterfaceServiceImpl implements CustomsInterfaceService { |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
tDxHttpLog.setStatus("2"); |
|
|
|
|
tDxHttpLog.setTotal(total); |
|
|
|
|
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); |
|
|
|
|
confirmDao.insert(tDxHttpLog); |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|