|
|
@@ -16,9 +16,7 @@ import org.springblade.check.dto.AuditProecessDTO;
|
|
|
import org.springblade.check.entity.AuditPathsActs;
|
|
|
import org.springblade.check.entity.AuditPathsLevels;
|
|
|
import org.springblade.check.feign.ICheckClient;
|
|
|
-import org.springblade.client.entity.CommonFile;
|
|
|
import org.springblade.client.entity.Message;
|
|
|
-import org.springblade.client.feign.ICommonFileClient;
|
|
|
import org.springblade.client.feign.IMessageClient;
|
|
|
import org.springblade.client.feign.ISerialClient;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
@@ -38,10 +36,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.MathContext;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 报关表 服务实现类
|
|
|
@@ -62,7 +57,6 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
private final DeclareCustomsFilesMapper filesMapper;//报关附件
|
|
|
|
|
|
private final ICheckClient iCheckClient;//审批
|
|
|
- private final ICommonFileClient commonFileClient;//附件
|
|
|
private final IFinanceClient financeClient;//财务
|
|
|
private final ISysClient sysClient;
|
|
|
|
|
|
@@ -278,38 +272,53 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
@GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public DeclareCustoms checkDeclareCustoms(DeclareCustoms declareCustoms) {
|
|
|
DeclareCustoms declare = baseMapper.selectById(declareCustoms.getId());
|
|
|
- if (declare.getStatus() == 1){
|
|
|
- throw new SecurityException("订单已请核,请勿重复请核");
|
|
|
+ if (declare.getStatus() == 1) {
|
|
|
+ throw new SecurityException("订单已开启审核,请勿重复提交");
|
|
|
+ }else if (declare.getStatus() == 5){
|
|
|
+ throw new SecurityException("订单已开启复审,请勿重复提交");
|
|
|
}
|
|
|
|
|
|
//审批数据
|
|
|
AuditProecessDTO auditProecessDTO = new AuditProecessDTO();
|
|
|
//获取审批级次
|
|
|
- List<AuditPathsLevels> auditPathsLevels;
|
|
|
+ List<AuditPathsLevels> auditPathsLevels = null;
|
|
|
// 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
|
|
|
- AuditPathsActs pathsActs;
|
|
|
+ AuditPathsActs pathsActs = null;
|
|
|
|
|
|
//报关进口审批流程
|
|
|
if ("BGJK".equals(declareCustoms.getImportExportSigns())){
|
|
|
- if (declare.getStatus() == 1) {
|
|
|
- throw new SecurityException("订单已开启审核,请勿重复提交");
|
|
|
+ if (declare.getStatus() == 0){
|
|
|
+ //是否开启流程
|
|
|
+ pathsActs = iCheckClient.getActsByActId(17, "status");
|
|
|
+ //获取审批信息
|
|
|
+ auditPathsLevels = iCheckClient.listLevelsByActId(17, "status");
|
|
|
+ auditProecessDTO.setTimes(1);
|
|
|
+ auditProecessDTO.setProcessType("报关进口审批");
|
|
|
+ }else if (declare.getStatus() == 4){
|
|
|
+ //是否开启流程
|
|
|
+ pathsActs = iCheckClient.getActsByActId(19, "status");
|
|
|
+ //获取审批信息
|
|
|
+ auditPathsLevels = iCheckClient.listLevelsByActId(19, "status");
|
|
|
+ auditProecessDTO.setTimes(2);
|
|
|
+ auditProecessDTO.setProcessType("报关进口复审审批");
|
|
|
}
|
|
|
- //是否开启流程
|
|
|
- pathsActs = iCheckClient.getActsByActId(17, "status");
|
|
|
- //获取审批信息
|
|
|
- auditPathsLevels = iCheckClient.listLevelsByActId(17, "status");
|
|
|
|
|
|
- auditProecessDTO.setProcessType("报关进口审批");
|
|
|
}else if ("BGCK".equals(declareCustoms.getImportExportSigns())){//报关出口审批流程
|
|
|
- if (declare.getStatus() == 1) {
|
|
|
- throw new SecurityException("订单已开启审核,请勿重复提交");
|
|
|
+ if(declare.getStatus() == 0){
|
|
|
+ //是否开启流程
|
|
|
+ pathsActs = iCheckClient.getActsByActId(18, "status");
|
|
|
+ //获取审批信息
|
|
|
+ auditPathsLevels = iCheckClient.listLevelsByActId(18, "status");
|
|
|
+ auditProecessDTO.setTimes(1);
|
|
|
+ auditProecessDTO.setProcessType("报关出口审批");
|
|
|
+ }else if (declare.getStatus() == 4){
|
|
|
+ //是否开启流程
|
|
|
+ pathsActs = iCheckClient.getActsByActId(20, "status");
|
|
|
+ //获取审批信息
|
|
|
+ auditPathsLevels = iCheckClient.listLevelsByActId(20, "status");
|
|
|
+ auditProecessDTO.setTimes(2);
|
|
|
+ auditProecessDTO.setProcessType("报关出口复审审批");
|
|
|
}
|
|
|
- //是否开启流程
|
|
|
- pathsActs = iCheckClient.getActsByActId(18, "status");
|
|
|
- //获取审批信息
|
|
|
- auditPathsLevels = iCheckClient.listLevelsByActId(18, "status");
|
|
|
-
|
|
|
- auditProecessDTO.setProcessType("报关出口审批");
|
|
|
}else {
|
|
|
throw new SecurityException("缺少必要参数,审批失败");
|
|
|
}
|
|
|
@@ -330,6 +339,24 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
auditProecessDTO.setPageStatus(declareCustoms.getPageStatus());
|
|
|
auditProecessDTO.setPageLabel(declareCustoms.getPageLabel());
|
|
|
|
|
|
+ //获得明细信息
|
|
|
+ LambdaQueryWrapper<DeclareCustomsItem> itemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ itemLambdaQueryWrapper.eq(DeclareCustomsItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(DeclareCustomsItem::getIsDeleted, 0)
|
|
|
+ .eq(DeclareCustomsItem::getPid, declare.getId());
|
|
|
+ List<DeclareCustomsItem> itemList = declareCustomsItemMapper.selectList(itemLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(itemList)){
|
|
|
+ //数量
|
|
|
+ auditProecessDTO.setOrderQuantity(itemList.stream().map(DeclareCustomsItem::getTransactionsNumber).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ //金额
|
|
|
+ auditProecessDTO.setAmount(itemList.stream().map(DeclareCustomsItem::getTotalPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ }else {
|
|
|
+ auditProecessDTO.setOrderQuantity(BigDecimal.ZERO);
|
|
|
+ auditProecessDTO.setAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//应付
|
|
|
LambdaQueryWrapper<DeclareCustomsFees> receivableLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
receivableLambdaQueryWrapper.eq(DeclareCustomsFees::getIsDeleted, 0);
|
|
|
@@ -377,8 +404,14 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- declare.setStatus(1);
|
|
|
- declare.setAuditStatus("提交审核");
|
|
|
+ if (declare.getStatus() == 0){
|
|
|
+ declare.setStatus(1);
|
|
|
+ declare.setAuditStatus("初审提交审核");
|
|
|
+ }else if (declare.getStatus() == 4){
|
|
|
+ declare.setStatus(5);
|
|
|
+ declare.setAuditStatus("复审提交审核");
|
|
|
+ }
|
|
|
+
|
|
|
declare.setAuditTime(new Date());
|
|
|
baseMapper.updateById(declare);
|
|
|
|
|
|
@@ -394,17 +427,24 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
if (declareCustoms == null){
|
|
|
throw new SecurityException("审批通过失败");
|
|
|
}
|
|
|
- if (declareCustoms.getStatus() == 3){
|
|
|
+ if (declareCustoms.getStatus() == 4){
|
|
|
throw new SecurityException("订单已审批通过请勿重复审批");
|
|
|
+ }else if (declareCustoms.getStatus() == 7){
|
|
|
+ throw new SecurityException("订单已复审通过请勿重复审批");
|
|
|
}
|
|
|
|
|
|
- //生成账单
|
|
|
- this.paymentApply(declareCustoms, declareCustoms.getImportExportSigns(), declareCustoms.getImportExportSigns());
|
|
|
- declareCustoms.setStatus(3);
|
|
|
- declareCustoms.setAuditStatus("审批通过");
|
|
|
+ if (declareCustoms.getStatus() == 1 || declareCustoms.getStatus() == 2){
|
|
|
+ declareCustoms.setStatus(4);
|
|
|
+ declareCustoms.setAuditStatus("初审完成");
|
|
|
+ }else if (declareCustoms.getStatus() == 5 || declareCustoms.getStatus() == 6){
|
|
|
+ //生成账单
|
|
|
+ this.paymentApply(declareCustoms, declareCustoms.getImportExportSigns(), declareCustoms.getImportExportSigns());
|
|
|
+ declareCustoms.setStatus(7);
|
|
|
+ declareCustoms.setAuditStatus("复审通过");
|
|
|
+ }
|
|
|
baseMapper.updateById(declareCustoms);
|
|
|
|
|
|
- return R.success("审批通过");
|
|
|
+ return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -417,8 +457,14 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
throw new SecurityException("审批通过失败");
|
|
|
}
|
|
|
|
|
|
- declareCustoms.setStatus(2);
|
|
|
- declareCustoms.setAuditStatus("审批中");
|
|
|
+ if (declareCustoms.getStatus() == 1 || declareCustoms.getStatus() == 2){
|
|
|
+ declareCustoms.setStatus(2);
|
|
|
+ declareCustoms.setAuditStatus("初审审批中");
|
|
|
+ }else if (declareCustoms.getStatus() == 5 || declareCustoms.getStatus() == 6){
|
|
|
+ declareCustoms.setStatus(6);
|
|
|
+ declareCustoms.setAuditStatus("复审审批中");
|
|
|
+ }
|
|
|
+
|
|
|
baseMapper.updateById(declareCustoms);
|
|
|
|
|
|
return R.success("操作成功");
|
|
|
@@ -435,10 +481,18 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
}
|
|
|
if (declareCustoms.getStatus() == 0){
|
|
|
throw new SecurityException("订单已驳回或未提交审批,请勿重复操作");
|
|
|
+ }else if (declareCustoms.getStatus() == 4){
|
|
|
+ throw new SecurityException("订单已驳回或未提交复审,请勿重复操作");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (declareCustoms.getStatus() == 1 || declareCustoms.getStatus() == 2){
|
|
|
+ declareCustoms.setStatus(0);
|
|
|
+ declareCustoms.setAuditStatus("录入");
|
|
|
+ }else if (declareCustoms.getStatus() == 5 || declareCustoms.getStatus() == 6){
|
|
|
+ declareCustoms.setStatus(4);
|
|
|
+ declareCustoms.setAuditStatus("初审完成");
|
|
|
}
|
|
|
|
|
|
- declareCustoms.setStatus(0);
|
|
|
- declareCustoms.setAuditStatus("录入");
|
|
|
baseMapper.updateById(declareCustoms);
|
|
|
|
|
|
return R.success("操作成功");
|
|
|
@@ -461,51 +515,69 @@ public class DeclareCustomsServiceImpl extends ServiceImpl<DeclareCustomsMapper,
|
|
|
throw new SecurityException("撤销失败,订单已审核通过");
|
|
|
}else if (customs.getStatus().equals(0)){
|
|
|
throw new SecurityException("撤销失败,订单未提交审核");
|
|
|
+ }else if (customs.getStatus().equals(6)){
|
|
|
+ throw new SecurityException("撤销失败,订单正在复审审批中");
|
|
|
+ }else if (customs.getStatus().equals(7)){
|
|
|
+ throw new SecurityException("撤销失败,订单复审已审核通过");
|
|
|
+ }else if (customs.getStatus().equals(4)){
|
|
|
+ throw new SecurityException("撤销失败,订单未提交复审审核");
|
|
|
}
|
|
|
|
|
|
- //获取账单信息
|
|
|
- Acc acc = new Acc();
|
|
|
- acc.setSrcParentId(customs.getId());
|
|
|
- if ("BGJK".equals(customs.getImportExportSigns())) {
|
|
|
- acc.setBillType("申请");
|
|
|
- } else {
|
|
|
- acc.setBillType("收费");
|
|
|
- }
|
|
|
- acc.setTradeType("JGBG");
|
|
|
- acc.setSrcType(8);
|
|
|
- R<List<Acc>> r = financeClient.getAccListByCondition(acc);
|
|
|
- if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
- for (Acc acc_ : r.getData()) {
|
|
|
- //判断是否有结算 true 不允许撤销审核 false 删除账单信息并撤销审核
|
|
|
- if (!acc_.getSettlementAmount().equals(new BigDecimal("0.00"))) {
|
|
|
- throw new SecurityException("订单已结算,不允许撤销");
|
|
|
- } else {
|
|
|
- financeClient.remove(acc_.getId() + "");
|
|
|
+ if (customs.getStatus() == 1){
|
|
|
+ //修改单据状态
|
|
|
+ customs.setStatus(0);
|
|
|
+ customs.setAuditStatus("初审撤销");
|
|
|
+ customs.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ customs.setUpdateTime(new Date());
|
|
|
+ //撤销
|
|
|
+ iCheckClient.deteleByBillIdOrGrade(declareCustoms.getId(), 1);
|
|
|
+ }else if (customs.getStatus() == 5){
|
|
|
+ //获取账单信息
|
|
|
+ Acc acc = new Acc();
|
|
|
+ acc.setSrcParentId(customs.getId());
|
|
|
+ if ("BGJK".equals(customs.getImportExportSigns())) {
|
|
|
+ acc.setBillType("申请");
|
|
|
+ } else {
|
|
|
+ acc.setBillType("收费");
|
|
|
+ }
|
|
|
+ acc.setTradeType("JGBG");
|
|
|
+ acc.setSrcType(8);
|
|
|
+ R<List<Acc>> r = financeClient.getAccListByCondition(acc);
|
|
|
+ if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
+ for (Acc acc_ : r.getData()) {
|
|
|
+ //判断是否有结算 true 不允许撤销审核 false 删除账单信息并撤销审核
|
|
|
+ if (!acc_.getSettlementAmount().equals(new BigDecimal("0.00"))) {
|
|
|
+ throw new SecurityException("订单已结算,不允许撤销");
|
|
|
+ } else {
|
|
|
+ financeClient.remove(acc_.getId() + "");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //修改单据状态
|
|
|
- customs.setStatus(0);
|
|
|
- customs.setAuditStatus("审核撤销");
|
|
|
- customs.setUpdateUser(AuthUtil.getUserId());
|
|
|
- customs.setUpdateTime(new Date());
|
|
|
- baseMapper.updateById(customs);
|
|
|
+ //修改单据状态
|
|
|
+ customs.setStatus(4);
|
|
|
+ customs.setAuditStatus("复审撤销");
|
|
|
+ customs.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ customs.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ //获取订单费用信息
|
|
|
+ LambdaQueryWrapper<DeclareCustomsFees> feesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ feesLambdaQueryWrapper.eq(DeclareCustomsFees::getIsDeleted, 0);
|
|
|
+ feesLambdaQueryWrapper.eq(DeclareCustomsFees::getPid, customs.getId());
|
|
|
+ feesLambdaQueryWrapper.eq(DeclareCustomsFees::getTenantId, AuthUtil.getTenantId());
|
|
|
+ feesLambdaQueryWrapper.eq(DeclareCustomsFees::getSubmitPay, 1);
|
|
|
+ List<DeclareCustomsFees> feesList = feesMapper.selectList(feesLambdaQueryWrapper);
|
|
|
+ for (DeclareCustomsFees declareCustomsFees : feesList) {
|
|
|
+ declareCustomsFees.setSubmitPay(0);
|
|
|
+ feesMapper.updateById(declareCustomsFees);
|
|
|
+ }
|
|
|
+ //撤销
|
|
|
+ iCheckClient.deteleByBillIdOrGrade(declareCustoms.getId(), 2);
|
|
|
|
|
|
- //获取订单费用信息
|
|
|
- LambdaQueryWrapper<DeclareCustomsFees> feesLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- feesLambdaQueryWrapper.eq(DeclareCustomsFees::getIsDeleted, 0);
|
|
|
- feesLambdaQueryWrapper.eq(DeclareCustomsFees::getPid, customs.getId());
|
|
|
- feesLambdaQueryWrapper.eq(DeclareCustomsFees::getTenantId, AuthUtil.getTenantId());
|
|
|
- feesLambdaQueryWrapper.eq(DeclareCustomsFees::getSubmitPay, 1);
|
|
|
- List<DeclareCustomsFees> feesList = feesMapper.selectList(feesLambdaQueryWrapper);
|
|
|
- for (DeclareCustomsFees declareCustomsFees : feesList) {
|
|
|
- declareCustomsFees.setSubmitPay(0);
|
|
|
- feesMapper.updateById(declareCustomsFees);
|
|
|
}
|
|
|
|
|
|
- //撤销
|
|
|
- iCheckClient.deteleByBillId(declareCustoms.getId());
|
|
|
+ baseMapper.updateById(customs);
|
|
|
+
|
|
|
return customs;
|
|
|
}
|
|
|
|