From 87ccf9689e96390311a486f29a7784520db12916 Mon Sep 17 00:00:00 2001 From: yefei Date: Sun, 8 Oct 2023 10:21:01 +0800 Subject: [PATCH 01/10] =?UTF-8?q?ariesy=20=20=E9=87=87=E9=9B=86=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dxhy-core/pom.xml | 4 +++ .../com/dxhy/core/config/RedissionConfig.java | 33 +++++++++++++++++++ .../impl/InvoiceInterfaceServiceImpl.java | 24 ++++++++++++-- 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java diff --git a/dxhy-core/pom.xml b/dxhy-core/pom.xml index 45cd4923..a4af582f 100644 --- a/dxhy-core/pom.xml +++ b/dxhy-core/pom.xml @@ -164,6 +164,10 @@ itext-asian 5.2.0 + + org.redisson + redisson-spring-boot-starter + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config diff --git a/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java b/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java new file mode 100644 index 00000000..cbcea2b1 --- /dev/null +++ b/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java @@ -0,0 +1,33 @@ +package com.dxhy.core.config; + +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RedissionConfig { + + @Value("${spring.redis.host}") + private String host; + + @Value("${spring.redis.port}") + private String port; + + @Value("${spring.redis.password}") + private String redisPassword; + + @Bean + public RedissonClient getRedisson(){ + + Config config = new Config(); + //单机模式 依次设置redis地址和密码 + config.useSingleServer() + .setAddress("redis://" + host + ":" + port) + .setPassword(redisPassword); + return Redisson.create(config); + } +} + diff --git a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java index 841e44f5..45dfde96 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java @@ -14,7 +14,10 @@ import javax.crypto.spec.SecretKeySpec; import com.dxhy.core.job.thread.InvoiceParseHandle; 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.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import com.alibaba.fastjson.JSON; @@ -72,6 +75,16 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { @Resource private Sender sender; + @Resource + private StringRedisTemplate stringRedisTemplate; + + @Resource + private RedissonClient redisson; + + private static final String REDIS_KEY = "redis_oa_01"; + + private static final int MAX_SIZE = 1000; + @Value("${jxjk.collectUrl}") private String collectUrl; @Value("${jxjk.invoiceGet}") @@ -651,10 +664,17 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { } else { invoiceSelectInfo.setAuthStatus("0"); } + + //加分布式锁 + String lockKey = invoiceSelectInfo.getUuid(); + + RLock lock = redisson.getLock(lockKey); + lock.lock(); + stringRedisTemplate.opsForValue().set(REDIS_KEY, String.valueOf(0)); + // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao - .findInvoiceByUUid(invoiceSelectInfo.getUuid()); + TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); if (entity != null) { boolean flag = false; if (StringUtils.isBlank(entity.getCheckCode()) From c3e63f6e17a99b769ae2e8950f7b4a4f6fab1c1c Mon Sep 17 00:00:00 2001 From: yefei Date: Sun, 8 Oct 2023 10:30:33 +0800 Subject: [PATCH 02/10] =?UTF-8?q?ariesy=20=20=E9=87=87=E9=9B=86=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D-=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/InvoiceInterfaceServiceImpl.java | 232 +++++++++--------- 1 file changed, 118 insertions(+), 114 deletions(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java index 45dfde96..d54ef101 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java @@ -81,7 +81,7 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { @Resource private RedissonClient redisson; - private static final String REDIS_KEY = "redis_oa_01"; + private static final String REDIS_KEY = "collect_invoice_"; private static final int MAX_SIZE = 1000; @@ -657,6 +657,9 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { String company = tDxRecordInvoiceJobDao.findCompany(taxno); List logList = new ArrayList<>(); for (InvoiceSelectInfo invoiceSelectInfo : invoicesList) { + //加分布式锁 + String lockKey = REDIS_KEY + invoiceSelectInfo.getUuid(); + RLock lock = redisson.getLock(lockKey); invoiceSelectInfo.setUuid(invoiceSelectInfo.getInvoiceCode() + invoiceSelectInfo.getInvoiceNo()); if ("1".equals(invoiceSelectInfo.getLegalizeState())) { //认证处理状态 0-未认证 1-已勾选未确认,2已确认 3 已发送认证 4 认证成功 5 认证失败 @@ -664,126 +667,127 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { } else { invoiceSelectInfo.setAuthStatus("0"); } - - //加分布式锁 - String lockKey = invoiceSelectInfo.getUuid(); - - RLock lock = redisson.getLock(lockKey); - lock.lock(); - stringRedisTemplate.opsForValue().set(REDIS_KEY, String.valueOf(0)); - - // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 - DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); - if (entity != null) { - boolean flag = false; - if (StringUtils.isBlank(entity.getCheckCode()) - && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { - entity.setCheckCode(invoiceSelectInfo.getCheckCode()); - entity.setCheckDate(new Date()); - flag = true; - } - if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { - entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); - entity.setStatusUpdateDate(new Date()); - flag = true; - } - if ("0".equals(entity.getRzhYesorno()) - && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { - if ("1".equals(invoiceSelectInfo.getRzlx())) { - entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); - 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("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())); + try { + lock.lock(); + stringRedisTemplate.opsForValue().set(lockKey, String.valueOf(0)); + + // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 + DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); + TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); + if (entity != null) { + boolean flag = false; + if (StringUtils.isBlank(entity.getCheckCode()) + && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { + entity.setCheckCode(invoiceSelectInfo.getCheckCode()); + entity.setCheckDate(new Date()); + flag = true; + } + if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { + entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); + entity.setStatusUpdateDate(new Date()); + flag = true; + } + if ("0".equals(entity.getRzhYesorno()) + && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { + if ("1".equals(invoiceSelectInfo.getRzlx())) { + entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); + 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("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"); } - if ("1".equals(invoiceSelectInfo.getLegalizeState())) { - entity.setAuthStatus("4"); - } else { - entity.setAuthStatus("0"); + flag = true; + + } else if (!"0".equals(entity.getRzhYesorno()) + && !"1".equals(invoiceSelectInfo.getLegalizeState())) { + 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(""); } - entity.setBdkStatus("2"); + tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); } - flag = true; - - } else if (!"0".equals(entity.getRzhYesorno()) - && !"1".equals(invoiceSelectInfo.getLegalizeState())) { - 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(""); + // 艺龙推送数据 + if (yLcompany.equals(company)) { + DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); + InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao + .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); + if (selectSign != null && "1".equals(selectSign.getQsStatus())) { + String record = JSON.toJSONString(entity); + sender.sendToStatus(Base64.encode(record)); + } } - tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); - } - // 艺龙推送数据 - if (yLcompany.equals(company)) { - DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao - .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); - if (selectSign != null && "1".equals(selectSign.getQsStatus())) { - String record = JSON.toJSONString(entity); - 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); } - } 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) { + e.printStackTrace(); + } finally { + lock.unlock(); } - 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); } httpLog.setStatus("1"); httpLog.setTotal(total); From fc604ad5d711de687b55c7fb6099685a88bd06b2 Mon Sep 17 00:00:00 2001 From: yefei Date: Sun, 8 Oct 2023 10:35:56 +0800 Subject: [PATCH 03/10] =?UTF-8?q?ariesy=20=20=E9=87=87=E9=9B=86=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D-=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java index d54ef101..69759873 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java @@ -786,6 +786,8 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { }catch (Exception e) { e.printStackTrace(); } finally { + //关锁 + stringRedisTemplate.opsForValue().set(lockKey, String.valueOf(1)); lock.unlock(); } } From 355a3c4d221ee75c7ce48a614bd2284fc67c6688 Mon Sep 17 00:00:00 2001 From: yefei Date: Mon, 16 Oct 2023 09:43:57 +0800 Subject: [PATCH 04/10] =?UTF-8?q?ariesy=20=E5=8A=A0=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/InvoiceInterfaceServiceImpl.java | 220 +++++++++--------- 1 file changed, 111 insertions(+), 109 deletions(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java index 69759873..a3dd8a1b 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java @@ -668,126 +668,128 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { invoiceSelectInfo.setAuthStatus("0"); } try { - lock.lock(); - stringRedisTemplate.opsForValue().set(lockKey, String.valueOf(0)); - - // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 - DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); - if (entity != null) { - boolean flag = false; - if (StringUtils.isBlank(entity.getCheckCode()) - && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { - entity.setCheckCode(invoiceSelectInfo.getCheckCode()); - entity.setCheckDate(new Date()); - flag = true; - } - if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { - entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); - entity.setStatusUpdateDate(new Date()); - flag = true; - } - if ("0".equals(entity.getRzhYesorno()) - && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { - if ("1".equals(invoiceSelectInfo.getRzlx())) { - entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); - 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("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())); + boolean isLock = lock.tryLock(); + + if(!isLock){ + log.info("当前已有线程获取到锁"); + }else { + // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 + DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); + TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); + if (entity != null) { + boolean flag = false; + if (StringUtils.isBlank(entity.getCheckCode()) + && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { + entity.setCheckCode(invoiceSelectInfo.getCheckCode()); + entity.setCheckDate(new Date()); + flag = true; + } + if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { + entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); + entity.setStatusUpdateDate(new Date()); + flag = true; + } + if ("0".equals(entity.getRzhYesorno()) + && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { + if ("1".equals(invoiceSelectInfo.getRzlx())) { + entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); + 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("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"); } - if ("1".equals(invoiceSelectInfo.getLegalizeState())) { - entity.setAuthStatus("4"); - } else { - entity.setAuthStatus("0"); + flag = true; + + } else if (!"0".equals(entity.getRzhYesorno()) + && !"1".equals(invoiceSelectInfo.getLegalizeState())) { + 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(""); } - entity.setBdkStatus("2"); + tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); } - flag = true; - - } else if (!"0".equals(entity.getRzhYesorno()) - && !"1".equals(invoiceSelectInfo.getLegalizeState())) { - 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(""); + // 艺龙推送数据 + if (yLcompany.equals(company)) { + DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); + InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao + .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); + if (selectSign != null && "1".equals(selectSign.getQsStatus())) { + String record = JSON.toJSONString(entity); + sender.sendToStatus(Base64.encode(record)); + } } - tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); - } - // 艺龙推送数据 - if (yLcompany.equals(company)) { - DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao - .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); - if (selectSign != null && "1".equals(selectSign.getQsStatus())) { - String record = JSON.toJSONString(entity); - 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); } - } 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); } - 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) { e.printStackTrace(); } finally { //关锁 - stringRedisTemplate.opsForValue().set(lockKey, String.valueOf(1)); lock.unlock(); } } From bc2c6d8c03e197ab864d89e71ffeede6d42fbc5b Mon Sep 17 00:00:00 2001 From: wangrangrang Date: Tue, 17 Oct 2023 11:02:50 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dxhy/erp/controller/SDNYMainProcessController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index 1d58d7b4..8cd64a63 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -1048,7 +1048,7 @@ public class SDNYMainProcessController extends AbstractController { if (gsClients != null && gsClients.size() > 0) { object.setZFILED5(gsClients.get(0).getClient()); } else { - object.setZFILED5(environment); + throw new RuntimeException("未能查到 "+orgCode+" 公司对应的推送client"); } List sapInvoiceInfos = new ArrayList<>(); From b5284da765ced1806c720effcf676e9fbf98307a Mon Sep 17 00:00:00 2001 From: wangrangrang Date: Tue, 17 Oct 2023 14:13:18 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=8E=A8=E9=80=81?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC,=E4=BF=AE=E6=94=B9=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E5=8F=82=E6=95=B0=E4=B8=BA300?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java | 2 +- .../com/dxhy/erp/controller/SDNYMainProcessController.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java index dad62fa6..3fe32ba4 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java @@ -86,7 +86,7 @@ public class SdnyClientTask extends AbstractController { object.setSYSID("FPXT"); object.setIFYWID("FI846"); object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); - object.setZFILED5("200"); + object.setZFILED5("300"); object.setZDATA(""); //推送到SAP diff --git a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java index 8cd64a63..394593e7 100644 --- a/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java +++ b/dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java @@ -1048,7 +1048,8 @@ public class SDNYMainProcessController extends AbstractController { if (gsClients != null && gsClients.size() > 0) { object.setZFILED5(gsClients.get(0).getClient()); } else { - throw new RuntimeException("未能查到 "+orgCode+" 公司对应的推送client"); + log.error("未能查到 "+orgCode+" 公司对应的推送client"); + return ResponseEntity.ok(JSONObject.toJSONString(R.error("未能查到 "+orgCode+" 公司对应的推送client"))); } List sapInvoiceInfos = new ArrayList<>(); From d4f9900e343c2840d6c8fab05205e72109e3e678 Mon Sep 17 00:00:00 2001 From: yefei Date: Tue, 17 Oct 2023 14:40:58 +0800 Subject: [PATCH 07/10] =?UTF-8?q?ariesy=20client=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=8A=BD=E5=8F=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dxhy/core/task/SdnyClientTask.java | 87 ++++++++++--------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java index 3fe32ba4..e599359d 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java @@ -37,6 +37,9 @@ public class SdnyClientTask extends AbstractController { @Value("${sdny.snYxUrl}") private String snYxUrl; + @Value("${sdny.client}") + private String client; + @Value("${po.userName}") private String userName; @@ -79,48 +82,50 @@ public class SdnyClientTask extends AbstractController { scheduleJobService.updateById(scheduleJobEntity); // 准备请求参数 // 需判断 设置不认证状态 - - List list = new ArrayList<>(); - long startTime = System.currentTimeMillis(); - SNSAPObject object = new SNSAPObject(); - object.setSYSID("FPXT"); - object.setIFYWID("FI846"); - object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); - object.setZFILED5("300"); - object.setZDATA(""); - - //推送到SAP - log.info("推送山能数据:{}", JSONObject.toJSONString(object)); - JSONObject request = new JSONObject(); - request.put("IS_INPUT", object); - - log.info("{}获取公司client入参:{}", LOGGER_MSG, request.toJSONString()); - String result = HttpUtils.sendPo(snYxUrl, request.toJSONString(), userName, password); - log.info("{}获取公司client出参:{}", LOGGER_MSG, result); - PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); - EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); - String ztype = es_output.getZTYPE(); - String zmessage = es_output.getZMESSAGE(); - Object zdata = es_output.getZDATA(); - if ("s".equals(ztype)) { - List> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class); - gsClientList.stream().forEach(f -> { - GsClient gsClient = new GsClient(); - gsClient.setGsdm(ObjectUtil.isNull(f.get("BUKRS")) ? "" : f.get("BUKRS").toString()); - gsClient.setGsmc(ObjectUtil.isNull(f.get("BUTXT")) ? "" : f.get("BUTXT").toString()); - gsClient.setClient(ObjectUtil.isNull(f.get("MANDT")) ? "" : f.get("MANDT").toString()); - gsClient.setCreateTime(new Date()); - list.add(gsClient); - }); - } else { - log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage); + String[] split = client.split(","); + for(int i = 0;i < split.length;i++) { + List list = new ArrayList<>(); + long startTime = System.currentTimeMillis(); + SNSAPObject object = new SNSAPObject(); + object.setSYSID("FPXT"); + object.setIFYWID("FI846"); + object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); + object.setZFILED5(split[i]); + object.setZDATA(""); + + //推送到SAP + log.info("推送山能数据:{}", JSONObject.toJSONString(object)); + JSONObject request = new JSONObject(); + request.put("IS_INPUT", object); + + log.info("{}获取公司client入参:{}", LOGGER_MSG, request.toJSONString()); + String result = HttpUtils.sendPo(snYxUrl, request.toJSONString(), userName, password); + log.info("{}获取公司client出参:{}", LOGGER_MSG, result); + PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); + EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); + String ztype = es_output.getZTYPE(); + String zmessage = es_output.getZMESSAGE(); + Object zdata = es_output.getZDATA(); + if ("s".equals(ztype)) { + List> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class); + gsClientList.stream().forEach(f -> { + GsClient gsClient = new GsClient(); + gsClient.setGsdm(ObjectUtil.isNull(f.get("BUKRS")) ? "" : f.get("BUKRS").toString()); + gsClient.setGsmc(ObjectUtil.isNull(f.get("BUTXT")) ? "" : f.get("BUTXT").toString()); + gsClient.setClient(ObjectUtil.isNull(f.get("MANDT")) ? "" : f.get("MANDT").toString()); + gsClient.setCreateTime(new Date()); + list.add(gsClient); + }); + } else { + log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage); + } + log.info("{}删除gs_client表数据", LOGGER_MSG); + gsClientMapper.deleteAll(); + log.info("{}插入gs_client表", LOGGER_MSG); + gsClientMapper.insertList(list); + long endTime = System.currentTimeMillis(); + log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); } - log.info("{}删除gs_client表数据", LOGGER_MSG); - gsClientMapper.deleteAll(); - log.info("{}插入gs_client表", LOGGER_MSG); - gsClientMapper.insertList(list); - long endTime = System.currentTimeMillis(); - log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); } catch (Exception e) { e.printStackTrace(); From 28d64f6b79f7069b0ac88749731c4bbadadbbadb Mon Sep 17 00:00:00 2001 From: yefei Date: Tue, 17 Oct 2023 19:21:02 +0800 Subject: [PATCH 08/10] =?UTF-8?q?ariesy=20=E5=8E=BB=E6=8E=89redission?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dxhy/core/config/RedissionConfig.java | 48 ++-- .../impl/InvoiceInterfaceServiceImpl.java | 237 +++++++++--------- 2 files changed, 143 insertions(+), 142 deletions(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java b/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java index cbcea2b1..33478921 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java +++ b/dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java @@ -7,27 +7,27 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -@Configuration -public class RedissionConfig { - - @Value("${spring.redis.host}") - private String host; - - @Value("${spring.redis.port}") - private String port; - - @Value("${spring.redis.password}") - private String redisPassword; - - @Bean - public RedissonClient getRedisson(){ - - Config config = new Config(); - //单机模式 依次设置redis地址和密码 - config.useSingleServer() - .setAddress("redis://" + host + ":" + port) - .setPassword(redisPassword); - return Redisson.create(config); - } -} - +//@Configuration +//public class RedissionConfig { +// +// @Value("${spring.redis.host}") +// private String host; +// +// @Value("${spring.redis.port}") +// private String port; +// +// @Value("${spring.redis.password}") +// private String redisPassword; +// +// @Bean +// public RedissonClient getRedisson(){ +// +// Config config = new Config(); +// //单机模式 依次设置redis地址和密码 +// config.useSingleServer() +// .setAddress("redis://" + host + ":" + port) +// .setPassword(redisPassword); +// return Redisson.create(config); +// } +//} +// diff --git a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java index a3dd8a1b..c62e119f 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java +++ b/dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java @@ -78,8 +78,8 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { @Resource private StringRedisTemplate stringRedisTemplate; - @Resource - private RedissonClient redisson; +// @Resource +// private RedissonClient redisson; private static final String REDIS_KEY = "collect_invoice_"; @@ -658,8 +658,8 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { List logList = new ArrayList<>(); for (InvoiceSelectInfo invoiceSelectInfo : invoicesList) { //加分布式锁 - String lockKey = REDIS_KEY + invoiceSelectInfo.getUuid(); - RLock lock = redisson.getLock(lockKey); +// String lockKey = REDIS_KEY + invoiceSelectInfo.getUuid(); +// RLock lock = redisson.getLock(lockKey); invoiceSelectInfo.setUuid(invoiceSelectInfo.getInvoiceCode() + invoiceSelectInfo.getInvoiceNo()); if ("1".equals(invoiceSelectInfo.getLegalizeState())) { //认证处理状态 0-未认证 1-已勾选未确认,2已确认 3 已发送认证 4 认证成功 5 认证失败 @@ -668,130 +668,131 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService { invoiceSelectInfo.setAuthStatus("0"); } try { - boolean isLock = lock.tryLock(); - - if(!isLock){ - log.info("当前已有线程获取到锁"); - }else { - // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 - DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); - if (entity != null) { - boolean flag = false; - if (StringUtils.isBlank(entity.getCheckCode()) - && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { - entity.setCheckCode(invoiceSelectInfo.getCheckCode()); - entity.setCheckDate(new Date()); - flag = true; - } - if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { - entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); - entity.setStatusUpdateDate(new Date()); - flag = true; - } - if ("0".equals(entity.getRzhYesorno()) - && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { - if ("1".equals(invoiceSelectInfo.getRzlx())) { - entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); - 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("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"); +// boolean isLock = lock.tryLock(); + +// if(!isLock){ +// log.info("当前已有线程获取到锁"); +// }else { + // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 + DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); + TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid()); + if (entity != null) { + boolean flag = false; + if (StringUtils.isBlank(entity.getCheckCode()) + && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { + entity.setCheckCode(invoiceSelectInfo.getCheckCode()); + entity.setCheckDate(new Date()); + flag = true; + } + if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { + entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); + entity.setStatusUpdateDate(new Date()); + flag = true; + } + if ("0".equals(entity.getRzhYesorno()) + && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { + if ("1".equals(invoiceSelectInfo.getRzlx())) { + entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); + 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())); } - flag = true; - - } else if (!"0".equals(entity.getRzhYesorno()) - && !"1".equals(invoiceSelectInfo.getLegalizeState())) { - 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(""); + if ("1".equals(invoiceSelectInfo.getLegalizeState())) { + entity.setAuthStatus("4"); + } else { + entity.setAuthStatus("0"); } - tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); - } - // 艺龙推送数据 - if (yLcompany.equals(company)) { - DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); - InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao - .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); - if (selectSign != null && "1".equals(selectSign.getQsStatus())) { - String record = JSON.toJSONString(entity); - sender.sendToStatus(Base64.encode(record)); + 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"); } - } 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"); + flag = true; + + } else if (!"0".equals(entity.getRzhYesorno()) + && !"1".equals(invoiceSelectInfo.getLegalizeState())) { + 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); - tDxRecordInvoiceJobDao.insert(record); + if (StringUtils.isBlank(entity.getInvoiceCode())) { + entity.setInvoiceCode(""); + } + tDxRecordInvoiceJobDao.updateInvoice(entity, taxno); } - 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); + // 艺龙推送数据 + if (yLcompany.equals(company)) { + DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); + InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao + .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin); + if (selectSign != null && "1".equals(selectSign.getQsStatus())) { + String record = JSON.toJSONString(entity); + 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) { e.printStackTrace(); - } finally { - //关锁 - lock.unlock(); } +// finally { +// //关锁 +// lock.unlock(); +// } } httpLog.setStatus("1"); httpLog.setTotal(total); From a11d0d1e9c5fbd06e94c4573ac91910b85061a18 Mon Sep 17 00:00:00 2001 From: yefei Date: Tue, 17 Oct 2023 19:35:36 +0800 Subject: [PATCH 09/10] =?UTF-8?q?ariesy=20=E4=BF=AE=E6=94=B9=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java index e599359d..4f32484a 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java @@ -106,7 +106,7 @@ public class SdnyClientTask extends AbstractController { String ztype = es_output.getZTYPE(); String zmessage = es_output.getZMESSAGE(); Object zdata = es_output.getZDATA(); - if ("s".equals(ztype)) { + if ("S".equals(ztype)) { List> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class); gsClientList.stream().forEach(f -> { GsClient gsClient = new GsClient(); From 4dbf9d62e2df898e3b20d86ffb9b71febe843e9c Mon Sep 17 00:00:00 2001 From: yefei Date: Tue, 17 Oct 2023 19:40:55 +0800 Subject: [PATCH 10/10] =?UTF-8?q?ariesy=20=E4=BF=AE=E6=94=B9=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/dxhy/core/task/SdnyClientTask.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java index 4f32484a..eb490fe9 100644 --- a/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java +++ b/dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java @@ -80,12 +80,12 @@ public class SdnyClientTask extends AbstractController { scheduleJobEntity.setJobStatus("1"); DynamicContextHolder.push(DbConstant.BASICS_WRITE); scheduleJobService.updateById(scheduleJobEntity); + long startTime = System.currentTimeMillis(); + List list = new ArrayList<>(); // 准备请求参数 // 需判断 设置不认证状态 String[] split = client.split(","); for(int i = 0;i < split.length;i++) { - List list = new ArrayList<>(); - long startTime = System.currentTimeMillis(); SNSAPObject object = new SNSAPObject(); object.setSYSID("FPXT"); object.setIFYWID("FI846"); @@ -119,13 +119,14 @@ public class SdnyClientTask extends AbstractController { } else { log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage); } - log.info("{}删除gs_client表数据", LOGGER_MSG); - gsClientMapper.deleteAll(); - log.info("{}插入gs_client表", LOGGER_MSG); - gsClientMapper.insertList(list); - long endTime = System.currentTimeMillis(); - log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); } + log.info("{}删除gs_client表数据", LOGGER_MSG); + gsClientMapper.deleteAll(); + log.info("{}插入gs_client表", LOGGER_MSG); + gsClientMapper.insertList(list); + long endTime = System.currentTimeMillis(); + log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); + } catch (Exception e) { e.printStackTrace();