|
|
@@ -24,7 +24,12 @@ 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.StringUtil;
|
|
|
import org.springblade.los.Util.CurrencyUtils;
|
|
|
+import org.springblade.los.basic.business.entity.BusinessType;
|
|
|
+import org.springblade.los.basic.business.service.IBusinessTypeService;
|
|
|
+import org.springblade.los.billno.entity.BusinessBillNo;
|
|
|
+import org.springblade.los.billno.service.IBusinessBillNoService;
|
|
|
import org.springblade.los.box.entity.ExpenseApplication;
|
|
|
import org.springblade.los.box.entity.TradingBox;
|
|
|
import org.springblade.los.box.mapper.ExpenseApplicationMapper;
|
|
|
@@ -46,6 +51,7 @@ import org.springblade.los.finance.fee.service.IFinAccBillsService;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
@@ -82,6 +88,10 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
|
|
|
|
|
|
private final ISysClient sysClient;
|
|
|
|
|
|
+ private final IBusinessTypeService bBusinessTypeService;
|
|
|
+
|
|
|
+ private final IBusinessBillNoService businessBillNoService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ExpenseApplicationVO> selectExpenseApplicationPage(IPage<ExpenseApplicationVO> page, ExpenseApplicationVO expenseApplication) {
|
|
|
return page.setRecords(baseMapper.selectExpenseApplicationPage(page, expenseApplication));
|
|
|
@@ -146,184 +156,336 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
|
|
|
if (ObjectUtils.isNull(expenseApplication.getFeeCenterList()) || expenseApplication.getFeeCenterList().isEmpty()) {
|
|
|
throw new RuntimeException("请选择明细");
|
|
|
}
|
|
|
- StringBuilder text = new StringBuilder();
|
|
|
- for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
- if (1 == item.getAccStatus()) {
|
|
|
- text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("已生成账单,");
|
|
|
+ String status = sysClient.getParamService("expense.application");
|
|
|
+ if (status.equals("1")) {
|
|
|
+ StringBuilder text = new StringBuilder();
|
|
|
+ for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
+ if (1 == item.getAccStatus()) {
|
|
|
+ text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("已生成账单,");
|
|
|
+ }
|
|
|
+ if (item.getStlPid() != null) {
|
|
|
+ text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("已申请,");
|
|
|
+ }
|
|
|
}
|
|
|
- if (item.getStlPid() != null) {
|
|
|
- text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("已申请,");
|
|
|
+ if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
+ throw new RuntimeException(text.toString());
|
|
|
}
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
- throw new RuntimeException(text.toString());
|
|
|
- }
|
|
|
- if ("BUY,ZR,DL,OW-N,OW-F,XGFY,XGDX,CCSQ".contains(expenseApplication.getSrcType())) {
|
|
|
- TradingBox tradingBox = tradingBoxService.getById(expenseApplication.getSrcId());
|
|
|
- if (tradingBox == null) {
|
|
|
- throw new RuntimeException("未查到单据信息");
|
|
|
+ if ("BUY,ZR,DL,OW-N,OW-F,XGFY,XGDX,CCSQ".contains(expenseApplication.getSrcType())) {
|
|
|
+ TradingBox tradingBox = tradingBoxService.getById(expenseApplication.getSrcId());
|
|
|
+ if (tradingBox == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ expenseApplication.setCreateUser(AuthUtil.getUserId());
|
|
|
+ expenseApplication.setCreateTime(new Date());
|
|
|
+ expenseApplication.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ expenseApplication.setSrcNo(tradingBox.getSysNo());
|
|
|
+ expenseApplication.setSrcMblno(tradingBox.getContractNo());
|
|
|
+ expenseApplication.setSrcContainerNumber(tradingBox.getContainerNumber());
|
|
|
+ expenseApplication.setSrcContractNo(tradingBox.getContractNo());
|
|
|
+ expenseApplication.setStatus("审核提交");
|
|
|
+ expenseApplication.setSrcBusDate(new Date());
|
|
|
+ expenseApplication.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
+ expenseApplication.setCorpCnName(tradingBox.getPurchaseCompanyName());
|
|
|
+ expenseApplication.setCorpEnName(tradingBox.getPurchaseCompanyName());
|
|
|
+ expenseApplication.setBranchId(AuthUtil.getDeptId());
|
|
|
+ R<String> res = sysClient.getDeptName(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
+ if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
+ expenseApplication.setBranchName(res.getData());
|
|
|
+ }
|
|
|
+ } else if ("HYJK,HYCK".contains(expenseApplication.getSrcType())) {
|
|
|
+ Bills bills = billsService.getById(expenseApplication.getSrcId());
|
|
|
+ if (bills == null) {
|
|
|
+ throw new RuntimeException("未查到单据信息");
|
|
|
+ }
|
|
|
+ expenseApplication.setCreateUser(AuthUtil.getUserId());
|
|
|
+ expenseApplication.setCreateTime(new Date());
|
|
|
+ expenseApplication.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ expenseApplication.setSrcNo(bills.getBillNo());
|
|
|
+ expenseApplication.setSrcMblno(bills.getMblno());
|
|
|
+ expenseApplication.setSrcHblno(bills.getHblno());
|
|
|
+ expenseApplication.setSrcContainerNumber("");
|
|
|
+ expenseApplication.setSrcContractNo(bills.getBookingNo());
|
|
|
+ expenseApplication.setStatus("审核提交");
|
|
|
+ expenseApplication.setSrcBusDate(new Date());
|
|
|
+ expenseApplication.setCorpId(bills.getCorpId());
|
|
|
+ expenseApplication.setCorpCnName(bills.getCorpCnName());
|
|
|
+ expenseApplication.setCorpEnName(bills.getCorpEnName());
|
|
|
+ expenseApplication.setBranchId(bills.getBranchId());
|
|
|
+ expenseApplication.setBranchName(bills.getBranchName());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("类型错误,未查到单据");
|
|
|
}
|
|
|
- expenseApplication.setCreateUser(AuthUtil.getUserId());
|
|
|
- expenseApplication.setCreateTime(new Date());
|
|
|
- expenseApplication.setCreateUserName(AuthUtil.getUserName());
|
|
|
- expenseApplication.setSrcNo(tradingBox.getSysNo());
|
|
|
- expenseApplication.setSrcMblno(tradingBox.getContractNo());
|
|
|
- expenseApplication.setSrcContainerNumber(tradingBox.getContainerNumber());
|
|
|
- expenseApplication.setSrcContractNo(tradingBox.getContractNo());
|
|
|
- expenseApplication.setStatus("审核提交");
|
|
|
- expenseApplication.setSrcBusDate(new Date());
|
|
|
- expenseApplication.setCorpId(tradingBox.getPurchaseCompanyId());
|
|
|
- expenseApplication.setCorpCnName(tradingBox.getPurchaseCompanyName());
|
|
|
- expenseApplication.setCorpEnName(tradingBox.getPurchaseCompanyName());
|
|
|
- expenseApplication.setBranchId(AuthUtil.getDeptId());
|
|
|
- R<String> res = sysClient.getDeptName(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
- if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
|
|
|
- expenseApplication.setBranchName(res.getData());
|
|
|
+ baseMapper.insert(expenseApplication);
|
|
|
+ String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
|
|
|
+ if (!expenseApplication.getFeeCenterList().isEmpty()) {
|
|
|
+ if (expenseApplication.getFeeCenterList().stream().filter(e -> !e.getCurCode().equals(exrateType))
|
|
|
+ .map(FeeCenter::getCurCode).distinct().count() > 1) {
|
|
|
+ throw new RuntimeException("请选择单一非本币币种");
|
|
|
+ }
|
|
|
+ for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
+ item.setUpdateTime(new Date());
|
|
|
+ item.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
+ item.setStlPid(expenseApplication.getId());
|
|
|
+ item.setAuditStatus("1");
|
|
|
+ item.setApplyId(AuthUtil.getUserId());
|
|
|
+ item.setApplyName(AuthUtil.getUserName());
|
|
|
+ item.setApplyTime(new Date());
|
|
|
+ }
|
|
|
+ feeCenterService.updateBatchById(expenseApplication.getFeeCenterList());
|
|
|
}
|
|
|
- } else if ("HYJK,HYCK".contains(expenseApplication.getSrcType())) {
|
|
|
- Bills bills = billsService.getById(expenseApplication.getSrcId());
|
|
|
- if (bills == null) {
|
|
|
- throw new RuntimeException("未查到单据信息");
|
|
|
+ int actId;
|
|
|
+ String processType;
|
|
|
+ String checkType;
|
|
|
+ if ("C".equals(expenseApplication.getDc())) {
|
|
|
+ actId = 1132;
|
|
|
+ processType = "请核费用-付费";
|
|
|
+ checkType = "FYSQ-C";
|
|
|
+ } else {
|
|
|
+ actId = 1130;
|
|
|
+ processType = "请核费用";
|
|
|
+ checkType = "FYSQ";
|
|
|
}
|
|
|
- expenseApplication.setCreateUser(AuthUtil.getUserId());
|
|
|
- expenseApplication.setCreateTime(new Date());
|
|
|
- expenseApplication.setCreateUserName(AuthUtil.getUserName());
|
|
|
- expenseApplication.setSrcNo(bills.getBillNo());
|
|
|
- expenseApplication.setSrcMblno(bills.getMblno());
|
|
|
- expenseApplication.setSrcHblno(bills.getHblno());
|
|
|
- expenseApplication.setSrcContainerNumber("");
|
|
|
- expenseApplication.setSrcContractNo(bills.getBookingNo());
|
|
|
- expenseApplication.setStatus("审核提交");
|
|
|
- expenseApplication.setSrcBusDate(new Date());
|
|
|
- expenseApplication.setCorpId(bills.getCorpId());
|
|
|
- expenseApplication.setCorpCnName(bills.getCorpCnName());
|
|
|
- expenseApplication.setCorpEnName(bills.getCorpEnName());
|
|
|
- expenseApplication.setBranchId(bills.getBranchId());
|
|
|
- expenseApplication.setBranchName(bills.getBranchName());
|
|
|
- } else {
|
|
|
- throw new RuntimeException("类型错误,未查到单据");
|
|
|
- }
|
|
|
- baseMapper.insert(expenseApplication);
|
|
|
- String exrateType = currencyUtils.standardCurrency(AuthUtil.getDeptId());
|
|
|
- if (!expenseApplication.getFeeCenterList().isEmpty()) {
|
|
|
- if (expenseApplication.getFeeCenterList().stream().filter(e -> !e.getCurCode().equals(exrateType))
|
|
|
- .map(FeeCenter::getCurCode).distinct().count() > 1) {
|
|
|
- throw new RuntimeException("请选择单一非本币币种");
|
|
|
+ //审批数据
|
|
|
+ LosAuditProecessDTO auditProecessDTO = new LosAuditProecessDTO();
|
|
|
+ //获取审批级次
|
|
|
+ List<LosAuditPathsLevels> auditPathsLevels;
|
|
|
+ // 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
|
|
|
+ LosAuditPathsActs pathsActs;
|
|
|
+ //是否开启流程
|
|
|
+ LambdaQueryWrapper<LosAuditPathsActs> auditPathsActsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ auditPathsActsLambdaQueryWrapper
|
|
|
+ .eq(LosAuditPathsActs::getIsEnable, 1)
|
|
|
+ .eq(LosAuditPathsActs::getFidStatus, "status")
|
|
|
+ .eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(LosAuditPathsActs::getSalesCompanyId, expenseApplication.getBranchId())
|
|
|
+ .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, expenseApplication.getBranchId())
|
|
|
+ .eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId()));
|
|
|
+ Long pathId = losAuditPathsActs.getPathId();
|
|
|
+ auditPathsLevels = auditPathsLevelsService.list(new LambdaQueryWrapper<LosAuditPathsLevels>()
|
|
|
+ .eq(LosAuditPathsLevels::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(LosAuditPathsLevels::getPathId, pathId)
|
|
|
+ .eq(LosAuditPathsLevels::getSalesCompanyId, expenseApplication.getBranchId())
|
|
|
+ );
|
|
|
+ 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("/iosBasicData/feeApplication/index");
|
|
|
+ auditProecessDTO.setPageStatus("this.$store.getters.feeApproval");
|
|
|
+ auditProecessDTO.setPageLabel("费用申请(F)");
|
|
|
+ auditProecessDTO.setOrderRemark(expenseApplication.getRemarks());
|
|
|
+ List<LosAuditPathsLevels> pathsLevelsList = expenseApplication.getAuditPathsLevels();
|
|
|
+ if (ObjectUtils.isNotNull(pathsLevelsList) && !pathsLevelsList.isEmpty()) {
|
|
|
+ List<Long> idList = pathsLevelsList.stream().map(LosAuditPathsLevels::getId).collect(Collectors.toList());
|
|
|
+ List<LosAuditPathsLevels> levelsList = new ArrayList<>();
|
|
|
+ for (LosAuditPathsLevels item : auditPathsLevels) {
|
|
|
+ if (2 == item.getUserMold()) {
|
|
|
+ if (idList.contains(item.getId())) {
|
|
|
+ levelsList.add(item);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ levelsList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ auditProecessDTO.setPathsLevelsList(levelsList);
|
|
|
+ } else {
|
|
|
+ auditProecessDTO.setPathsLevelsList(auditPathsLevels);
|
|
|
+ }
|
|
|
+ auditProecessDTO.setActId(1);
|
|
|
+ auditProecessDTO.setSrcBillId(expenseApplication.getId());
|
|
|
+ auditProecessDTO.setBillId(expenseApplication.getSrcId());
|
|
|
+ auditProecessDTO.setBillNo(expenseApplication.getSrcNo());
|
|
|
+ auditProecessDTO.setSendUserId(AuthUtil.getUserId());
|
|
|
+ auditProecessDTO.setSendName(AuthUtil.getUserName());
|
|
|
+ auditProecessDTO.setSendTime(new Date());
|
|
|
+ auditProecessDTO.setBillTime(expenseApplication.getCreateTime());
|
|
|
+ auditProecessDTO.setTenantId(AuthUtil.getTenantId());
|
|
|
+ auditProecessDTO.setCorpId(expenseApplication.getCorpId());
|
|
|
+ auditProecessDTO.setCorpsName(expenseApplication.getCorpCnName());
|
|
|
+ auditProecessDTO.setReferenceNumber(expenseApplication.getSrcContainerNumber());
|
|
|
+ auditProecessDTO.setMorderNo(expenseApplication.getSrcMblno());
|
|
|
+ auditProecessDTO.setSrcBusType(expenseApplication.getSrcType());
|
|
|
+ auditProecessDTO.setSalesCompanyId(Long.parseLong(expenseApplication.getBranchId()));
|
|
|
+ auditProecessDTO.setSalesCompanyName(expenseApplication.getBranchName());
|
|
|
+ auditProecessDTO.setMblno(expenseApplication.getSrcMblno());
|
|
|
+ auditProecessDTO.setHblno(expenseApplication.getSrcHblno());
|
|
|
+ BigDecimal salesPrice = expenseApplication.getFeeCenterList().stream().filter(e -> e.getDc().equals("D"))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal costPrice = expenseApplication.getFeeCenterList().stream().filter(e -> e.getDc().equals("C"))
|
|
|
+ .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ auditProecessDTO.setPayAmount(costPrice);
|
|
|
+ auditProecessDTO.setReceivableAmount(salesPrice);
|
|
|
+ auditProecessDTO.setGrossProfit(salesPrice.subtract(costPrice));
|
|
|
+ R financeProcess = auditProecessService.createFinanceProcess(auditProecessDTO);
|
|
|
+ if (!financeProcess.isSuccess()) {
|
|
|
+ throw new SecurityException("操作失败,请联系管理员");
|
|
|
+ }
|
|
|
}
|
|
|
- for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
- item.setUpdateTime(new Date());
|
|
|
- item.setUpdateUser(AuthUtil.getUserId());
|
|
|
- item.setUpdateUserName(AuthUtil.getUserName());
|
|
|
- item.setStlPid(expenseApplication.getId());
|
|
|
- item.setAuditStatus("1");
|
|
|
- item.setApplyId(AuthUtil.getUserId());
|
|
|
- item.setApplyName(AuthUtil.getUserName());
|
|
|
- item.setApplyTime(new Date());
|
|
|
+ }else{
|
|
|
+ BusinessType businessType = bBusinessTypeService.getOne(new LambdaQueryWrapper<BusinessType>()
|
|
|
+ .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BusinessType::getIsDeleted, 0)
|
|
|
+ .eq(BusinessType::getStatus, 0)
|
|
|
+ .eq(BusinessType::getCode, "YWZD"));
|
|
|
+ if (businessType == null) {
|
|
|
+ throw new RuntimeException("未找到可用业务类型");
|
|
|
}
|
|
|
- feeCenterService.updateBatchById(expenseApplication.getFeeCenterList());
|
|
|
- }
|
|
|
- int actId;
|
|
|
- String processType;
|
|
|
- String checkType;
|
|
|
- if ("C".equals(expenseApplication.getDc())) {
|
|
|
- actId = 1132;
|
|
|
- processType = "请核费用-付费";
|
|
|
- checkType = "FYSQ-C";
|
|
|
- } else {
|
|
|
- actId = 1130;
|
|
|
- processType = "请核费用";
|
|
|
- checkType = "FYSQ";
|
|
|
- }
|
|
|
- //审批数据
|
|
|
- LosAuditProecessDTO auditProecessDTO = new LosAuditProecessDTO();
|
|
|
- //获取审批级次
|
|
|
- List<LosAuditPathsLevels> auditPathsLevels;
|
|
|
- // 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
|
|
|
- LosAuditPathsActs pathsActs;
|
|
|
- //是否开启流程
|
|
|
- LambdaQueryWrapper<LosAuditPathsActs> auditPathsActsLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- auditPathsActsLambdaQueryWrapper
|
|
|
- .eq(LosAuditPathsActs::getIsEnable, 1)
|
|
|
- .eq(LosAuditPathsActs::getFidStatus, "status")
|
|
|
- .eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(LosAuditPathsActs::getSalesCompanyId, expenseApplication.getBranchId())
|
|
|
- .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, expenseApplication.getBranchId())
|
|
|
- .eq(LosAuditPathsActs::getTenantId, AuthUtil.getTenantId()));
|
|
|
- Long pathId = losAuditPathsActs.getPathId();
|
|
|
- auditPathsLevels = auditPathsLevelsService.list(new LambdaQueryWrapper<LosAuditPathsLevels>()
|
|
|
- .eq(LosAuditPathsLevels::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(LosAuditPathsLevels::getPathId, pathId)
|
|
|
- .eq(LosAuditPathsLevels::getSalesCompanyId, expenseApplication.getBranchId())
|
|
|
- );
|
|
|
- auditProecessDTO.setTimes(1);
|
|
|
- auditProecessDTO.setProcessType(processType);
|
|
|
- // 没开启审批流直接走 通过流程
|
|
|
- if (pathsActs == null || pathsActs.getIsEnable() == 2) {
|
|
|
- throw new SecurityException("当前租户未查询到审批流配置");
|
|
|
- } else {
|
|
|
- if (CollectionUtils.isEmpty(auditPathsLevels)) {
|
|
|
- throw new SecurityException("开启审批失败:未查询到审批信息");
|
|
|
+ Bills bills = new Bills();
|
|
|
+ if ("HYJK,HYCK".contains(expenseApplication.getSrcType())) {
|
|
|
+ bills = billsService.getById(expenseApplication.getSrcId());
|
|
|
}
|
|
|
- // 绑定审核类型
|
|
|
- auditProecessDTO.setCheckType(checkType);
|
|
|
- // 追加跳转路由url
|
|
|
- auditProecessDTO.setUrl("/iosBasicData/feeApplication/index");
|
|
|
- auditProecessDTO.setPageStatus("this.$store.getters.feeApproval");
|
|
|
- auditProecessDTO.setPageLabel("费用申请(F)");
|
|
|
- auditProecessDTO.setOrderRemark(expenseApplication.getRemarks());
|
|
|
- List<LosAuditPathsLevels> pathsLevelsList = expenseApplication.getAuditPathsLevels();
|
|
|
- if (ObjectUtils.isNotNull(pathsLevelsList) && !pathsLevelsList.isEmpty()) {
|
|
|
- List<Long> idList = pathsLevelsList.stream().map(LosAuditPathsLevels::getId).collect(Collectors.toList());
|
|
|
- List<LosAuditPathsLevels> levelsList = new ArrayList<>();
|
|
|
- for (LosAuditPathsLevels item : auditPathsLevels) {
|
|
|
- if (2 == item.getUserMold()) {
|
|
|
- if (idList.contains(item.getId())) {
|
|
|
- levelsList.add(item);
|
|
|
- }
|
|
|
+ for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
+ if (1 == item.getAccStatus()) {
|
|
|
+ throw new RuntimeException("费用:" + item.getFeeCnName() + "已生成账单");
|
|
|
+ }
|
|
|
+ FinAccBills data = new FinAccBills();
|
|
|
+ data.setGenerationCorpId(item.getGenerationCorpId());
|
|
|
+ data.setGenerationCorpCnName(item.getGenerationCorpCnName());
|
|
|
+ data.setGenerationCorpEnName(item.getGenerationCorpEnName());
|
|
|
+ data.setCreateTime(new Date());
|
|
|
+ data.setCreateUser(AuthUtil.getUserId());
|
|
|
+ data.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNull(item.getBranchId())) {
|
|
|
+ data.setCreateDept(AuthUtil.getDeptId());
|
|
|
+ R<String> res = sysClient.getDeptName(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
+ if (res.isSuccess()) {
|
|
|
+ data.setCreateDeptName(res.getData());
|
|
|
+ data.setBranchName(res.getData());
|
|
|
+ data.setDeptName(res.getData());
|
|
|
+ }
|
|
|
+ data.setBranchId(item.getBranchId());
|
|
|
+ data.setDeptId(Long.parseLong(AuthUtil.getDeptId()));
|
|
|
+ } else {
|
|
|
+ data.setCreateDept(item.getBranchId());
|
|
|
+ data.setCreateDeptName(item.getBranchName());
|
|
|
+ data.setBranchId(item.getBranchId());
|
|
|
+ data.setBranchName(item.getBranchName());
|
|
|
+ data.setDeptId(Long.parseLong(item.getBranchId()));
|
|
|
+ data.setDeptName(item.getBranchName());
|
|
|
+ }
|
|
|
+ data.setBookingAgentId(item.getBookingAgentId());
|
|
|
+ data.setBookingAgentCnName(item.getBookingAgentCnName());
|
|
|
+ data.setBookingAgentEnName(item.getBookingAgentEnName());
|
|
|
+ data.setQuantityCntrDescr(item.getQuantityCntrDescr());
|
|
|
+ data.setTeu(item.getTeu());
|
|
|
+ BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
+ businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
+ businessBillNo.setCode("YWZD");
|
|
|
+ businessBillNo.setBranchId(item.getBranchId());
|
|
|
+ R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
+ if (!clientBillNo.isSuccess()) {
|
|
|
+ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
+ throw new RuntimeException("生成订单编号失败");
|
|
|
+ }
|
|
|
+ data.setWarehousingDate(item.getStorageDate());
|
|
|
+ data.setOutboundDate(item.getOutboundDate());
|
|
|
+ data.setBillNo((String) clientBillNo.getData());
|
|
|
+ data.setBillDate(new Date());
|
|
|
+ data.setAccountDc(item.getDc());
|
|
|
+ data.setAccountDate(item.getBillDate());
|
|
|
+ data.setBusinessType(item.getBusinessType());
|
|
|
+ data.setBusinessBillId(item.getPid());
|
|
|
+ data.setBusinessBillNo(item.getBillNo());
|
|
|
+ data.setBusinessDate(item.getBillDate());
|
|
|
+ data.setBillType(item.getBillType());
|
|
|
+ data.setSrcId(item.getSrcId());
|
|
|
+ data.setSrcCnName(item.getSrcCnName());
|
|
|
+ data.setSrcEnName(item.getSrcEnName());
|
|
|
+ data.setSrcType(item.getSrcType());
|
|
|
+ if (bills != null) {
|
|
|
+ data.setOperatorId(bills.getOperatorId());
|
|
|
+ data.setOperatorName(bills.getOperatorName());
|
|
|
+ } else {
|
|
|
+ data.setOperatorId(expenseApplication.getCreateUser());
|
|
|
+ data.setOperatorName(expenseApplication.getCreateUserName());
|
|
|
+ }
|
|
|
+ data.setPaymode(item.getPaymode());
|
|
|
+ data.setCorpId(item.getCorpId());
|
|
|
+ data.setCorpCnName(item.getCorpCnName());
|
|
|
+ data.setCorpEnName(item.getCorpEnName());
|
|
|
+ data.setBillCorpId(item.getBillCorpId());
|
|
|
+ data.setBillCorpCnName(item.getBillCorpCnName());
|
|
|
+ data.setBillCorpEnName(item.getBillCorpEnName());
|
|
|
+ data.setVesselId(item.getVesselId());
|
|
|
+ data.setVesselCnName(item.getVesselCnName());
|
|
|
+ data.setVesselEnName(item.getVesselEnName());
|
|
|
+ data.setVoyageNo(item.getVoyageNo());
|
|
|
+ data.setMblno(item.getMblno());
|
|
|
+ data.setHblno(item.getHblno());
|
|
|
+ data.setRefno(item.getRefno());
|
|
|
+ data.setBookingNo(item.getBookingNo());
|
|
|
+ data.setEtd(item.getEtd());
|
|
|
+ data.setEta(item.getEta());
|
|
|
+ data.setPolId(item.getPolId());
|
|
|
+ data.setPolCnName(item.getPolCnName());
|
|
|
+ data.setPolEnName(item.getPolEnName());
|
|
|
+ data.setPodId(item.getPodId());
|
|
|
+ data.setPodCnName(item.getPodCnName());
|
|
|
+ data.setPodCode(item.getPodCode());
|
|
|
+ data.setPodEnName(item.getPodEnName());
|
|
|
+ BigDecimal amountDrLoc = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
+ if ("CNY".equals(item.getCurCode())) {
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ data.setAmountDr(item.getAmount());
|
|
|
+ data.setAmountCr(new BigDecimal("0.00"));
|
|
|
} else {
|
|
|
- levelsList.add(item);
|
|
|
+ data.setAmountCr(item.getAmount());
|
|
|
+ data.setAmountDr(new BigDecimal("0.00"));
|
|
|
}
|
|
|
+ data.setAmountDrUsd(new BigDecimal("0.00"));
|
|
|
+ data.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ } else {
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ data.setAmountDrUsd(item.getAmount());
|
|
|
+ data.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ } else {
|
|
|
+ data.setAmountDrUsd(new BigDecimal("0.00"));
|
|
|
+ data.setAmountCrUsd(item.getAmount());
|
|
|
+ }
|
|
|
+ data.setAmountDr(new BigDecimal("0.00"));
|
|
|
+ data.setAmountCr(new BigDecimal("0.00"));
|
|
|
}
|
|
|
- auditProecessDTO.setPathsLevelsList(levelsList);
|
|
|
- } else {
|
|
|
- auditProecessDTO.setPathsLevelsList(auditPathsLevels);
|
|
|
- }
|
|
|
- auditProecessDTO.setActId(1);
|
|
|
- auditProecessDTO.setSrcBillId(expenseApplication.getId());
|
|
|
- auditProecessDTO.setBillId(expenseApplication.getSrcId());
|
|
|
- auditProecessDTO.setBillNo(expenseApplication.getSrcNo());
|
|
|
- auditProecessDTO.setSendUserId(AuthUtil.getUserId());
|
|
|
- auditProecessDTO.setSendName(AuthUtil.getUserName());
|
|
|
- auditProecessDTO.setSendTime(new Date());
|
|
|
- auditProecessDTO.setBillTime(expenseApplication.getCreateTime());
|
|
|
- auditProecessDTO.setTenantId(AuthUtil.getTenantId());
|
|
|
- auditProecessDTO.setCorpId(expenseApplication.getCorpId());
|
|
|
- auditProecessDTO.setCorpsName(expenseApplication.getCorpCnName());
|
|
|
- auditProecessDTO.setReferenceNumber(expenseApplication.getSrcContainerNumber());
|
|
|
- auditProecessDTO.setMorderNo(expenseApplication.getSrcMblno());
|
|
|
- auditProecessDTO.setSrcBusType(expenseApplication.getSrcType());
|
|
|
- auditProecessDTO.setSalesCompanyId(Long.parseLong(expenseApplication.getBranchId()));
|
|
|
- auditProecessDTO.setSalesCompanyName(expenseApplication.getBranchName());
|
|
|
- auditProecessDTO.setMblno(expenseApplication.getSrcMblno());
|
|
|
- auditProecessDTO.setHblno(expenseApplication.getSrcHblno());
|
|
|
- BigDecimal salesPrice = expenseApplication.getFeeCenterList().stream().filter(e -> e.getDc().equals("D"))
|
|
|
- .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal costPrice = expenseApplication.getFeeCenterList().stream().filter(e -> e.getDc().equals("C"))
|
|
|
- .map(FeeCenter::getAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- auditProecessDTO.setPayAmount(costPrice);
|
|
|
- auditProecessDTO.setReceivableAmount(salesPrice);
|
|
|
- auditProecessDTO.setGrossProfit(salesPrice.subtract(costPrice));
|
|
|
- R financeProcess = auditProecessService.createFinanceProcess(auditProecessDTO);
|
|
|
- if (!financeProcess.isSuccess()) {
|
|
|
- throw new SecurityException("操作失败,请联系管理员");
|
|
|
+ if (ObjectUtils.isNotNull(data.getAmountCrUsd()) && ObjectUtils.isNotNull(item.getExrate())) {
|
|
|
+ BigDecimal crCny = data.getAmountCrUsd().multiply(item.getExrate());
|
|
|
+ amountCrLoc = amountCrLoc.add(data.getAmountCr()).add(crCny);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(data.getAmountDrUsd()) && ObjectUtils.isNotNull(item.getExrate())) {
|
|
|
+ BigDecimal drCny = data.getAmountDrUsd().multiply(item.getExrate());
|
|
|
+ amountDrLoc = amountDrLoc.add(data.getAmountDr()).add(drCny);
|
|
|
+ }
|
|
|
+ data.setAmountDrLoc(amountDrLoc);
|
|
|
+ data.setAmountCrLoc(amountCrLoc);
|
|
|
+ finAccBillsService.save(data);
|
|
|
+ item.setAccBillId(data.getId());
|
|
|
+ item.setAccBillNo(data.getBillNo());
|
|
|
+ item.setAccDate(data.getBillDate());
|
|
|
+ item.setAccAmount(amountDrLoc.add(amountCrLoc));
|
|
|
+ item.setAccStatus(1);
|
|
|
+ item.setAccById(AuthUtil.getUserId());
|
|
|
+ item.setAccByName(AuthUtil.getUserName());
|
|
|
+ item.setAuditStatus("4");
|
|
|
+ int version = StringUtil.isBlank(item.getVersion()) ? 1 : Integer.parseInt(item.getVersion());
|
|
|
+ item.setVersion(String.valueOf(version + 1));
|
|
|
}
|
|
|
+ feeCenterService.updateBatchById(expenseApplication.getFeeCenterList());
|
|
|
}
|
|
|
+
|
|
|
return R.data(expenseApplication);
|
|
|
}
|
|
|
|
|
|
@@ -465,13 +627,13 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
|
|
|
.eq(LosAuditPathsActs::getActId, actId);
|
|
|
// 判断是否有审批流,如果审批流已开启就进入审批流,否则直接走申请通过
|
|
|
List<LosAuditPathsActs> pathsActsList = auditPathsActsService.list(auditPathsActsLambdaQueryWrapper);
|
|
|
- if (pathsActsList.isEmpty()){
|
|
|
+ if (pathsActsList.isEmpty()) {
|
|
|
throw new RuntimeException("请先维护审批路径");
|
|
|
}
|
|
|
//获取审批级次
|
|
|
List<LosAuditPathsLevels> auditPathsLevels = auditPathsLevelsService.list(new LambdaQueryWrapper<LosAuditPathsLevels>()
|
|
|
.eq(LosAuditPathsLevels::getTenantId, AuthUtil.getTenantId()));
|
|
|
- if (auditPathsLevels.isEmpty()){
|
|
|
+ if (auditPathsLevels.isEmpty()) {
|
|
|
throw new RuntimeException("请先维护审批人");
|
|
|
}
|
|
|
for (ExpenseApplication expenseApplication : expenseApplicationList) {
|
|
|
@@ -480,7 +642,7 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
|
|
|
auditProecessDTO.setTimes(1);
|
|
|
auditProecessDTO.setProcessType(processType);
|
|
|
//获取审批信息
|
|
|
- LosAuditPathsActs pathsActs = pathsActsList.stream().filter(e-> expenseApplication.getBranchId().equals(e.getSalesCompanyId()+""))
|
|
|
+ LosAuditPathsActs pathsActs = pathsActsList.stream().filter(e -> expenseApplication.getBranchId().equals(e.getSalesCompanyId() + ""))
|
|
|
.findFirst().orElse(null);
|
|
|
// 没开启审批流直接走 通过流程
|
|
|
if (pathsActs == null || pathsActs.getIsEnable() == 2) {
|
|
|
@@ -488,7 +650,7 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
|
|
|
} else {
|
|
|
Long pathId = pathsActs.getPathId();
|
|
|
//获取审批级次
|
|
|
- List<LosAuditPathsLevels> levelsList = auditPathsLevels.stream().filter(e-> e.getPathId().equals(pathId))
|
|
|
+ List<LosAuditPathsLevels> levelsList = auditPathsLevels.stream().filter(e -> e.getPathId().equals(pathId))
|
|
|
.collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(levelsList)) {
|
|
|
throw new SecurityException("开启审批失败:未查询到审批信息");
|
|
|
@@ -543,53 +705,87 @@ public class ExpenseApplicationServiceImpl extends ServiceImpl<ExpenseApplicatio
|
|
|
if (ObjectUtils.isNull(expenseApplication.getFeeCenterList()) || expenseApplication.getFeeCenterList().isEmpty()) {
|
|
|
throw new RuntimeException("请选择明细");
|
|
|
}
|
|
|
- List<Long> idList = expenseApplication.getFeeCenterList().stream().map(FeeCenter::getStlPid).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
- if (idList.isEmpty()){
|
|
|
- throw new RuntimeException("数据错误,请联系管理员");
|
|
|
- }
|
|
|
- List<FeeCenter> feeCenterListOld = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
- .eq(FeeCenter::getIsDeleted, 0)
|
|
|
- .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
- .in(FeeCenter::getStlPid, idList));
|
|
|
- StringBuilder text = new StringBuilder();
|
|
|
- List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
- for (FeeCenter item : feeCenterListOld) {
|
|
|
- if (item.getStlPid() == null) {
|
|
|
- text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("未申请,");
|
|
|
+ String status = sysClient.getParamService("expense.application");
|
|
|
+ if (status.equals("1")){
|
|
|
+ List<Long> idList = expenseApplication.getFeeCenterList().stream().map(FeeCenter::getStlPid).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ if (idList.isEmpty()) {
|
|
|
+ throw new RuntimeException("数据错误,请联系管理员");
|
|
|
}
|
|
|
- if (item.getStlTtlAmount().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- text.append("费用:").append(item.getFeeCnName()).append("已结算");
|
|
|
+ List<FeeCenter> feeCenterListOld = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
|
|
|
+ .eq(FeeCenter::getIsDeleted, 0)
|
|
|
+ .eq(FeeCenter::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .in(FeeCenter::getStlPid, idList));
|
|
|
+ StringBuilder text = new StringBuilder();
|
|
|
+ List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
+ for (FeeCenter item : feeCenterListOld) {
|
|
|
+ if (item.getStlPid() == null) {
|
|
|
+ text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("未申请,");
|
|
|
+ }
|
|
|
+ if (item.getStlTtlAmount().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ text.append("费用:").append(item.getFeeCnName()).append("已结算");
|
|
|
+ }
|
|
|
+ if (1 == item.getAccStatus()) {
|
|
|
+ feeCenterList.add(item);
|
|
|
+ }
|
|
|
}
|
|
|
- if (1 == item.getAccStatus()) {
|
|
|
- feeCenterList.add(item);
|
|
|
+ if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
+ throw new RuntimeException(text.toString());
|
|
|
}
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
- throw new RuntimeException(text.toString());
|
|
|
- }
|
|
|
- if (!feeCenterList.isEmpty()) {
|
|
|
- FinAccBills finAccBills = new FinAccBills();
|
|
|
- finAccBills.setFeeCenterList(feeCenterList);
|
|
|
- finAccBillsService.revokeBill(finAccBills);
|
|
|
- }
|
|
|
- for (FeeCenter item : feeCenterListOld) {
|
|
|
- item.setStlPid(null);
|
|
|
- item.setAuditStatus("0");
|
|
|
- item.setAccStatus(0);
|
|
|
- item.setApplyId(0L);
|
|
|
- item.setApplyName("");
|
|
|
- item.setApplyTime(null);
|
|
|
- }
|
|
|
- feeCenterService.updateBatchById(feeCenterListOld);
|
|
|
- if (idList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到请核费用单据id");
|
|
|
- }
|
|
|
- this.removeByIds(idList);
|
|
|
- for (Long item : idList) {
|
|
|
- R financeProcess = auditProecessService.deteleBySrcBillId(item);
|
|
|
- if (!financeProcess.isSuccess()) {
|
|
|
- throw new SecurityException("操作失败,请联系管理员");
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ FinAccBills finAccBills = new FinAccBills();
|
|
|
+ finAccBills.setFeeCenterList(feeCenterList);
|
|
|
+ finAccBillsService.revokeBill(finAccBills);
|
|
|
+ }
|
|
|
+ for (FeeCenter item : feeCenterListOld) {
|
|
|
+ item.setStlPid(null);
|
|
|
+ item.setAuditStatus("0");
|
|
|
+ item.setAccStatus(0);
|
|
|
+ item.setApplyId(0L);
|
|
|
+ item.setApplyName("");
|
|
|
+ item.setApplyTime(null);
|
|
|
+ }
|
|
|
+ feeCenterService.updateBatchById(feeCenterListOld);
|
|
|
+ if (idList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到请核费用单据id");
|
|
|
+ }
|
|
|
+ this.removeByIds(idList);
|
|
|
+ for (Long item : idList) {
|
|
|
+ R financeProcess = auditProecessService.deteleBySrcBillId(item);
|
|
|
+ if (!financeProcess.isSuccess()) {
|
|
|
+ throw new SecurityException("操作失败,请联系管理员");
|
|
|
+ }
|
|
|
}
|
|
|
+ }else{
|
|
|
+ StringBuilder text = new StringBuilder();
|
|
|
+ List<FeeCenter> feeCenterList = new ArrayList<>();
|
|
|
+ for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
+ if (item.getStlPid() == null) {
|
|
|
+ text.append("费用:").append(item.getFeeCnName()).append("金额:").append(item.getAmount()).append("未申请,");
|
|
|
+ }
|
|
|
+ if (item.getStlTtlAmount().compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ text.append("费用:").append(item.getFeeCnName()).append("已结算");
|
|
|
+ }
|
|
|
+ if (1 == item.getAccStatus()) {
|
|
|
+ feeCenterList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(text.toString())) {
|
|
|
+ throw new RuntimeException(text.toString());
|
|
|
+ }
|
|
|
+ if (!feeCenterList.isEmpty()) {
|
|
|
+ FinAccBills finAccBills = new FinAccBills();
|
|
|
+ finAccBills.setFeeCenterList(feeCenterList);
|
|
|
+ finAccBillsService.revokeBill(finAccBills);
|
|
|
+ }
|
|
|
+ for (FeeCenter item : expenseApplication.getFeeCenterList()) {
|
|
|
+ item.setStlPid(null);
|
|
|
+ item.setAuditStatus("0");
|
|
|
+ item.setAccStatus(0);
|
|
|
+ item.setApplyId(0L);
|
|
|
+ item.setApplyName("");
|
|
|
+ item.setApplyTime(null);
|
|
|
+ }
|
|
|
+ feeCenterService.updateBatchById(expenseApplication.getFeeCenterList());
|
|
|
}
|
|
|
return R.data(expenseApplication);
|
|
|
}
|