Merge remote-tracking branch 'origin/0815-通过销项获取当前组织最新税号' into release

# Conflicts:
#	dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
#	dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.java
#	dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtInvoicePoolController.java
release
wangrangrang 2 years ago
commit 580f6bee91
  1. 28
      dxhy-admin/src/main/java/com/dxhy/admin/sys/entity/SaleTaxnoEntity.java
  2. 2
      dxhy-admin/src/main/java/com/dxhy/admin/sys/service/SysUserService.java
  3. 60
      dxhy-admin/src/main/java/com/dxhy/admin/sys/service/impl/SsoLoginServiceImpl.java
  4. 40
      dxhy-admin/src/main/java/com/dxhy/admin/sys/service/impl/SysUserServiceImpl.java
  5. 8
      dxhy-admin/src/main/resources/bootstrap-test.yaml
  6. 391
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
  7. 2
      dxhy-erp/src/main/java/com/dxhy/erp/dao/VihicleInvoiceDetailDao.java
  8. 40
      dxhy-erp/src/main/java/com/dxhy/erp/service/SNPushCheckRecordService.java
  9. 4
      dxhy-erp/src/main/java/com/dxhy/erp/service/impl/InvoicePoolServiceImpl.java
  10. 14
      dxhy-erp/src/main/resources/bootstrap-dev.yaml
  11. 4
      dxhy-erp/src/main/resources/bootstrap-test.yaml
  12. 16
      dxhy-extend/src/main/java/com/dxhy/extend/controller/ExtInvoicePoolController.java
  13. 10
      pom.xml

@ -0,0 +1,28 @@
package com.dxhy.admin.sys.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* 系统用户
*
* @author jiaohongyang
*/
@Data
public class SaleTaxnoEntity implements Serializable {
private static final long serialVersionUID = 1L;
private String groupId;
private String groupName;
private String xhfNsrsbh;
}

@ -52,6 +52,8 @@ public interface SysUserService extends IService<SysUserEntity> {
*/
void saveUser(SysUserEntity user);
void saveUser(SysUserEntity user,Map<String, String> taxnos);
/**
* 修改用户
*

@ -1,14 +1,13 @@
package com.dxhy.admin.sys.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import com.alibaba.fastjson.JSONArray;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
@ -32,6 +31,12 @@ import lombok.extern.slf4j.Slf4j;
@Service("ssoLoginService")
@Slf4j
public class SsoLoginServiceImpl implements SsoLoginService {
private static final String LOGGER_MSG = "(请求http访问)";
@Value("${sdny.xxUrl}")
private String xxUrl;
@Resource
private SysUserService sysUserService;
@Resource
@ -50,14 +55,21 @@ public class SsoLoginServiceImpl implements SsoLoginService {
@Override
public boolean saveUser(SsoUser user) {
String taxNoInfo = getTaxNoInfo(xxUrl, "");
JSONObject object = JSONObject.parseObject(taxNoInfo);
String taxnoListInfo = object.getString("groupInfo");
List<SaleTaxnoEntity> taxnoList = JSONObject.parseArray(taxnoListInfo,SaleTaxnoEntity.class);
Map<String, String> taxnos = taxnoList.stream().collect(Collectors.toMap(SaleTaxnoEntity::getGroupId, SaleTaxnoEntity::getXhfNsrsbh));
log.info("从销项获取的税号列表为:{}",taxnos);
if (user.getUserSource() == 1) {
// 保存 机构信息
boolean insertOrg = this.insertOrg(user);
boolean insertOrg = this.insertOrg(user,taxnos);
// 保存角色信息
boolean insertRole = this.insertRole(user);
// 保存用户信息
boolean insertUser = this.insertUser(user);
boolean insertUser = this.insertUser(user,taxnos);
log.info("insertOrg = {},insertRole={},insertUser",insertOrg,insertRole,insertUser);
@ -70,12 +82,12 @@ public class SsoLoginServiceImpl implements SsoLoginService {
}
public boolean insertUser(SsoUser user) {
public boolean insertUser(SsoUser user,Map<String, String> taxnos) {
try {
SysUserEntity userEntity = this.toUser(user);
// 先删除用户信息,在新增
sysUserService.deleteUserBigb(userEntity.getUserId());
sysUserService.saveUser(userEntity);
sysUserService.saveUser(userEntity,taxnos);
return true;
} catch (Exception e) {
log.error("insertUser 报错信息为{}",e);
@ -110,9 +122,9 @@ public class SsoLoginServiceImpl implements SsoLoginService {
* 用户信息
* @return 返回信息
*/
public boolean insertOrg(SsoUser user) {
public boolean insertOrg(SsoUser user,Map<String, String> taxnos) {
try {
List<SysDeptEntity> deptList = this.toDept(user);
List<SysDeptEntity> deptList = this.toDept(user,taxnos);
if (deptList != null && deptList.size() > 0) {
sysDeptService.saveDeptList(deptList);
}
@ -125,7 +137,7 @@ public class SsoLoginServiceImpl implements SsoLoginService {
}
public List<SysDeptEntity> toDept(SsoUser user) {
public List<SysDeptEntity> toDept(SsoUser user,Map<String, String> taxnos) {
List<SysDeptEntity> deptList = new ArrayList<>();
int deptSum = 0;
SysDeptEntity dept;
@ -135,7 +147,13 @@ public class SsoLoginServiceImpl implements SsoLoginService {
dept = new SysDeptEntity();
dept.setDeptId(entity.getDeptId());
dept.setParentId(entity.getParentId());
dept.setTaxno(entity.getTaxpayerCode());
if(StringUtils.isNotBlank(entity.getTaxpayerCode())){
dept.setTaxno(entity.getTaxpayerCode());
}else{
String deptId = String.valueOf(entity.getDeptId());
dept.setTaxno(taxnos.get(deptId));
}
dept.setTaxname(entity.getName());
dept.setName(entity.getName());
dept.setLinkman("");
@ -146,7 +164,7 @@ public class SsoLoginServiceImpl implements SsoLoginService {
dept.setCompany(AdminConfig.company);
dept.setOrgCode(entity.getEnterpriseNumbers());
String deptType = this.toDeptType(String.valueOf(entity.getDeptType()),
String.valueOf(entity.getParentId()), entity.getTaxpayerCode());
String.valueOf(entity.getParentId()), entity.getTaxpayerCode());
dept.setDeptType(deptType);
dept.setOrgType(this.toOrgType(dept.getDeptType(), String.valueOf(entity.getParentId())));
dept.setUpgradeStatus(AdminConfig.upgradeStatus);
@ -377,7 +395,7 @@ public class SsoLoginServiceImpl implements SsoLoginService {
sysMenuEntity = new SysMenuEntity();
String systemSign = sysMenu.getSystemSign();
if ("JXXT".equals(systemSign) || "QYPC".equals(systemSign) || "GYL".equals(systemSign)
|| "YWXT".equals(systemSign)) {
|| "YWXT".equals(systemSign)) {
if (StringUtils.isNotBlank(sysMenu.getUrl()) && StringUtils.isNotBlank(sysMenu.getName())) {
sysMenuEntity.setMenuId(sysMenu.getMenuId());
sysMenuEntity.setParentId(sysMenu.getParentId());
@ -406,7 +424,7 @@ public class SsoLoginServiceImpl implements SsoLoginService {
} else if (1 == sysMenu.getType() || 2 == sysMenu.getType()) {
String[] split = sysMenu.getUrl().split("/");
SysMenuEntity menu =
this.queryMenu("/" + split[split.length - 1], sysMenu.getType(), sysMenu.getSystemSign());
this.queryMenu("/" + split[split.length - 1], sysMenu.getType(), sysMenu.getSystemSign());
if (menu != null) {
sysMenuEntity.setComponent(menu.getComponent());
sysMenuEntity.setIcon(menu.getIcon());
@ -520,7 +538,7 @@ public class SsoLoginServiceImpl implements SsoLoginService {
return runMap;
}
AdminSsoConfigModel adminSsoConfigModel =
JSON.parseObject(sysConfigEntity.getParamValue(), AdminSsoConfigModel.class);
JSON.parseObject(sysConfigEntity.getParamValue(), AdminSsoConfigModel.class);
String body = HttpRequest.post(adminSsoConfigModel.getQueryUserUrl()).header("token", token).execute().body();
log.info("获取用户信息:{}", body);
SsoUserReModel ssoUserReModel = JSON.parseObject(body, SsoUserReModel.class);
@ -659,7 +677,7 @@ public class SsoLoginServiceImpl implements SsoLoginService {
for (SsoUserTaxplayercodeDept sysDeptEntity : dept) {
// 获取税号信息
SysDeptEntity deptEntity =
sysDeptService.queryDeptTaxno(configModel.getCompany(), sysDeptEntity.getTaxpayerCode());
sysDeptService.queryDeptTaxno(configModel.getCompany(), sysDeptEntity.getTaxpayerCode());
if (deptEntity != null) {
userOrg = new SysUserOrgEntity();
userOrg.setCompany(configModel.getCompany());
@ -712,4 +730,12 @@ public class SsoLoginServiceImpl implements SsoLoginService {
}
}
public String getTaxNoInfo(String url, String request) {
long startTime = System.currentTimeMillis();
String body = HttpRequest.post(url).body(request).timeout(300000).execute().body();
long endTime = System.currentTimeMillis();
log.debug("{}以字符串调用post请求url:{},耗时:{}", LOGGER_MSG, url, endTime - startTime);
return body;
}
}

@ -113,6 +113,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
this.uploadUser(user);
}
@Override
public void saveUser(SysUserEntity user,Map<String, String> taxnos) {
DynamicContextHolder.push(DbConstant.BASICS_WRITE);
user.setCreateTime(DateUtil.date());
user.setUpdateTime(DateUtil.date());
// 查询用户关联菜单信息
Aops.getSelf(this).insertUser(user,taxnos);
this.insertRedis(user);
DynamicContextHolder.push(DbConstant.BASICS_READ);
this.uploadUser(user);
}
@Transactional(rollbackFor = Exception.class)
public void insertUser(SysUserEntity user) {
user.setCreateTime(new Date());
@ -133,6 +145,34 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUserEntity> i
}
@Transactional(rollbackFor = Exception.class)
public void insertUser(SysUserEntity user,Map<String, String> taxnos) {
user.setCreateTime(new Date());
String salt = RandomStringUtils.randomAlphanumeric(20);
user.setSalt(salt);
user.setScanType("5");
user.setPlpassword(Base64.encode(user.getPassword()));
user.setPassword(new BCryptPasswordEncoder(UserConstant.PW_ENCORDER_SALT).encode(user.getPassword()));
this.saveOrUpdate(user);
// 保存用户与角色关系
sysUserRoleService.saveOrUpdate(user.getUserId(), user.getRoleIdList());
// 保存客户信息,更新企业税号
user.getUserOrgEntities().stream().forEach(userOrg -> {
if(StringUtils.isEmpty(userOrg.getTaxno())){
if(StringUtils.isNotEmpty(taxnos.get(userOrg.getDeptId()))) {
userOrg.setTaxno(taxnos.get(userOrg.getDeptId()));
}
}
});
// 获取关联 数据权限
sysUserOrgService.saveOrUpdate(user.getUserId(), user.getUserOrgEntities());
// 保存用户与业务单元关系
if (user.getBusinessList() != null && user.getBusinessList().size() > 0) {
sysUserBusinessService.saveOrUpdate(user.getUserId(), user.getBusinessList());
}
}
@Override
public void update(SysUserEntity user) {
DynamicContextHolder.push(DbConstant.BASICS_WRITE);

@ -4,9 +4,9 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
# Nacos config 命名空间,对应配置中的名称(dxhy-jxpt-namespace)
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
namespace: c8ce91b7-c3a9-4a6e-a354-8405ce60d66c
# Nacos config 分组
group: dxhy-admin-group
# Nacos config 登录用户名
@ -19,9 +19,9 @@ spring:
file-extension: yaml
# Nacos discovery 配置
discovery:
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
# Nacos config 登录用户名
username: admin
# Nacos config 登录密码
password: Invoice.nacos.!1
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
namespace: c8ce91b7-c3a9-4a6e-a354-8405ce60d66c

@ -111,6 +111,7 @@ public class SDNYMainProcessController extends AbstractController {
@Resource
private RequestRecordService requestRecordService;
/**
* 查验发票
*/
@ -123,7 +124,7 @@ public class SDNYMainProcessController extends AbstractController {
String dbName = "business";
JSONObject checkInvoiceResult = null;
RequestRecord singleInvoiceCheckRecord = requestRecordService.getBaseRequestRecord(JSONObject.toJSONString(pramsMap),
"/singleInvoiceCheck",pramsMap.get("invoiceCode"),pramsMap.get("invoiceNumber"), "singleInvoiceCheck");
"/singleInvoiceCheck", pramsMap.get("invoiceCode"), pramsMap.get("invoiceNumber"), "singleInvoiceCheck");
//挡板开关
if ("1".equals(isPresure)) {
@ -140,7 +141,7 @@ public class SDNYMainProcessController extends AbstractController {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
@ -157,9 +158,9 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,JSONObject.toJSONString(R.error("发票号码不能为空!")), "发票号码不能为空!");
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(R.error("发票号码不能为空!")), "发票号码不能为空!");
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票号码不能为空!")));
@ -176,10 +177,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,
JSONObject.toJSONString(R.error("开票日期不能为空!")), "开票日期不能为空!");
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("开票日期不能为空!")));
@ -189,10 +190,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,
JSONObject.toJSONString(R.error("发票类型不能为空!")), "发票类型不能为空!");
} catch (BaseException e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("发票类型不能为空!")));
@ -208,10 +209,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,
JSONObject.toJSONString(R.error("金额不能为空!")), "金额不能为空!");
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("金额不能为空!")));
@ -221,10 +222,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,
JSONObject.toJSONString(R.error("校验码不能为空!")), "校验码不能为空!");
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("校验码不能为空!")));
@ -244,10 +245,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,
JSONObject.toJSONString(R.error(notes)), notes);
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error(notes)));
@ -274,11 +275,10 @@ public class SDNYMainProcessController extends AbstractController {
DynamicContextHolder.push("business" + DbConstant.DETAIL_READ);
baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper);
}
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ);
if((baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0) && (vehicleList == null || vehicleList.size() == 0)){
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,null);
if ((baseTDxRecordInvoiceDetail == null || baseTDxRecordInvoiceDetail.size() == 0) && (vehicleList == null || vehicleList.size() == 0)) {
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null);
List<String> activeCallRequest = new ArrayList<>();
activeCallRequest.add(JSONObject.toJSONString(pramsMap));
@ -291,7 +291,7 @@ public class SDNYMainProcessController extends AbstractController {
if (!checkInvoiceResult.containsKey("cyjg")) {
//先删除原有主数据,再查验更新主数据和明细数据
int delete = baseTDxRecordInvoiceDao.delete(recordWrapper);
if(delete > 0) {
if (delete > 0) {
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber"));
signSaveInvoiceInfoService.saveQueryInvoiceResult(checkInvoiceResult, userid, "1", dbName);
if ("10104".equals(pramsMap.get("invoiceType")) || "10105".equals(pramsMap.get("invoiceType"))) {
@ -301,16 +301,17 @@ public class SDNYMainProcessController extends AbstractController {
baseTDxRecordInvoiceDetail = baseTDxRecordInvoiceDetailDao.selectList(detailWrapper);
DynamicContextHolder.push("business" + DbConstant.BUSINESS_READ);
}
}
}else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) {
} else if (checkInvoiceResult.containsKey("cyjg") && !"0001".equals(checkInvoiceResult.getString("cyjg"))) {
data = errorInfo(checkInvoiceResult, data);
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,JSONObject.toJSONString(data),
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(data),
(String) checkInvoiceResult.get("cyjgxx"));
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -335,14 +336,14 @@ public class SDNYMainProcessController extends AbstractController {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
if (checkInvoiceResult != null) {
if (checkInvoiceResult.containsKey("code")) {
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,JSONObject.toJSONString(data),
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(data),
(String) checkInvoiceResult.get("message"));
}
} else {
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord,JSONObject.toJSONString(data));
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data));
}
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -373,7 +374,7 @@ public class SDNYMainProcessController extends AbstractController {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -382,29 +383,29 @@ public class SDNYMainProcessController extends AbstractController {
}
try {
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,"1");
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, "1");
List<String> activeCallRequest = new ArrayList<>();
activeCallRequest.add(JSONObject.toJSONString(pramsMap));
activeCallRequest.add(JSONObject.toJSONString("1"));
singleInvoiceCheckRecord.setActiveCallRequestDetail(JSONObject.toJSONString(activeCallRequest));
singleInvoiceCheckRecord.setActiveCall("singleCheckInvoice");
singleInvoiceCheckRecord.setActiveCallResponse(JSONObject.toJSONString(checkInvoiceResult));
List<String> activeCallRequest = new ArrayList<>();
activeCallRequest.add(JSONObject.toJSONString(pramsMap));
activeCallRequest.add(JSONObject.toJSONString("1"));
singleInvoiceCheckRecord.setActiveCallRequestDetail(JSONObject.toJSONString(activeCallRequest));
singleInvoiceCheckRecord.setActiveCall("singleCheckInvoice");
singleInvoiceCheckRecord.setActiveCallResponse(JSONObject.toJSONString(checkInvoiceResult));
log.info("查验结果为:{}", checkInvoiceResult);
log.info("查验结果为:{}", checkInvoiceResult);
} catch (Exception e) {
e.printStackTrace();
log.error("查验失败,errormsg:{}",e.getMessage());
log.error("查验失败,errormsg:{}", e.getMessage());
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,1,JSONObject.toJSONString(R.error("查验失败,"+e.getMessage())),
"查验失败,异常信息:{}"+JSONObject.toJSONString(e.getMessage()));
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 1, JSONObject.toJSONString(R.error("查验失败," + e.getMessage())),
"查验失败,异常信息:{}" + JSONObject.toJSONString(e.getMessage()));
} catch (Exception exception) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败,"+e.getMessage())));
return ResponseEntity.ok(JSONObject.toJSONString(R.error("查验失败," + e.getMessage())));
}
if (!checkInvoiceResult.containsKey("code")) {
@ -415,10 +416,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0,JSONObject.toJSONString(data),
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(data),
(String) checkInvoiceResult.get("cyjgxx"));
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -436,9 +437,9 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord,JSONObject.toJSONString(data));
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
}
@ -448,7 +449,7 @@ public class SDNYMainProcessController extends AbstractController {
Map map = JSONObject.parseObject(JSONObject.toJSONString(object), Map.class);
String taxRate = (String) map.get("taxRate");
if ("0".equals(taxRate) || "*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) {
map.put("taxRate","0.00");
map.put("taxRate", "0.00");
}
}
data.put("data", checkInvoiceResult);
@ -458,7 +459,7 @@ public class SDNYMainProcessController extends AbstractController {
} else {
//其他类发票,直接入库
R data = new R(1000, "default success");
if(!checkInvoiceResult.isEmpty()) {
if (!checkInvoiceResult.isEmpty()) {
log.info("其他类发票,不做查验,直接入库");
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
data.put("message", "success");
@ -468,15 +469,15 @@ public class SDNYMainProcessController extends AbstractController {
log.info("返回给影像系统的结果为:{}", checkInvoiceResult);
data.put("data", checkInvoiceResult);
}else{
} else {
data.put("message", "error 其他类发票不支持查验");
}
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord,JSONObject.toJSONString(data));
requestRecordService.saveSuccessfulRequestRecord(singleInvoiceCheckRecord, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -485,10 +486,10 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord,0,JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)),
requestRecordService.saveFailedRequestRecord(singleInvoiceCheckRecord, 0, JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)),
"未知异常,请联系管理员");
} catch (Exception e) {
log.error("发票查验接口记录保存失败,errormsg:{}",e);
log.error("发票查验接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error().put("data", checkInvoiceResult)));
@ -823,6 +824,209 @@ public class SDNYMainProcessController extends AbstractController {
String taxRate = "";
List<Map<String, String>> returnDetailList = new ArrayList<>();
JSONArray detailList = detailArray;
for (int i = 0; i < detailList.size(); i++) {
String taxRateDetail = "";
JSONObject detail = (JSONObject) detailList.get(i);
if (StringUtils.isNotEmpty(detail.getString("goodsName")) && (detail.getString("goodsName").equals("(详见销货清单)") || detail.getString("goodsName").equals("(详见销货清单)"))) {
continue;
}
Map<String, String> snDetailMap = new HashMap<String, String>();
snDetailMap.put("rowNo", i + 1 + "");
snDetailMap.put("commodityCode", detail.getString("goodsNum"));
snDetailMap.put("commodityName", detail.getString("goodsName"));
snDetailMap.put("specificationModel", detail.getString("model"));
snDetailMap.put("unit", detail.getString("unit"));
String quantity = detail.getString("num");
snDetailMap.put("quantity", quantity);
String unitPrice = detail.getString("unitPrice");
snDetailMap.put("unitPrice", unitPrice);
if ("11".equals(invoiceType)) {
snDetailMap.put("tax", "0");
//如果是卷票计算合计金额
String hjje = null;
if (detail.getString("detailAmount") != null && detail.getString("taxAmount") != null) {
BigDecimal je = new BigDecimal(detail.getString("detailAmount"));
if (detail.getString("taxAmount") != null) {
hjje = je.add(new BigDecimal(detail.getString("taxAmount"))).toPlainString();
} else {
hjje = je.toPlainString();
}
}
if (StringUtils.isNotBlank(hjje))
snDetailMap.put("amount", hjje);
} else {
snDetailMap.put("tax", "***".equals(detail.getString("taxAmount")) ? "0.00" : detail.getString("taxAmount"));
snDetailMap.put("amount", detail.getString("detailAmount"));
}
if ("免税".equals(detail.getString("taxRate")) || "不征税".equals(detail.getString("taxRate")) || "***".equals(detail.getString("taxRate"))) {
taxRateDetail = "0";
snDetailMap.put("taxRate", taxRateDetail);
} else {
if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) {
try {
taxRateDetail = detail.get("taxRate").toString();
if (!"0".equals(taxRateDetail)) {
if (StringUtils.isNoneBlank(taxRateDetail)) {
if (taxRateDetail.contains("%")) {
taxRateDetail = taxRateDetail.replace("%", "");
}
BigDecimal tax = new BigDecimal(taxRateDetail);
BigDecimal tax1 = tax.divide(new BigDecimal("100"));
if (tax.compareTo(new BigDecimal("0.99")) < 1) {
taxRateDetail = tax.toPlainString();
} else {
taxRateDetail = tax1.toPlainString();
}
}
}
} catch (Exception e) {
log.error("报错的原因为:{}", e);
taxRateDetail = "0.00";
}
if ("11".equals(invoiceType)) {
taxRateDetail = "0.000";
}
log.info("明细-发票税率为:{}", taxRateDetail);
snDetailMap.put("taxRate", taxRateDetail);
}
}
log.info("明细-tax={}", detail.get("taxAmount"));
snDetailMap.put("currentDateEnd", detail.getString("txrqz"));
snDetailMap.put("currentDateStart", detail.getString("txrqq"));
snDetailMap.put("licensePlateNum", detail.getString("cph"));
snDetailMap.put("type", detail.getString("lx"));
returnDetailList.add(snDetailMap);
}
}
checkInvoice.put("invoiceLineList", returnDetailList);
}
private void convertToResult(JSONObject checkInvoice, JSONArray detailArray, JSONObject vehicleList) throws ParseException {
checkInvoice.put("totalTax", checkInvoice.getString("taxAmount"));
checkInvoice.put("amountTax", checkInvoice.getString("totalAmount"));
checkInvoice.put("totalAmount", checkInvoice.getString("invoiceAmount"));
// 增加备注字段
checkInvoice.put("remarks", checkInvoice.getString("remark"));
//添加非空判断
String invoiceCode = null;
if (checkInvoice.get("invoiceCode") != null) {
invoiceCode = checkInvoice.get("invoiceCode").toString();
}
String invoiceType = checkInvoice.get("invoiceType").toString();
if ("22".equals(invoiceType)) {
invoiceType = "33";
}
if ("21".equals(invoiceType)) {
invoiceType = "31";
}
checkInvoice.put("invoiceType", invoiceType);
checkInvoice.put("administrativeDivisionNo", "");
checkInvoice.put("administrativeDivisionName", "");
if ("31".equals(invoiceType) || "32".equals(invoiceType) || "185".equals(invoiceType) || "186".equals(invoiceType)) {
checkInvoice.put("invoiceCode", "");
checkInvoice.put("invoiceNumber", invoiceCode == null ? checkInvoice.get("invoiceNo").toString() : invoiceCode + checkInvoice.get("invoiceNo").toString());
} else {
checkInvoice.put("invoiceCode", invoiceCode);
checkInvoice.put("invoiceNumber", checkInvoice.get("invoiceNo").toString());
}
String uuid = "";
if (invoiceCode != null && StringUtils.isNoneBlank(invoiceCode)) {
uuid = invoiceCode + checkInvoice.get("invoiceNo").toString();
checkInvoice.put("uuid", uuid);
} else {
uuid = checkInvoice.get("invoiceNo").toString();
checkInvoice.put("uuid", uuid);
}
String kprq = checkInvoice.get("invoiceDate").toString();
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
Date date = sdf.parse(kprq);
String formatStr = new SimpleDateFormat("yyyy-MM-dd").format(date);
log.info("开票日期为:{} ", formatStr);
checkInvoice.put("billingDate", formatStr);
checkInvoice.put("purchaserName", checkInvoice.get("gfName"));
checkInvoice.put("purchaserTaxNo", checkInvoice.get("gfTaxNo"));
checkInvoice.put("purchaserBank", checkInvoice.get("gfBankAndNo"));
checkInvoice.put("purchaserAddressPhone", checkInvoice.get("gfAddressAndPhone"));
checkInvoice.put("salesName", checkInvoice.get("xfName"));
checkInvoice.put("salesTaxNo", checkInvoice.get("xfTaxNo"));
checkInvoice.put("salesAddressPhone", checkInvoice.get("gfAddressAndPhone"));
checkInvoice.put("salesBank", checkInvoice.get("gfBankAndNo"));
checkInvoice.put("checkCode", checkInvoice.get("checkCode"));
if("1".equals(checkInvoice.get("invoiceStatus"))){
checkInvoice.put("state", "3");
}else if("2".equals(checkInvoice.get("invoiceStatus"))){
checkInvoice.put("state", "1");
}else if("3".equals(checkInvoice.get("invoiceStatus")) || "7".equals(checkInvoice.get("invoiceStatus")) || "8".equals(checkInvoice.get("invoiceStatus"))){
checkInvoice.put("state", "2");
}else if("4".equals(checkInvoice.get("invoiceStatus"))){
checkInvoice.put("state", "4");
}else if("0".equals(checkInvoice.get("invoiceStatus"))){
checkInvoice.put("state", "0");
}
checkInvoice.put("tollSign", "07");
//机动车
if ("03".equals(invoiceType)) {
checkInvoice.put("vehicleType", vehicleList.getString("vehicleType"));
checkInvoice.put("brandModel", vehicleList.getString("factoryModel"));
checkInvoice.put("originPlace", vehicleList.getString("productPlace"));
checkInvoice.put("certificateNo", vehicleList.getString("certificate"));
checkInvoice.put("inspectionListNo", vehicleList.getString("inspectionNum"));
checkInvoice.put("engineNo", vehicleList.getString("engineNo"));
checkInvoice.put("vehicleNo", vehicleList.getString("vehicleNo"));
checkInvoice.put("paymentVoucherNo", vehicleList.getString("taxRecords"));
checkInvoice.put("passengersLimited", vehicleList.getString("limitPeople"));
checkInvoice.put("taxAuthorityNo", vehicleList.getString("taxBureauCode"));
checkInvoice.put("taxAuthorityName", vehicleList.getString("taxBureauName"));
checkInvoice.put("idcardNo", vehicleList.getString("buyerIdNum"));
checkInvoice.put("amountTax", vehicleList.getString("carPrice"));
}
//二手车
if ("15".equals(invoiceType)) {
checkInvoice.put("vehicleType", vehicleList.getString("vehicleType"));
checkInvoice.put("vehicleNo", vehicleList.getString("vehicleNo"));
checkInvoice.put("brandModel", vehicleList.getString("factoryModel"));
checkInvoice.put("licensePlate", vehicleList.getString("plateNo"));
checkInvoice.put("buyerUnitOrIndividual", vehicleList.getString("buyerUnit"));
checkInvoice.put("buyerUnitCodeOrIdNo", vehicleList.getString("buyerUnitCode"));
checkInvoice.put("buyerUnitOrIndividualAddress", vehicleList.getString("buyerUnitAddress"));
checkInvoice.put("sellerUnitOrIndividual", vehicleList.getString("sellerUnit"));
checkInvoice.put("sellerUnitCodeOrIdNo", vehicleList.getString("sellerUnitCode"));
checkInvoice.put("sellerUnitOrIndividualAddress", vehicleList.getString("sellerUnitAddress"));
checkInvoice.put("sellerPhone", vehicleList.getString("sellerPhone"));
checkInvoice.put("lemonMarket", vehicleList.getString("carMarket"));
checkInvoice.put("lemonMarketAddress", vehicleList.getString("carMarketAddress"));
checkInvoice.put("lemonMarketPhone", vehicleList.getString("carMarketPhone"));
checkInvoice.put("lemonMarketBankAndAccount", vehicleList.getString("carMarketBank"));
checkInvoice.put("vehicleAdminOffice", vehicleList.getString("vehicleAdminOffice"));
checkInvoice.put("registrationNo", vehicleList.getString("registrationNo"));
checkInvoice.put("lemonMarketTaxNo", vehicleList.getString("carMarketTaxNo"));
checkInvoice.put("idcardNo", vehicleList.getString("buyerIdNum"));
checkInvoice.put("amountTax", vehicleList.getString("carPrice"));
}
String taxRate = "";
List<Map<String, String>> returnDetailList = new ArrayList<>();
JSONArray detailList = detailArray;
if (detailList != null) {
for (int i = 0; i < detailList.size(); i++) {
@ -925,15 +1129,15 @@ public class SDNYMainProcessController extends AbstractController {
List<String> invoiceCodes = new ArrayList<>();
List<String> invoiceNos = new ArrayList<>();
RequestRecord record=null;
if (snRequestObject.getInvoiceInfoList()!=null && snRequestObject.getInvoiceInfoList().size()>0) {
snRequestObject.getInvoiceInfoList().stream().forEach(invoiceInfo->{
RequestRecord record = null;
if (snRequestObject.getInvoiceInfoList() != null && snRequestObject.getInvoiceInfoList().size() > 0) {
snRequestObject.getInvoiceInfoList().stream().forEach(invoiceInfo -> {
invoiceCodes.add(invoiceInfo.getInvoiceCode());
invoiceNos.add(invoiceInfo.getInvoiceNumber());
});
log.info("影像系统同步数据的发票号码为:{}", JSONObject.toJSONString(invoiceNos));
log.info("影像系统同步数据的发票代码为:{}", JSONObject.toJSONString(invoiceCodes));
if (invoiceCodes.size()>0) {
if (invoiceCodes.size() > 0) {
record = requestRecordService.getBaseRequestRecord(JSONObject.toJSONString(snRequestObject),
"/syncInvoiceInfo",
JSONObject.toJSONString(invoiceCodes),
@ -1017,9 +1221,9 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(record,0, JSONObject.toJSONString(R.error(result)), result);
requestRecordService.saveFailedRequestRecord(record, 0, JSONObject.toJSONString(R.error(result)), result);
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error(result)));
@ -1043,15 +1247,32 @@ public class SDNYMainProcessController extends AbstractController {
result = snPushCheckRecordService.pushCheckResultToSAP(request.toJSONString());
record.setActiveCallResponse(JSONObject.toJSONString(result));
R data = new R(1000, "default success");
data.put("data", result);
R data = new R();
JSONObject sapResult = JSONObject.parseObject(result);
String es_output = sapResult.getString("ES_OUTPUT");
if(StringUtils.isNotEmpty(es_output)) {
JSONObject outputResult = JSONObject.parseObject(es_output);
if ("S".equals(outputResult.getString("ZTYPE"))) {
data = new R(1000, "default success");
data.put("data", result);
} else if ("E".equals(outputResult.getString("ZTYPE"))) {
data = new R(1001, "request error");
data.put("data", result);
} else {
data = new R(1002, "unknown error");
data.put("data", result);
}
}else{
data = new R(1002, "unknown error");
data.put("data", result);
}
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(record, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -1062,10 +1283,10 @@ public class SDNYMainProcessController extends AbstractController {
// requestRecordService.saveRecord(pushCheckResultToSAPRecord,1, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)), 1);
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)),
"推送sap失败,失败原因:"+"{"+JSONObject.toJSONString(e)+"}");
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)),
"推送sap失败,失败原因:" + "{" + JSONObject.toJSONString(e) + "}");
} catch (Exception exception) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_PUSH_SDNY)));
@ -1092,7 +1313,7 @@ public class SDNYMainProcessController extends AbstractController {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(record, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -1117,7 +1338,7 @@ public class SDNYMainProcessController extends AbstractController {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveSuccessfulRequestRecord(record, JSONObject.toJSONString(data));
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.ok(JSONObject.toJSONString(data));
@ -1130,36 +1351,36 @@ public class SDNYMainProcessController extends AbstractController {
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)),
"同步SAP失败,报错信息为:"+"{"+JSONObject.toJSONString(exception)+"}");
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)),
"同步SAP失败,报错信息为:" + "{" + JSONObject.toJSONString(exception) + "}");
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.status(HttpStatus.GATEWAY_TIMEOUT).body(JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)));
} catch(NullPointerException exception){
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.CONNECT_TIMEOUT)));
} catch (NullPointerException exception) {
log.error("同步SAP失败,报错信息为:{}", exception);
exception.printStackTrace();
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)),
"同步SAP失败,报错信息为:"+"{"+JSONObject.toJSONString(exception)+"}");
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)),
"同步SAP失败,报错信息为:" + "{" + JSONObject.toJSONString(exception) + "}");
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)));
} catch(Exception exception){
return ResponseEntity.ok(JSONObject.toJSONString(R.error(CommonConstants.NULL_POINTER_TIMEOUT)));
} catch (Exception exception) {
log.error("同步SAP失败,报错信息为:{}", exception);
exception.printStackTrace();
try {
DynamicContextHolder.push("business" + DbConstant.BUSINESS_WRITE);
requestRecordService.saveFailedRequestRecord(record,1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)),
"同步SAP失败,报错信息为:"+"{"+JSONObject.toJSONString(exception)+"}");
requestRecordService.saveFailedRequestRecord(record, 1, JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)),
"同步SAP失败,报错信息为:" + "{" + JSONObject.toJSONString(exception) + "}");
} catch (Exception e) {
log.error("发票同步接口记录保存失败,errormsg:{}",e);
log.error("发票同步接口记录保存失败,errormsg:{}", e);
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(JSONObject.toJSONString(R.error(CommonConstants.MSG_ERR_DEFAULT)));
@ -1296,13 +1517,13 @@ public class SDNYMainProcessController extends AbstractController {
if (snInvoiceDetail.getAmount() != null)
sapInvoiceDetail.setZJK(snInvoiceDetail.getAmount());
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo());
sapInvoiceDetail.setZHH(snInvoiceDetail.getRowNo());
//将类似于0.03数据格式转化为3.00
if (snInvoiceDetail.getTaxRate() != null && snInvoiceDetail.getTaxRate() != "") {
String taxRate = snInvoiceDetail.getTaxRate();
sapInvoiceDetail.setZTAX(taxRate);
if (taxRate.contains("%")){
taxRate = taxRate.replace("%","");
if (taxRate.contains("%")) {
taxRate = taxRate.replace("%", "");
}
if ("0".equals(taxRate) || "*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) {
sapInvoiceDetail.setZTAX("0.00");
@ -1315,7 +1536,7 @@ public class SDNYMainProcessController extends AbstractController {
sapInvoiceDetail.setZTAX(tax1.toString());
if (tax1.compareTo(new BigDecimal("99")) > 0) {
sapInvoiceDetail.setZTAX(taxRate);
}else {
} else {
DecimalFormat decimalFormat = new DecimalFormat("#.00");
String formattedDecimal = decimalFormat.format(tax1);
sapInvoiceDetail.setZTAX(formattedDecimal);
@ -1390,7 +1611,7 @@ public class SDNYMainProcessController extends AbstractController {
BigDecimal tax = new BigDecimal(taxRate);
info.setZSM(getZSM(tax.toPlainString()));
BigDecimal tax1 = tax.multiply(new BigDecimal("100"));
info.setZTAX(tax1.setScale(2,RoundingMode.FLOOR).toPlainString());
info.setZTAX(tax1.setScale(2, RoundingMode.FLOOR).toPlainString());
}
if (taxRate != null && "0".equals(taxRate)) {
@ -1485,12 +1706,12 @@ public class SDNYMainProcessController extends AbstractController {
|| "08".equals(snInvoice.getInvoiceType()) || "10".equals(snInvoice.getInvoiceType()) || "11".equals(snInvoice.getInvoiceType()) || "14".equals(snInvoice.getInvoiceType())
|| "15".equals(snInvoice.getInvoiceType()) || "31".equals(snInvoice.getInvoiceType()) || "32".equals(snInvoice.getInvoiceType())) {
//可查验发票,
log.info("发票类型为:{}",snInvoice.getInvoiceType());
log.info("发票类型为:{}", snInvoice.getInvoiceType());
//0608 区块链发票 并且 checkStatus = 3 的时候 提交sap状态为3(刘振和谈楚才提出需求)
if("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())){
if ("10".equals(snInvoice.getInvoiceType()) && "3".equals(snInvoice.getCheckStatus())) {
log.info("区块链发票 传输状态checkStatus = 3");
info.setZCYZT("3");
}else {
} else {
info.setZCYZT("1");
}
} else {

@ -16,4 +16,4 @@ public interface VihicleInvoiceDetailDao extends BaseMapper<TDxVehicleSaleInvoic
List<TDxVehicleSaleInvoice> selectVehicleInvoiceInfo(String uuid);
}
}

@ -79,9 +79,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
@Resource
private ApiUtils apiUtils;
@Autowired
private AreaDao areaDao;
@Resource
private BaseTDxTaxCurrentDao baseTDxTaxCurrentDao;
@ -109,6 +106,9 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
@Resource
private TdxPlatformCheckLogService platformCheckLogService;
@Resource
private VihicleInvoiceDetailDao vihicleInvoiceDetailDao;
public String pushCheckResultToSAP(String requestParam) {
log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl);
String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password);
@ -117,7 +117,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
return post;
}
public String pushInvoiceToRecordInvoice(SNInvoice snInvoice, String taxNo, String company, String imageId, String compCode) {
public String pushInvoiceToRecordInvoice(SNInvoice snInvoice, String taxNo, String company, String imageId, String compCode) {
TDxInvoiceReimburse recordInvoice = new TDxInvoiceReimburse();
// DynamicContextHolder.push(DbConstant.BASICS_READ);
@ -275,6 +275,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
/**
* 发票查验API
*
* @param pramsMap
* @param isInteger
* @return
@ -403,11 +404,11 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
jsonObject.put("checkCode", invoiceData.get("jym"));
if ("N".equals(invoiceData.get("zfbz"))) {
if ("N".equals(invoiceData.get("fpzt"))) {
jsonObject.put("state", "0");
} else if ("H".equals(invoiceData.get("zfbz"))) {
} else if ("3".equals(invoiceData.get("fpzt")) || "7".equals(invoiceData.get("fpzt")) || "8".equals(invoiceData.get("fpzt"))) {
jsonObject.put("state", "2");
} else if ("Y".equals(invoiceData.get("zfbz"))) {
} else if ("Y".equals(invoiceData.get("fpzt"))) {
jsonObject.put("state", "1");
}
@ -476,10 +477,10 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
if (StringUtils.isNoneBlank(invoiceData.get("sl").toString())) {
taxRate = invoiceData.get("sl").toString();
if (taxRate.contains("%")) {
taxRate = taxRate.replace("%","");
taxRate = taxRate.replace("%", "");
}
//按照小数处理
if(StringUtils.isNotBlank(isInteger)){
if (StringUtils.isNotBlank(isInteger)) {
BigDecimal bigDecimal = new BigDecimal(taxRate);
taxRate = bigDecimal.divide(new BigDecimal("100")).toPlainString();
}
@ -579,13 +580,13 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
// taxRate = taxRate.substring(0, taxRate.length() - 1);
// }
//按照小数处理
if(StringUtils.isNotBlank(isInteger)){
if (StringUtils.isNotBlank(isInteger)) {
if ("*".equals(taxRate) || "**".equals(taxRate) || "***".equals(taxRate) || "不征税".equals(taxRate) || "免税".equals(taxRate)) {
} else {
BigDecimal bigDecimal = new BigDecimal(taxRate);
taxRate = bigDecimal.divide(new BigDecimal("100")).toPlainString();
}
BigDecimal bigDecimal = new BigDecimal(taxRate);
taxRate = bigDecimal.divide(new BigDecimal("100")).toPlainString();
}
}
if ("11".equals(invoiceType)) {
taxRate = "0";
}
@ -645,7 +646,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
}
if(!flag) {
if (!flag) {
invoiceResult = this.valoremTaxCount(invoiceInfo, "Y");
InvoiceInfo data = invoiceResult.getData();
if (data != null) {
@ -725,20 +726,20 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
String billingDate = invoice.getBillingDate().replaceAll("-", "");
pramsMap.put("billingDate", billingDate);
}
if("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())){
if ("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())) {
pramsMap.put("totalAmount", invoice.getAmountTax());
}else{
} else {
pramsMap.put("totalAmount", invoice.getTotalAmount());
}
pramsMap.put("purchaserTaxNo", invoice.getPurchaserTaxNo());
if("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())){
if ("31".equals(invoice.getInvoiceType()) || "32".equals(invoice.getInvoiceType())) {
pramsMap.put("invoiceType", "21");
}else {
} else {
pramsMap.put("invoiceType", invoice.getInvoiceType());
}
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap,null);
checkInvoiceResult = snPushCheckRecordService.singleCheckInvoice(pramsMap, null);
log.info("补充查验结果为:{}", checkInvoiceResult);
} catch (Exception e) {
e.printStackTrace();
@ -894,6 +895,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter {
}
private InvoiceInfo convertToInvoiceInfo(SNInvoice snInvoice) {
InvoiceInfo invoice = new InvoiceInfo();
invoice.setInvoiceTypeCode(snInvoice.getInvoiceType());

@ -1709,7 +1709,9 @@ public class InvoicePoolServiceImpl implements InvoicePoolService {
&& detailInfo.getGoodsName().indexOf("详见") >= 0) {
detailInfo.setGoodsName(changeBrackets(detailInfo.getGoodsName()));
}
set.add(detailInfo.getIncentiveFlag().trim());
if(StringUtils.isNotEmpty(detailInfo.getIncentiveFlag())) {
set.add(detailInfo.getIncentiveFlag().trim());
}
detailInfo.setInvoiceCode(invoiceCode);
detailInfo.setInvoiceNo(invoiceNo);
detailInfo.setUuid(invoiceCode + invoiceNo);

@ -4,13 +4,13 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 172.31.36.147:33000
server-addr: 172.31.36.146:33000
# Nacos config 命名空间,对应配置中的名称(dxhy-jxpt-namespace)
namespace: eb6eab27-62a4-4ccf-8640-b8e91df0a1a6
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
# Nacos config 分组
group: dxhy-erp-group
# Nacos config 登录用户名
username: nacos
username: admin
# Nacos config 登录密码
password: Invoice.nacos.!1
# Nacos config 配置文件前缀
@ -19,9 +19,7 @@ spring:
file-extension: yaml
# Nacos discovery 配置
discovery:
server-addr: 172.31.36.147:33000
# Nacos config 登录用户名
username: nacos
# Nacos config 登录密码
server-addr: 172.31.36.146:33000
username: admin
password: Invoice.nacos.!1
namespace: eb6eab27-62a4-4ccf-8640-b8e91df0a1a6
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c

@ -4,7 +4,7 @@ spring:
nacos:
config:
# Nacos config 地址
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
# Nacos config 命名空间,对应配置中的名称(dxhy-jxpt-namespace)
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c
# Nacos config 分组
@ -19,7 +19,7 @@ spring:
file-extension: yaml
# Nacos discovery 配置
discovery:
server-addr: 172.31.36.143:33000
server-addr: 172.31.36.146:33000
username: admin
password: Invoice.nacos.!1
namespace: b271ba8e-84d9-4393-88b8-9271aff9465c

@ -178,8 +178,20 @@ public class ExtInvoicePoolController extends AbstractController {
pramsMap.put("accountPeriod", accountPeriod);
log.info("accountPeriod:{}",accountPeriod);
}
int curr = (int)pramsMap.get("curr");
int size = (int)pramsMap.get("size");
if (StringHelper.isNotBlank(companyCode) && "99".equals(companyCode)){
pramsMap.put("companyCodes",getUserInfo().getCompanyCodes());
log.info("组织编码===>{}", pramsMap.get("companyCodes"));
}
int curr = 1;
int size = 20;
if(pramsMap.get("curr") != null) {
curr = (int) pramsMap.get("curr");
}
if(pramsMap.get("size") != null) {
size = (int) pramsMap.get("size");
}
try {
log.info("其他发票采集接收参数 {}" ,pramsMap);
return ResponseEntity.ok(R.ok().put("data", extInvoicePoolService.listOther(pramsMap, curr, size)));

@ -188,7 +188,10 @@
<deployType>test</deployType>
<logging.file>/home/dxhy/logs/</logging.file>
</properties>
<!-- 默认激活 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!-- 伊利测试环境 -->
<profile>
@ -221,10 +224,7 @@
<deployType>std</deployType>
<logging.file>/home/dxhy/logs/</logging.file>
</properties>
<!-- 默认激活 -->
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>

Loading…
Cancel
Save