Merge branches '1007-认证人和组织权限需要匹配,只显示启用了该组织进项功能的人' and 'release' of http://192.168.12.182/invoice/pt into 1007-认证人和组织权限需要匹配,只显示启用了该组织进项功能的人

release
yefei 2 years ago
commit 79b3bbe118
  1. 4
      dxhy-core/pom.xml
  2. 33
      dxhy-core/src/main/java/com/dxhy/core/config/RedissionConfig.java
  3. 241
      dxhy-core/src/main/java/com/dxhy/core/job/service/impl/InvoiceInterfaceServiceImpl.java
  4. 76
      dxhy-core/src/main/java/com/dxhy/core/task/SdnyClientTask.java
  5. 3
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java

@ -164,6 +164,10 @@
<artifactId>itext-asian</artifactId> <artifactId>itext-asian</artifactId>
<version>5.2.0</version> <version>5.2.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.alibaba.cloud</groupId> <groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>

@ -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);
// }
//}
//

@ -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,119 +667,132 @@ public class InvoiceInterfaceServiceImpl implements InvoiceInterfaceService {
} else { } else {
invoiceSelectInfo.setAuthStatus("0"); invoiceSelectInfo.setAuthStatus("0");
} }
// 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新 try {
DynamicContextHolder.push(db + DbConstant.BUSINESS_READ); // boolean isLock = lock.tryLock();
TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao
.findInvoiceByUUid(invoiceSelectInfo.getUuid()); // if(!isLock){
if (entity != null) { // log.info("当前已有线程获取到锁");
boolean flag = false; // }else {
if (StringUtils.isBlank(entity.getCheckCode()) // 判断库里是否已经存在,存在则只更新发票状态,状态更新时间,认证状态以及相关字段更新
&& StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) { DynamicContextHolder.push(db + DbConstant.BUSINESS_READ);
entity.setCheckCode(invoiceSelectInfo.getCheckCode()); TDxRecordInvoiceJobEntity entity = tDxRecordInvoiceJobDao.findInvoiceByUUid(invoiceSelectInfo.getUuid());
entity.setCheckDate(new Date()); if (entity != null) {
flag = true; boolean flag = false;
} if (StringUtils.isBlank(entity.getCheckCode())
if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) { && StringUtils.isNotBlank(invoiceSelectInfo.getCheckCode())) {
entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus()); entity.setCheckCode(invoiceSelectInfo.getCheckCode());
entity.setStatusUpdateDate(new Date()); entity.setCheckDate(new Date());
flag = true; flag = true;
} }
if ("0".equals(entity.getRzhYesorno()) if (!entity.getInvoiceStatus().equals(invoiceSelectInfo.getInvoiceStatus())) {
&& !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) { entity.setInvoiceStatus(invoiceSelectInfo.getInvoiceStatus());
if ("1".equals(invoiceSelectInfo.getRzlx())) { entity.setStatusUpdateDate(new Date());
entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState()); flag = true;
entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate()); }
entity.setRzlx(invoiceSelectInfo.getRzlx()); if ("0".equals(entity.getRzhYesorno())
entity.setRzhType(invoiceSelectInfo.getLegalizeType()); && !entity.getRzhYesorno().equals(invoiceSelectInfo.getLegalizeState())) {
entity.setSfygx("1"); if ("1".equals(invoiceSelectInfo.getRzlx())) {
if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) { entity.setRzhYesorno(invoiceSelectInfo.getLegalizeState());
SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd"); entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate());
entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate())); entity.setRzlx(invoiceSelectInfo.getRzlx());
} entity.setRzhType(invoiceSelectInfo.getLegalizeType());
if ("1".equals(invoiceSelectInfo.getLegalizeState())) { entity.setSfygx("1");
entity.setAuthStatus("4"); if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) {
} else { SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd");
entity.setAuthStatus("0"); entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate()));
} }
entity.setBdkStatus("1"); if ("1".equals(invoiceSelectInfo.getLegalizeState())) {
} else if ("4".equals(invoiceSelectInfo.getRzlx())) { entity.setAuthStatus("4");
entity.setRzhYesorno("2"); } else {
entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate()); entity.setAuthStatus("0");
entity.setRzlx(invoiceSelectInfo.getRzlx()); }
entity.setRzhType(invoiceSelectInfo.getLegalizeType()); entity.setBdkStatus("1");
entity.setSfygx("1"); } else if ("4".equals(invoiceSelectInfo.getRzlx())) {
if (StringUtils.isNotBlank(invoiceSelectInfo.getLegalizeDate())) { entity.setRzhYesorno("2");
SimpleDateFormat sim = new SimpleDateFormat("yyyyMMdd"); entity.setRzhBelongDate(invoiceSelectInfo.getLegalizeBlongDate());
entity.setRzhDate(sim.parse(invoiceSelectInfo.getLegalizeDate())); 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())) { flag = true;
entity.setAuthStatus("4");
} else { } else if (!"0".equals(entity.getRzhYesorno())
entity.setAuthStatus("0"); && !"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; // 艺龙推送数据
if (yLcompany.equals(company)) {
} else if (!"0".equals(entity.getRzhYesorno()) DynamicContextHolder.push(db + DbConstant.BUSINESS_READ);
&& !"1".equals(invoiceSelectInfo.getLegalizeState())) { InvoiceScanEntity selectSign = tDxRecordInvoiceJobDao
entity.setRzhYesorno("0"); .selectByScan(entity.getInvoiceCode() + entity.getInvoiceNo(), dxhyAdmin);
entity.setRzhBelongDate(null); if (selectSign != null && "1".equals(selectSign.getQsStatus())) {
entity.setRzlx("0"); String record = JSON.toJSONString(entity);
entity.setRzhType(null); sender.sendToStatus(Base64.encode(record));
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); } else {
} if (StringUtils.isBlank(invoiceSelectInfo.getLegalizeDate())) {
// 艺龙推送数据 invoiceSelectInfo.setLegalizeDate(null);
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));
} }
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 { InvoiceLog invoiceLog = new InvoiceLog();
if (StringUtils.isBlank(invoiceSelectInfo.getLegalizeDate())) { invoiceLog.setInvoiceCode(invoiceSelectInfo.getInvoiceCode());
invoiceSelectInfo.setLegalizeDate(null); invoiceLog.setInvoiceNo(invoiceSelectInfo.getInvoiceNo());
} invoiceLog.setType("1");
TDxRecordInvoiceJobEntity record = exchangePo2Entity(invoiceSelectInfo); invoiceLog.setInputStatus("0");
record.setCompany(company); invoiceLog.setCreateDate(new Date());
record.setCollectStatus("1"); invoiceLog.setInputName("系统自动");
record.setCollectFrom("0"); logList.add(invoiceLog);
record.setCollectDate(new Date()); // }
record.setPoolStatus("0"); }catch (Exception e) {
DynamicContextHolder.push(db + DbConstant.BUSINESS_WRITE); e.printStackTrace();
tDxRecordInvoiceJobDao.insert(record);
} }
InvoiceLog invoiceLog = new InvoiceLog(); // finally {
invoiceLog.setInvoiceCode(invoiceSelectInfo.getInvoiceCode()); // //关锁
invoiceLog.setInvoiceNo(invoiceSelectInfo.getInvoiceNo()); // lock.unlock();
invoiceLog.setType("1"); // }
invoiceLog.setInputStatus("0");
invoiceLog.setCreateDate(new Date());
invoiceLog.setInputName("系统自动");
logList.add(invoiceLog);
} }
httpLog.setStatus("1"); httpLog.setStatus("1");
httpLog.setTotal(total); httpLog.setTotal(total);

@ -37,6 +37,9 @@ public class SdnyClientTask extends AbstractController {
@Value("${sdny.snYxUrl}") @Value("${sdny.snYxUrl}")
private String snYxUrl; private String snYxUrl;
@Value("${sdny.client}")
private String client;
@Value("${po.userName}") @Value("${po.userName}")
private String userName; private String userName;
@ -77,43 +80,45 @@ public class SdnyClientTask extends AbstractController {
scheduleJobEntity.setJobStatus("1"); scheduleJobEntity.setJobStatus("1");
DynamicContextHolder.push(DbConstant.BASICS_WRITE); DynamicContextHolder.push(DbConstant.BASICS_WRITE);
scheduleJobService.updateById(scheduleJobEntity); scheduleJobService.updateById(scheduleJobEntity);
long startTime = System.currentTimeMillis();
List<GsClient> list = new ArrayList<>();
// 准备请求参数 // 准备请求参数
// 需判断 设置不认证状态 // 需判断 设置不认证状态
String[] split = client.split(",");
List<GsClient> list = new ArrayList<>(); for(int i = 0;i < split.length;i++) {
long startTime = System.currentTimeMillis(); SNSAPObject object = new SNSAPObject();
SNSAPObject object = new SNSAPObject(); object.setSYSID("FPXT");
object.setSYSID("FPXT"); object.setIFYWID("FI846");
object.setIFYWID("FI846"); object.setBSKEY(UUID.randomUUID().toString().replace("-", ""));
object.setBSKEY(UUID.randomUUID().toString().replace("-", "")); object.setZFILED5(split[i]);
object.setZFILED5("200"); object.setZDATA("");
object.setZDATA("");
//推送到SAP
//推送到SAP log.info("推送山能数据:{}", JSONObject.toJSONString(object));
log.info("推送山能数据:{}", JSONObject.toJSONString(object)); JSONObject request = new JSONObject();
JSONObject request = new JSONObject(); request.put("IS_INPUT", object);
request.put("IS_INPUT", object);
log.info("{}获取公司client入参:{}", LOGGER_MSG, request.toJSONString());
log.info("{}获取公司client入参:{}", LOGGER_MSG, request.toJSONString()); String result = HttpUtils.sendPo(snYxUrl, request.toJSONString(), userName, password);
String result = HttpUtils.sendPo(snYxUrl, request.toJSONString(), userName, password); log.info("{}获取公司client出参:{}", LOGGER_MSG, result);
log.info("{}获取公司client出参:{}", LOGGER_MSG, result); PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class);
PoCommonResponseParam poCommonResponseParam = JsonUtils.getInstance().parseObject(result, PoCommonResponseParam.class); EsOutput es_output = poCommonResponseParam.getES_OUTPUT();
EsOutput es_output = poCommonResponseParam.getES_OUTPUT(); String ztype = es_output.getZTYPE();
String ztype = es_output.getZTYPE(); String zmessage = es_output.getZMESSAGE();
String zmessage = es_output.getZMESSAGE(); Object zdata = es_output.getZDATA();
Object zdata = es_output.getZDATA(); if ("S".equals(ztype)) {
if ("s".equals(ztype)) { List<Map<String, String>> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class);
List<Map<String, String>> gsClientList = JsonUtils.getInstance().parseObject(zdata.toString(), List.class); gsClientList.stream().forEach(f -> {
gsClientList.stream().forEach(f -> { GsClient gsClient = new GsClient();
GsClient gsClient = new GsClient(); gsClient.setGsdm(ObjectUtil.isNull(f.get("BUKRS")) ? "" : f.get("BUKRS").toString());
gsClient.setGsdm(ObjectUtil.isNull(f.get("BUKRS")) ? "" : f.get("BUKRS").toString()); gsClient.setGsmc(ObjectUtil.isNull(f.get("BUTXT")) ? "" : f.get("BUTXT").toString());
gsClient.setGsmc(ObjectUtil.isNull(f.get("BUTXT")) ? "" : f.get("BUTXT").toString()); gsClient.setClient(ObjectUtil.isNull(f.get("MANDT")) ? "" : f.get("MANDT").toString());
gsClient.setClient(ObjectUtil.isNull(f.get("MANDT")) ? "" : f.get("MANDT").toString()); gsClient.setCreateTime(new Date());
gsClient.setCreateTime(new Date()); list.add(gsClient);
list.add(gsClient); });
}); } else {
} else { log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage);
log.error("{}client:{},获取公司client出错:{}", LOGGER_MSG, "200", zmessage); }
} }
log.info("{}删除gs_client表数据", LOGGER_MSG); log.info("{}删除gs_client表数据", LOGGER_MSG);
gsClientMapper.deleteAll(); gsClientMapper.deleteAll();
@ -122,6 +127,7 @@ public class SdnyClientTask extends AbstractController {
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime); log.debug("{}任务结束,耗时:{}", LOGGER_MSG, endTime - startTime);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {

@ -1048,7 +1048,8 @@ public class SDNYMainProcessController extends AbstractController {
if (gsClients != null && gsClients.size() > 0) { if (gsClients != null && gsClients.size() > 0) {
object.setZFILED5(gsClients.get(0).getClient()); object.setZFILED5(gsClients.get(0).getClient());
} else { } else {
object.setZFILED5(environment); log.error("未能查到 "+orgCode+" 公司对应的推送client");
return ResponseEntity.ok(JSONObject.toJSONString(R.error("未能查到 "+orgCode+" 公司对应的推送client")));
} }
List<SAPInvoiceInfo> sapInvoiceInfos = new ArrayList<>(); List<SAPInvoiceInfo> sapInvoiceInfos = new ArrayList<>();

Loading…
Cancel
Save