ariesy 去掉redission相关代码

release
yefei 2 years ago
parent 3c2940dc63
commit 28d64f6b79
  1. 48
      dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java
  2. 237
      dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java

@ -7,27 +7,27 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration //@Configuration
public class RedissionConfig { //public class RedissionConfig {
//
@Value("${spring.redis.host}") // @Value("${spring.redis.host}")
private String host; // private String host;
//
@Value("${spring.redis.port}") // @Value("${spring.redis.port}")
private String port; // private String port;
//
@Value("${spring.redis.password}") // @Value("${spring.redis.password}")
private String redisPassword; // private String redisPassword;
//
@Bean // @Bean
public RedissonClient getRedisson(){ // public RedissonClient getRedisson(){
//
Config config = new Config(); // Config config = new Config();
//单机模式 依次设置redis地址和密码 // //单机模式 依次设置redis地址和密码
config.useSingleServer() // config.useSingleServer()
.setAddress("redis://" + host + ":" + port) // .setAddress("redis://" + host + ":" + port)
.setPassword(redisPassword); // .setPassword(redisPassword);
return Redisson.create(config); // return Redisson.create(config);
} // }
} //}
//

@ -78,8 +78,8 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService {
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@Resource // @Resource
private RedissonClient redisson; // private RedissonClient redisson;
private static final String REDIS_KEY = "collect_invoice_"; private static final String REDIS_KEY = "collect_invoice_";
@ -658,8 +658,8 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService {
List<InvoiceLog> logList = new ArrayList<>(); List<InvoiceLog> logList = new ArrayList<>();
for (InvoiceSelectInfo invoiceSelectInfo : invoicesList) { for (InvoiceSelectInfo invoiceSelectInfo : invoicesList) {
//加分布式锁 //加分布式锁
String lockKey = REDIS_KEY + invoiceSelectInfo.getUuid(); // String lockKey = REDIS_KEY + invoiceSelectInfo.getUuid();
RLock lock = redisson.getLock(lockKey); // 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 认证失败
@ -668,130 +668,131 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService {
invoiceSelectInfo.setAuthStatus("0"); invoiceSelectInfo.setAuthStatus("0");
} }
try { try {
boolean isLock = lock.tryLock(); // boolean isLock = lock.tryLock();
if(!isLock){ // if(!isLock){
log.info("当前已有线程获取到锁"); // log.info("当前已有线程获取到锁");
}else { // }else {
// 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); DynamicContextHolder.push(db + DbConstant.BUSINESS_READ);
TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.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())
&& StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) {
entity.setCheckCode(invoiceSelectInfo.getCheckCode()); entity.setCheckCode(invoiceSelectInfo.getCheckCode());
entity.setCheckDate(new Date()); entity.setCheckDate(new Date());
flag = true; flag = true;
} }
if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) {
entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus());
entity.setStatusUpdateDate(new Date()); entity.setStatusUpdateDate(new Date());
flag = true; flag = true;
} }
if ("0".equals(entity.getRzhYesorno()) if ("0".equals(entity.getRzhYesorno())
&& !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) {
if ("1".equals(invoiceSelectInfo.getRzlx())) { if ("1".equals(invoiceSelectInfo.getRzlx())) {
entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState());
entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate()); entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate());
entity.setRzlx(invoiceSelectInfo.getRzlx()); entity.setRzlx(invoiceSelectInfo.getRzlx());
entity.setRzhType(invoiceSelectInfo.getLegalizeType()); entity.setRzhType(invoiceSelectInfo.getLegalizeType());
entity.setSfygx("1"); entity.setSfygx("1");
if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) { if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) {
SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd"); SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd");
entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate())); entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate()));
}
if ("1".equals(invoiceSelectInfo.getLegalizeState())) {
entity.setAuthStatus("4");
} else {
entity.setAuthStatus("0");
}
entity.setBdkStatus("1");
} else if ("4".equals(invoiceSelectInfo.getRzlx())) {
entity.setRzhYesorno("2");
entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate());
entity.setRzlx(invoiceSelectInfo.getRzlx());
entity.setRzhType(invoiceSelectInfo.getLegalizeType());
entity.setSfygx("1");
if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) {
SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd");
entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate()));
}
if ("1".equals(invoiceSelectInfo.getLegalizeState())) {
entity.setAuthStatus("4");
} else {
entity.setAuthStatus("0");
}
entity.setBdkStatus("2");
} }
flag = true; if ("1".equals(invoiceSelectInfo.getLegalizeState())) {
entity.setAuthStatus("4");
} else if (!"0".equals(entity.getRzhYesorno()) } else {
&& !"1".equals(invoiceSelectInfo.getLegalizeState())) { entity.setAuthStatus("0");
entity.setRzhYesorno("0");
entity.setRzhBelongDate(null);
entity.setRzlx("0");
entity.setRzhType(null);
entity.setRzhDate(null);
entity.setAuthStatus("0");
entity.setBdkStatus("0");
entity.setSfygx("0");
flag = true;
}
//TODO 这块业务不理解??
if ("1".equals(entity.getSourceSystem()) && "0".equals(entity.getCollectStatus())) {
entity.setCollectStatus("1");
entity.setCollectFrom("0");
entity.setCollectDate(new Date());
entity.setPoolStatus("1");
entity.setInPoolReason("数据重复");
flag = true;
}
if (flag) {
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE);
if (StringUtils.isBlank(entity.getInvoiceCode())) {
entity.setInvoiceCode("");
} }
tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); entity.setBdkStatus("1");
} } else if ("4".equals(invoiceSelectInfo.getRzlx())) {
// 艺龙推送数据 entity.setRzhYesorno("2");
if (yLcompany.equals(company)) { entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate());
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); entity.setRzlx(invoiceSelectInfo.getRzlx());
InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao entity.setRzhType(invoiceSelectInfo.getLegalizeType());
.selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); entity.setSfygx("1");
if (selectSign != null && "1".equals(selectSign.getQsStatus())) { if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) {
String record = JSON.toJSONString(entity); SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd");
sender.sendToStatus(Base64.encode(record)); entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate()));
} }
if ("1".equals(invoiceSelectInfo.getLegalizeState())) {
entity.setAuthStatus("4");
} else {
entity.setAuthStatus("0");
}
entity.setBdkStatus("2");
} }
} else { flag = true;
if (StringUtils.isBlank(invoiceSelectInfo.getLegalizeDate())) {
invoiceSelectInfo.setLegalizeDate(null); } else if (!"0".equals(entity.getRzhYesorno())
} && !"1".equals(invoiceSelectInfo.getLegalizeState())) {
TDxRecordInvoiceJobEntity record = exchangePo2Entity(invoiceSelectInfo); entity.setRzhYesorno("0");
record.setCompany(company); entity.setRzhBelongDate(null);
record.setCollectStatus("1"); entity.setRzlx("0");
record.setCollectFrom("0"); entity.setRzhType(null);
record.setCollectDate(new Date()); entity.setRzhDate(null);
record.setPoolStatus("0"); entity.setAuthStatus("0");
entity.setBdkStatus("0");
entity.setSfygx("0");
flag = true;
}
//TODO 这块业务不理解??
if ("1".equals(entity.getSourceSystem()) && "0".equals(entity.getCollectStatus())) {
entity.setCollectStatus("1");
entity.setCollectFrom("0");
entity.setCollectDate(new Date());
entity.setPoolStatus("1");
entity.setInPoolReason("数据重复");
flag = true;
}
if (flag) {
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE);
tDxRecordInvoiceJobDao.insert(record); if (StringUtils.isBlank(entity.getInvoiceCode())) {
entity.setInvoiceCode("");
}
tDxRecordInvoiceJobDao.updateInvoice(entity, taxno);
} }
InvoiceLog invoiceLog = new InvoiceLog(); // 艺龙推送数据
invoiceLog.setInvoiceCode(invoiceSelectInfo.getInvoiceCode()); if (yLcompany.equals(company)) {
invoiceLog.setInvoiceNo(invoiceSelectInfo.getInvoiceNo()); DynamicContextHolder.push(db + DbConstant.BUSINESS_READ);
invoiceLog.setType("1"); InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao
invoiceLog.setInputStatus("0"); .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin);
invoiceLog.setCreateDate(new Date()); if (selectSign != null && "1".equals(selectSign.getQsStatus())) {
invoiceLog.setInputName("系统自动"); String record = JSON.toJSONString(entity);
logList.add(invoiceLog); sender.sendToStatus(Base64.encode(record));
}
}
} else {
if (StringUtils.isBlank(invoiceSelectInfo.getLegalizeDate())) {
invoiceSelectInfo.setLegalizeDate(null);
}
TDxRecordInvoiceJobEntity record = exchangePo2Entity(invoiceSelectInfo);
record.setCompany(company);
record.setCollectStatus("1");
record.setCollectFrom("0");
record.setCollectDate(new Date());
record.setPoolStatus("0");
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE);
tDxRecordInvoiceJobDao.insert(record);
} }
InvoiceLog invoiceLog = new InvoiceLog();
invoiceLog.setInvoiceCode(invoiceSelectInfo.getInvoiceCode());
invoiceLog.setInvoiceNo(invoiceSelectInfo.getInvoiceNo());
invoiceLog.setType("1");
invoiceLog.setInputStatus("0");
invoiceLog.setCreateDate(new Date());
invoiceLog.setInputName("系统自动");
logList.add(invoiceLog);
// }
}catch (Exception e) { }catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
//关锁
lock.unlock();
} }
// finally {
// //关锁
// lock.unlock();
// }
} }
httpLog.setStatus("1"); httpLog.setStatus("1");
httpLog.setTotal(total); httpLog.setTotal(total);

Loading…
Cancel
Save