|
|
@@ -1,22 +1,22 @@
|
|
|
package com.ydtech.modules.inv.service.impl;
|
|
|
|
|
|
+import com.alibaba.excel.annotation.format.DateTimeFormat;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.core.page.HttpResult;
|
|
|
import com.ydtech.core.page.PageRequest;
|
|
|
import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.inv.dao.InvAccountMapper;
|
|
|
-import com.ydtech.modules.inv.dao.InvAccountOperateMapper;
|
|
|
import com.ydtech.modules.inv.model.*;
|
|
|
import com.ydtech.modules.inv.model.excel.AccountExcel;
|
|
|
import com.ydtech.modules.inv.model.vo.InvAccountQueryVo;
|
|
|
-import com.ydtech.modules.inv.service.InvAccountCardService;
|
|
|
import com.ydtech.modules.inv.service.InvAccountOpService;
|
|
|
import com.ydtech.modules.inv.service.InvAccountProfitService;
|
|
|
import com.ydtech.modules.inv.service.InvAccountService;
|
|
|
import com.ydtech.modules.inv.utils.EasyExcelUtils;
|
|
|
import com.ydtech.modules.inv.utils.LocalDateTimeUtils;
|
|
|
+import net.sf.cglib.core.Local;
|
|
|
+import org.joda.time.LocalDateTime;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -24,8 +24,6 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
@@ -84,9 +82,11 @@ public class InvAccountServiceImpl extends ServiceImpl<InvAccountMapper, InvAcco
|
|
|
if (ord.getInvoicingAmountExcess() != null) {
|
|
|
|
|
|
rel.setQuarterAmountExcess(new BigDecimal("300000").subtract(new BigDecimal("5000000").subtract(new BigDecimal(ord.getInvoicingAmountExcess()))).toString());
|
|
|
+ rel.setSumInvoicingAmount("0");
|
|
|
} else {
|
|
|
if (!rel.getBusinessQuality().equals("0")) {
|
|
|
rel.setQuarterAmountExcess("300000");
|
|
|
+ rel.setSumInvoicingAmount("0");
|
|
|
}
|
|
|
}
|
|
|
return rel;
|
|
|
@@ -102,7 +102,7 @@ public class InvAccountServiceImpl extends ServiceImpl<InvAccountMapper, InvAcco
|
|
|
.map(ord -> {
|
|
|
if (ord.getSumInvoicingAmount() != null) {
|
|
|
|
|
|
- rel.setSumInvoicingAmount(new BigDecimal(ord.getSumInvoicingAmount()).add(new BigDecimal(ord.getSumInvoicingAmount())).toString());
|
|
|
+ rel.setSumInvoicingAmount(new BigDecimal(rel.getSumInvoicingAmount()).add(new BigDecimal(ord.getSumInvoicingAmount())).toString());
|
|
|
|
|
|
}
|
|
|
return rel;
|
|
|
@@ -165,17 +165,116 @@ public class InvAccountServiceImpl extends ServiceImpl<InvAccountMapper, InvAcco
|
|
|
List<InvAccountOp> list = invAccountOpService.list();
|
|
|
|
|
|
File folder = new File(uploadFilePath);
|
|
|
- if (folder.exists()){
|
|
|
- return HttpResult.ok("",EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list));
|
|
|
- }else {
|
|
|
- if (folder.mkdirs()){
|
|
|
- return HttpResult.ok( "",EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list));
|
|
|
- }else {
|
|
|
+ if (folder.exists()) {
|
|
|
+ return HttpResult.ok("", EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list));
|
|
|
+ } else {
|
|
|
+ if (folder.mkdirs()) {
|
|
|
+ return HttpResult.ok("", EasyExcelUtils.noModelWrite(uploadFilePath, invAccountProfitList, insAccounts, list));
|
|
|
+ } else {
|
|
|
throw new SystemException("文件导出失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpResult selectAccountList(InvAccountQueryVo invAccountQueryVo) {
|
|
|
+ invAccountQueryVo.setInvoiceTimeStart(LocalDateTimeUtils.get12MonthsBefore()); // 获取12月前月的第一天
|
|
|
+ invAccountQueryVo.setInvoiceTimeEnd(LocalDateTimeUtils.getTodayLastDay()); //获取当前月最后一天
|
|
|
+
|
|
|
+
|
|
|
+ List<InvAccount> invAccountIPage = insAccountMapper.selectAccountsListPage(invAccountQueryVo);
|
|
|
+
|
|
|
+
|
|
|
+ //计算当前季度剩余300000减去
|
|
|
+ invAccountQueryVo.setInvoiceTimeStart(LocalDateTimeUtils.quarterStartTime());
|
|
|
+ invAccountQueryVo.setInvoiceTimeEnd(LocalDateTimeUtils.quarterEndTime());
|
|
|
+ List<InvAccount> invAccountIPage1 = insAccountMapper.selectAccountsListPage(invAccountQueryVo);
|
|
|
+
|
|
|
+ //将当前季度额度赋值
|
|
|
+ List<InvAccount> collect = invAccountIPage.stream()
|
|
|
+ .map(rel -> invAccountIPage1.stream()
|
|
|
+ .filter(ord -> Objects.equals(rel.getAccountId(), ord.getAccountId()))
|
|
|
+ .findFirst()
|
|
|
+ .map(ord -> {
|
|
|
+ if (ord.getInvoicingAmountExcess() != null) {
|
|
|
+
|
|
|
+ rel.setQuarterAmountExcess(new BigDecimal("300000").subtract(new BigDecimal("5000000").subtract(new BigDecimal(ord.getInvoicingAmountExcess()))).toString());
|
|
|
+ rel.setSumInvoicingAmount("0");
|
|
|
+ } else {
|
|
|
+ if (!rel.getBusinessQuality().equals("0")) {
|
|
|
+ rel.setQuarterAmountExcess("300000");
|
|
|
+ rel.setSumInvoicingAmount("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rel;
|
|
|
+ }).orElse(null)
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //将总开票额度赋值
|
|
|
+ List<InvAccount> sumInvoicingAmount = insAccountMapper.getSumInvoicingAmount(invAccountQueryVo);
|
|
|
+ List<InvAccount> collect1 = collect.stream()
|
|
|
+ .map(rel -> sumInvoicingAmount.stream()
|
|
|
+ .filter(ord -> Objects.equals(rel.getAccountId(), ord.getAccountId()))
|
|
|
+ .findFirst()
|
|
|
+ .map(ord -> {
|
|
|
+ if (ord.getSumInvoicingAmount() != null) {
|
|
|
+ rel.setSumInvoicingAmount(new BigDecimal(rel.getSumInvoicingAmount()).add(new BigDecimal(ord.getSumInvoicingAmount())).toString());
|
|
|
+ }
|
|
|
+ return rel;
|
|
|
+ }).orElse(null)
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
+ collect1.forEach(invAccount -> {
|
|
|
+ if (invAccount != null) {
|
|
|
+ if (invAccount.getInvAccountCardList().size() < 2) {
|
|
|
+ if (invAccount.getInvAccountCardList().get(0).getBankCardNum() == null) {
|
|
|
+ invAccount.setInvAccountCardList(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (invAccount.getBusinessQuality().equals("3")) {
|
|
|
+ invAccount.setQuarterAmountExcess(null);
|
|
|
+ invAccount.setSumInvoicingAmount(null);
|
|
|
+ invAccount.setInvoicingAmountExcess(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<AccountExcel> accountExcels = new ArrayList<>();
|
|
|
+
|
|
|
+ collect1.forEach(invAccount -> {
|
|
|
+ if (invAccount.getInvAccountCardList() != null){
|
|
|
+ invAccount.getInvAccountCardList().forEach(invAccountCard -> {
|
|
|
+ AccountExcel accountExcel = new AccountExcel();
|
|
|
+ accountExcel.setAccountId(invAccount.getAccountId());
|
|
|
+ accountExcel.setBankName(invAccountCard.getBankName());
|
|
|
+ if (invAccount.getBusinessQuality() != null){
|
|
|
+ if (invAccount.getBusinessQuality().equals("3")){
|
|
|
+ accountExcel.setBusinessQuality("一般纳税");
|
|
|
+ }else if (invAccount.getBusinessQuality().equals("1")){
|
|
|
+ accountExcel.setBusinessQuality("小规模");
|
|
|
+ }else if (invAccount.getBusinessQuality().equals("2")){
|
|
|
+ accountExcel.setBusinessQuality("小规模");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ accountExcel.setOwned(invAccount.getOwned());
|
|
|
+ if (invAccount.getEstablishTime() != null){
|
|
|
+ LocalDateTime establishTime = LocalDateTime.fromDateFields(invAccount.getEstablishTime());
|
|
|
+ accountExcel.setEstablishTime(establishTime.toString().substring(0,establishTime.toString().indexOf("T")));
|
|
|
+ }
|
|
|
+ accountExcel.setSumInvoicingAmount(invAccount.getSumInvoicingAmount());
|
|
|
+ accountExcel.setQuarterAmountExcess(invAccount.getQuarterAmountExcess());
|
|
|
+ accountExcel.setInvoicingAmountExcess(invAccount.getInvoicingAmountExcess());
|
|
|
+ accountExcel.setBalance(invAccountCard.getBalance());
|
|
|
+ accountExcels.add(accountExcel);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ return HttpResult.ok("", EasyExcelUtils.downExcel(uploadFilePath, AccountExcel.class, accountExcels));
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|