|
|
@@ -0,0 +1,663 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
+ *
|
|
|
+ * Redistribution and use in source and binary forms, with or without
|
|
|
+ * modification, are permitted provided that the following conditions are met:
|
|
|
+ *
|
|
|
+ * Redistributions of source code must retain the above copyright notice,
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|
|
+ * notice, this list of conditions and the following disclaimer in the
|
|
|
+ * documentation and/or other materials provided with the distribution.
|
|
|
+ * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
+ * contributors may be used to endorse or promote products derived from
|
|
|
+ * this software without specific prior written permission.
|
|
|
+ * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
+ */
|
|
|
+package org.springblade.los.business.customsDeclaration.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
+import org.springblade.los.Util.IDeptUtils;
|
|
|
+import org.springblade.los.basic.business.entity.BusinessType;
|
|
|
+import org.springblade.los.basic.business.service.IBusinessTypeService;
|
|
|
+import org.springblade.los.basic.cur.service.IBCurrencyService;
|
|
|
+import org.springblade.los.billno.entity.BusinessBillNo;
|
|
|
+import org.springblade.los.billno.service.IBusinessBillNoService;
|
|
|
+import org.springblade.los.business.aea.entity.AeaBills;
|
|
|
+import org.springblade.los.business.customsDeclaration.entity.CustomsDeclaration;
|
|
|
+import org.springblade.los.business.customsDeclaration.entity.CustomsDeclarationGoods;
|
|
|
+import org.springblade.los.business.customsDeclaration.mapper.CustomsDeclarationMapper;
|
|
|
+import org.springblade.los.business.customsDeclaration.service.ICustomsDeclarationGoodsService;
|
|
|
+import org.springblade.los.business.customsDeclaration.service.ICustomsDeclarationService;
|
|
|
+import org.springblade.los.business.customsDeclaration.vo.CustomsDeclarationVO;
|
|
|
+import org.springblade.los.business.files.entity.FilesCenter;
|
|
|
+import org.springblade.los.business.files.service.IFilesCenterService;
|
|
|
+import org.springblade.los.check.dto.LosAuditProecessDTO;
|
|
|
+import org.springblade.los.check.entity.LosAuditPathsActs;
|
|
|
+import org.springblade.los.check.entity.LosAuditPathsLevels;
|
|
|
+import org.springblade.los.check.service.IAuditPathsActsService;
|
|
|
+import org.springblade.los.check.service.IAuditPathsLevelsService;
|
|
|
+import org.springblade.los.check.service.IAuditProecessService;
|
|
|
+import org.springblade.los.finance.fee.entity.FeeCenter;
|
|
|
+import org.springblade.los.finance.fee.entity.FinAccBills;
|
|
|
+import org.springblade.los.finance.fee.service.IFeeCenterService;
|
|
|
+import org.springblade.los.finance.fee.service.IFinAccBillsService;
|
|
|
+import org.springblade.system.feign.ISysClient;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 业务-报关 服务实现类
|
|
|
+ *
|
|
|
+ * @author BladeX
|
|
|
+ * @since 2024-01-31
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+public class CustomsDeclarationServiceImpl extends ServiceImpl<CustomsDeclarationMapper, CustomsDeclaration> implements ICustomsDeclarationService {
|
|
|
+
|
|
|
+ private final ISysClient sysClient;
|
|
|
+
|
|
|
+ private final IDeptUtils deptUtils;
|
|
|
+
|
|
|
+ private final IFeeCenterService feeCenterService;
|
|
|
+
|
|
|
+ private final IBusinessTypeService bBusinessTypeService;
|
|
|
+
|
|
|
+ private final IBusinessBillNoService businessBillNoService;
|
|
|
+
|
|
|
+ private final IFinAccBillsService finAccBillsService;
|
|
|
+
|
|
|
+ private final IBCurrencyService bCurrencyService;
|
|
|
+
|
|
|
+ private final IFilesCenterService filesCenterService;
|
|
|
+
|
|
|
+ private final IAuditPathsActsService auditPathsActsService;
|
|
|
+
|
|
|
+ private final IAuditPathsLevelsService auditPathsLevelsService;
|
|
|
+
|
|
|
+ private final IAuditProecessService auditProecessService;
|
|
|
+
|
|
|
+ private final ICustomsDeclarationGoodsService customsDeclarationGoodsService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<CustomsDeclarationVO> selectCustomsDeclarationPage(IPage<CustomsDeclarationVO> page, CustomsDeclarationVO customsDeclaration) {
|
|
|
+ return page.setRecords(baseMapper.selectCustomsDeclarationPage(page, customsDeclaration));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CustomsDeclaration detail(CustomsDeclaration customsDeclaration) {
|
|
|
+ if (customsDeclaration.getId() == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ CustomsDeclaration detail = baseMapper.selectById(customsDeclaration.getId());
|
|
|
+ detail.setFilesList(filesCenterService.list(new LambdaQueryWrapper<FilesCenter>()
|
|
|
+ .eq(FilesCenter::getIsDeleted, 0)
|
|
|
+ .eq(FilesCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FilesCenter::getPid, detail.getId())));
|
|
|
+ detail.setFeeCenterListC(feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getPid, detail.getId())
|
|
|
+ .eq(FeeCenter::getDc, "C")
|
|
|
+ ));
|
|
|
+ detail.setFeeCenterListD(feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getPid, detail.getId())
|
|
|
+ .eq(FeeCenter::getDc, "D")
|
|
|
+ ));
|
|
|
+ detail.setCustomsDeclarationGoodsList(customsDeclarationGoodsService.list(new LambdaQueryWrapper<CustomsDeclarationGoods>()
|
|
|
+ .eq(CustomsDeclarationGoods::getIsDeleted, 0)
|
|
|
+ .eq(CustomsDeclarationGoods::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CustomsDeclarationGoods::getPid, detail.getId())
|
|
|
+ ));
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R submit(CustomsDeclaration customsDeclaration) {
|
|
|
+ String deptId = "";
|
|
|
+ String deptName = "";
|
|
|
+ String branchId = deptUtils.getDeptPid() + "";
|
|
|
+ //获取部门ids对应中文名
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ deptId = AuthUtil.getDeptId();
|
|
|
+ R<List<String>> res = sysClient.getDeptNames(AuthUtil.getDeptId());
|
|
|
+ if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
+ deptName = String.join(",", res.getData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(customsDeclaration.getMblno())) {
|
|
|
+ customsDeclaration.setMblno(customsDeclaration.getMblno().replaceAll(" ", ""));
|
|
|
+ }
|
|
|
+ List<CustomsDeclaration> count = baseMapper.selectList(new LambdaQueryWrapper<CustomsDeclaration>()
|
|
|
+ .eq(CustomsDeclaration::getCreateDept, AuthUtil.getDeptId())
|
|
|
+ .eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CustomsDeclaration::getIsDeleted, 0)
|
|
|
+ .eq(CustomsDeclaration::getMblno, customsDeclaration.getMblno()
|
|
|
+ ));
|
|
|
+ if (customsDeclaration.getId() == null) {
|
|
|
+ if (count.size() > 0) {
|
|
|
+ throw new RuntimeException("提单号不允许重复");
|
|
|
+ }
|
|
|
+ BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
|
|
|
+ .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BusinessType::getIsDeleted, 0)
|
|
|
+ .eq(BusinessType::getStatus, 0)
|
|
|
+ .eq(BusinessType::getCode, customsDeclaration.getBusinessTypeCode()));
|
|
|
+ if (businessType == null) {
|
|
|
+ throw new RuntimeException("未找到可用业务类型");
|
|
|
+ }
|
|
|
+ BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
+ businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo.setCode(customsDeclaration.getBillNoFormat());
|
|
|
+ R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
+ if (!clientBillNo.isSuccess()) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ return R.fail(500, "生成订单编号失败");
|
|
|
+ }
|
|
|
+ customsDeclaration.setBillNo((String) clientBillNo.getData());
|
|
|
+ customsDeclaration.setCreateTime(new Date());
|
|
|
+ customsDeclaration.setCreateUser(AuthUtil.getUserId());
|
|
|
+ customsDeclaration.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ customsDeclaration.setBranchId(branchId);
|
|
|
+ customsDeclaration.setCreateDept(deptId);
|
|
|
+ customsDeclaration.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ List<Long> ids = count.stream().map(CustomsDeclaration::getId).distinct().collect(Collectors.toList());
|
|
|
+ if (count.size() > 0 && !ids.contains(customsDeclaration.getId())) {
|
|
|
+ throw new RuntimeException("提单号不允许重复");
|
|
|
+ }
|
|
|
+ customsDeclaration.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ customsDeclaration.setUpdateTime(new Date());
|
|
|
+ customsDeclaration.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(customsDeclaration);
|
|
|
+ /**-------------费用计算---------*/
|
|
|
+ BigDecimal amountDr = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCr = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfit = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountDrUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitUsd = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountDrLoc = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountProfitLoc = new BigDecimal("0.00");
|
|
|
+ //应付
|
|
|
+ if (ObjectUtils.isNotNull(customsDeclaration.getFeeCenterListC())) {
|
|
|
+ for (FeeCenter item : customsDeclaration.getFeeCenterListC()) {
|
|
|
+ item.setPid(customsDeclaration.getId());
|
|
|
+ item.setBillNo(customsDeclaration.getBillNo());
|
|
|
+ item.setBusinessType(customsDeclaration.getBusinessType());
|
|
|
+ item.setBillDate(customsDeclaration.getBillDate());
|
|
|
+ item.setSrcType(customsDeclaration.getSrcType());
|
|
|
+ item.setSrcId(customsDeclaration.getSrcId());
|
|
|
+ item.setSrcCnName(customsDeclaration.getSrcCnName());
|
|
|
+ item.setSrcEnName(customsDeclaration.getSrcEnName());
|
|
|
+ item.setBillCorpId(customsDeclaration.getCorpId());
|
|
|
+ item.setBillCorpCnName(customsDeclaration.getCorpCnName());
|
|
|
+ item.setBillCorpEnName(customsDeclaration.getCorpEnName());
|
|
|
+ item.setMblno(customsDeclaration.getMblno());
|
|
|
+ item.setHblno(item.getHblno());
|
|
|
+ item.setEtd(customsDeclaration.getEtdDate());
|
|
|
+ item.setRefno(customsDeclaration.getRefno());
|
|
|
+ if ("USD".equals(item.getCurCode())) {
|
|
|
+ amountCrUsd = amountCrUsd.add(item.getAmount());
|
|
|
+ } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ amountCr = amountCr.add(item.getAmount());
|
|
|
+ } else {
|
|
|
+ BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
|
|
|
+ amountCrUsd = amountCrUsd.add(usd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterService.submitList(customsDeclaration.getFeeCenterListC());
|
|
|
+ }
|
|
|
+ //应收
|
|
|
+ if (ObjectUtils.isNotNull(customsDeclaration.getFeeCenterListD())) {
|
|
|
+ for (FeeCenter item : customsDeclaration.getFeeCenterListD()) {
|
|
|
+ item.setPid(customsDeclaration.getId());
|
|
|
+ item.setBillNo(customsDeclaration.getBillNo());
|
|
|
+ item.setBusinessType(customsDeclaration.getBusinessType());
|
|
|
+ item.setBillDate(customsDeclaration.getBillDate());
|
|
|
+ item.setSrcType(customsDeclaration.getSrcType());
|
|
|
+ item.setSrcId(customsDeclaration.getSrcId());
|
|
|
+ item.setSrcCnName(customsDeclaration.getSrcCnName());
|
|
|
+ item.setSrcEnName(customsDeclaration.getSrcEnName());
|
|
|
+ item.setBillCorpId(customsDeclaration.getCorpId());
|
|
|
+ item.setBillCorpCnName(customsDeclaration.getCorpCnName());
|
|
|
+ item.setBillCorpEnName(customsDeclaration.getCorpEnName());
|
|
|
+ item.setMblno(customsDeclaration.getMblno());
|
|
|
+ item.setHblno(item.getHblno());
|
|
|
+ item.setEtd(customsDeclaration.getEtdDate());
|
|
|
+ item.setRefno(customsDeclaration.getRefno());
|
|
|
+ if ("USD".equals(item.getCurCode())) {
|
|
|
+ amountDrUsd = amountDrUsd.add(item.getAmount());
|
|
|
+ } else if ("CNY".equals(item.getCurCode())) {
|
|
|
+ amountDr = amountDr.add(item.getAmount());
|
|
|
+ } else {
|
|
|
+ BigDecimal usd = bCurrencyService.converter(item.getCurCode(), item.getAmount(), item.getDc());
|
|
|
+ amountDrUsd = amountDrUsd.add(usd);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ feeCenterService.submitList(customsDeclaration.getFeeCenterListD());
|
|
|
+ }
|
|
|
+ //利润 = 收 - 付
|
|
|
+ amountProfit = amountDr.subtract(amountCr);
|
|
|
+ amountProfitUsd = amountDrUsd.subtract(amountCrUsd);
|
|
|
+ amountDrLoc = amountDrLoc.add(bCurrencyService.converterCny("USD", amountDrUsd, "D")).add(amountDr);
|
|
|
+ amountCrLoc = amountCrLoc.add(bCurrencyService.converterCny("USD", amountCrUsd, "C")).add(amountCr);
|
|
|
+ amountProfitLoc = amountDrLoc.subtract(amountCrLoc);
|
|
|
+ customsDeclaration.setAmountDr(amountDr);
|
|
|
+ customsDeclaration.setAmountCr(amountCr);
|
|
|
+ customsDeclaration.setAmountProfit(amountProfit);
|
|
|
+ customsDeclaration.setAmountDrUsd(amountDrUsd);
|
|
|
+ customsDeclaration.setAmountCrUsd(amountCrUsd);
|
|
|
+ customsDeclaration.setAmountProfitUsd(amountProfitUsd);
|
|
|
+ customsDeclaration.setAmountDrLoc(amountDrLoc);
|
|
|
+ customsDeclaration.setAmountCrLoc(amountCrLoc);
|
|
|
+ customsDeclaration.setAmountProfitLoc(amountProfitLoc);
|
|
|
+ this.saveOrUpdate(customsDeclaration);
|
|
|
+ /**-------------费用计算---------*/
|
|
|
+ return R.data(customsDeclaration);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CustomsDeclaration checkCustomsDeclaration(CustomsDeclaration customsDeclaration) {
|
|
|
+ CustomsDeclaration declare = baseMapper.selectById(customsDeclaration.getId());
|
|
|
+ Integer actId = 1118;
|
|
|
+ String processType = "报关审核";
|
|
|
+ String checkType = "BGDJ";
|
|
|
+ //审批数据
|
|
|
+ LosAuditProecessDTO auditProecessDTO = new LosAuditProecessDTO();
|
|
|
+ //获取审批级次
|
|
|
+ List<LosAuditPathsLevels> auditPathsLevels = null;
|
|
|
+ // 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
|
|
|
+ LosAuditPathsActs pathsActs = null;
|
|
|
+ //是否开启流程
|
|
|
+ LambdaQueryWrapper<LosAuditPathsActs> auditPathsActsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ auditPathsActsLambdaQueryWrapper
|
|
|
+ .eq(LosAuditPathsActs::getIsEnable, 1)
|
|
|
+ .eq(LosAuditPathsActs::getFidStatus, "status")
|
|
|
+ .eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(LosAuditPathsActs::getSalesCompanyId, deptUtils.getDeptPid())
|
|
|
+ .eq(LosAuditPathsActs::getActId, actId);
|
|
|
+ pathsActs = auditPathsActsService.getOne(auditPathsActsLambdaQueryWrapper);
|
|
|
+ //获取审批信息
|
|
|
+ LosAuditPathsActs losAuditPathsActs = auditPathsActsService.getOne(new LambdaQueryWrapper<LosAuditPathsActs>()
|
|
|
+ .eq(LosAuditPathsActs::getActId, actId)
|
|
|
+ .eq(LosAuditPathsActs::getFidStatus, "status")
|
|
|
+ .eq(LosAuditPathsActs::getSalesCompanyId, deptUtils.getDeptPid())
|
|
|
+ .eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId()));
|
|
|
+ Long pathId = losAuditPathsActs.getPathId();
|
|
|
+ auditPathsLevels = auditPathsLevelsService.list(new LambdaQueryWrapper<LosAuditPathsLevels>()
|
|
|
+ .eq(LosAuditPathsLevels::getTenantId, AuthUtil.getTenantId()).eq(LosAuditPathsLevels::getPathId, pathId));
|
|
|
+ auditProecessDTO.setTimes(1);
|
|
|
+ auditProecessDTO.setProcessType(processType);
|
|
|
+
|
|
|
+ // 没开启审批流直接走 通过流程
|
|
|
+ if (pathsActs == null || pathsActs.getIsEnable() == 2) {
|
|
|
+ throw new SecurityException("当前租户未查询到审批流配置");
|
|
|
+ } else {
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(auditPathsLevels)) {
|
|
|
+ throw new SecurityException("开启审批失败:未查询到审批信息");
|
|
|
+ }
|
|
|
+ // 绑定审核类型
|
|
|
+ auditProecessDTO.setCheckType(checkType);
|
|
|
+ // 追加跳转路由url
|
|
|
+ auditProecessDTO.setUrl(customsDeclaration.getUrl());
|
|
|
+ auditProecessDTO.setPageStatus(customsDeclaration.getPageStatus());
|
|
|
+ auditProecessDTO.setPageLabel(customsDeclaration.getPageLabel());
|
|
|
+ auditProecessDTO.setOrderRemark(declare.getRemarks());
|
|
|
+ auditProecessDTO.setPathsLevelsList(auditPathsLevels);
|
|
|
+ auditProecessDTO.setActId(1);
|
|
|
+ auditProecessDTO.setSrcBillId(declare.getId());
|
|
|
+ auditProecessDTO.setBillId(declare.getId());
|
|
|
+ auditProecessDTO.setBillNo(declare.getBillNo());
|
|
|
+ auditProecessDTO.setSendUserId(AuthUtil.getUserId());
|
|
|
+ auditProecessDTO.setSendName(AuthUtil.getUserName());
|
|
|
+ auditProecessDTO.setSendTime(new Date());
|
|
|
+ auditProecessDTO.setBillTime(declare.getCreateTime());
|
|
|
+ auditProecessDTO.setTenantId(AuthUtil.getTenantId());
|
|
|
+ auditProecessDTO.setCorpId(declare.getCorpId());
|
|
|
+ auditProecessDTO.setSalesCompanyId(Long.parseLong(declare.getCreateDept()));
|
|
|
+ auditProecessDTO.setSalesCompanyName(declare.getCreateDeptName());
|
|
|
+ auditProecessDTO.setPayAmount(declare.getAmountCrLoc());
|
|
|
+ auditProecessDTO.setReceivableAmount(declare.getAmountDrLoc());
|
|
|
+ auditProecessDTO.setGrossProfit(declare.getAmountProfitLoc());
|
|
|
+ auditProecessDTO.setSalesCompanyName(declare.getCreateDeptName());
|
|
|
+ R financeProcess = auditProecessService.createFinanceProcess(auditProecessDTO);
|
|
|
+ if (!financeProcess.isSuccess()) {
|
|
|
+ throw new SecurityException("操作失败,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ declare.setStatus(1);
|
|
|
+ baseMapper.updateById(declare);
|
|
|
+ return declare;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CustomsDeclaration revokeCheckCustomsDeclaration(CustomsDeclaration customsDeclaration) {
|
|
|
+ CustomsDeclaration declare = baseMapper.selectById(customsDeclaration.getId());
|
|
|
+ if (3 == declare.getStatus()) {
|
|
|
+ throw new SecurityException("审核已通过,撤销失败");
|
|
|
+ }
|
|
|
+ R financeProcess = auditProecessService.deteleByBillId(customsDeclaration.getId());
|
|
|
+ if (!financeProcess.isSuccess()) {
|
|
|
+ throw new SecurityException("操作失败,请联系管理员");
|
|
|
+ }
|
|
|
+ declare.setStatus(0);
|
|
|
+ baseMapper.updateById(declare);
|
|
|
+ return declare;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R passCheck(Long id) {
|
|
|
+ CustomsDeclaration customsDeclaration = baseMapper.selectById(id);
|
|
|
+ if (customsDeclaration == null) {
|
|
|
+ throw new SecurityException("审批通过失败");
|
|
|
+ }
|
|
|
+ customsDeclaration.setStatus(3);
|
|
|
+ customsDeclaration.setBillStatus(2);
|
|
|
+ baseMapper.updateById(customsDeclaration);
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getAccStatus, 0)
|
|
|
+ .eq(FeeCenter::getPid, customsDeclaration.getId()));
|
|
|
+ for (FeeCenter item : feeCenterList) {
|
|
|
+ item.setApproverId(AuthUtil.getUserId());
|
|
|
+ item.setApproverName(AuthUtil.getUserName());
|
|
|
+ item.setApproveTime(new Date());
|
|
|
+ }
|
|
|
+ feeCenterService.saveOrUpdateBatch(feeCenterList);
|
|
|
+ if (feeCenterList.size() != 0) {
|
|
|
+ FinAccBills finAccBills = new FinAccBills();
|
|
|
+ finAccBills.setFeeCenterList(feeCenterList);
|
|
|
+ finAccBills.setBusinessTypeCode("HYZD");
|
|
|
+ finAccBills.setBillNoFormat("HYZD");
|
|
|
+ finAccBills.setAccountType("");
|
|
|
+ finAccBills.setRefno(customsDeclaration.getRefno());
|
|
|
+ finAccBillsService.generateBill(finAccBills);
|
|
|
+ }
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R underReview(Long id) {
|
|
|
+ CustomsDeclaration customsDeclaration = baseMapper.selectById(id);
|
|
|
+ if (customsDeclaration == null) {
|
|
|
+ throw new SecurityException("审批通过失败");
|
|
|
+ }
|
|
|
+ customsDeclaration.setStatus(2);
|
|
|
+ baseMapper.updateById(customsDeclaration);
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, customsDeclaration.getId()));
|
|
|
+ for (FeeCenter item : feeCenterList) {
|
|
|
+ item.setApproverId(AuthUtil.getUserId());
|
|
|
+ item.setApproverName(AuthUtil.getUserName());
|
|
|
+ item.setApproveTime(new Date());
|
|
|
+ }
|
|
|
+ feeCenterService.saveOrUpdateBatch(feeCenterList);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R passCancel(Long id) {
|
|
|
+ CustomsDeclaration customsDeclaration = baseMapper.selectById(id);
|
|
|
+ if (customsDeclaration == null) {
|
|
|
+ throw new SecurityException("审批通过失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ customsDeclaration.setStatus(4);
|
|
|
+ baseMapper.updateById(customsDeclaration);
|
|
|
+ List<FeeCenter> feeCenterList = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getPid, customsDeclaration.getId()));
|
|
|
+ for (FeeCenter item : feeCenterList) {
|
|
|
+ item.setApproverId(AuthUtil.getUserId());
|
|
|
+ item.setApproverName(AuthUtil.getUserName());
|
|
|
+ item.setApproveTime(new Date());
|
|
|
+ }
|
|
|
+ feeCenterService.saveOrUpdateBatch(feeCenterList);
|
|
|
+ return R.success("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CustomsDeclaration copyCustomsDeclaration(CustomsDeclaration customsDeclaration) {
|
|
|
+ if (customsDeclaration.getId() == null) {
|
|
|
+ throw new SecurityException("缺少必要参数");
|
|
|
+ }
|
|
|
+ CustomsDeclaration detail = baseMapper.selectById(customsDeclaration.getId());
|
|
|
+ List<FilesCenter> filesList = filesCenterService.list(new LambdaQueryWrapper<FilesCenter>()
|
|
|
+ .eq(FilesCenter::getIsDeleted, 0)
|
|
|
+ .eq(FilesCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FilesCenter::getPid, detail.getId()));
|
|
|
+ for (FilesCenter item : filesList) {
|
|
|
+ item.setPid(null);
|
|
|
+ item.setId(null);
|
|
|
+ item.setItemId(null);
|
|
|
+ item.setBillNo("");
|
|
|
+ item.setBusinessType(null);
|
|
|
+ item.setHblno("");
|
|
|
+ item.setMblno("");
|
|
|
+ }
|
|
|
+ List<FeeCenter> feeCenterListC = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getPid, detail.getId())
|
|
|
+ .eq(FeeCenter::getDc, "C")
|
|
|
+ .eq(FeeCenter::getBillNo, detail.getBillNo())
|
|
|
+ );
|
|
|
+ for (FeeCenter item : feeCenterListC) {
|
|
|
+ item.setPid(null);
|
|
|
+ item.setId(null);
|
|
|
+ item.setBusinessType(null);
|
|
|
+ item.setBillType(null);
|
|
|
+ item.setBillNo("");
|
|
|
+ item.setBillDate(null);
|
|
|
+ item.setAccountDate(null);
|
|
|
+ item.setMblno("");
|
|
|
+ item.setHblno("");
|
|
|
+ item.setAccountDate(null);
|
|
|
+ item.setAccBillId(null);
|
|
|
+ item.setAccBillNo("");
|
|
|
+ item.setAccDate(null);
|
|
|
+ item.setAccStatus(0);
|
|
|
+ item.setAccById(0L);
|
|
|
+ item.setAccByName("");
|
|
|
+ item.setCheckBillId(0L);
|
|
|
+ item.setCheckBillNo("");
|
|
|
+ item.setCheckDate(null);
|
|
|
+ item.setCheckAmount(new BigDecimal("0.00"));
|
|
|
+ item.setCheckStatus(0);
|
|
|
+ item.setCheckById(0L);
|
|
|
+ item.setCheckByName("");
|
|
|
+ item.setStlBillId(0L);
|
|
|
+ item.setStlBillNo("");
|
|
|
+ item.setStlDate(null);
|
|
|
+ item.setStlOrgAmount(new BigDecimal("0.00"));
|
|
|
+ item.setStlCurCode("");
|
|
|
+ item.setStlExrate(new BigDecimal("0.00"));
|
|
|
+ item.setStlExrateLoc(new BigDecimal("0.00"));
|
|
|
+ item.setStlAmount(new BigDecimal("0.00"));
|
|
|
+ item.setStlAmountLoc(new BigDecimal("0.00"));
|
|
|
+ item.setStlStatus(0);
|
|
|
+ item.setStlById(0L);
|
|
|
+ item.setStlByName("");
|
|
|
+ item.setStlTtlAmount(new BigDecimal("0.00"));
|
|
|
+ item.setUnsettledAmount(item.getAmount());
|
|
|
+ item.setVoucherBillId(0L);
|
|
|
+ item.setVoucherBillNo("");
|
|
|
+ item.setVoucherNo("");
|
|
|
+ item.setVoucherDate(null);
|
|
|
+ item.setVoucherStatus(0);
|
|
|
+ item.setVoucherById(0L);
|
|
|
+ item.setVoucherByName("");
|
|
|
+ item.setInvoiceBillId("");
|
|
|
+ item.setInvoiceBillNo("");
|
|
|
+ item.setInvoiceNo("");
|
|
|
+ item.setInvoiceDate(null);
|
|
|
+ item.setInvoiceStatus(0);
|
|
|
+ item.setInvoiceCurCode("");
|
|
|
+ item.setInvoiceExrate(new BigDecimal("0.00"));
|
|
|
+ item.setInvoiceAmount(new BigDecimal("0.00"));
|
|
|
+ item.setInvoiceAmountLoc(new BigDecimal("0.00"));
|
|
|
+ item.setUninvoicedAmount(new BigDecimal("0.00"));
|
|
|
+ item.setAppliedAmount(new BigDecimal("0.00"));
|
|
|
+ item.setAppliedInvoiceAmount(new BigDecimal("0.00"));
|
|
|
+ item.setReconciliationAmount(new BigDecimal("0.00"));
|
|
|
+ item.setInvoiceById(0L);
|
|
|
+ item.setInvoiceByName("");
|
|
|
+ item.setIsSignfor(0);
|
|
|
+ item.setSignforId(0);
|
|
|
+ item.setSignforName("");
|
|
|
+ item.setSignforDate(null);
|
|
|
+ item.setApplyId(0L);
|
|
|
+ item.setApplyName("");
|
|
|
+ item.setApplyTime(null);
|
|
|
+ item.setApproverId(0L);
|
|
|
+ item.setApproverName("");
|
|
|
+ item.setApproveTime(null);
|
|
|
+ item.setAuditStatus("0");
|
|
|
+ }
|
|
|
+ List<FeeCenter> feeCenterListD = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FeeCenter::getPid, detail.getId())
|
|
|
+ .eq(FeeCenter::getDc, "D")
|
|
|
+ .eq(FeeCenter::getBillNo, detail.getBillNo())
|
|
|
+ );
|
|
|
+ for (FeeCenter item : feeCenterListD) {
|
|
|
+ item.setPid(null);
|
|
|
+ item.setId(null);
|
|
|
+ item.setBusinessType(null);
|
|
|
+ item.setBillType(null);
|
|
|
+ item.setBillNo("");
|
|
|
+ item.setBillDate(null);
|
|
|
+ item.setAccountDate(null);
|
|
|
+ item.setMblno("");
|
|
|
+ item.setHblno("");
|
|
|
+ item.setAccountDate(null);
|
|
|
+ item.setAccBillId(null);
|
|
|
+ item.setAccBillNo("");
|
|
|
+ item.setAccDate(null);
|
|
|
+ item.setAccStatus(0);
|
|
|
+ item.setAccById(0L);
|
|
|
+ item.setAccByName("");
|
|
|
+ item.setCheckBillId(0L);
|
|
|
+ item.setCheckBillNo("");
|
|
|
+ item.setCheckDate(null);
|
|
|
+ item.setCheckAmount(new BigDecimal("0.00"));
|
|
|
+ item.setCheckStatus(0);
|
|
|
+ item.setCheckById(0L);
|
|
|
+ item.setCheckByName("");
|
|
|
+ item.setStlBillId(0L);
|
|
|
+ item.setStlBillNo("");
|
|
|
+ item.setStlDate(null);
|
|
|
+ item.setStlOrgAmount(new BigDecimal("0.00"));
|
|
|
+ item.setStlCurCode("");
|
|
|
+ item.setStlExrate(new BigDecimal("0.00"));
|
|
|
+ item.setStlExrateLoc(new BigDecimal("0.00"));
|
|
|
+ item.setStlAmount(new BigDecimal("0.00"));
|
|
|
+ item.setStlAmountLoc(new BigDecimal("0.00"));
|
|
|
+ item.setStlStatus(0);
|
|
|
+ item.setStlById(0L);
|
|
|
+ item.setStlByName("");
|
|
|
+ item.setStlTtlAmount(new BigDecimal("0.00"));
|
|
|
+ item.setUnsettledAmount(item.getAmount());
|
|
|
+ item.setVoucherBillId(0L);
|
|
|
+ item.setVoucherBillNo("");
|
|
|
+ item.setVoucherNo("");
|
|
|
+ item.setVoucherDate(null);
|
|
|
+ item.setVoucherStatus(0);
|
|
|
+ item.setVoucherById(0L);
|
|
|
+ item.setVoucherByName("");
|
|
|
+ item.setInvoiceBillId("");
|
|
|
+ item.setInvoiceBillNo("");
|
|
|
+ item.setInvoiceNo("");
|
|
|
+ item.setInvoiceDate(null);
|
|
|
+ item.setInvoiceStatus(0);
|
|
|
+ item.setInvoiceCurCode("");
|
|
|
+ item.setInvoiceExrate(new BigDecimal("0.00"));
|
|
|
+ item.setInvoiceAmount(new BigDecimal("0.00"));
|
|
|
+ item.setInvoiceAmountLoc(new BigDecimal("0.00"));
|
|
|
+ item.setUninvoicedAmount(new BigDecimal("0.00"));
|
|
|
+ item.setAppliedAmount(new BigDecimal("0.00"));
|
|
|
+ item.setAppliedInvoiceAmount(new BigDecimal("0.00"));
|
|
|
+ item.setReconciliationAmount(new BigDecimal("0.00"));
|
|
|
+ item.setInvoiceById(0L);
|
|
|
+ item.setInvoiceByName("");
|
|
|
+ item.setIsSignfor(0);
|
|
|
+ item.setSignforId(0);
|
|
|
+ item.setSignforName("");
|
|
|
+ item.setSignforDate(null);
|
|
|
+ item.setApplyId(0L);
|
|
|
+ item.setApplyName("");
|
|
|
+ item.setApplyTime(null);
|
|
|
+ item.setApproverId(0L);
|
|
|
+ item.setApproverName("");
|
|
|
+ item.setApproveTime(null);
|
|
|
+ item.setAuditStatus("0");
|
|
|
+ }
|
|
|
+ CustomsDeclaration copyBills = new CustomsDeclaration();
|
|
|
+ BeanUtil.copyProperties(detail, copyBills);
|
|
|
+ copyBills.setId(null);
|
|
|
+ copyBills.setBillNo("");
|
|
|
+ copyBills.setMblno("");
|
|
|
+ copyBills.setRefno("");
|
|
|
+ copyBills.setStatus(0);
|
|
|
+ copyBills.setBillStatus(0);
|
|
|
+ copyBills.setAmountDr(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountCr(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountProfit(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountDrUsd(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountProfitUsd(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountDrLoc(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountCrLoc(new BigDecimal("0.00"));
|
|
|
+ copyBills.setAmountProfitLoc(new BigDecimal("0.00"));
|
|
|
+ copyBills.setCheckDrStatus(0);
|
|
|
+ copyBills.setCheckDrStatusDescr("未对账");
|
|
|
+ copyBills.setCheckCrStatus(0);
|
|
|
+ copyBills.setCheckCrStatusDescr("未对账");
|
|
|
+ copyBills.setStlDrStatus(0);
|
|
|
+ copyBills.setStlDrStatusDescr("未结");
|
|
|
+ copyBills.setStlCrStatus(0);
|
|
|
+ copyBills.setStlCrStatusDescr("未结");
|
|
|
+ copyBills.setInvoiceDrStatus(0);
|
|
|
+ copyBills.setInvoiceDrStatusDescr("未开");
|
|
|
+ copyBills.setInvoiceCrStatus(0);
|
|
|
+ copyBills.setInvoiceCrStatusDescr("未开");
|
|
|
+ copyBills.setBillStatus(0);
|
|
|
+ copyBills.setAccountStatus(0);
|
|
|
+ copyBills.setFeeCenterListC(feeCenterListC);
|
|
|
+ copyBills.setFeeCenterListD(feeCenterListD);
|
|
|
+ copyBills.setQuantity(new BigDecimal("0.00"));
|
|
|
+ copyBills.setGrossWeight(new BigDecimal("0.00"));
|
|
|
+ copyBills.setFilesList(filesList);
|
|
|
+ return copyBills;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|