|
|
@@ -24,16 +24,13 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import io.seata.spring.annotation.GlobalTransactional;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.core.excel.util.ExcelUtil;
|
|
|
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.acc.entity.Accounts;
|
|
|
import org.springblade.los.basic.acc.service.IAccountsService;
|
|
|
-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.aea.service.IAeaBillsService;
|
|
|
import org.springblade.los.business.amends.entity.Amends;
|
|
|
@@ -44,6 +41,7 @@ import org.springblade.los.business.sea.entity.Bills;
|
|
|
import org.springblade.los.business.sea.service.IBillsService;
|
|
|
import org.springblade.los.excel.ReviewFailedExcel;
|
|
|
import org.springblade.los.excel.UnbookkeptExcel;
|
|
|
+import org.springblade.los.finance.genleg.dto.PeriodExchangeRate;
|
|
|
import org.springblade.los.finance.genleg.dto.PeriodVouchersAccItems;
|
|
|
import org.springblade.los.finance.genleg.dto.PeriodVouchersTemplate;
|
|
|
import org.springblade.los.finance.genleg.entity.FinGenleg;
|
|
|
@@ -62,9 +60,10 @@ import org.springblade.los.finance.vouchers.service.IFinVouchersService;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
@@ -104,14 +103,8 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
|
|
|
private final IFinGenlegService finGenlegService;
|
|
|
|
|
|
- private final IBusinessTypeService bBusinessTypeService;
|
|
|
-
|
|
|
- private final IBusinessBillNoService businessBillNoService;
|
|
|
-
|
|
|
private final IAccountsService accountsService;
|
|
|
|
|
|
- private final IBCurrencyService bCurrencyService;
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public IPage<FinPeriodVO> selectFinPeriodPage(IPage<FinPeriodVO> page, FinPeriodVO finPeriod) {
|
|
|
@@ -163,7 +156,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
}
|
|
|
LocalDate date = finPeriod.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
Integer periodYear = date.getYear();
|
|
|
- Integer periodMonth = date.lengthOfMonth();
|
|
|
+ Integer periodMonth = date.getMonthValue();
|
|
|
List<FinGenlegCalc> finGenlegCalcList = finGenlegCalcService.list(new LambdaQueryWrapper<FinGenlegCalc>()
|
|
|
.eq(FinGenlegCalc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FinGenlegCalc::getBranchId, deptUtils.getDeptPid())
|
|
|
@@ -203,12 +196,26 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
}
|
|
|
List<ReviewFailedExcel> reviewFailedExcelList = new ArrayList<>();
|
|
|
List<UnbookkeptExcel> unbookkeptExcelList = new ArrayList<>();
|
|
|
+ String beginDate = "";
|
|
|
+ String endDate = "";
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if (null != detail.getBeginDate()) {
|
|
|
+ beginDate = sdf.format(detail.getBeginDate());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("该期间缺少开始时间,操作失败");
|
|
|
+ }
|
|
|
+ if (null != detail.getEndDate()) {
|
|
|
+ endDate = sdf.format(detail.getEndDate());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("该期间缺少结束时间,操作失败");
|
|
|
+ }
|
|
|
List<Bills> billsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
.eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Bills::getIsDeleted, 0)
|
|
|
.eq(Bills::getBranchId, detail.getBranchId())
|
|
|
- .apply("((business_type = 'SE' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + " ) " +
|
|
|
- "or (business_type = 'SI' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))"));
|
|
|
+ .apply("not find_in_set(bill_status,'1,3')")
|
|
|
+ .apply("((business_type = 'SE' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
|
|
|
+ "or (business_type = 'SI' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"));
|
|
|
if (!billsList.isEmpty()) {
|
|
|
List<Bills> bills = billsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
for (Bills item : bills) {
|
|
|
@@ -232,8 +239,9 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
.eq(AeaBills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(AeaBills::getIsDeleted, 0)
|
|
|
.eq(AeaBills::getBranchId, detail.getBranchId())
|
|
|
- .apply("((business_type = 'AE' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + " ) " +
|
|
|
- "or (business_type = 'AI' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))"));
|
|
|
+ .apply("not find_in_set(bill_status,'1,3')")
|
|
|
+ .apply("((business_type = 'AE' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
|
|
|
+ "or (business_type = 'AI' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"));
|
|
|
if (!aeaBillsList.isEmpty()) {
|
|
|
List<AeaBills> aeaBills = aeaBillsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
for (AeaBills item : aeaBills) {
|
|
|
@@ -257,10 +265,11 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
.eq(Amends::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(Amends::getIsDeleted, 0)
|
|
|
.eq(Amends::getBranchId, detail.getBranchId())
|
|
|
- .apply("((business_type = 'SEA' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + " ) " +
|
|
|
- "or (business_type = 'SIA' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))" +
|
|
|
- "or (business_type = 'AEA' and etd >=" + detail.getBeginDate() + " and etd <= " + detail.getEndDate() + "))" +
|
|
|
- "or (business_type = 'AIA' and eta >=" + detail.getBeginDate() + " and eta <= " + detail.getEndDate() + "))"
|
|
|
+ .apply("not find_in_set(bill_status,'3')")
|
|
|
+ .apply("((business_type = 'SEA' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
|
|
|
+ "or (business_type = 'SIA' and eta >='" + beginDate + "' and eta <= '" + endDate + "')" +
|
|
|
+ "or (business_type = 'AEA' and etd >='" + beginDate + "' and etd <= '" + endDate + "')" +
|
|
|
+ "or (business_type = 'AIA' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"
|
|
|
));
|
|
|
if (!amendsList.isEmpty()) {
|
|
|
List<Amends> bills = amendsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
@@ -330,6 +339,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
List<CustomsDeclaration> customsDeclarationList = customsDeclarationService.list(new LambdaQueryWrapper<CustomsDeclaration>()
|
|
|
.eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(CustomsDeclaration::getIsDeleted, 0)
|
|
|
+ .apply("not find_in_set(bill_status,'3')")
|
|
|
.eq(CustomsDeclaration::getBranchId, detail.getBranchId())
|
|
|
.gt(CustomsDeclaration::getDeclareDate, detail.getBeginDate())
|
|
|
.lt(CustomsDeclaration::getDeclareDate, detail.getEndDate())
|
|
|
@@ -361,9 +371,10 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
.eq(FinStlBills::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FinStlBills::getIsDeleted, 0)
|
|
|
.eq(FinStlBills::getBusinessType, "STL")
|
|
|
+ .eq(FinStlBills::getStatus, 3)
|
|
|
.eq(FinStlBills::getBranchId, detail.getBranchId())
|
|
|
- .gt(FinStlBills::getBillDate, detail.getBeginDate())
|
|
|
- .lt(FinStlBills::getBillDate, detail.getEndDate())
|
|
|
+ .gt(FinStlBills::getBillDate, beginDate)
|
|
|
+ .lt(FinStlBills::getBillDate, endDate)
|
|
|
);
|
|
|
if (!finStlBillsList.isEmpty()) {
|
|
|
List<FinStlBills> bills = finStlBillsList.stream().filter(e -> e.getBillStatus().equals("3")).collect(Collectors.toList());
|
|
|
@@ -375,8 +386,8 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
.eq(FinVouchers::getIsDeleted, 0)
|
|
|
.eq(FinVouchers::getBranchId, detail.getBranchId())
|
|
|
.in(FinVouchers::getSrcId, ids)
|
|
|
- .gt(FinVouchers::getVoucherDate, detail.getBeginDate())
|
|
|
- .lt(FinVouchers::getVoucherDate, detail.getEndDate()));
|
|
|
+ .gt(FinVouchers::getVoucherDate, beginDate)
|
|
|
+ .lt(FinVouchers::getVoucherDate, endDate));
|
|
|
for (FinStlBills item : bills) {
|
|
|
FinVouchers finVouchers = finVouchersList.stream().filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
|
|
|
if (finVouchers == null) {
|
|
|
@@ -389,30 +400,49 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
reviewFailedExcel.setSalesperson(item.getSalesName());
|
|
|
reviewFailedExcelList.add(reviewFailedExcel);
|
|
|
} else {
|
|
|
- UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
|
|
|
- unbookkeptExcel.setYear(finVouchers.getAccountYear() + "");
|
|
|
- unbookkeptExcel.setMonth(finVouchers.getAccountMonth() + "");
|
|
|
- unbookkeptExcel.setVoucherNumber(finVouchers.getVoucherNo());
|
|
|
- unbookkeptExcel.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
- unbookkeptExcel.setOperator(finVouchers.getCreateUserName());
|
|
|
- unbookkeptExcelList.add(unbookkeptExcel);
|
|
|
+ if (3 != finVouchers.getStatus()) {
|
|
|
+ UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
|
|
|
+ unbookkeptExcel.setYear(finVouchers.getAccountYear() + "");
|
|
|
+ unbookkeptExcel.setMonth(finVouchers.getAccountMonth() + "");
|
|
|
+ unbookkeptExcel.setVoucherNumber(finVouchers.getVoucherNo());
|
|
|
+ unbookkeptExcel.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ unbookkeptExcel.setOperator(finVouchers.getCreateUserName());
|
|
|
+ unbookkeptExcelList.add(unbookkeptExcel);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
|
|
|
+ .eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinVouchers::getIsDeleted, 0)
|
|
|
+ .eq(FinVouchers::getBranchId, detail.getBranchId())
|
|
|
+ .gt(FinVouchers::getVoucherDate, beginDate)
|
|
|
+ .lt(FinVouchers::getVoucherDate, endDate));
|
|
|
+ for (FinVouchers item : finVouchersList) {
|
|
|
+ if (3 != item.getStatus()) {
|
|
|
+ UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
|
|
|
+ unbookkeptExcel.setYear(item.getAccountYear() + "");
|
|
|
+ unbookkeptExcel.setMonth(item.getAccountMonth() + "");
|
|
|
+ unbookkeptExcel.setVoucherNumber(item.getVoucherNo());
|
|
|
+ unbookkeptExcel.setVoucherDate(item.getVoucherDate());
|
|
|
+ unbookkeptExcel.setOperator(item.getCreateUserName());
|
|
|
+ unbookkeptExcelList.add(unbookkeptExcel);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!reviewFailedExcelList.isEmpty()) {
|
|
|
return R.data(reviewFailedExcelList, "审核未通过");
|
|
|
}
|
|
|
if (!unbookkeptExcelList.isEmpty()) {
|
|
|
- return R.data(reviewFailedExcelList, "凭证未记账");
|
|
|
+ return R.data(unbookkeptExcelList, "凭证未记账");
|
|
|
}
|
|
|
detail.setUpdateTime(new Date());
|
|
|
detail.setUpdateUserName(AuthUtil.getUserName());
|
|
|
detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
detail.setLockingStatus(1);
|
|
|
- baseMapper.updateById(finPeriod);
|
|
|
- return R.data(finPeriod);
|
|
|
+ baseMapper.updateById(detail);
|
|
|
+ return R.data(detail);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -459,13 +489,14 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
detail.setPeriod(JSON.toJSONString(detail.getPeriodVouchersTemplate()));
|
|
|
}
|
|
|
}
|
|
|
- baseMapper.updateById(finPeriod);
|
|
|
+ baseMapper.updateById(detail);
|
|
|
|
|
|
List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
|
|
|
.eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FinVouchers::getIsDeleted, 0)
|
|
|
.eq(FinVouchers::getBranchId, detail.getBranchId())
|
|
|
- .eq(FinVouchers::getVoucherSource, "SYSTEM")
|
|
|
+ .and(e -> e.eq(FinVouchers::getVoucherSource, "FM-PERIOD-PL-TRANSFER")
|
|
|
+ .or().eq(FinVouchers::getVoucherSource, "FM-CURRENCY-PL-TRANSFER"))
|
|
|
.eq(FinVouchers::getAccountYear, detail.getPeriodYear())
|
|
|
.eq(FinVouchers::getAccountMonth, detail.getPeriodMonth())
|
|
|
.gt(FinVouchers::getVoucherDate, detail.getBeginDate())
|
|
|
@@ -499,8 +530,81 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
finPeriodNew.setPeriod(JSON.toJSONString(finPeriodNew.getPeriodVouchersTemplate()));
|
|
|
}
|
|
|
}
|
|
|
+ finPeriodNew.setExchange(detail.getExchange());
|
|
|
+ finPeriodNew.setPeriod(detail.getPeriod());
|
|
|
this.submit(finPeriodNew);
|
|
|
- return R.data(finPeriod);
|
|
|
+
|
|
|
+ List<FinGenlegCalc> finGenlegCalcList = finGenlegCalcService.list(new LambdaQueryWrapper<FinGenlegCalc>()
|
|
|
+ .eq(FinGenlegCalc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinGenlegCalc::getAccyear, detail.getPeriodYear())
|
|
|
+ .eq(FinGenlegCalc::getAccmonth, detail.getPeriodMonth()));
|
|
|
+ List<FinGenlegCalc> finGenlegCalcNewList = new ArrayList<>();
|
|
|
+ for (FinGenlegCalc item : finGenlegCalcList) {
|
|
|
+ FinGenlegCalc finGenlegCalc = new FinGenlegCalc();
|
|
|
+ BeanUtil.copyProperties(item, finGenlegCalc);
|
|
|
+ finGenlegCalc.setId(null);
|
|
|
+ finGenlegCalc.setAccmonth(finPeriodNew.getPeriodMonth());
|
|
|
+ finGenlegCalc.setAccyear(finPeriodNew.getPeriodYear());
|
|
|
+ //本期上期余额等于上期余额
|
|
|
+ finGenlegCalc.setAmountLastBlc(item.getAmountBlc());
|
|
|
+ finGenlegCalc.setAmountLastBlcUsd(item.getAmountUsdBlc());
|
|
|
+ //本期借,贷金额清零
|
|
|
+ finGenlegCalc.setAmountDr(new BigDecimal("0.00"));
|
|
|
+ finGenlegCalc.setAmountCr(new BigDecimal("0.00"));
|
|
|
+ finGenlegCalc.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ finGenlegCalc.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ //本期余额 = 上期余额+借-贷
|
|
|
+ finGenlegCalc.setAmountBlc(finGenlegCalc.getAmountLastBlc().add(finGenlegCalc.getAmountDr()).subtract(finGenlegCalc.getAmountCr()));
|
|
|
+ finGenlegCalc.setAmountUsdBlc(finGenlegCalc.getAmountLastBlcUsd().add(finGenlegCalc.getAmountDrUsd()).subtract(finGenlegCalc.getAmountCrUsd()));
|
|
|
+
|
|
|
+ //本期上期数量等于上期余额数量
|
|
|
+ finGenlegCalc.setQuantityLastBlc(item.getQuantityBlc());
|
|
|
+ //本期借,贷数量清零
|
|
|
+ finGenlegCalc.setQuantityDr(new BigDecimal("0.00"));
|
|
|
+ finGenlegCalc.setQuantityCr(new BigDecimal("0.00"));
|
|
|
+ //本期余额数量 = 上期余额数量+借-贷
|
|
|
+ finGenlegCalc.setQuantityBlc(finGenlegCalc.getQuantityLastBlc().add(finGenlegCalc.getQuantityDr()).subtract(finGenlegCalc.getQuantityCr()));
|
|
|
+ finGenlegCalcNewList.add(finGenlegCalc);
|
|
|
+ }
|
|
|
+ if (!finGenlegCalcNewList.isEmpty()) {
|
|
|
+ finGenlegCalcService.saveOrUpdateBatch(finGenlegCalcNewList);
|
|
|
+ }
|
|
|
+ List<FinGenleg> finGenlegList = finGenlegService.list(new LambdaQueryWrapper<FinGenleg>()
|
|
|
+ .eq(FinGenleg::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinGenleg::getAccyear, detail.getPeriodYear())
|
|
|
+ .eq(FinGenleg::getAccmonth, detail.getPeriodMonth()));
|
|
|
+ List<FinGenleg> finGenlegNewList = new ArrayList<>();
|
|
|
+ for (FinGenleg item : finGenlegList) {
|
|
|
+ FinGenleg finGenleg = new FinGenleg();
|
|
|
+ BeanUtil.copyProperties(item, finGenleg);
|
|
|
+ finGenleg.setId(null);
|
|
|
+ finGenleg.setAccmonth(finPeriodNew.getPeriodMonth());
|
|
|
+ finGenleg.setAccyear(finPeriodNew.getPeriodYear());
|
|
|
+ //本期上期余额等于上期余额
|
|
|
+ finGenleg.setAmountLastBlc(item.getAmountBlc());
|
|
|
+ finGenleg.setAmountLastBlcUsd(item.getAmountUsdBlc());
|
|
|
+ //本期借,贷金额清零
|
|
|
+ finGenleg.setAmountDr(new BigDecimal("0.00"));
|
|
|
+ finGenleg.setAmountCr(new BigDecimal("0.00"));
|
|
|
+ finGenleg.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ finGenleg.setAmountCrUsd(new BigDecimal("0.00"));
|
|
|
+ //本期余额 = 上期余额+借-贷
|
|
|
+ finGenleg.setAmountBlc(finGenleg.getAmountLastBlc().add(finGenleg.getAmountDr()).subtract(finGenleg.getAmountCr()));
|
|
|
+ finGenleg.setAmountUsdBlc(finGenleg.getAmountLastBlcUsd().add(finGenleg.getAmountDrUsd()).subtract(finGenleg.getAmountCrUsd()));
|
|
|
+
|
|
|
+ //本期上期数量等于上期余额数量
|
|
|
+ finGenleg.setQuantityLastBlc(item.getQuantityBlc());
|
|
|
+ //本期借,贷数量清零
|
|
|
+ finGenleg.setQuantityDr(new BigDecimal("0.00"));
|
|
|
+ finGenleg.setQuantityCr(new BigDecimal("0.00"));
|
|
|
+ //本期余额数量 = 上期余额数量+借-贷
|
|
|
+ finGenleg.setQuantityBlc(finGenleg.getQuantityLastBlc().add(finGenleg.getQuantityDr()).subtract(finGenleg.getQuantityCr()));
|
|
|
+ finGenlegNewList.add(finGenleg);
|
|
|
+ }
|
|
|
+ if (!finGenlegNewList.isEmpty()) {
|
|
|
+ finGenlegService.saveOrUpdateBatch(finGenlegNewList);
|
|
|
+ }
|
|
|
+ return R.data(detail);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -519,25 +623,27 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
detail.setIsClosed(0);
|
|
|
detail.setCloseDate(null);
|
|
|
- baseMapper.updateById(finPeriod);
|
|
|
- LocalDate date = detail.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
- // 获取下个月的第一天
|
|
|
- LocalDate firstDayOfNextMonth = date.with(TemporalAdjusters.firstDayOfNextMonth());
|
|
|
- // 获取下个月的最后一天
|
|
|
- LocalDate lastDayOfNextMonth;
|
|
|
- if (firstDayOfNextMonth.getMonthValue() == 12) {
|
|
|
- lastDayOfNextMonth = firstDayOfNextMonth.withDayOfMonth(31);
|
|
|
- } else {
|
|
|
- lastDayOfNextMonth = firstDayOfNextMonth.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ baseMapper.updateById(detail);
|
|
|
+ Integer periodYear = detail.getPeriodYear();
|
|
|
+ Integer periodMonth = detail.getPeriodMonth();
|
|
|
+ if (periodMonth == 12) {
|
|
|
+ periodMonth = 1;
|
|
|
+ periodYear += 1;
|
|
|
}
|
|
|
FinPeriod finPeriodNew = baseMapper.selectOne(new LambdaQueryWrapper<FinPeriod>()
|
|
|
.eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FinPeriod::getIsDeleted, 0)
|
|
|
.eq(FinPeriod::getBranchId, detail.getBranchId())
|
|
|
- .eq(FinPeriod::getIsClosed, 1)
|
|
|
- .eq(FinPeriod::getBeginDate, firstDayOfNextMonth)
|
|
|
- .eq(FinPeriod::getEndDate, lastDayOfNextMonth));
|
|
|
+ .eq(FinPeriod::getIsClosed, 0)
|
|
|
+ .eq(FinPeriod::getPeriodYear, periodYear)
|
|
|
+ .eq(FinPeriod::getPeriodMonth, periodMonth + 1));
|
|
|
if (finPeriodNew != null) {
|
|
|
+ if (1 == finPeriodNew.getIsClosed()) {
|
|
|
+ throw new RuntimeException(periodYear + "年" + (periodMonth + 1) + "月期间已结转,操作失败");
|
|
|
+ }
|
|
|
+ if (1 == finPeriodNew.getLockingStatus()) {
|
|
|
+ throw new RuntimeException(periodYear + "年" + (periodMonth + 1) + "月期间已锁定,操作失败");
|
|
|
+ }
|
|
|
baseMapper.deleteById(finPeriodNew.getId());
|
|
|
} else {
|
|
|
List<FinPeriod> finPeriodList = baseMapper.selectList(new LambdaQueryWrapper<FinPeriod>()
|
|
|
@@ -548,7 +654,23 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
throw new RuntimeException("未查到下期数据,操作失败!");
|
|
|
}
|
|
|
}
|
|
|
- return R.data(finPeriod);
|
|
|
+ List<FinGenlegCalc> finGenlegCalcList = finGenlegCalcService.list(new LambdaQueryWrapper<FinGenlegCalc>()
|
|
|
+ .eq(FinGenlegCalc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinGenlegCalc::getAccyear, detail.getPeriodYear())
|
|
|
+ .eq(FinGenlegCalc::getAccmonth, detail.getPeriodMonth()));
|
|
|
+ if (!finGenlegCalcList.isEmpty()) {
|
|
|
+ List<Long> ids = finGenlegCalcList.stream().map(FinGenlegCalc::getId).collect(Collectors.toList());
|
|
|
+ finGenlegCalcService.removeByIds(ids);
|
|
|
+ }
|
|
|
+ List<FinGenleg> finGenlegList = finGenlegService.list(new LambdaQueryWrapper<FinGenleg>()
|
|
|
+ .eq(FinGenleg::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinGenleg::getAccyear, detail.getPeriodYear())
|
|
|
+ .eq(FinGenleg::getAccmonth, detail.getPeriodMonth()));
|
|
|
+ if (!finGenlegList.isEmpty()) {
|
|
|
+ List<Long> ids = finGenlegList.stream().map(FinGenleg::getId).collect(Collectors.toList());
|
|
|
+ finGenlegService.removeByIds(ids);
|
|
|
+ }
|
|
|
+ return R.data(detail);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -566,21 +688,18 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
deptName = String.join(",", res.getData());
|
|
|
}
|
|
|
}
|
|
|
- if (baseMapper.selectCount(new LambdaQueryWrapper<FinPeriod>()
|
|
|
- .eq(FinPeriod::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(FinPeriod::getIsDeleted, 0)
|
|
|
- .eq(FinPeriod::getBranchId, branchId)) > 0) {
|
|
|
- throw new RuntimeException("本年度已有账期,请勿重复生成");
|
|
|
- }
|
|
|
if (finPeriod.getId() == null) {
|
|
|
if (ObjectUtils.isNotNull(finPeriod.getBeginDate())) {
|
|
|
LocalDate date = finPeriod.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
finPeriod.setPeriodYear(date.getYear());
|
|
|
- finPeriod.setPeriodMonth(date.lengthOfMonth());
|
|
|
+ finPeriod.setPeriodMonth(date.getMonthValue());
|
|
|
+ // 获取当前月的最后一天
|
|
|
+ LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ finPeriod.setEndDate(Date.from(lastDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
} else {
|
|
|
LocalDate date = LocalDate.now();
|
|
|
finPeriod.setPeriodYear(date.getYear());
|
|
|
- finPeriod.setPeriodMonth(date.lengthOfMonth());
|
|
|
+ finPeriod.setPeriodMonth(date.getMonthValue());
|
|
|
// 获取当前月的第一天
|
|
|
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
|
|
|
// 获取当前月的最后一天
|
|
|
@@ -612,6 +731,20 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
finPeriod.setPeriod(JSON.toJSONString(finPeriod.getPeriodVouchersTemplate()));
|
|
|
}
|
|
|
}
|
|
|
+ PeriodVouchersTemplate exchange = JSONObject.parseObject(finPeriod.getExchange(), PeriodVouchersTemplate.class);
|
|
|
+ if (exchange != null) {
|
|
|
+ exchange.setId(finPeriod.getId() + "");
|
|
|
+ exchange.setDate(finPeriod.getPeriodYear() + "-" + finPeriod.getPeriodMonth());
|
|
|
+ exchange.setStatus(finPeriod.getIsClosed());
|
|
|
+ finPeriod.setExchange(JSON.toJSONString(exchange));
|
|
|
+ }
|
|
|
+ PeriodVouchersTemplate period = JSONObject.parseObject(finPeriod.getPeriod(), PeriodVouchersTemplate.class);
|
|
|
+ if (period != null) {
|
|
|
+ period.setId(finPeriod.getId() + "");
|
|
|
+ period.setDate(finPeriod.getPeriodYear() + "-" + finPeriod.getPeriodMonth());
|
|
|
+ period.setStatus(finPeriod.getIsClosed());
|
|
|
+ finPeriod.setPeriod(JSON.toJSONString(period));
|
|
|
+ }
|
|
|
this.updateById(finPeriod);
|
|
|
return R.data(finPeriod);
|
|
|
}
|
|
|
@@ -629,8 +762,8 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
detail.setUpdateUserName(AuthUtil.getUserName());
|
|
|
detail.setUpdateUser(AuthUtil.getUserId());
|
|
|
detail.setLockingStatus(0);
|
|
|
- baseMapper.updateById(finPeriod);
|
|
|
- return R.data(finPeriod);
|
|
|
+ baseMapper.updateById(detail);
|
|
|
+ return R.data(detail);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -657,13 +790,17 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
if (ObjectUtils.isNotNull(finPeriod.getBeginDate())) {
|
|
|
LocalDate date = finPeriod.getBeginDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
finPeriod.setPeriodYear(date.getYear());
|
|
|
- finPeriod.setPeriodMonth(date.lengthOfMonth());
|
|
|
+ finPeriod.setPeriodMonth(date.getMonthValue());
|
|
|
+ // 获取当前月的最后一天
|
|
|
+ LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ finPeriod.setEndDate(Date.from(lastDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
} else {
|
|
|
LocalDate date = LocalDate.now();
|
|
|
finPeriod.setPeriodYear(date.getYear());
|
|
|
- finPeriod.setPeriodMonth(date.lengthOfMonth());
|
|
|
+ finPeriod.setPeriodMonth(date.getMonthValue());
|
|
|
// 获取当前月的第一天
|
|
|
LocalDate firstDayOfMonth = date.with(TemporalAdjusters.firstDayOfMonth());
|
|
|
+
|
|
|
// 获取当前月的最后一天
|
|
|
LocalDate lastDayOfMonth = date.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
finPeriod.setBeginDate(Date.from(firstDayOfMonth.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
@@ -678,6 +815,48 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
finPeriod.setCreateDeptName(deptName);
|
|
|
}
|
|
|
this.saveOrUpdate(finPeriod);
|
|
|
+
|
|
|
+ PeriodVouchersTemplate exchange = new PeriodVouchersTemplate();
|
|
|
+ exchange.setId(finPeriod.getId() + "");
|
|
|
+ exchange.setStatus(0);
|
|
|
+ exchange.setBsType("FM-CURRENCY-PL-TRANSFER");
|
|
|
+ exchange.setVkno("转");
|
|
|
+ Accounts accountsExchange = accountsService.getOne(new LambdaQueryWrapper<Accounts>()
|
|
|
+ .eq(Accounts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Accounts::getCode, "550303")
|
|
|
+ );
|
|
|
+ if (null == accountsExchange) {
|
|
|
+ throw new RuntimeException("未找到到科目代码550303信息");
|
|
|
+ }
|
|
|
+ exchange.setPlAccCnm(accountsExchange.getCnName());
|
|
|
+ exchange.setPlAccFnm(accountsExchange.getCode() + "-" + accountsExchange.getFullName());
|
|
|
+ exchange.setPlAccNo(accountsExchange.getCode());
|
|
|
+ exchange.setPlAccID(accountsExchange.getId() + "");
|
|
|
+ exchange.setDescr(accountsExchange.getCnName() + "结转");
|
|
|
+ exchange.setAccItems(new ArrayList<>());
|
|
|
+ exchange.setDate(finPeriod.getPeriodYear() + "-" + finPeriod.getPeriodMonth());
|
|
|
+ finPeriod.setExchange(JSON.toJSONString(exchange));
|
|
|
+ PeriodVouchersTemplate period = new PeriodVouchersTemplate();
|
|
|
+ period.setId(finPeriod.getId() + "");
|
|
|
+ period.setStatus(0);
|
|
|
+ period.setBsType("FM-PERIOD-PL-TRANSFER");
|
|
|
+ period.setVkno("转");
|
|
|
+ Accounts accountsPeriod = accountsService.getOne(new LambdaQueryWrapper<Accounts>()
|
|
|
+ .eq(Accounts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Accounts::getCode, "550304")
|
|
|
+ );
|
|
|
+ if (null == accountsPeriod) {
|
|
|
+ throw new RuntimeException("未找到到科目代码550304信息");
|
|
|
+ }
|
|
|
+ period.setPlAccCnm(accountsPeriod.getCnName());
|
|
|
+ period.setPlAccFnm(accountsPeriod.getCode() + "-" + accountsPeriod.getFullName());
|
|
|
+ period.setPlAccNo(accountsPeriod.getCode());
|
|
|
+ period.setPlAccID(accountsPeriod.getId() + "");
|
|
|
+ period.setDescr(accountsPeriod.getCnName() + "结转");
|
|
|
+ period.setAccItems(new ArrayList<>());
|
|
|
+ period.setDate(finPeriod.getPeriodYear() + "-" + finPeriod.getPeriodMonth());
|
|
|
+ finPeriod.setPeriod(JSON.toJSONString(period));
|
|
|
+ this.updateById(finPeriod);
|
|
|
return R.data(finPeriod);
|
|
|
}
|
|
|
|
|
|
@@ -717,11 +896,11 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
if (accItems.isEmpty()) {
|
|
|
throw new RuntimeException("模版科目明细不能为空");
|
|
|
}
|
|
|
+ List<PeriodExchangeRate> exchangeRateList = periodVouchersTemplate.getExchangeRateList();
|
|
|
+ if (exchangeRateList.isEmpty()) {
|
|
|
+ throw new RuntimeException("缺少汇率信息");
|
|
|
+ }
|
|
|
FinVouchers finVouchers = new FinVouchers();
|
|
|
- List<BusinessType> businessTypeList = bBusinessTypeService.list(new LambdaQueryWrapper<BusinessType>()
|
|
|
- .eq(BusinessType::getIsDeleted, 0)
|
|
|
- .eq(BusinessType::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(BusinessType::getStatus, 0));
|
|
|
//创建凭证主表信息
|
|
|
String deptId = "";
|
|
|
String deptName = "";
|
|
|
@@ -734,29 +913,7 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
deptName = String.join(",", res.getData());
|
|
|
}
|
|
|
}
|
|
|
- BusinessType businessType = businessTypeList.stream().filter(e -> e.getCode().equals("PZDH")).findFirst().orElse(null);
|
|
|
- if (businessType == null) {
|
|
|
- throw new RuntimeException("未找到可用业务类型");
|
|
|
- }
|
|
|
- BusinessBillNo businessBillNo = new BusinessBillNo();
|
|
|
- businessBillNo.setBusinessTypeId(businessType.getId());
|
|
|
- businessBillNo.setCode("PZDH-Z");
|
|
|
- R clientBillNo = businessBillNoService.getBillNoLos(businessBillNo);
|
|
|
- if (!clientBillNo.isSuccess()) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- throw new RuntimeException("生成订单编号失败");
|
|
|
- }
|
|
|
- finVouchers.setBillNo((String) clientBillNo.getData());
|
|
|
finVouchers.setVoucherType("转");
|
|
|
- BusinessBillNo businessBillNo1 = new BusinessBillNo();
|
|
|
- businessBillNo1.setBusinessTypeId(businessType.getId());
|
|
|
- businessBillNo1.setCode("转");
|
|
|
- R voucherNo = businessBillNoService.getVoucherNoLos(businessBillNo1);
|
|
|
- if (!clientBillNo.isSuccess()) {
|
|
|
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
- throw new RuntimeException("生成凭证号失败");
|
|
|
- }
|
|
|
- finVouchers.setVoucherNo((String) voucherNo.getData());
|
|
|
finVouchers.setVoucherSource(periodVouchersTemplate.getBsType());
|
|
|
finVouchers.setVoucherDate(new Date());
|
|
|
LocalDate currentDate = LocalDate.now();
|
|
|
@@ -772,7 +929,6 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
finVouchers.setBranchId(branchId);
|
|
|
finVouchers.setCreateDeptName(deptName);
|
|
|
}
|
|
|
- finVouchersService.save(finVouchers);
|
|
|
List<FinVouchersItems> finVouchersItemsList = new ArrayList<>();
|
|
|
//获取所需科目列表信息
|
|
|
String accountsCode = accItems.stream().map(PeriodVouchersAccItems::getAccNo).collect(Collectors.joining(","));
|
|
|
@@ -784,158 +940,574 @@ public class FinPeriodServiceImpl extends ServiceImpl<FinPeriodMapper, FinPeriod
|
|
|
List<FinGenlegCalc> finGenlegCalcList = finGenlegCalcService.list(new LambdaQueryWrapper<FinGenlegCalc>()
|
|
|
.eq(FinGenlegCalc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FinGenlegCalc::getBranchId, deptUtils.getDeptPid())
|
|
|
+ .eq(FinGenlegCalc::getAccyear, year)
|
|
|
+ .eq(FinGenlegCalc::getAccmonth, month)
|
|
|
.in(FinGenlegCalc::getAccId, ids));
|
|
|
- /*List<FinGenleg> finGenlegList = finGenlegService.list(new LambdaQueryWrapper<FinGenleg>()
|
|
|
+ if (finGenlegCalcList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到项目总账信息");
|
|
|
+ }
|
|
|
+ List<FinGenleg> finGenlegList = finGenlegService.list(new LambdaQueryWrapper<FinGenleg>()
|
|
|
.eq(FinGenleg::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(FinGenleg::getBranchId, deptUtils.getDeptPid())
|
|
|
- .in(FinGenleg::getAccId, ids));*/
|
|
|
+ .eq(FinGenleg::getAccyear, year)
|
|
|
+ .eq(FinGenleg::getAccmonth, month)
|
|
|
+ .in(FinGenleg::getAccId, ids));
|
|
|
+ if (finGenlegList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到总账信息");
|
|
|
+ }
|
|
|
int count = 0;
|
|
|
//循环复制凭证明细信息
|
|
|
for (Accounts item : accountsList) {
|
|
|
count++;
|
|
|
- FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
- finVouchersItems.setCreateTime(new Date());
|
|
|
- finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
- finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
- if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
- finVouchersItems.setCreateDept(deptId);
|
|
|
- finVouchersItems.setBranchId(branchId);
|
|
|
- finVouchersItems.setCreateDeptName(deptName);
|
|
|
+ PeriodExchangeRate periodExchangeRate = exchangeRateList.stream()
|
|
|
+ .filter(e -> e.getCurCode().equals(item.getCurCode())).findFirst().orElse(null);
|
|
|
+ if (periodExchangeRate == null) {
|
|
|
+ throw new RuntimeException("未找到汇率信息");
|
|
|
}
|
|
|
- finVouchersItems.setPid(finVouchers.getId());
|
|
|
- finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
- finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
- finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
- finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
- finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
- finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
- finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
- finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
- finVouchersItems.setAccountId(item.getId());
|
|
|
- finVouchersItems.setAccountCode(item.getCode());
|
|
|
- finVouchersItems.setAccountCnName(item.getCnName());
|
|
|
- finVouchersItems.setAccountEnName(item.getEnName());
|
|
|
- finVouchersItems.setAccountProperty(item.getProperty());
|
|
|
- finVouchersItems.setAccountLevel(item.getLevel());
|
|
|
- finVouchersItems.setDc(item.getDc());
|
|
|
- finVouchersItems.setCurCode(item.getCurCode());
|
|
|
-
|
|
|
if (1 == item.getIsCorp() || 1 == item.getIsDept() || 1 == item.getIsEmpl()) {
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /*判断是否人民币,美元
|
|
|
- * 人民币 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
- * 美元 判断模版借贷方向与科目借贷方向是否一致 true D+D=正 D+C=负 C+C=正 C+D=负
|
|
|
- * 借或贷金额为零时跳过本次循环
|
|
|
- * */
|
|
|
- /*if ("CNY".equals(item.getCurCode())) {
|
|
|
- finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
- if ("D".equals(item.getDc())) {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountDr(amount[count - 1]);
|
|
|
- } else {
|
|
|
- continue;
|
|
|
+ List<FinGenlegCalc> finGenlegCalcs = finGenlegCalcList.stream()
|
|
|
+ .filter(e -> e.getAccId().equals(item.getId()) && e.getCurCode().equals(item.getCurCode())).collect(Collectors.toList());
|
|
|
+ if (finGenlegCalcs.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到科目:" + item.getCnName() + "项目总账信息");
|
|
|
+ }
|
|
|
+ for (FinGenlegCalc calc : finGenlegCalcs) {
|
|
|
+ count++;
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountCr(amount[count - 1]);
|
|
|
- } else {
|
|
|
- continue;
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(item.getId());
|
|
|
+ finVouchersItems.setAccountCode(item.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(item.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(item.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(item.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(item.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getDc());
|
|
|
+ finVouchersItems.setCurCode(item.getCurCode());
|
|
|
+ finVouchersItems.setLineNo(count);
|
|
|
+ finVouchersItems.setDescr(periodVouchersTemplate.getDescr());
|
|
|
+ //判断是否核算客户 true 向明细中客户字段复制
|
|
|
+ finVouchersItems.setIsCorp(item.getIsCorp());
|
|
|
+ if (1 == finVouchersItems.getIsCorp()) {
|
|
|
+ finVouchersItems.setCorpId(calc.getCorpId());
|
|
|
+ finVouchersItems.setCorpCnName(calc.getCorpCnName());
|
|
|
+ finVouchersItems.setCorpEnName(calc.getCorpEnName());
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- finVouchersItems.setExrate(periodVouchersTemplate.getExrate());
|
|
|
- if ("D".equals(item.getDc())) {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountDrUsd(amount[count - 1]);
|
|
|
- finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodVouchersTemplate.getExrate()));
|
|
|
- } else {
|
|
|
- continue;
|
|
|
+ finVouchersItems.setIsDept(item.getIsDept());
|
|
|
+ //判断是否核算部门 true 向明细中部门字段复制
|
|
|
+ if (1 == finVouchersItems.getIsDept()) {
|
|
|
+ finVouchersItems.setDeptId(calc.getDeptId());
|
|
|
+ finVouchersItems.setDeptName(calc.getDeptName());
|
|
|
}
|
|
|
- } else {
|
|
|
- if (new BigDecimal("0.00").compareTo(amount[count - 1]) != 0) {
|
|
|
- finVouchersItems.setAmountCrUsd(amount[count - 1]);
|
|
|
- finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodVouchersTemplate.getExrate()));
|
|
|
+ finVouchersItems.setIsEmpl(item.getIsEmpl());
|
|
|
+ //判断是否核算职员 true 向明细中职员字段复制
|
|
|
+ if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
+ finVouchersItems.setEmplId(calc.getEmplId());
|
|
|
+ finVouchersItems.setEmplName(calc.getEmplName());
|
|
|
+ }
|
|
|
+ if ("FM-CURRENCY-PL-TRANSFER".equals(periodVouchersTemplate.getBsType())) {
|
|
|
+ if (!"CNY".equals(item.getCurCode())) {
|
|
|
+ finVouchersItems.setExrate(periodExchangeRate.getExrate());
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ BigDecimal amountDrUsdNew = periodExchangeRate.getExrate().multiply(calc.getAmountDrUsd());
|
|
|
+ BigDecimal amountDrUsdSubtract = calc.getAmountDr().subtract(amountDrUsdNew);
|
|
|
+ if (new BigDecimal("0.00").compareTo(amountDrUsdSubtract) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(amountDrUsdSubtract);
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BigDecimal amountCrUsdNew = periodExchangeRate.getExrate().multiply(calc.getAmountCrUsd());
|
|
|
+ BigDecimal amountCrUsdSubtract = calc.getAmountCr().subtract(amountCrUsdNew);
|
|
|
+ if (new BigDecimal("0.00").compareTo(amountCrUsdSubtract) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(amountCrUsdSubtract);
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
+ }
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ if (!"CNY".equals(item.getCurCode())) {
|
|
|
+ finVouchersItems.setExrate(periodExchangeRate.getExrate());
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(calc.getAmountDrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(calc.getAmountDrUsd());
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(calc.getAmountCrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(calc.getAmountCrUsd());
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(calc.getAmountDrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(calc.getAmountDrUsd());
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(calc.getAmountCrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(calc.getAmountCrUsd());
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- //计算借,贷人民币与美金合计人民币金额
|
|
|
- finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
- .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd(), "D", "1")));
|
|
|
- finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
- .add(bCurrencyService.converterCny("USD", ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd(), "C", "1")));
|
|
|
- finVouchersItems.setIsCorp(item.getIsCorp());
|
|
|
- //判断是否核算客户 true 向明细中客户字段复制
|
|
|
- if (1 == finVouchersItems.getIsCorp()) {
|
|
|
- if (bCorps != null) {
|
|
|
- finVouchersItems.setCorpId(bCorps.getId());
|
|
|
- finVouchersItems.setCorpCnName(bCorps.getCnName());
|
|
|
- finVouchersItems.setCorpEnName(bCorps.getEnName());
|
|
|
+ } else {
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
}
|
|
|
- }
|
|
|
- finVouchersItems.setIsDept(item.getIsDept());
|
|
|
- //判断是否核算部门 true 向明细中部门字段复制
|
|
|
- if (1 == finVouchersItems.getIsDept()) {
|
|
|
- if (dept != null) {
|
|
|
- finVouchersItems.setDeptId(dept.getId());
|
|
|
- finVouchersItems.setDeptName(dept.getDeptName());
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ finVouchersItems.setAccountId(item.getId());
|
|
|
+ finVouchersItems.setAccountCode(item.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(item.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(item.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(item.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(item.getLevel());
|
|
|
+ finVouchersItems.setDc(item.getDc());
|
|
|
+ finVouchersItems.setCurCode(item.getCurCode());
|
|
|
+ FinGenleg finGenleg = finGenlegList.stream().filter(e -> e.getAccId().equals(item.getId())).findFirst().orElse(null);
|
|
|
+ if (finGenleg == null) {
|
|
|
+ throw new RuntimeException("未查到科目:" + item.getCnName() + "总账信息");
|
|
|
}
|
|
|
- }
|
|
|
- finVouchersItems.setIsEmpl(item.getIsEmpl());
|
|
|
- //判断是否核算职员 true 向明细中职员字段复制
|
|
|
- if (1 == finVouchersItems.getIsEmpl()) {
|
|
|
- if (user != null) {
|
|
|
- finVouchersItems.setEmplId(user.getId());
|
|
|
- finVouchersItems.setEmplName(user.getName());
|
|
|
+ if ("FM-CURRENCY-PL-TRANSFER".equals(periodVouchersTemplate.getBsType())) {
|
|
|
+ if (!"CNY".equals(item.getCurCode())) {
|
|
|
+ finVouchersItems.setExrate(periodExchangeRate.getExrate());
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ BigDecimal amountDrUsdNew = periodExchangeRate.getExrate().multiply(finGenleg.getAmountDrUsd());
|
|
|
+ BigDecimal amountDrUsdSubtract = finGenleg.getAmountDr().subtract(amountDrUsdNew);
|
|
|
+ if (new BigDecimal("0.00").compareTo(amountDrUsdSubtract) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(amountDrUsdSubtract);
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BigDecimal amountCrUsdNew = periodExchangeRate.getExrate().multiply(finGenleg.getAmountCrUsd());
|
|
|
+ BigDecimal amountCrUsdSubtract = finGenleg.getAmountCr().subtract(amountCrUsdNew);
|
|
|
+ if (new BigDecimal("0.00").compareTo(amountCrUsdSubtract) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(amountCrUsdSubtract);
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
+ }
|
|
|
} else {
|
|
|
- if (userSrc != null) {
|
|
|
- finVouchersItems.setEmplId(userSrc.getId());
|
|
|
- finVouchersItems.setEmplName(userSrc.getCnName());
|
|
|
+ if (!"CNY".equals(item.getCurCode())) {
|
|
|
+ finVouchersItems.setExrate(periodExchangeRate.getExrate());
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountCrUsd(finGenleg.getAmountDrUsd());
|
|
|
+ finVouchersItems.setAmountCr(finVouchersItems.getAmountCrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountDrUsd(finGenleg.getAmountCrUsd());
|
|
|
+ finVouchersItems.setAmountDr(finVouchersItems.getAmountDrUsd().multiply(periodExchangeRate.getExrate()));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setExrate(new BigDecimal("1"));
|
|
|
+ if ("D".equals(item.getDc())) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(finGenleg.getAmountDrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountCr(finGenleg.getAmountDrUsd());
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (new BigDecimal("0.00").compareTo(finGenleg.getAmountCrUsd()) != 0) {
|
|
|
+ finVouchersItems.setAmountDr(finGenleg.getAmountCrUsd());
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ finVouchersItems.setAmountDrLoc(ObjectUtils.isNull(finVouchersItems.getAmountDr()) ? new BigDecimal("0") : finVouchersItems.getAmountDr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountDrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountDrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItems.setAmountCrLoc(ObjectUtils.isNull(finVouchersItems.getAmountCr()) ? new BigDecimal("0") : finVouchersItems.getAmountCr()
|
|
|
+ .add((ObjectUtils.isNull(finVouchersItems.getAmountCrUsd()) ? new BigDecimal("0") : finVouchersItems.getAmountCrUsd())).multiply(periodExchangeRate.getExrate()));
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
}
|
|
|
- }*/
|
|
|
- finVouchersItems.setLineNo(count);
|
|
|
- finVouchersItems.setDescr(periodVouchersTemplate.getDescr());
|
|
|
- finVouchersItemsList.add(finVouchersItems);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
throw new RuntimeException("未找到对应科目信息");
|
|
|
}
|
|
|
-
|
|
|
-// finVouchersItemsService.saveOrUpdateBatch(finVouchersItemsList);
|
|
|
BigDecimal amountDrCNY = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrCNY = new BigDecimal("0.00");
|
|
|
BigDecimal amountDrUSD = new BigDecimal("0.00");
|
|
|
BigDecimal amountCrUSD = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountDrLoc = new BigDecimal("0.00");
|
|
|
+ BigDecimal amountCrLoc = new BigDecimal("0.00");
|
|
|
amountDrCNY = amountDrCNY.add(finVouchersItemsList.stream()
|
|
|
.filter(e -> "CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDr)
|
|
|
.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- finVouchers.setAmountDr(amountDrCNY);
|
|
|
amountCrCNY = amountCrCNY.add(finVouchersItemsList.stream()
|
|
|
.filter(e -> "CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCr)
|
|
|
.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- finVouchers.setAmountCr(amountCrCNY);
|
|
|
amountDrUSD = amountDrUSD.add(finVouchersItemsList.stream()
|
|
|
- .filter(e -> "USD".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd)
|
|
|
+ .filter(e -> !"CNY".equals(e.getCurCode()) && "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrUsd)
|
|
|
.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- finVouchers.setAmountDrUsd(amountDrUSD);
|
|
|
amountCrUSD = amountCrUSD.add(finVouchersItemsList.stream()
|
|
|
- .filter(e -> "USD".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd)
|
|
|
+ .filter(e -> !"CNY".equals(e.getCurCode()) && "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrUsd)
|
|
|
.filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- finVouchers.setAmountCrUsd(amountCrUSD);
|
|
|
- finVouchers.setAmountDrLoc(amountDrCNY.add(bCurrencyService.converterCny("USD", amountDrUSD, "D", "1")));
|
|
|
- finVouchers.setAmountCrLoc(amountCrCNY.add(bCurrencyService.converterCny("USD", amountCrUSD, "C", "1")));
|
|
|
- finVouchers.setDescr(finVouchersItemsList.get(0).getDescr());
|
|
|
- if (finVouchersItemsList.stream().anyMatch(e -> "USD".equals(e.getCurCode()))) {
|
|
|
+ amountDrLoc = amountDrLoc.add(finVouchersItemsList.stream()
|
|
|
+ .filter(e -> "D".equals(e.getDc())).map(FinVouchersItems::getAmountDrLoc)
|
|
|
+ .filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ amountCrLoc = amountCrLoc.add(finVouchersItemsList.stream()
|
|
|
+ .filter(e -> "C".equals(e.getDc())).map(FinVouchersItems::getAmountCrLoc)
|
|
|
+ .filter(ObjectUtils::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ finVouchers.setDescr(periodVouchersTemplate.getDescr());
|
|
|
+ if (finVouchersItemsList.stream().anyMatch(e -> !"CNY".equals(e.getCurCode()))) {
|
|
|
finVouchers.setIsForeign(1);
|
|
|
}
|
|
|
- finVouchersService.updateById(finVouchers);
|
|
|
- return null;
|
|
|
+ FinVouchersItems finVouchersItems = new FinVouchersItems();
|
|
|
+ finVouchersItems.setCreateTime(new Date());
|
|
|
+ finVouchersItems.setCreateUser(AuthUtil.getUserId());
|
|
|
+ finVouchersItems.setCreateUserName(AuthUtil.getUserName());
|
|
|
+ if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
|
|
|
+ finVouchersItems.setCreateDept(deptId);
|
|
|
+ finVouchersItems.setBranchId(branchId);
|
|
|
+ finVouchersItems.setCreateDeptName(deptName);
|
|
|
+ }
|
|
|
+ finVouchersItems.setBillNo(finVouchers.getBillNo());
|
|
|
+ finVouchersItems.setVoucherSource(finVouchers.getVoucherSource());
|
|
|
+ finVouchersItems.setVoucherType(finVouchers.getVoucherType());
|
|
|
+ finVouchersItems.setVoucherNo(finVouchers.getVoucherNo());
|
|
|
+ finVouchersItems.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ finVouchersItems.setAccountYear(finVouchers.getAccountYear());
|
|
|
+ finVouchersItems.setAccountMonth(finVouchers.getAccountMonth());
|
|
|
+ finVouchersItems.setAccountDay(finVouchers.getAccountDay());
|
|
|
+ Accounts accounts = accountsService.getById(periodVouchersTemplate.getPlAccID());
|
|
|
+ if (accounts == null) {
|
|
|
+ throw new RuntimeException("科目:" + periodVouchersTemplate.getPlAccCnm() + "不存在");
|
|
|
+ }
|
|
|
+ finVouchersItems.setAccountId(accounts.getId());
|
|
|
+ finVouchersItems.setAccountCode(accounts.getCode());
|
|
|
+ finVouchersItems.setAccountCnName(accounts.getCnName());
|
|
|
+ finVouchersItems.setAccountEnName(accounts.getEnName());
|
|
|
+ finVouchersItems.setAccountProperty(accounts.getProperty());
|
|
|
+ finVouchersItems.setAccountLevel(accounts.getLevel());
|
|
|
+ finVouchersItems.setDc(accounts.getDc());
|
|
|
+ finVouchersItems.setCurCode(accounts.getCurCode());
|
|
|
+ if (!"CNY".equals(accounts.getCurCode())) {
|
|
|
+ throw new RuntimeException("科目:" + periodVouchersTemplate.getPlAccCnm() + "币别不是CNY");
|
|
|
+ }
|
|
|
+ if ("FM-CURRENCY-PL-TRANSFER".equals(periodVouchersTemplate.getBsType())) {
|
|
|
+ BigDecimal subtract = amountDrLoc.subtract(amountCrLoc);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountDr(subtract);
|
|
|
+ finVouchersItems.setAmountDrLoc(subtract);
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountCr(subtract);
|
|
|
+ finVouchersItems.setAmountCrLoc(subtract);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BigDecimal subtract = amountDrLoc.subtract(amountCrLoc);
|
|
|
+ if ("D".equals(accounts.getDc())) {
|
|
|
+ finVouchersItems.setAmountCr(subtract);
|
|
|
+ finVouchersItems.setAmountCrLoc(subtract);
|
|
|
+ } else {
|
|
|
+ finVouchersItems.setAmountDr(subtract);
|
|
|
+ finVouchersItems.setAmountDrLoc(subtract);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ finVouchersItemsList.add(finVouchersItems);
|
|
|
+ finVouchers.setAmountDr(amountDrCNY.add(finVouchersItems.getAmountDr()));
|
|
|
+ finVouchers.setAmountCr(amountCrCNY.add(finVouchersItems.getAmountCr()));
|
|
|
+ finVouchers.setAmountDrUsd(amountDrUSD.add(finVouchersItems.getAmountDrUsd()));
|
|
|
+ finVouchers.setAmountCrUsd(amountCrUSD.add(finVouchersItems.getAmountCrUsd()));
|
|
|
+ finVouchers.setAmountDrLoc(amountDrLoc.add(finVouchersItems.getAmountDrLoc()));
|
|
|
+ finVouchers.setAmountCrLoc(amountCrLoc.add(finVouchersItems.getAmountCrLoc()));
|
|
|
+ finVouchers.setFinVouchersItemsList(finVouchersItemsList);
|
|
|
+ return R.data(finVouchers);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void export(FinPeriod finPeriod, HttpServletResponse response) {
|
|
|
+ if (finPeriod.getId() == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ FinPeriod detail = baseMapper.selectById(finPeriod.getId());
|
|
|
+ if (1 == detail.getLockingStatus()) {
|
|
|
+ throw new RuntimeException("该期间已锁定,请勿重复锁定!");
|
|
|
+ }
|
|
|
+ List<ReviewFailedExcel> reviewFailedExcelList = new ArrayList<>();
|
|
|
+ List<UnbookkeptExcel> unbookkeptExcelList = new ArrayList<>();
|
|
|
+ String beginDate = "";
|
|
|
+ String endDate = "";
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ if (null != detail.getBeginDate()) {
|
|
|
+ beginDate = sdf.format(detail.getBeginDate());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("该期间缺少开始时间,操作失败");
|
|
|
+ }
|
|
|
+ if (null != detail.getEndDate()) {
|
|
|
+ endDate = sdf.format(detail.getEndDate());
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("该期间缺少结束时间,操作失败");
|
|
|
+ }
|
|
|
+ List<Bills> billsList = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getBranchId, detail.getBranchId())
|
|
|
+ .apply("((business_type = 'SE' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
|
|
|
+ "or (business_type = 'SI' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"));
|
|
|
+ if (!billsList.isEmpty()) {
|
|
|
+ List<Bills> bills = billsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
+ for (Bills item : bills) {
|
|
|
+ ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
|
|
|
+ if ("SE".equals(item.getBusinessType())) {
|
|
|
+ reviewFailedExcel.setBusinessType("海运出口");
|
|
|
+ } else {
|
|
|
+ reviewFailedExcel.setBusinessType("海运进口");
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBillNo(item.getBillNo());
|
|
|
+ reviewFailedExcel.setBusinessDate(item.getBillDate());
|
|
|
+ reviewFailedExcel.setMblno(item.getMblno());
|
|
|
+ reviewFailedExcel.setOperator(item.getOperatorName());
|
|
|
+ if ("SALES".equals(item.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(item.getSrcCnName());
|
|
|
+ }
|
|
|
+ reviewFailedExcelList.add(reviewFailedExcel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<AeaBills> aeaBillsList = aeaBillsService.list(new LambdaQueryWrapper<AeaBills>()
|
|
|
+ .eq(AeaBills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AeaBills::getIsDeleted, 0)
|
|
|
+ .eq(AeaBills::getBranchId, detail.getBranchId())
|
|
|
+ .apply("((business_type = 'AE' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
|
|
|
+ "or (business_type = 'AI' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"));
|
|
|
+ if (!aeaBillsList.isEmpty()) {
|
|
|
+ List<AeaBills> aeaBills = aeaBillsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
+ for (AeaBills item : aeaBills) {
|
|
|
+ ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
|
|
|
+ if ("AE".equals(item.getBusinessType())) {
|
|
|
+ reviewFailedExcel.setBusinessType("空运出口");
|
|
|
+ } else {
|
|
|
+ reviewFailedExcel.setBusinessType("空运进口");
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBillNo(item.getBillNo());
|
|
|
+ reviewFailedExcel.setBusinessDate(item.getBillDate());
|
|
|
+ reviewFailedExcel.setMblno(item.getMblno());
|
|
|
+ reviewFailedExcel.setOperator(item.getOperatorName());
|
|
|
+ if ("SALES".equals(item.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(item.getSrcCnName());
|
|
|
+ }
|
|
|
+ reviewFailedExcelList.add(reviewFailedExcel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Amends> amendsList = amendsService.list(new LambdaQueryWrapper<Amends>()
|
|
|
+ .eq(Amends::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Amends::getIsDeleted, 0)
|
|
|
+ .eq(Amends::getBranchId, detail.getBranchId())
|
|
|
+ .apply("((business_type = 'SEA' and etd >='" + beginDate + "' and etd <= '" + endDate + "' ) " +
|
|
|
+ "or (business_type = 'SIA' and eta >='" + beginDate + "' and eta <= '" + endDate + "')" +
|
|
|
+ "or (business_type = 'AEA' and etd >='" + beginDate + "' and etd <= '" + endDate + "')" +
|
|
|
+ "or (business_type = 'AIA' and eta >='" + beginDate + "' and eta <= '" + endDate + "'))"
|
|
|
+ ));
|
|
|
+ if (!amendsList.isEmpty()) {
|
|
|
+ List<Amends> bills = amendsList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
+ List<Bills> billsList1 = new ArrayList<>();
|
|
|
+ List<AeaBills> aeaBillsList1 = new ArrayList<>();
|
|
|
+ if (!bills.isEmpty()) {
|
|
|
+ List<Long> billsId = bills.stream().map(Amends::getOrigId).collect(Collectors.toList());
|
|
|
+ if (!billsId.isEmpty()) {
|
|
|
+ billsList1 = billsService.list(new LambdaQueryWrapper<Bills>()
|
|
|
+ .eq(Bills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Bills::getIsDeleted, 0)
|
|
|
+ .eq(Bills::getBranchId, detail.getBranchId())
|
|
|
+ .in(Bills::getId, billsId)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ List<Long> aeaBillsId = bills.stream().map(Amends::getOrigId).collect(Collectors.toList());
|
|
|
+ if (!aeaBillsId.isEmpty()) {
|
|
|
+ aeaBillsList1 = aeaBillsService.list(new LambdaQueryWrapper<AeaBills>()
|
|
|
+ .eq(AeaBills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(AeaBills::getIsDeleted, 0)
|
|
|
+ .eq(AeaBills::getBranchId, detail.getBranchId())
|
|
|
+ .in(AeaBills::getId, aeaBillsId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Amends item : bills) {
|
|
|
+ ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
|
|
|
+ if ("AEA".equals(item.getBusinessType())) {
|
|
|
+ if (!aeaBillsList1.isEmpty()) {
|
|
|
+ AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
|
|
|
+ if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBusinessType("空运出口Amends");
|
|
|
+ } else if ("AIA".equals(item.getBusinessType())) {
|
|
|
+ if (!aeaBillsList1.isEmpty()) {
|
|
|
+ AeaBills aeaBills = aeaBillsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
|
|
|
+ if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBusinessType("空运进口Amends");
|
|
|
+ } else if ("SIA".equals(item.getBusinessType())) {
|
|
|
+ if (!billsList1.isEmpty()) {
|
|
|
+ Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
|
|
|
+ if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBusinessType("海运进口Amends");
|
|
|
+ } else if ("SEA".equals(item.getBusinessType())) {
|
|
|
+ if (!billsList1.isEmpty()) {
|
|
|
+ Bills aeaBills = billsList1.stream().filter(e -> e.getId().equals(item.getOrigId())).findFirst().orElse(null);
|
|
|
+ if (aeaBills != null && "SALES".equals(aeaBills.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(aeaBills.getSrcCnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBusinessType("海运出口Amends");
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBillNo(item.getBillNo());
|
|
|
+ reviewFailedExcel.setBusinessDate(item.getBillDate());
|
|
|
+ reviewFailedExcel.setMblno(item.getMblno());
|
|
|
+ reviewFailedExcel.setOperator(item.getOperatorName());
|
|
|
+ reviewFailedExcelList.add(reviewFailedExcel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<CustomsDeclaration> customsDeclarationList = customsDeclarationService.list(new LambdaQueryWrapper<CustomsDeclaration>()
|
|
|
+ .eq(CustomsDeclaration::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(CustomsDeclaration::getIsDeleted, 0)
|
|
|
+ .eq(CustomsDeclaration::getBranchId, detail.getBranchId())
|
|
|
+ .gt(CustomsDeclaration::getDeclareDate, detail.getBeginDate())
|
|
|
+ .lt(CustomsDeclaration::getDeclareDate, detail.getEndDate())
|
|
|
+ );
|
|
|
+ if (!customsDeclarationList.isEmpty()) {
|
|
|
+ List<CustomsDeclaration> bills = customsDeclarationList.stream().filter(e -> e.getBillStatus().equals(3)).collect(Collectors.toList());
|
|
|
+ for (CustomsDeclaration item : bills) {
|
|
|
+ ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
|
|
|
+ if ("BGSE".equals(item.getBusinessType())) {
|
|
|
+ reviewFailedExcel.setBusinessType("海运报关");
|
|
|
+ } else if ("BGSI".equals(item.getBusinessType())) {
|
|
|
+ reviewFailedExcel.setBusinessType("海运报关");
|
|
|
+ } else if ("BGAE".equals(item.getBusinessType())) {
|
|
|
+ reviewFailedExcel.setBusinessType("空运报关");
|
|
|
+ } else if ("BGAI".equals(item.getBusinessType())) {
|
|
|
+ reviewFailedExcel.setBusinessType("空运报关");
|
|
|
+ }
|
|
|
+ reviewFailedExcel.setBillNo(item.getBillNo());
|
|
|
+ reviewFailedExcel.setBusinessDate(item.getBillDate());
|
|
|
+ reviewFailedExcel.setMblno(item.getMblno());
|
|
|
+ reviewFailedExcel.setOperator(item.getCreateUserName());
|
|
|
+ if ("SALES".equals(item.getSrcType())) {
|
|
|
+ reviewFailedExcel.setSalesperson(item.getSrcCnName());
|
|
|
+ }
|
|
|
+ reviewFailedExcelList.add(reviewFailedExcel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<FinStlBills> finStlBillsList = finStlBillsService.list(new LambdaQueryWrapper<FinStlBills>()
|
|
|
+ .eq(FinStlBills::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinStlBills::getIsDeleted, 0)
|
|
|
+ .eq(FinStlBills::getBusinessType, "STL")
|
|
|
+ .eq(FinStlBills::getBranchId, detail.getBranchId())
|
|
|
+ .gt(FinStlBills::getBillDate, beginDate)
|
|
|
+ .lt(FinStlBills::getBillDate, endDate)
|
|
|
+ );
|
|
|
+ if (!finStlBillsList.isEmpty()) {
|
|
|
+ List<FinStlBills> bills = finStlBillsList.stream().filter(e -> e.getBillStatus().equals("3")).collect(Collectors.toList());
|
|
|
+ if (!bills.isEmpty()) {
|
|
|
+ List<Long> ids = bills.stream().map(FinStlBills::getId).collect(Collectors.toList());
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
+ List<FinVouchers> finVouchersList = finVouchersService.list(new LambdaQueryWrapper<FinVouchers>()
|
|
|
+ .eq(FinVouchers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(FinVouchers::getIsDeleted, 0)
|
|
|
+ .eq(FinVouchers::getBranchId, detail.getBranchId())
|
|
|
+ .in(FinVouchers::getSrcId, ids)
|
|
|
+ .gt(FinVouchers::getVoucherDate, beginDate)
|
|
|
+ .lt(FinVouchers::getVoucherDate, endDate));
|
|
|
+ for (FinStlBills item : bills) {
|
|
|
+ FinVouchers finVouchers = finVouchersList.stream().filter(e -> e.getSrcId().equals(item.getId())).findFirst().orElse(null);
|
|
|
+ if (finVouchers == null) {
|
|
|
+ ReviewFailedExcel reviewFailedExcel = new ReviewFailedExcel();
|
|
|
+ reviewFailedExcel.setBusinessType("结算中心");
|
|
|
+ reviewFailedExcel.setBillNo(item.getBillNo());
|
|
|
+ reviewFailedExcel.setBusinessDate(item.getBillDate());
|
|
|
+ reviewFailedExcel.setMblno(item.getMblno());
|
|
|
+ reviewFailedExcel.setOperator(item.getCreateUserName());
|
|
|
+ reviewFailedExcel.setSalesperson(item.getSalesName());
|
|
|
+ reviewFailedExcelList.add(reviewFailedExcel);
|
|
|
+ } else {
|
|
|
+ UnbookkeptExcel unbookkeptExcel = new UnbookkeptExcel();
|
|
|
+ unbookkeptExcel.setYear(finVouchers.getAccountYear() + "");
|
|
|
+ unbookkeptExcel.setMonth(finVouchers.getAccountMonth() + "");
|
|
|
+ unbookkeptExcel.setVoucherNumber(finVouchers.getVoucherNo());
|
|
|
+ unbookkeptExcel.setVoucherDate(finVouchers.getVoucherDate());
|
|
|
+ unbookkeptExcel.setOperator(finVouchers.getCreateUserName());
|
|
|
+ unbookkeptExcelList.add(unbookkeptExcel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!reviewFailedExcelList.isEmpty()) {
|
|
|
+ ExcelUtil.export(response, "审核未通过", "审核未通过", BeanUtil.copy(reviewFailedExcelList, ReviewFailedExcel.class), ReviewFailedExcel.class);
|
|
|
+ }
|
|
|
+ if (!unbookkeptExcelList.isEmpty()) {
|
|
|
+ ExcelUtil.export(response, "凭证未记账", "凭证未记账", BeanUtil.copy(unbookkeptExcelList, UnbookkeptExcel.class), UnbookkeptExcel.class);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|